1 7 package org.jboss.test.remoting.transport.socket.ssl.custom; 8 9 import java.rmi.server.UID ; 10 import org.jboss.logging.Logger; 11 import org.jboss.remoting.Client; 12 import org.jboss.remoting.InvokerLocator; 13 import org.jboss.remoting.invocation.NameBasedInvocation; 14 import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants; 15 16 import junit.framework.TestCase; 17 18 19 24 public class InvokerClientTest extends TestCase implements SSLInvokerConstants 25 { 26 private static final Logger log = Logger.getLogger(InvokerClientTest.class); 27 28 private String sessionId = new UID ().toString(); 29 30 private Client client; 31 32 public void init() 33 { 34 try 35 { 36 String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile(); 39 System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath); 40 41 InvokerLocator locator = new InvokerLocator(transport + "://localhost:" + port); 42 client = new Client(locator, "mock"); 43 client.connect(); 44 } 45 catch(Exception e) 46 { 47 log.error(e.getMessage(), e); 48 } 49 } 50 51 public void testRemoteCall() throws Throwable 52 { 53 log.debug("running testRemoteCall()"); 54 55 log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator()); 56 57 Object ret = makeInvocation("foo", "bar"); 59 assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret)); 60 if("bar".equals(ret)) 61 { 62 log.debug("PASS"); 63 } 64 else 65 { 66 log.debug("FAILED"); 67 } 68 assertEquals("bar", ret); 69 70 } 71 72 private Object makeInvocation(String method, String param) throws Throwable 73 { 74 Object ret = client.invoke(new NameBasedInvocation(method, 75 new Object []{param}, 76 new String []{String .class.getName()}), 77 null); 78 79 return ret; 80 } 81 82 public void setUp() throws Exception 83 { 84 init(); 85 } 86 87 public void tearDown() throws Exception 88 { 89 if(client != null) 90 { 91 client.disconnect(); 92 client = null; 93 } 94 } 95 96 97 } 98 | Popular Tags |