1 19 20 package org.openide.execution; 21 22 import junit.framework.Assert; 23 import junit.framework.Test; 24 import junit.framework.TestSuite; 25 import org.openide.execution.ExecutionEngine; 26 import org.openide.util.Lookup; 27 import org.openide.util.lookup.AbstractLookup; 28 import org.openide.util.lookup.InstanceContent; 29 30 34 public class ExecutionCompatibilityTest { 35 36 37 private ExecutionCompatibilityTest() { 38 } 39 40 43 public static Test suite() { 44 return suite(null); 45 } 46 47 50 public static Test suite(ExecutionEngine engine) { 51 System.setProperty("org.openide.util.Lookup", ExecutionCompatibilityTest.class.getName() + "$Lkp"); 52 Object o = Lookup.getDefault(); 53 if (!(o instanceof Lkp)) { 54 Assert.fail("Wrong lookup object: " + o); 55 } 56 57 Lkp l = (Lkp)o; 58 l.assignExecutionEngine(engine); 59 60 if (engine != null) { 61 Assert.assertEquals("Same engine found", engine, ExecutionEngine.getDefault()); 62 } else { 63 o = ExecutionEngine.getDefault(); 64 Assert.assertNotNull("Engine found", o); 65 Assert.assertEquals(ExecutionEngine.Trivial.class, o.getClass()); 66 } 67 68 TestSuite ts = new TestSuite(); 69 ts.addTestSuite(ExecutionEngineHid.class); 70 71 return ts; 72 } 73 74 76 public static final class Lkp extends AbstractLookup { 77 private InstanceContent ic; 78 79 public Lkp() { 80 this(new InstanceContent()); 81 } 82 private Lkp(InstanceContent ic) { 83 super(ic); 84 this.ic = ic; 85 } 86 87 final void assignExecutionEngine(ExecutionEngine executionEngine) { 88 if (executionEngine != null) { 90 ic.add(executionEngine); 91 } 92 } 93 94 95 } 96 } 97 | Popular Tags |