1 19 20 package org.openide.execution; 21 22 import java.security.AllPermission ; 23 import java.security.CodeSource ; 24 import java.security.PermissionCollection ; 25 import java.security.Permissions ; 26 import junit.framework.TestCase; 27 import org.openide.execution.ExecutionEngine; 28 import org.openide.execution.ExecutorTask; 29 import org.openide.util.Lookup; 30 import org.openide.windows.IOProvider; 31 import org.openide.windows.InputOutput; 32 33 37 public class ExecutionEngineHid extends TestCase { 38 39 public ExecutionEngineHid(String testName) { 40 super(testName); 41 } 42 43 public void testGetDefault() { 44 ExecutionEngine result = ExecutionEngine.getDefault(); 45 assertNotNull(result); 46 } 47 48 public void testExecuteIsNonBlocking() throws Exception { 49 class Block implements Runnable { 50 public boolean here; 51 52 53 public synchronized void run() { 54 here = true; 55 notifyAll(); 56 try { 57 wait(); 58 } catch (InterruptedException ex) { 59 ex.printStackTrace(); 60 } 61 } 62 63 public synchronized void waitForRun() throws InterruptedException { 64 while(!here) { 65 wait(); 66 } 67 notifyAll(); 68 } 69 } 70 Block block = new Block(); 71 72 73 ExecutionEngine instance = ExecutionEngine.getDefault(); 74 ExecutorTask result = instance.execute("My task", block, InputOutput.NULL); 75 76 assertFalse("Of course it is not finished, as it is blocked", result.isFinished()); 77 block.waitForRun(); 78 79 int r = result.result(); 80 assertEquals("Default result is 0", 0, r); 81 } 82 83 } 84 | Popular Tags |