diff options
| author | Markus Keller | 2015-03-16 22:49:45 +0000 |
|---|---|---|
| committer | Markus Keller | 2015-03-16 22:49:45 +0000 |
| commit | 5ac42d5eb45adc17ab1e8ef893cc7501eb224918 (patch) | |
| tree | d062d336049c71267e20ec1962b40b9e670b3a9b | |
| parent | cfca412f57f26eae63a2010e2327c439d2554f16 (diff) | |
| download | eclipse.jdt.ui-5ac42d5eb45adc17ab1e8ef893cc7501eb224918.tar.gz eclipse.jdt.ui-5ac42d5eb45adc17ab1e8ef893cc7501eb224918.tar.xz eclipse.jdt.ui-5ac42d5eb45adc17ab1e8ef893cc7501eb224918.zip | |
Bug 461999: Warning option for bug 410218I20150324-0800I20150320-0800I20150320-0030I20150319-1640I20150319-1430I20150318-2000I20150318-1300I20150318-0800I20150317-2000I20150317-1130I20150317-0800I20150316-2000
| -rw-r--r-- | org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java index 001b88a29f..44353dc057 100644 --- a/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java +++ b/org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,13 +11,11 @@ package org.eclipse.jdt.ui.tests.preferences; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; +import java.util.HashSet; import org.eclipse.jdt.core.JavaCore; @@ -29,6 +27,10 @@ import org.eclipse.jdt.internal.ui.preferences.OptionsConfigurationBlock.Key; import org.eclipse.jdt.internal.ui.preferences.ProblemSeveritiesConfigurationBlock; import org.eclipse.jdt.internal.ui.preferences.TodoTaskConfigurationBlock; +import junit.framework.Test; +import junit.framework.TestCase; +import junit.framework.TestSuite; + public class OptionsConfigurationBlockTest extends TestCase { /* @@ -111,20 +113,38 @@ public class OptionsConfigurationBlockTest extends TestCase { })); } - private void checkConfigurationBlock(Class configurationBlock, HashMap coreFieldLookup) throws IllegalAccessException { + private void checkConfigurationBlock(Class configurationBlock, HashMap coreFieldLookup) throws Exception { + Method keysMethod; + try { + keysMethod= configurationBlock.getDeclaredMethod("getKeys"); + } catch (NoSuchMethodException e) { + try { + keysMethod= configurationBlock.getDeclaredMethod("getAllKeys"); + } catch (NoSuchMethodException e1) { + keysMethod= configurationBlock.getDeclaredMethod("getKeys", boolean.class); + } + } + keysMethod.setAccessible(true); + Key[] keys= (Key[]) (keysMethod.getParameterTypes().length > 0 ? keysMethod.invoke(null, Boolean.FALSE) : keysMethod.invoke(null)); + HashSet<Key> keySet= new HashSet<Key>(Arrays.asList(keys)); + Field[] prefFields= configurationBlock.getDeclaredFields(); for (int i= 0; i < prefFields.length; i++) { Field field= prefFields[i]; field.setAccessible(true); if (field.getType() == Key.class) { Key key= (Key)field.get(null); + boolean keyWasInKeySet= keySet.remove(key); if (JavaCore.PLUGIN_ID.equals(key.getQualifier())) { Object fieldName= coreFieldLookup.remove(key.getName()); assertTrue( "No core constant for key " + key.getName() + " in class " + configurationBlock.getName(), fieldName != null); + assertTrue(configurationBlock.getName() + "#getKeys() is missing key '" + key.getName() + "'", keyWasInKeySet); } } } + + assertEquals(configurationBlock.getName() + "#getKeys() includes keys that are not declared in the class", Collections.emptySet(), keySet); } } |
