This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 86997 - Provide not persistent impl. of Preferences for tests
Summary: Provide not persistent impl. of Preferences for tests
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: -- Other -- (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: rmatous
URL:
Keywords: API
Depends on:
Blocks: 73474
  Show dependency tree
 
Reported: 2006-10-12 12:51 UTC by rmatous
Modified: 2008-12-22 18:46 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
patch (9.43 KB, patch)
2006-10-12 12:54 UTC, rmatous
Details | Diff
Simplified, maybe no API neded (3.69 KB, patch)
2006-10-12 16:00 UTC, rmatous
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description rmatous 2006-10-12 12:51:10 UTC
MemoryPreferences would be needed for tests.
Comment 1 rmatous 2006-10-12 12:54:29 UTC
Created attachment 35132 [details]
patch
Comment 2 rmatous 2006-10-12 13:03:48 UTC
I'm going to apply this patch.
Comment 3 Jaroslav Tulach 2006-10-12 13:32:37 UTC
No! Do not override setUp in NbTestCase, if you add new method into that 
class, make sure it has javadoc, and is documented in apichanges. Anyway I am 
not sure that getPreferencesFactoryClass() is really the right API, what would 
people would use it for?
Comment 4 Jesse Glick 2006-10-12 15:55:38 UTC
Don't like the API either. (Shouldn't this be assigned to apireviews?)
MemoryPreferencesFactory by itself is enough, I think - should suffice to write

protected void setUp() throws Exception {
  super.setUp();
  MockServices.setServices(MemoryPreferencesFactory.class);
}

both for Preferences.* and NbPreferences.* factory methods. Please try it and
see if that works.
Comment 5 rmatous 2006-10-12 16:00:00 UTC
Created attachment 35145 [details]
Simplified, maybe no API neded
Comment 6 rmatous 2006-10-12 16:13:10 UTC
I don't acually think that someone should like to replace MemoryPreferencesFactory
by anything else (neither default JDK impl.). So, maybe default registration of
MemoryPreferencesFactory could be enough - see last attachment. 

Definitely System.setProperty("java.util.prefs.PreferencesFactory",... works
but MockServices.setServices(MemoryPreferencesFactory.class) NOT.

Comment 7 Jesse Glick 2006-10-12 18:24:29 UTC
Probably OK. I guess MockServices did not work because Preferences looks only in
the system class loader, not the thread context class loader.
Comment 8 rmatous 2006-10-13 13:36:14 UTC
/cvs/xtest/nbjunit/manifest.mf,v  <--  manifest.mf
new revision: 1.20; previous revision: 1.19

/cvs/xtest/nbjunit/apichanges.xml,v  <--  apichanges.xml
new revision: 1.6; previous revision: 1.5

/cvs/xtest/nbjunit/src/org/netbeans/junit/NbTestCase.java,v  <--  new revision:
1.58; previous revision: 1.57

/cvs/xtest/nbjunit/test/unit/src/org/netbeans/junit/NbTestCaseTest.java,v  <-- 
new revision: 1.6; previous revision: 1.5

/cvs/core/startup/test/unit/src/org/netbeans/core/startup/preferences/NbPreferencesTest.java,v
 new revision: 1.3; previous revision: 1.2
xtest/nbjunit/src/org/netbeans/junit/internal/MemoryPreferencesFactory.java;

/cvs/xtest/nbjunit/src/org/netbeans/junit/internal/MemoryPreferencesFactory.java,v
 initial revision: 1.1

/cvs/openide/util/src/org/openide/util/doc-files/preferences.html,v  <--  new
revision: 1.5; previous revision: 1.4