1.1 --- a/openide.util/test/unit/src/org/openide/util/RequestProcessorTest.java Tue Mar 17 13:14:27 2009 +0300
1.2 +++ b/openide.util/test/unit/src/org/openide/util/RequestProcessorTest.java Thu Mar 26 03:16:42 2009 +0300
1.3 @@ -177,7 +177,8 @@
1.4 rp = null;
1.5 assertGC("runnable should be collected", wr);
1.6 } /**/
1.7 -
1.8 +
1.9 + @RandomlyFails
1.10 public void testScheduleAndIsFinished() throws InterruptedException {
1.11 class Run implements Runnable {
1.12 public boolean run;
2.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java Tue Mar 17 13:14:27 2009 +0300
2.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/MetaInfServicesLookupTest.java Thu Mar 26 03:16:42 2009 +0300
2.3 @@ -78,6 +78,7 @@
2.4 import org.openide.util.LookupEvent;
2.5 import org.openide.util.LookupListener;
2.6 import org.openide.util.RequestProcessor;
2.7 +import org.openide.util.test.MockLookup;
2.8
2.9 /** Test finding services from manifest.
2.10 * @author Jesse Glick
2.11 @@ -223,7 +224,7 @@
2.12 Lookup l = getTestedLookup(c2);
2.13 Class xface = c1.loadClass("org.foo.Interface");
2.14 List results = new ArrayList(l.lookup(new Lookup.Template(xface)).allInstances());
2.15 - assertEquals(2, results.size());
2.16 + assertEquals("Two items in result: " + results, 2, results.size());
2.17 // Note that they have to be in order:
2.18 assertEquals("org.foo.impl.Implementation1", results.get(0).getClass().getName());
2.19 assertEquals("org.bar.Implementation2", results.get(1).getClass().getName());
2.20 @@ -385,6 +386,8 @@
2.21 no = null;
2.22 l = null;
2.23 lookups.clear();
2.24 + MockLookup.setInstances();
2.25 + Thread.currentThread().setContextClassLoader(null);
2.26 assertGC("Class can be garbage collected", ref);
2.27 }
2.28
3.1 --- a/openide.util/test/unit/src/org/openide/util/lookup/NamedServicesLookupTest.java Tue Mar 17 13:14:27 2009 +0300
3.2 +++ b/openide.util/test/unit/src/org/openide/util/lookup/NamedServicesLookupTest.java Thu Mar 26 03:16:42 2009 +0300
3.3 @@ -66,8 +66,8 @@
3.4 @Override
3.5 protected Lookup createLookup(ClassLoader c) {
3.6 MockLookup.setInstances(c);
3.7 + Thread.currentThread().setContextClassLoader(c);
3.8 Lookup l = Lookups.forPath("sub/path");
3.9 - MockLookup.setInstances();
3.10 return l;
3.11 }
3.12
4.1 --- a/openide.util/test/unit/src/org/openide/util/test/MockLookup.java Tue Mar 17 13:14:27 2009 +0300
4.2 +++ b/openide.util/test/unit/src/org/openide/util/test/MockLookup.java Thu Mar 26 03:16:42 2009 +0300
4.3 @@ -113,6 +113,16 @@
4.4 */
4.5 public static void setInstances(Object... instances) {
4.6 ClassLoader l = MockLookup.class.getClassLoader();
4.7 + setLookup(Lookups.fixed(instances), Lookups.metaInfServices(l), Lookups.singleton(l));
4.8 + }
4.9 + /**
4.10 + * Sets the global default lookup with some fixed instances and
4.11 + * content read from Services folder from system file system.
4.12 + * Will also include (at a lower priority) a {@link ClassLoader},
4.13 + * and services found from <code>META-INF/services/*</code> in the classpath.
4.14 + */
4.15 + public static void setLayersAndInstances(Object... instances) {
4.16 + ClassLoader l = MockLookup.class.getClassLoader();
4.17 if (l != Lookup.getDefault().lookup(ClassLoader.class)) {
4.18 setLookup(Lookups.fixed(instances), Lookups.metaInfServices(l), Lookups.singleton(l));
4.19 }