Bug 363836 - [prefs] Don't write date/timestamp comment in preferences
file
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 @@
 	}
 
 	/*
+	 * 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.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 @@
 	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 IPath getLocation() {
-		return null;
+		if (location == null) {
+			location = computeLocation(baseLocation, qualifier);
+		}
+		return location;
 	}
 
 	public String getName() {