1 7 package org.jboss.remoting.marshall.dynamic.local; 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 MarshallerLoadingTestCase extends DistributedTestCase 28 { 29 private List results = new ArrayList (); 30 31 public MarshallerLoadingTestCase(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") + System.getProperty("path.separator") + 39 convertFileSeperator(System.getProperty("loader.path")) + 40 " " + MarshallerLoadingClient.class.getName() + " 3"; 42 System.out.println("clientcmd: " + clientcmd); 43 String svrcmd = "java -cp " + System.getProperty("java.class.path") + System.getProperty("path.separator") + 44 convertFileSeperator(System.getProperty("loader.path")) + 45 " " + MarshallerLoadingServer.class.getName() + " 3"; 47 System.out.println("svrcmd: " + svrcmd); 48 49 final Process local = Runtime.getRuntime().exec(clientcmd); 50 final Process remote = Runtime.getRuntime().exec(svrcmd); 51 52 } 53 54 protected void tearDown() throws Exception 55 { 56 } 58 59 private String convertFileSeperator(String property) 60 { 61 String newPath = property; 62 try 63 { 64 String fileSeperator = System.getProperty("file.separator"); 65 String seperatorToReplace = "\\"; 66 if(seperatorToReplace.equals(fileSeperator)) 67 { 68 seperatorToReplace = "/"; 69 } 70 System.out.println("fileSeperator = " + fileSeperator); 71 System.out.println("seperatorToReplace = " + seperatorToReplace); 72 73 CharSequence charSet = seperatorToReplace.subSequence(0, 1); 74 System.out.println("charSet = " + charSet); 75 char c = charSet.charAt(0); 76 System.out.println("char = " + c); 77 78 CharSequence charSet2 = fileSeperator.subSequence(0, 1); 79 System.out.println("charSet = " + charSet2); 80 char c2 = charSet2.charAt(0); 81 System.out.println("char = " + c2); 82 83 newPath = property.replace(c, c2); 84 85 } 86 catch(Exception e) 87 { 88 e.printStackTrace(); 89 } 90 System.out.println("New path = " + newPath); 91 return newPath; 92 } 93 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(MarshallerLoadingTestCase.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 |