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