Author: ron.sigal(a)jboss.com
Date: 2011-01-25 23:44:40 -0500 (Tue, 25 Jan 2011)
New Revision: 6221
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java
Log:
JBREM-1144: Added testServerIdentityWithLeasingNewLease().
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java
===================================================================
---
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java 2011-01-26
04:16:48 UTC (rev 6220)
+++
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/connection/identity/ServerIdentityTestCase.java 2011-01-26
04:44:40 UTC (rev 6221)
@@ -170,7 +170,7 @@
log.info(getName() + " PASSES");
}
- public void testServerIdentityWithLeasing() throws Throwable
+ public void testServerIdentityWithLeasingNewServer() throws Throwable
{
log.info("entering " + getName());
@@ -227,6 +227,67 @@
}
+ public void testServerIdentityWithLeasingNewLease() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true);
+
+ // Create client. Adding "dummy=dummy" assures that InvokerRegistry will
not create a
+ // LocalClientInvoker for the ConnectionValidator.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI +
"&dummy=dummy");
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("numberOfCallRetries", "3"); // for
ConnectionValidator
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Install connection listener.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put(Remoting.USE_SERVER_CONNECTION_IDENTITY, "true");
+ metadata.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "10000");
+ metadata.put(ConnectionValidator.VALIDATOR_PING_TIMEOUT, "10000");
+ client.addConnectionListener(listener, metadata);
+ log.info(this + " added connection listener: " + listener);
+ // Allow time to get serverId of first server.
+ Thread.sleep(15000);
+
+ // Verify listener is notified if Lease is destroyed.
+ Field field = ServerInvoker.class.getDeclaredField("clientLeases");
+ field.setAccessible(true);
+ Map clientLeases = (Map) field.get(connector.getServerInvoker());
+ clientLeases.clear();
+ log.info("REMOVED LEASE");
+ Thread.sleep(15000);
+ log.info(this + " listener.connectionFailed: " +
listener.connectionFailed);
+ assertTrue(listener.connectionFailed);
+
+ setOut(originalOutPrintStream);
+ String sOut = new String(baosOut.toByteArray());
+ setErr(originalErrPrintStream);
+ String sErr = new String(baosErr.toByteArray());
+ if (!(sOut.indexOf("detected new serverId:") > -1 ||
sErr.indexOf("detected new serverId:") > -1))
+ {
+ System.out.println(sOut);
+ System.out.println(sErr);
+ }
+ assertTrue(sOut.indexOf("detected new serverId:") > -1 ||
sErr.indexOf("detected new serverId:") > -1);
+
+ client.disconnect();
+ shutdownServer();
+
+ log.info(getName() + " PASSES");
+ }
+
+
protected String getTransport()
{
return "socket";
Show replies by date