1 7 package org.jboss.remoting.marshall.dynamic.remote.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.jboss.remoting.marshall.dynamic.local.MarshallerLoadingServer; 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 SocketMarshallerLoadingTestCase extends DistributedTestCase 29 { 30 private List results = new ArrayList (); 31 32 public SocketMarshallerLoadingTestCase(String name) 33 { 34 super(name); 35 } 36 37 protected void setUp() throws Exception 38 { 39 System.out.println(System.getProperty("loader.path")); 40 String clientcmd = "java -cp " + System.getProperty("java.class.path") + 41 " " + org.jboss.remoting.marshall.dynamic.local.MarshallerLoadingClient.class.getName() + " 3"; 43 System.out.println("clientcmd: " + clientcmd); 44 String svrcmd = "java -cp " + System.getProperty("java.class.path") + System.getProperty("path.separator") + 45 convertFileSeperator(System.getProperty("loader.path")) + 46 " " + MarshallerLoadingServer.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 private String convertFileSeperator(String property) 56 { 57 String newPath = property; 58 try 59 { 60 String fileSeperator = System.getProperty("file.separator"); 61 String seperatorToReplace = "\\"; 62 if(seperatorToReplace.equals(fileSeperator)) 63 { 64 seperatorToReplace = "/"; 65 } 66 System.out.println("fileSeperator = " + fileSeperator); 67 System.out.println("seperatorToReplace = " + seperatorToReplace); 68 69 CharSequence charSet = seperatorToReplace.subSequence(0, 1); 70 System.out.println("charSet = " + charSet); 71 char c = charSet.charAt(0); 72 System.out.println("char = " + c); 73 74 CharSequence charSet2 = fileSeperator.subSequence(0, 1); 75 System.out.println("charSet = " + charSet2); 76 char c2 = charSet2.charAt(0); 77 System.out.println("char = " + c2); 78 79 newPath = property.replace(c, c2); 80 81 } 82 catch(Exception e) 83 { 84 e.printStackTrace(); 85 } 86 System.out.println("New path = " + newPath); 87 return newPath; 88 } 89 90 protected void tearDown() throws Exception 91 { 92 } 94 95 public void testInvokers() 96 { 97 try 98 { 99 startup(3); 100 System.out.println("startup() called"); 101 shutdown(); 102 System.out.println("shutdown() called"); 103 } 104 catch(Exception e) 105 { 106 e.printStackTrace(); 107 assertTrue("Problem starting or stopping client/server processes.", false); 108 } 109 finally 110 { 111 try 113 { 114 Thread.currentThread().sleep(5000); 115 } 116 catch(InterruptedException e) 117 { 118 e.printStackTrace(); 119 } 120 System.out.println("results.size() = " + results.size()); 121 if(results.size() > 0) 122 { 123 Iterator itr = results.iterator(); 124 while(itr.hasNext()) 125 { 126 String message = (String ) itr.next(); 127 assertTrue(message, false); 128 } 129 } 130 else 131 { 132 assertTrue("No test failures or errors.", true); 133 } 134 135 } 136 } 137 138 143 public void receiveAssert(Address source, String message) 144 { 145 super.receiveAssert(source, message); 146 results.add("Assert source: " + source + "\tmessage: " + message); 147 } 148 149 public static Test suite() 150 { 151 return new TestSuite(SocketMarshallerLoadingTestCase.class); 152 } 153 154 public static void main(String [] args) 155 { 156 TestRunner.run(suite()); 157 System.exit(0); 158 } 159 160 161 } | Popular Tags |