1 7 package org.jboss.remoting.transport.socket; 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.util.ArrayList ; 16 import java.util.Iterator ; 17 import java.util.List ; 18 19 27 public class InvokerTestCase extends DistributedTestCase 28 { 29 private List results = new ArrayList (); 30 31 public InvokerTestCase(String name) 32 { 33 super(name); 34 } 35 36 protected void setUp() throws Exception 37 { 38 String clientcmd = "java -cp " + System.getProperty("java.class.path") + 39 " " + InvokerClientTest.class.getName() + " 3"; 41 System.out.println("clientcmd: " + clientcmd); 42 String svrcmd = "java -cp " + System.getProperty("java.class.path") + 43 " " + InvokerServerTest.class.getName() + " 3"; 45 System.out.println("svrcmd: " + svrcmd); 46 47 final Process local = Runtime.getRuntime().exec(clientcmd); 48 final Process remote = Runtime.getRuntime().exec(svrcmd); 49 50 } 51 52 protected void tearDown() throws Exception 53 { 54 } 56 57 public void testInvokers() 58 { 59 try 60 { 61 startup(3); 62 System.out.println("startup() called"); 63 shutdown(); 64 System.out.println("shutdown() called"); 65 } 66 catch(Exception e) 67 { 68 e.printStackTrace(); 69 assertTrue("Problem starting or stopping client/server processes.", false); 70 } 71 finally 72 { 73 try 75 { 76 Thread.currentThread().sleep(5000); 77 } 78 catch(InterruptedException e) 79 { 80 e.printStackTrace(); 81 } 82 System.out.println("results.size() = " + results.size()); 83 if(results.size() > 0) 84 { 85 Iterator itr = results.iterator(); 86 while(itr.hasNext()) 87 { 88 String message = (String ) itr.next(); 89 assertTrue(message, false); 90 } 91 } 92 else 93 { 94 assertTrue("No test failures or errors.", true); 95 } 96 97 } 98 } 99 100 105 public void receiveAssert(Address source, String message) 106 { 107 super.receiveAssert(source, message); 108 results.add("Assert source: " + source + "\tmessage: " + message); 109 } 110 111 public static Test suite() 112 { 113 return new TestSuite(InvokerTestCase.class); 114 } 115 116 public static void main(String [] args) 117 { 118 TestRunner.run(suite()); 119 System.exit(0); 120 } 121 122 123 } | Popular Tags |