aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDJ Houghton2012-01-11 17:30:15 (EST)
committerDJ Houghton2012-01-11 17:30:15 (EST)
commit7224e6030758d5efcb82d8177eb3f8e6055c8197 (patch)
treeec69715ddaaf266d1a80dfc8155fa310e3902633
parent141a5960077ceb94e56327de6dc5e16ff59e7a3b (diff)
downloadeclipse.platform.runtime-7224e6030758d5efcb82d8177eb3f8e6055c8197.zip
eclipse.platform.runtime-7224e6030758d5efcb82d8177eb3f8e6055c8197.tar.gz
eclipse.platform.runtime-7224e6030758d5efcb82d8177eb3f8e6055c8197.tar.bz2
Bug 368397 - [prefs] migrate tests from 3.7.x stream
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java53
-rw-r--r--tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope.java15
2 files changed, 65 insertions, 3 deletions
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java
index e8b2751..03a484e 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/EclipsePreferencesTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -1057,6 +1057,57 @@ public class EclipsePreferencesTest extends RuntimeTest {
}
/*
+ * Bug 342709 - [prefs] Don't write date/timestamp comment in preferences file
+ */
+ public void test_342709() {
+ // set some prefs
+ IEclipsePreferences root = Platform.getPreferencesService().getRootNode();
+ String one = getUniqueString();
+ String two = getUniqueString();
+ String three = getUniqueString();
+ String key = "key";
+ String value = "value";
+ Preferences node = root.node(TestScope.SCOPE).node(one).node(two).node(three);
+ node.put(key, value);
+
+ // save the prefs to disk
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ fail("1.99", e);
+ }
+
+ assertTrue("2.0", node instanceof TestScope);
+
+ // read the file outside of the pref mechanism
+ IPath location = ((TestScope) node).getLocation();
+ Collection<String> lines = null;
+ try {
+ lines = read(location);
+ } catch (IOException e) {
+ fail("4.99", e);
+ }
+
+ // ensure there is no comment or timestamp in the file
+ for (String line : lines) {
+ assertFalse("3." + line, line.startsWith("#"));
+ }
+ }
+
+ public static Collection<String> read(IPath location) throws IOException {
+ Collection<String> result = new ArrayList<String>();
+ BufferedReader reader = new BufferedReader(new FileReader(location.toFile()));
+ String line;
+ try {
+ while ((line = reader.readLine()) != null)
+ result.add(line);
+ } finally {
+ reader.close();
+ }
+ return result;
+ }
+
+ /*
* Bug 55410 - [runtime] prefs: keys and valid chars
*/
public void test_55410() {
diff --git a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope.java b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope.java
index a7fe711..d96f0ed 100644
--- a/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope.java
+++ b/tests/org.eclipse.core.tests.runtime/src/org/eclipse/core/tests/internal/preferences/TestScope.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 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
@@ -15,6 +15,7 @@ import org.eclipse.core.internal.preferences.EclipsePreferences;
import org.eclipse.core.runtime.*;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
+import org.eclipse.core.tests.harness.CoreTest;
import org.osgi.service.prefs.BackingStoreException;
/**
@@ -27,6 +28,13 @@ public class TestScope extends EclipsePreferences implements IScopeContext {
private int segmentCount;
private IEclipsePreferences loadLevel;
+ public static IPath baseLocation;
+ private IPath location;
+
+ static {
+ baseLocation = new CoreTest().getRandomLocation();
+ }
+
public TestScope() {
this(null, null);
}
@@ -65,7 +73,10 @@ public class TestScope extends EclipsePreferences implements IScopeContext {
}
public IPath getLocation() {
- return null;
+ if (location == null) {
+ location = computeLocation(baseLocation, qualifier);
+ }
+ return location;
}
public String getName() {