1
package org.jboss.test.remoting.transport.socket.ssl.connection_check;
3
import junit.framework.TestCase;
4
import org.apache.log4j.Level;
5
import org.jboss.logging.Logger;
6
import org.jboss.remoting.Client;
7
import org.jboss.remoting.InvokerLocator;
8
import org.jboss.remoting.invocation.NameBasedInvocation;
9
import org.jboss.remoting.transport.socket.SocketServerInvoker;
10
import org.jboss.test.remoting.transport.socket.ssl.SSLInvokerConstants;
13
* This is the actual concrete test for the invoker client. Uses socket transport by default.
15
* @author <a href="mailto:telrod@e2technologies.net">Tom Elrod</a>
17
public class InvokerClientTest extends TestCase implements SSLInvokerConstants
19
private Client client;
20
private static final Logger log = Logger.getLogger(InvokerClientTest.class);
26
// since doing basic (using default ssl server socket factory)
27
// need to set the system properties to the truststore
28
String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
29
System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
31
InvokerLocator locator = new InvokerLocator(getTransport() + "://" + host + ":" + getPort() + "/?" + SocketServerInvoker.CHECK_CONNECTION_KEY + "=" + Boolean.TRUE);
32
client = new Client(locator, "mock");
37
InvokerClientTest.log.error(e.getMessage(), e);
41
public void testRemoteCall() throws Throwable
43
InvokerClientTest.log.debug("running testRemoteCall()");
45
InvokerClientTest.log.debug("client.getInvoker().getLocator()" + client.getInvoker().getLocator());
47
// simple invoke, should return bar
48
Object ret = makeInvocation("foo", "bar");
49
assertTrue("Result of testRemoteCall() invocation of foo.", "bar".equals(ret));
50
if ("bar".equals(ret))
52
InvokerClientTest.log.debug("PASS");
56
InvokerClientTest.log.debug("FAILED");
58
assertEquals("bar", ret);
62
protected String getTransport()
67
protected int getPort()
72
private Object makeInvocation(String method, String param) throws Throwable
74
Object ret = client.invoke(new NameBasedInvocation(method,
76
new String[]{String.class.getName()}),
82
public void setUp() throws Exception
84
org.apache.log4j.BasicConfigurator.configure();
85
org.apache.log4j.Category.getRoot().setLevel(Level.INFO);
86
org.apache.log4j.Category.getInstance("org.jgroups").setLevel(Level.INFO);
87
org.apache.log4j.Category.getInstance("org.jboss.remoting").setLevel(Level.DEBUG);
88
org.apache.log4j.Category.getInstance("test").setLevel(Level.DEBUG);
93
public void tearDown() throws Exception