[jboss-cvs] JBossRemoting/src/tests/org/jboss/test/remoting/detection/multicast/deadlock ...
Tom Elrod
tom.elrod at jboss.com
Sun Jul 23 15:14:25 EDT 2006
User: telrod
Date: 06/07/23 15:14:25
Modified: src/tests/org/jboss/test/remoting/detection/multicast/deadlock
DeadlockTestCase.java MulticastDetectorClient.java
MulticastDetectorServer.java
Log:
JBREM-553 - updating deadlock test to use ssl socket transport and include client on server side.
Revision Changes Path
1.2 +9 -1 JBossRemoting/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/DeadlockTestCase.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: DeadlockTestCase.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/DeadlockTestCase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- DeadlockTestCase.java 21 Jul 2006 20:02:22 -0000 1.1
+++ DeadlockTestCase.java 23 Jul 2006 19:14:25 -0000 1.2
@@ -22,6 +22,7 @@
package org.jboss.test.remoting.detection.multicast.deadlock;
import junit.framework.TestCase;
+import org.apache.log4j.Level;
/**
* Test for JBREM-553
@@ -31,6 +32,10 @@
{
public static void main(String[] args)
{
+
+ org.apache.log4j.BasicConfigurator.configure();
+ org.apache.log4j.Category.getRoot().setLevel(Level.DEBUG);
+
DeadlockTestCase test = new DeadlockTestCase();
try
{
@@ -51,11 +56,14 @@
server.setUp();
client.setUp();
client.testDetection();
+ server.tearDown();
+ client.disconnect();
+ System.out.println("done testing.");
}
finally
{
client.tearDown();
- server.tearDown();
+// server.tearDown();
}
}
}
\ No newline at end of file
1.2 +79 -3 JBossRemoting/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/MulticastDetectorClient.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MulticastDetectorClient.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/MulticastDetectorClient.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- MulticastDetectorClient.java 21 Jul 2006 20:02:22 -0000 1.1
+++ MulticastDetectorClient.java 23 Jul 2006 19:14:25 -0000 1.2
@@ -2,14 +2,22 @@
import junit.framework.TestCase;
import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.detection.multicast.MulticastDetector;
import org.jboss.remoting.network.NetworkInstance;
import org.jboss.remoting.network.NetworkRegistry;
+import org.jboss.remoting.security.SSLSocketBuilder;
+import org.jboss.remoting.transport.Connector;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
+import java.util.HashMap;
+import java.util.Map;
/**
* Test for JBREM-553
@@ -19,6 +27,9 @@
{
private MulticastDetector detector;
private NetworkRegistry registry;
+ private Connector connector;
+
+ private Client remotingClient = null;
public void setUp() throws Exception
{
@@ -52,12 +63,30 @@
NetworkInstance ni = instances[0];
InvokerLocator[] locator = ni.getLocators();
InvokerLocator serverLocator = locator[0];
- Client remotingClient = new Client(serverLocator);
+
+ Map config = new HashMap();
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
+ String trustStoreFilePath = this.getClass().getResource("ssl/.truststore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
+ String keyStoreFilePath = this.getClass().getResource("ssl/.keystore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server");
+ config.put(SSLSocketBuilder.REMOTING_CLIENT_AUTH_MODE, SSLSocketBuilder.CLIENT_AUTH_MODE_WANT);
+
+ remotingClient = new Client(serverLocator, config);
remotingClient.connect();
+ String invokerLocatorurl = "socket://localhost:8700";
+ connector = new Connector(invokerLocatorurl, config);
+ connector.create();
+
+ connector.addInvocationHandler("test", new LocalHandler());
+ connector.start();
+
try
{
- Object ret = remotingClient.invoke("foobar");
+ Object ret = remotingClient.invoke(invokerLocatorurl);
System.out.println("return from calling server is " + ret);
}
catch (Throwable throwable)
@@ -66,22 +95,69 @@
throw new Exception(throwable.getMessage());
}
- Thread.currentThread().sleep(10000);
+// Thread.currentThread().sleep(20000);
+//
+// System.out.println("Disconnecting.");
+//
+// remotingClient.disconnect();
+//
+// System.out.println("Disconnected.");
+ }
+
+ public void disconnect() throws InterruptedException
+ {
+ Thread.currentThread().sleep(30000);
System.out.println("Disconnecting.");
remotingClient.disconnect();
System.out.println("Disconnected.");
+
+ remotingClient = null;
+
}
public void tearDown() throws Exception
{
+ if (remotingClient != null)
+ {
+ remotingClient.disconnect();
+ }
if (detector != null)
{
detector.stop();
}
}
+ public class LocalHandler implements ServerInvocationHandler
+ {
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ //TODO: -TME Implement
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ //TODO: -TME Implement
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ return "foo";
+ }
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ //TODO: -TME Implement
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ //TODO: -TME Implement
+ }
+ }
+
}
1.2 +93 -3 JBossRemoting/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/MulticastDetectorServer.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MulticastDetectorServer.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/tests/org/jboss/test/remoting/detection/multicast/deadlock/MulticastDetectorServer.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- MulticastDetectorServer.java 21 Jul 2006 20:02:22 -0000 1.1
+++ MulticastDetectorServer.java 23 Jul 2006 19:14:25 -0000 1.2
@@ -2,16 +2,23 @@
import org.apache.log4j.Level;
import org.jboss.jrunit.extensions.ServerTestCase;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.detection.multicast.MulticastDetector;
import org.jboss.remoting.network.NetworkRegistry;
+import org.jboss.remoting.security.SSLSocketBuilder;
import org.jboss.remoting.transport.Connector;
import org.jboss.test.remoting.TestUtil;
-import org.jboss.test.remoting.transport.mock.MockServerInvocationHandler;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
+import java.util.HashMap;
+import java.util.Map;
/**
* Test for JBREM-553
@@ -22,6 +29,7 @@
private MulticastDetector detector;
private Connector connector;
private NetworkRegistry registry;
+ private Map config = new HashMap();
public void setUp() throws Exception
{
@@ -41,11 +49,21 @@
InvokerLocator locator = new InvokerLocator("socket://localhost:" + port);
System.out.println("Starting remoting server with locator uri of: " + locator.getLocatorURI());
- connector = new Connector();
+
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
+ String trustStoreFilePath = this.getClass().getResource("ssl/.truststore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
+ String keyStoreFilePath = this.getClass().getResource("ssl/.keystore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server");
+ config.put(SSLSocketBuilder.REMOTING_CLIENT_AUTH_MODE, SSLSocketBuilder.CLIENT_AUTH_MODE_WANT);
+
+ connector = new Connector(config);
connector.setInvokerLocator(locator.getLocatorURI());
connector.create();
- MockServerInvocationHandler handler = new MockServerInvocationHandler();
+ TestHandler handler = new TestHandler();
connector.addInvocationHandler("mock", handler);
ObjectName obj = new ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
@@ -89,5 +107,77 @@
}
+ public class TestHandler implements ServerInvocationHandler
+ {
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ //TODO: -TME Implement
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ //TODO: -TME Implement
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ Object obj = invocation.getParameter();
+ if(obj instanceof String)
+ {
+ String locator = (String)obj;
+ ServerClient client = new ServerClient(locator);
+ new Thread(client).start();
+ }
+
+
+ return "foobar";
+ }
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ //TODO: -TME Implement
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ //TODO: -TME Implement
+ }
+ }
+
+ public class ServerClient implements Runnable
+ {
+ private String locatorUrl = null;
+
+ public ServerClient(String locator)
+ {
+ this.locatorUrl = locator;
+ }
+
+ public void run()
+ {
+
+ try
+ {
+ Client remotingClient = new Client(new InvokerLocator(locatorUrl), config);
+ remotingClient.connect();
+ Object ret = remotingClient.invoke("bar");
+ System.out.println("client returned " + ret);
+ Thread.currentThread().sleep(3000);
+ remotingClient.disconnect();
+ System.out.println("server client disconnected.");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ catch (Throwable throwable)
+ {
+ throwable.printStackTrace();
+ }
+
+ }
+ }
+
}
More information about the jboss-cvs-commits
mailing list