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