Open GoogleCodeExporter opened 9 years ago
From Simeon Fitch:
This is from an old posting, but I have a basic (and simple) solution
to what I was looking for in the description below, and wanted to
share it in case anyone else wanted it as well. I don't think it's
generalized or significant enough to be a part of the FEST suite (I
report, you decide), but here it is:
public static void initPreferencesStore() throws IOException {
File dir = new File("tmpPrefs");
if(dir.exists()) {
dir.delete();
}
dir.mkdirs();
dir.deleteOnExit();
System.setProperty("java.util.prefs.PreferencesFactory",
"java.util.prefs.FileSystemPreferencesFactory");
System.setProperty("java.util.prefs.userRoot", new File(dir,
"user").getCanonicalPath());
System.setProperty("java.util.prefs.userSystem", new File(dir,
"system").getCanonicalPath());
// Initialize Preferences system by accessing something.
Preferences.userRoot();
}
Note that this has to be called before *any* call to the Preferences
API, or otherwise the property settings won't have any effect. The end
result is that you get a completely empty preferences store for your
test invocation, which is then deleted after execution ends. Note that
I've only tested this on MacOS X.
Original comment by Alex.Rui...@gmail.com
on 5 Sep 2008 at 8:47
[deleted comment]
[deleted comment]
Issue migrated to http://kenai.com/jira/browse/FEST-32
Original comment by Alex.Rui...@gmail.com
on 15 Feb 2009 at 7:20
Issue migrated to http://jira.codehaus.org/browse/FEST-33
Original comment by Alex.Rui...@gmail.com
on 4 Mar 2009 at 1:49
Original issue reported on code.google.com by
Alex.Rui...@gmail.com
on 14 Jul 2008 at 7:53