Author: ron.sigal(a)jboss.com
Date: 2009-05-16 00:08:12 -0400 (Sat, 16 May 2009)
New Revision: 5241
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java
Log:
JBREM-1102: Added tests for case in which passing config map is turned off.
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java 2009-05-15
21:52:16 UTC (rev 5240)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java 2009-05-16
04:08:12 UTC (rev 5241)
@@ -26,6 +26,7 @@
import org.apache.log4j.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
import org.jboss.remoting.callback.Callback;
import org.jboss.remoting.callback.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
@@ -49,7 +50,7 @@
return "bisocket";
}
- public void testDatatypeConfigWithCallbacks() throws Throwable
+ public void testDatatypeConfigWithCallbacksDefault() throws Throwable
{
log.info("entering " + getName());
@@ -80,8 +81,8 @@
client.addListener(callbackHandler, new HashMap());
// Do tests.
- assertTrue(ConfigTestMarshaller.ok(16));
- assertTrue(ConfigTestUnmarshaller.ok(12));
+ assertTrue(ConfigTestMarshaller.ok(false, 4));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
assertTrue(LocatorTestMarshaller.ok());
assertTrue(LocatorTestUnmarshaller.ok());
assertEquals(1, callbackHandler.counter);
@@ -92,12 +93,102 @@
}
- public void testFQNConfigWithCallbacks() throws Throwable
+ public void testDatatypeConfigWithCallbacksPassConfigMapFalse() throws Throwable
{
log.info("entering " + getName());
+ // Cache marshaller/unmarshaller.
+ MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new
ConfigTestUnmarshaller());
+
// Start server.
HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.DATATYPE, "config");
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.DATATYPE, "config");
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ 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 callbacks.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ client.addListener(callbackHandler, new HashMap());
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(false, 4));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+ assertEquals(1, callbackHandler.counter);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testDatatypeConfigWithCallbacksPassConfigMapTrue() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Cache marshaller/unmarshaller.
+ MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new
ConfigTestUnmarshaller());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.DATATYPE, "config");
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.DATATYPE, "config");
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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 callbacks.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ client.addListener(callbackHandler, new HashMap());
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(true, 16));
+ assertTrue(ConfigTestUnmarshaller.ok(true, 12));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+ assertEquals(1, callbackHandler.counter);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testFQNConfigWithCallbacksDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
serverConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
setupServer("x=y", serverConfig);
@@ -123,8 +214,8 @@
client.addListener(callbackHandler, new HashMap());
// Do tests.
- assertTrue(ConfigTestMarshaller.ok(8));
- assertTrue(ConfigTestUnmarshaller.ok(6));
+ assertTrue(ConfigTestMarshaller.ok(false, 2));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
assertTrue(LocatorTestMarshaller.ok());
assertTrue(LocatorTestUnmarshaller.ok());
assertEquals(1, callbackHandler.counter);
@@ -135,6 +226,96 @@
}
+ public void testFQNConfigWithCallbacksPassConfigMapFalse() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ serverConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ clientConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ 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");
+
+ // Do callback.
+ // Configure callbacks.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ client.addListener(callbackHandler, new HashMap());
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(false, 2));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+ assertEquals(1, callbackHandler.counter);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testFQNConfigWithCallbacksPassConfigMapTrue() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ serverConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ clientConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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");
+
+ // Do callback.
+ // Configure callbacks.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ client.addListener(callbackHandler, new HashMap());
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(true, 8));
+ assertTrue(ConfigTestUnmarshaller.ok(true, 6));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+ assertEquals(1, callbackHandler.counter);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
protected TestInvocationHandler getInvocationHandler()
{
return new BisocketTestInvocationHandler();
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java 2009-05-15
21:52:16 UTC (rev 5240)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java 2009-05-16
04:08:12 UTC (rev 5241)
@@ -52,15 +52,15 @@
public Marshaller cloneMarshaller() throws CloneNotSupportedException
{
cloned++;
- log.info("cloned ConfigTestMarshaller");
// log.info("cloned ConfigTestMarshaller", new Exception());
+// log.info("cloned ConfigTestMarshaller", new Exception());
return new ConfigTestMarshaller();
}
- public static boolean ok(int count)
+ public static boolean ok(boolean b, int count)
{
log.info("wrote: " + wrote + ", cloned: " + cloned);
- return wrote && cloned == count;
+ return wrote == b && cloned == count;
}
public static void reset()
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java 2009-05-15
21:52:16 UTC (rev 5240)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java 2009-05-16
04:08:12 UTC (rev 5241)
@@ -38,7 +38,7 @@
*/
public class ConfigTestUnmarshaller extends SerializableUnMarshaller
{
- protected Logger log = Logger.getLogger(ConfigTestUnmarshaller.class);
+ protected static Logger log = Logger.getLogger(ConfigTestUnmarshaller.class);
private static final long serialVersionUID = 1L;
public static int cloned;
public static boolean read;
@@ -65,9 +65,10 @@
return ((Wrapper)o).wrappee;
}
- public static boolean ok(int count)
+ public static boolean ok(boolean b, int count)
{
- return read && cloned == count;
+ log.info("read: " + read + ", cloned: " + cloned);
+ return read == b && cloned == count;
}
public static void reset()
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java
===================================================================
---
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java 2009-05-15
21:52:16 UTC (rev 5240)
+++
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java 2009-05-16
04:08:12 UTC (rev 5241)
@@ -35,6 +35,7 @@
import org.jboss.logging.XLevel;
import org.jboss.remoting.Client;
import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.Remoting;
import org.jboss.remoting.marshal.MarshalFactory;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
@@ -88,7 +89,7 @@
}
- public void testDatatypeConfig() throws Throwable
+ public void testDatatypeConfigDefault() throws Throwable
{
log.info("entering " + getName());
@@ -115,8 +116,8 @@
log.info("connection is good");
// Do tests.
- assertTrue(ConfigTestMarshaller.ok(6));
- assertTrue(ConfigTestUnmarshaller.ok(4));
+ assertTrue(ConfigTestMarshaller.ok(false, 2));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
assertTrue(LocatorTestMarshaller.ok());
assertTrue(LocatorTestUnmarshaller.ok());
@@ -126,12 +127,92 @@
}
- public void testFQNConfig() throws Throwable
+ public void testDatatypePassConfigMapFalse() throws Throwable
{
log.info("entering " + getName());
+ // Cache marshaller/unmarshaller.
+ MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new
ConfigTestUnmarshaller());
+
// Start server.
HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.DATATYPE, "config");
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.DATATYPE, "config");
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ 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");
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(false, 2));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testDatatypePassConfigMapTrue() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Cache marshaller/unmarshaller.
+ MarshalFactory.addMarshaller("config", new ConfigTestMarshaller(), new
ConfigTestUnmarshaller());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.DATATYPE, "config");
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.DATATYPE, "config");
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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");
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(true, 6));
+ assertTrue(ConfigTestUnmarshaller.ok(true, 4));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testFQNConfigDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
serverConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
setupServer("x=y", serverConfig);
@@ -152,8 +233,8 @@
log.info("connection is good");
// Do tests.
- assertTrue(ConfigTestMarshaller.ok(configTestMarshallerCount()));
- assertTrue(ConfigTestUnmarshaller.ok(configTestUnmarshallerCount()));
+ assertTrue(ConfigTestMarshaller.ok(false, 1));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
assertTrue(LocatorTestMarshaller.ok());
assertTrue(LocatorTestUnmarshaller.ok());
@@ -163,6 +244,86 @@
}
+
+
+ public void testFQNPassConfigMapFalse() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ serverConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ clientConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "false");
+ 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");
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(false, 1));
+ assertTrue(ConfigTestUnmarshaller.ok(false, 0));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testFQNConfigPassConfigMapTrue() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ HashMap serverConfig = new HashMap();
+ serverConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ serverConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ serverConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "true");
+ setupServer("x=y", serverConfig);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(InvokerLocator.MARSHALLER, ConfigTestMarshaller.class.getName());
+ clientConfig.put(InvokerLocator.UNMARSHALLER,
ConfigTestUnmarshaller.class.getName());
+ clientConfig.put(Remoting.PASS_CONFIG_MAP_TO_MARSHAL_FACTORY, "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");
+
+ // Do tests.
+ assertTrue(ConfigTestMarshaller.ok(true, configTestMarshallerCount()));
+ assertTrue(ConfigTestUnmarshaller.ok(true, configTestUnmarshallerCount()));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
protected int configTestMarshallerCount()
{
return 3;