Author: ron.sigal(a)jboss.com
Date: 2008-04-24 01:36:33 -0400 (Thu, 24 Apr 2008)
New Revision: 4053
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorServer.java
Log:
JBREM-930: Instead of expecting a single Connect, the client expects to find the Connector
created by the server.
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorClient.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorClient.java 2008-04-24
04:26:07 UTC (rev 4052)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorClient.java 2008-04-24
05:36:33 UTC (rev 4053)
@@ -22,6 +22,9 @@
package org.jboss.test.remoting.detection.multicast.startup;
import junit.framework.TestCase;
+
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.detection.multicast.MulticastDetector;
import org.jboss.remoting.network.NetworkInstance;
import org.jboss.remoting.network.NetworkRegistry;
@@ -61,10 +64,41 @@
NetworkInstance[] instances = detector.forceDetection();
long end = System.currentTimeMillis();
- System.out.println("instance = " + instances);
+ System.out.println("instances");
+ for (int i = 0; i < instances.length; i++)
+ {
+ System.out.println(" " + instances[i]);
+ }
System.out.println("force detection took " + (end - start) + "
milliseconds.");
+
+ boolean foundServer = false;
+ mainLoop: for (int i = 0; i < instances.length; i++)
+ {
+ InvokerLocator[] locators = instances[i].getLocators();
+ for (int j = 0; j < locators.length; j++)
+ {
+ Client client = new Client(locators[j]);
+ client.connect();
+ try
+ {
+ if
("MulticastDetectorServer".equals(client.invoke("abc")))
+ {
+ foundServer = true;
+ break mainLoop;
+ }
+ }
+ catch (Throwable t)
+ {
+ t.printStackTrace();
+ }
+ finally
+ {
+ client.disconnect();
+ }
+ }
+ }
- assertEquals(1, instances.length);
+ assertTrue(foundServer);
}
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorServer.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorServer.java 2008-04-24
04:26:07 UTC (rev 4052)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/detection/multicast/startup/MulticastDetectorServer.java 2008-04-24
05:36:33 UTC (rev 4053)
@@ -25,13 +25,15 @@
import org.apache.log4j.Level;
import org.jboss.jrunit.extensions.ServerTestCase;
+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.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;
@@ -69,7 +71,7 @@
connector.setInvokerLocator(locator.getLocatorURI());
connector.create();
- MockServerInvocationHandler handler = new MockServerInvocationHandler();
+ TestInvocationHandler handler = new TestInvocationHandler();
connector.addInvocationHandler("mock", handler);
ObjectName obj = new
ObjectName("jboss.remoting:type=Connector,transport=" + locator.getProtocol());
@@ -114,5 +116,15 @@
}
-
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return "MulticastDetectorServer";
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
}
\ No newline at end of file
Show replies by date