1 7 package org.jboss.remoting.callback.pull.memory.callbackstore; 8 9 import junit.framework.Test; 10 import junit.framework.TestSuite; 11 import junit.textui.TestRunner; 12 import org.jboss.dtf.DistributedTestCase; 13 import org.jgroups.Address; 14 15 import java.io.IOException ; 16 import java.util.ArrayList ; 17 import java.util.Iterator ; 18 import java.util.List ; 19 20 28 public class CallbackStoreCallbackTestCase extends DistributedTestCase 29 { 30 private List results = new ArrayList (); 31 32 public CallbackStoreCallbackTestCase(String name) 33 { 34 super(name); 35 } 36 37 protected void setUp() throws Exception 38 { 39 new Thread () 40 { 41 42 public void run() 43 { 44 String clientcmd = "java -cp " + System.getProperty("java.class.path") + 45 " " + CallbackTestClient.class.getName() + " 3"; 47 System.out.println("clientcmd: " + clientcmd); 48 String svrcmd = "java -cp " + System.getProperty("java.class.path") + 49 " " + CallbackTestServer.class.getName() + " 3"; 51 System.out.println("svrcmd: " + svrcmd); 52 53 try 54 { 55 final Process local = Runtime.getRuntime().exec(clientcmd); 56 final Process remote = Runtime.getRuntime().exec(svrcmd); 57 } 58 catch(IOException e) 59 { 60 e.printStackTrace(); 61 } 62 } 63 }.start(); 64 } 65 66 protected void tearDown() throws Exception 67 { 68 } 70 71 public void testInvokers() 72 { 73 try 74 { 75 setShutdownTimeout(600000); startup(3); 77 System.out.println("startup() called"); 78 shutdown(); 79 System.out.println("shutdown() called"); 80 } 81 catch(Exception e) 82 { 83 e.printStackTrace(); 84 assertTrue("Problem starting or stopping client/server processes.", false); 85 } 86 finally 87 { 88 try 90 { 91 Thread.currentThread().sleep(5000); 92 } 93 catch(InterruptedException e) 94 { 95 e.printStackTrace(); 96 } 97 System.out.println("results.size() = " + results.size()); 98 if(results.size() > 0) 99 { 100 Iterator itr = results.iterator(); 101 while(itr.hasNext()) 102 { 103 String message = (String ) itr.next(); 104 assertTrue(message, false); 105 } 106 } 107 else 108 { 109 assertTrue("No test failures or errors.", true); 110 } 111 112 } 113 } 114 115 120 public void receiveAssert(Address source, String message) 121 { 122 super.receiveAssert(source, message); 123 results.add("Assert source: " + source + "\tmessage: " + message); 124 } 125 126 public static Test suite() 127 { 128 return new TestSuite(CallbackStoreCallbackTestCase.class); 129 } 130 131 public static void main(String [] args) 132 { 133 TestRunner.run(suite()); 134 System.exit(0); 135 } 136 137 138 } | Popular Tags |