Author: ron.sigal(a)jboss.com
Date: 2009-03-20 02:40:57 -0400 (Fri, 20 Mar 2009)
New Revision: 4883
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java
Log:
JBREM-1082: Added several test methods.
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java 2009-03-20
06:38:41 UTC (rev 4882)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java 2009-03-20
06:40:57 UTC (rev 4883)
@@ -115,14 +115,14 @@
assertEquals("abc", client.invoke("abc"));
log.info("connection is good");
- // Configure callback polling.
+ // Configure ConnectionListener.
TestConnectionListener listener = new TestConnectionListener();
HashMap metadata = new HashMap();
metadata.put("validatorPingTimeout", "555");
client.addConnectionListener(listener, metadata);
- // Test setting of parameters in CallbackPoller.
- testParameters(client, 333, 555, true);
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 555, true);
client.removeConnectionListener(listener);
client.disconnect();
@@ -156,14 +156,14 @@
assertEquals("abc", client.invoke("abc"));
log.info("connection is good");
- // Configure callback polling.
+ // Configure ConnectionListener.
TestConnectionListener listener = new TestConnectionListener();
HashMap metadata = new HashMap();
metadata.put("validatorPingTimeout", "555");
client.addConnectionListener(listener, metadata);
- // Test setting of parameters in CallbackPoller.
- testParameters(client, 333, 555, true);
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 555, true);
client.removeConnectionListener(listener);
client.disconnect();
@@ -197,14 +197,14 @@
assertEquals("abc", client.invoke("abc"));
log.info("connection is good");
- // Configure callback polling.
+ // Configure ConnectionListener.
TestConnectionListener listener = new TestConnectionListener();
HashMap metadata = new HashMap();
metadata.put("validatorPingTimeout", "555");
client.addConnectionListener(listener, metadata);
- // Test setting of parameters in CallbackPoller.
- testParameters(client, 333, 555, true);
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 555, true);
client.removeConnectionListener(listener);
client.disconnect();
@@ -237,15 +237,15 @@
assertEquals("abc", client.invoke("abc"));
log.info("connection is good");
- // Configure callback polling.
+ // Configure ConnectionListener.
TestConnectionListener listener = new TestConnectionListener();
HashMap metadata = new HashMap();
metadata.put("validatorPingTimeout", "555");
metadata.put(Client.USE_ALL_PARAMS, "false");
client.addConnectionListener(listener, metadata);
- // Test setting of parameters in CallbackPoller.
- testParameters(client, 333, 555, true);
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 555, true);
client.removeConnectionListener(listener);
client.disconnect();
@@ -279,14 +279,14 @@
assertEquals("abc", client.invoke("abc"));
log.info("connection is good");
- // Configure callback polling.
+ // Configure ConnectionListener.
TestConnectionListener listener = new TestConnectionListener();
HashMap metadata = new HashMap();
metadata.put("validatorPingTimeout", "555");
client.addConnectionListener(listener, metadata);
- // Test setting of parameters in CallbackPoller.
- testParameters(client, 333, 555, false);
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 555, false);
client.removeConnectionListener(listener);
client.disconnect();
@@ -320,14 +320,14 @@
assertEquals("abc", client.invoke("abc"));
log.info("connection is good");
- // Configure callback polling.
+ // Configure ConnectionListener.
TestConnectionListener listener = new TestConnectionListener();
HashMap metadata = new HashMap();
metadata.put("validatorPingTimeout", "555");
client.addConnectionListener(listener, metadata);
- // Test setting of parameters in CallbackPoller.
- testParameters(client, 333, 555, false);
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 555, false);
client.removeConnectionListener(listener);
client.disconnect();
@@ -360,15 +360,15 @@
assertEquals("abc", client.invoke("abc"));
log.info("connection is good");
- // Configure callback polling.
+ // Configure ConnectionListener.
TestConnectionListener listener = new TestConnectionListener();
HashMap metadata = new HashMap();
metadata.put("validatorPingTimeout", "555");
metadata.put(Client.USE_ALL_PARAMS, "true");
client.addConnectionListener(listener, metadata);
- // Test setting of parameters in CallbackPoller.
- testParameters(client, 333, 555, false);
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 555, false);
client.removeConnectionListener(listener);
client.disconnect();
@@ -377,10 +377,232 @@
}
- protected void testParameters(Client client,
- int pingPeriodExpected,
- int pingTimeoutExpected,
- boolean tieToLeaseExpected)
+ public void testUseLocatorParamsTrueInLocatorAllParamsInLocator() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI +=
"&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=true";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Configure ConnectionListener.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 111, 222, false);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testExplicitPingPeriodOverridesLocatorAndConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Client.USE_ALL_PARAMS, "true");
+ clientConfig.put("validatorPingPeriod", "222");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Configure ConnectionListener.
+ TestConnectionListener listener = new TestConnectionListener();
+ client.addConnectionListener(listener, 333);
+
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 333, 1000, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUnaryLocatorOverridesWithUseAllParams() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(Client.USE_ALL_PARAMS, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Configure ConnectionListener.
+ TestConnectionListener listener = new TestConnectionListener();
+ client.addConnectionListener(listener);
+
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 111, 1000, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUnaryLocatorDoesntOverrideWithoutUseAllParams() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Configure ConnectionListener.
+ TestConnectionListener listener = new TestConnectionListener();
+ client.addConnectionListener(listener);
+
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 2000, 1000, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+
+ public void testUnaryConfigOverrides() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "111");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Configure ConnectionListener.
+ TestConnectionListener listener = new TestConnectionListener();
+ client.addConnectionListener(listener);
+
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 111, 1000, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUnaryDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Configure ConnectionListener.
+ TestConnectionListener listener = new TestConnectionListener();
+ client.addConnectionListener(listener);
+
+ // Test setting of parameters in ConnectionListener.
+ doTestParameters(client, 2000, 1000, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+
+ protected void doTestParameters(Client client,
+ int pingPeriodExpected,
+ int pingTimeoutExpected,
+ boolean tieToLeaseExpected)
throws SecurityException, NoSuchFieldException, IllegalArgumentException,
IllegalAccessException
{
Field field = Client.class.getDeclaredField("connectionValidator");