1 package org.sapia.ubik.rmi.server.command; 2 3 import junit.framework.TestCase; 4 5 import org.sapia.ubik.net.ServerAddress; 6 import org.sapia.ubik.rmi.server.VmId; 7 8 9 13 public class OutQueueTest extends TestCase { 14 17 public OutQueueTest(String name) { 18 super(name); 19 } 20 21 public void testShutdownAll() throws Exception { 22 OutQueue.setResponseSender(new TestResponseSender()); 23 24 CommandProcessor proc = new CommandProcessor(1); 25 VmId vmid = VmId.getInstance(); 26 ServerAddress addr = new TestAddress("testAddress"); 27 proc.processAsyncCommand("cmdId", vmid, addr, 28 new TestCommand() { 29 public Object execute() throws Throwable { 30 try { 31 Thread.sleep(500); 32 } catch (InterruptedException e) { 33 } 34 35 return null; 36 } 37 }); 38 proc.shutdown(2000); 39 40 OutQueue queue = OutQueue.getQueueFor(new Destination(addr, vmid)); 41 super.assertEquals(0, queue.size()); 42 } 43 44 public static class TestAddress implements ServerAddress { 45 String _id; 46 47 TestAddress(String id) { 48 _id = id; 49 } 50 51 54 public String getTransportType() { 55 return "testTransport"; 56 } 57 58 public int hashCode() { 59 return _id.hashCode(); 60 } 61 62 65 public boolean equals(Object o) { 66 return _id.equals(o); 67 } 68 } 69 70 static class TestCommand extends Command { 71 74 public TestCommand() { 75 super(); 76 } 77 78 81 public Object execute() throws Throwable { 82 return null; 83 } 84 } 85 } 86 | Popular Tags |