Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-03-16 22:49:45 +0000
committerMarkus Keller2015-03-16 22:49:45 +0000
commit5ac42d5eb45adc17ab1e8ef893cc7501eb224918 (patch)
treed062d336049c71267e20ec1962b40b9e670b3a9b
parentcfca412f57f26eae63a2010e2327c439d2554f16 (diff)
downloadeclipse.jdt.ui-5ac42d5eb45adc17ab1e8ef893cc7501eb224918.tar.gz
eclipse.jdt.ui-5ac42d5eb45adc17ab1e8ef893cc7501eb224918.tar.xz
eclipse.jdt.ui-5ac42d5eb45adc17ab1e8ef893cc7501eb224918.zip
-rw-r--r--org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/preferences/OptionsConfigurationBlockTest.java32
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);
}
}

Back to the top