aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Ptaszkiewicz2012-09-18 14:22:36 (EDT)
committerJohn Arthorne2012-09-18 14:22:36 (EDT)
commitd41164e4b98acdb50d9559b4c433c722994e20f7 (patch)
treeaeef9175ad6f0a3c961115f1a4f30ce94592226c
parent52c9fd68ad53a869587823b8ac54fd41377074c2 (diff)
downloadeclipse.platform.runtime-d41164e4b98acdb50d9559b4c433c722994e20f7.zip
eclipse.platform.runtime-d41164e4b98acdb50d9559b4c433c722994e20f7.tar.gz
eclipse.platform.runtime-d41164e4b98acdb50d9559b4c433c722994e20f7.tar.bz2
consult pluginCustomization file
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllTests.java1
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestBug388004.java95
2 files changed, 96 insertions, 0 deletions
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllTests.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllTests.java
index 67f0cd2..aeb08e1 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllTests.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/AllTests.java
@@ -35,6 +35,7 @@ public class AllTests extends TestCase {
suite.addTest(PreferencesServiceTest.suite());
suite.addTest(IScopeContextTest.suite());
suite.addTest(ListenerRegistryTest.suite());
+ suite.addTest(TestBug388004.suite());
return suite;
}
}
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestBug388004.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestBug388004.java
new file mode 100644
index 0000000..84c10eb
--- /dev/null
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestBug388004.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2012 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.core.tests.internal.preferences;
+
+import java.io.*;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.tests.harness.FileSystemHelper;
+import org.eclipse.core.tests.runtime.RuntimeTestsPlugin;
+import org.eclipse.core.tests.session.*;
+import org.eclipse.core.tests.session.SetupManager.SetupException;
+import org.osgi.service.prefs.BackingStoreException;
+import org.osgi.service.prefs.Preferences;
+
+/**
+ * Test for bug 388004.
+ */
+public class TestBug388004 extends TestCase {
+ private static final String FILE_NAME = FileSystemHelper.getTempDir().append("plugin_customization.ini").toOSString();
+ private static final String NODE = "dummy_node";
+ private static final String KEY = "key";
+ private static final String VALUE = "value";
+
+ public static Test suite() {
+ SessionTestSuite suite = new SessionTestSuite(RuntimeTestsPlugin.PI_RUNTIME_TESTS, TestBug388004.class.getName());
+ try {
+ // create plugin_customization.ini file
+ File file = new File(FILE_NAME);
+ BufferedWriter writer = new BufferedWriter(new FileWriter(file));
+ writer.write("org.eclipse.core.tests.runtime/dummy_node/key=value");
+ writer.close();
+
+ // add pluginCustomization argument
+ Setup setup = suite.getSetup();
+ setup.setEclipseArgument("pluginCustomization", file.toString());
+ } catch (IOException e) {
+ // ignore, the test will fail for us
+ } catch (SetupException e) {
+ // ignore, the test will fail for us
+ }
+ suite.addTest(new TestBug388004("testBug"));
+ return suite;
+ }
+
+ public TestBug388004() {
+ super();
+ }
+
+ public TestBug388004(String name) {
+ super(name);
+ }
+
+ protected void tearDown() throws Exception {
+ new File(FILE_NAME).delete();
+ }
+
+ public void testBug() throws BackingStoreException {
+ Preferences node = Platform.getPreferencesService().getRootNode().node(DefaultScope.SCOPE);
+
+ // test relative path of ancestor
+ if (!node.nodeExists(RuntimeTestsPlugin.PI_RUNTIME_TESTS))
+ fail("This node exists in pluginCustomization file.");
+ // test absolute path of ancestor
+ if (!node.nodeExists("/default/" + RuntimeTestsPlugin.PI_RUNTIME_TESTS))
+ fail("This node exists in pluginCustomization file.");
+
+ // test relative path
+ if (!node.nodeExists(RuntimeTestsPlugin.PI_RUNTIME_TESTS + "/" + NODE))
+ fail("This node exists in pluginCustomization file.");
+ // test absolute path
+ if (!node.nodeExists("/default/" + RuntimeTestsPlugin.PI_RUNTIME_TESTS + "/" + NODE))
+ fail("This node exists in pluginCustomization file.");
+
+ // test relative path of non-existing node
+ if (node.nodeExists(RuntimeTestsPlugin.PI_RUNTIME_TESTS + "/" + NODE + "/" + KEY))
+ fail("This node does not exist in pluginCustomization file.");
+ // test absolute path of non-existing node
+ if (node.nodeExists("/default/" + RuntimeTestsPlugin.PI_RUNTIME_TESTS + "/" + NODE + "/" + KEY))
+ fail("This node does not exist in pluginCustomization file.");
+
+ node = node.node(RuntimeTestsPlugin.PI_RUNTIME_TESTS + "/" + NODE);
+ String value = node.get(KEY, null);
+ assertEquals(VALUE, value);
+ }
+}