Author: ron.sigal(a)jboss.com
Date: 2008-11-28 20:02:41 -0500 (Fri, 28 Nov 2008)
New Revision: 4740
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorConfigTestClient.java
Log:
JBREM-1069: Added testSetPingPeriodByClientConfigUsingSingleArgMethod().
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorConfigTestClient.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorConfigTestClient.java 2008-11-29
01:00:15 UTC (rev 4739)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/ConnectionValidatorConfigTestClient.java 2008-11-29
01:02:41 UTC (rev 4740)
@@ -181,6 +181,59 @@
/**
* Verifies that pingPeriod is set correctly if it appears in Client
+ * configuration map but Client.addConnectionListener(ConnectionListener listener)
+ * puts default value in metadata map.
+ */
+ public void testSetPingPeriodByClientConfigUsingSingleArgMethod() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ addExtraClientConfig(clientConfig);
+ clientConfig.put(ConnectionValidator.VALIDATOR_PING_PERIOD, "3468");
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ assertEquals("abc", client.invoke("abc"));
+
+ // Add connection listener.
+ ConnectionListener listener = new TestConnectionListener();
+ client.addConnectionListener(listener);
+
+ // Test pingPeriod.
+ Field field = Client.class.getDeclaredField("connectionValidator");
+ field.setAccessible(true);
+ ConnectionValidator validator = (ConnectionValidator) field.get(client);
+ field = ConnectionValidator.class.getDeclaredField("pingPeriod");
+ field.setAccessible(true);
+ long pingPeriod = ((Long) field.get(validator)).longValue();
+ assertEquals(3468, pingPeriod);
+
+ // Test timeout.
+ field = ConnectionValidator.class.getDeclaredField("clientInvoker");
+ field.setAccessible(true);
+ AbstractInvoker invoker = (AbstractInvoker) field.get(validator);
+ field = AbstractInvoker.class.getDeclaredField("configuration");
+ field.setAccessible(true);
+ Map config = (Map) field.get(invoker);
+ Object o = config.get(ServerInvoker.TIMEOUT);
+ assertEquals(ConnectionValidator.DEFAULT_PING_TIMEOUT, o);
+
+ // Test ping retries.
+ assertTrue(invoker instanceof MicroSocketClientInvoker);
+ MicroSocketClientInvoker socketInvoker = (MicroSocketClientInvoker) invoker;
+ int defaultPingRetries =
Integer.parseInt(ConnectionValidator.DEFAULT_NUMBER_OF_PING_RETRIES);
+ assertEquals(defaultPingRetries, socketInvoker.getNumberOfCallRetries());
+
+ client.disconnect();
+ }
+
+
+ /**
+ * Verifies that pingPeriod is set correctly if it appears in Client
* configuration map.
*/
public void testSetPingPeriodByClientConfig() throws Throwable
@@ -230,8 +283,8 @@
client.disconnect();
}
-
+
/**
* Verifies that pingPeriod is set correctly if a call is made to
* Client.addConnectionListener(ConnectionListener listener, Map metadata).
Show replies by date