JBoss Remoting SVN: r4902 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-24 03:32:54 -0400 (Tue, 24 Mar 2009)
New Revision: 4902
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/ServletConfigurationMapTestClient.java
Log:
JBREM-1102: New unit tests for servlet transport.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/ServletConfigurationMapTestClient.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/ServletConfigurationMapTestClient.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/ServletConfigurationMapTestClient.java 2009-03-24 07:32:54 UTC (rev 4902)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.transport.servlet.marshal;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.test.remoting.marshall.config.ConfigurationMapTestParent;
+
+/**
+ * Unit tests for JBREM-1102.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class ServletConfigurationMapTestClient extends ConfigurationMapTestParent
+{
+ protected static Logger log = Logger.getLogger(ServletConfigurationMapTestClient.class);
+
+ public void testDatatypeConfig() throws Throwable
+ {
+ log.info("skipping " + getName());
+ }
+
+ protected int configTestMarshallerCount()
+ {
+ return 1;
+ }
+
+ protected int configTestUnmarshallerCount()
+ {
+ return 1;
+ }
+
+ protected String getTransport()
+ {
+ return "servlet";
+ }
+
+ protected void setupServer(String parameter, Map extraConfig) throws Exception
+ {
+ locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?" +
+ "marshaller=org.jboss.test.remoting.marshall.config.ConfigTestMarshaller&" +
+ "unmarshaller=org.jboss.test.remoting.marshall.config.ConfigTestUnmarshaller";
+
+ log.info("setting InvokerLocator to " + locatorURI);
+ }
+}
+
15 years, 9 months
JBoss Remoting SVN: r4901 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet: marshal and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-24 03:32:43 -0400 (Tue, 24 Mar 2009)
New Revision: 4901
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/remoting-servlet-service.xml
Log:
JBREM-1102: New unit tests for servlet transport.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/remoting-servlet-service.xml
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/remoting-servlet-service.xml (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/marshal/remoting-servlet-service.xml 2009-03-24 07:32:43 UTC (rev 4901)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:service=Connector,transport=Servlet,target=tests"
+ display-name="Servlet transport Connector">
+
+ <attribute name="InvokerLocator">
+ servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?marshaller=org.jboss.test.remoting.marshall.config.ConfigTestMarshaller&unmarshaller=org.jboss.test.remoting.marshall.config.ConfigTestUnmarshaller
+ </attribute>
+
+ <attribute name="Configuration">
+ <config>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.marshall.config.TestInvocationHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
15 years, 9 months
JBoss Remoting SVN: r4900 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-24 03:30:02 -0400 (Tue, 24 Mar 2009)
New Revision: 4900
Added:
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/LocatorTestMarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java
Log:
JBREM-1102: Broke classes out of ConfigurationMapTestParent.
Added: 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 (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestMarshaller.java 2009-03-24 07:30:02 UTC (rev 4900)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+import java.io.IOException;
+import java.io.OutputStream;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class ConfigTestMarshaller extends SerializableMarshaller
+{
+ protected static Logger log = Logger.getLogger(ConfigTestMarshaller.class);
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean wrote;
+
+ public void write(Object dataObject, OutputStream output, int version) throws IOException
+ {
+ log.info(this + "writing Wrapper");
+ super.write(new Wrapper(dataObject), output, version);
+ wrote = true;
+ }
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned ConfigTestMarshaller");
+// log.info("cloned ConfigTestMarshaller", new Exception());
+ return new ConfigTestMarshaller();
+ }
+
+ public static boolean ok(int count)
+ {
+ log.info("wrote: " + wrote + ", count: " + count);
+ return wrote && cloned == count;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ wrote = false;
+ }
+}
+
Added: 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 (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigTestUnmarshaller.java 2009-03-24 07:30:02 UTC (rev 4900)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class ConfigTestUnmarshaller extends SerializableUnMarshaller
+{
+ protected Logger log = Logger.getLogger(ConfigTestUnmarshaller.class);
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean read;
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned ConfigTestUnmarshaller");
+// log.info("cloned ConfigTestUnmarshaller", new Exception());
+ ConfigTestUnmarshaller unmarshaller = new ConfigTestUnmarshaller();
+ unmarshaller.setClassLoader(this.customClassLoader);
+ return unmarshaller;
+ }
+
+ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
+ {
+ Object o = super.read(inputStream, metadata, version);
+ if (!(o instanceof Wrapper))
+ {
+ throw new IOException("expected Wrapper");
+ }
+ log.info(this + "read Wrapper");
+ read = true;
+ return ((Wrapper)o).wrappee;
+ }
+
+ public static boolean ok(int count)
+ {
+ return read && cloned == count;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ read = false;
+ }
+}
+
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-03-24 03:46:02 UTC (rev 4899)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java 2009-03-24 07:30:02 UTC (rev 4900)
@@ -22,16 +22,10 @@
package org.jboss.test.remoting.marshall.config;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.Map;
-import javax.management.MBeanServer;
-
import junit.framework.TestCase;
import org.apache.log4j.ConsoleAppender;
@@ -40,16 +34,8 @@
import org.apache.log4j.PatternLayout;
import org.jboss.logging.XLevel;
import org.jboss.remoting.Client;
-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.marshal.MarshalFactory;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
-import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
@@ -166,8 +152,8 @@
log.info("connection is good");
// Do tests.
- assertTrue(ConfigTestMarshaller.ok(3));
- assertTrue(ConfigTestUnmarshaller.ok(2));
+ assertTrue(ConfigTestMarshaller.ok(configTestMarshallerCount()));
+ assertTrue(ConfigTestUnmarshaller.ok(configTestUnmarshallerCount()));
assertTrue(LocatorTestMarshaller.ok());
assertTrue(LocatorTestUnmarshaller.ok());
@@ -177,6 +163,18 @@
}
+ protected int configTestMarshallerCount()
+ {
+ return 3;
+ }
+
+
+ protected int configTestUnmarshallerCount()
+ {
+ return 2;
+ }
+
+
protected abstract String getTransport();
@@ -224,156 +222,4 @@
{
return new TestInvocationHandler();
}
-
-
- static class TestInvocationHandler implements ServerInvocationHandler
- {
- public void addListener(InvokerCallbackHandler callbackHandler) {}
- public Object invoke(final InvocationRequest invocation) throws Throwable
- {
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
-
-
- public static class ConfigTestMarshaller extends SerializableMarshaller
- {
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static boolean wrote;
-
- public void write(Object dataObject, OutputStream output, int version) throws IOException
- {
- log.info(this + "writing Wrapper");
- super.write(new Wrapper(dataObject), output, version);
- wrote = true;
- }
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- cloned++;
- log.info("cloned ConfigTestMarshaller");
-// log.info("cloned ConfigTestMarshaller", new Exception());
- return new ConfigTestMarshaller();
- }
-
- public static boolean ok(int count)
- {
- return wrote && cloned == count;
- }
-
- public static void reset()
- {
- cloned = 0;
- wrote = false;
- }
- }
-
- public static class LocatorTestMarshaller extends ConfigTestMarshaller
- {
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static boolean wrote;
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- cloned++;
- log.info("cloned LocatorTestMarshaller");
- return new LocatorTestMarshaller();
- }
-
- public static boolean ok()
- {
- return !wrote && cloned == 0;
- }
-
- public static void reset()
- {
- cloned = 0;
- wrote = false;
- }
- }
-
- public static class ConfigTestUnmarshaller extends SerializableUnMarshaller
- {
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static boolean read;
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- cloned++;
- log.info("cloned ConfigTestUnmarshaller");
-// log.info("cloned ConfigTestUnmarshaller", new Exception());
- ConfigTestUnmarshaller unmarshaller = new ConfigTestUnmarshaller();
- unmarshaller.setClassLoader(this.customClassLoader);
- return unmarshaller;
- }
-
- public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
- {
- Object o = super.read(inputStream, metadata, version);
- if (!(o instanceof Wrapper))
- {
- throw new IOException("expected Wrapper");
- }
- log.info(this + "read Wrapper");
- read = true;
- return ((Wrapper)o).wrappee;
- }
-
- public static boolean ok(int count)
- {
- return read && cloned == count;
- }
-
- public static void reset()
- {
- cloned = 0;
- read = false;
- }
- }
-
-
- public static class LocatorTestUnmarshaller extends ConfigTestUnmarshaller
- {
- private static final long serialVersionUID = 1L;
- public static int cloned;
- public static boolean read;
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- cloned++;
- log.info("cloned LocatorTestUnmarshaller");
- ConfigTestUnmarshaller unmarshaller = new LocatorTestUnmarshaller();
- unmarshaller.setClassLoader(this.customClassLoader);
- return unmarshaller;
- }
-
- public static boolean ok()
- {
- return !read && cloned == 0;
- }
-
- public static void reset()
- {
- cloned = 0;
- read = false;
- }
- }
-
-
- static class Wrapper implements Serializable
- {
- private static final long serialVersionUID = 1L;
- public Object wrappee;
-
- public Wrapper(Object o)
- {
- wrappee = o;
- }
- }
}
\ No newline at end of file
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestMarshaller.java 2009-03-24 07:30:02 UTC (rev 4900)
@@ -0,0 +1,58 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+import org.jboss.remoting.marshal.Marshaller;
+
+/**
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class LocatorTestMarshaller extends ConfigTestMarshaller
+{
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean wrote;
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned LocatorTestMarshaller");
+ return new LocatorTestMarshaller();
+ }
+
+ public static boolean ok()
+ {
+ return !wrote && cloned == 0;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ wrote = false;
+ }
+}
+
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/LocatorTestUnmarshaller.java 2009-03-24 07:30:02 UTC (rev 4900)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+import org.jboss.remoting.marshal.UnMarshaller;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+public class LocatorTestUnmarshaller extends ConfigTestUnmarshaller
+{
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean read;
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned LocatorTestUnmarshaller");
+ ConfigTestUnmarshaller unmarshaller = new LocatorTestUnmarshaller();
+ unmarshaller.setClassLoader(this.customClassLoader);
+ return unmarshaller;
+ }
+
+ public static boolean ok()
+ {
+ return !read && cloned == 0;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ read = false;
+ }
+}
+
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/TestInvocationHandler.java 2009-03-24 07:30:02 UTC (rev 4900)
@@ -0,0 +1,49 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+import javax.management.MBeanServer;
+
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+ public class TestInvocationHandler implements ServerInvocationHandler
+{
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+}
+
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/Wrapper.java 2009-03-24 07:30:02 UTC (rev 4900)
@@ -0,0 +1,44 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+import java.io.Serializable;
+
+
+/**
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 24, 2009
+ * </p>
+ */
+class Wrapper implements Serializable
+{
+ private static final long serialVersionUID = 1L;
+ public Object wrappee;
+
+ public Wrapper(Object o)
+ {
+ wrappee = o;
+ }
+}
+
15 years, 9 months
JBoss Remoting SVN: r4899 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/web.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-23 23:46:02 -0400 (Mon, 23 Mar 2009)
New Revision: 4899
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/web/WebServerInvoker.java
Log:
JBREM-1102: Uses configuration when it calls MarshalFactory.getMarshaller() and MarshalFactory.getUnMarshaller().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/web/WebServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/web/WebServerInvoker.java 2009-03-24 03:45:24 UTC (rev 4898)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/web/WebServerInvoker.java 2009-03-24 03:46:02 UTC (rev 4899)
@@ -99,7 +99,7 @@
public UnMarshaller getUnMarshaller()
{
- UnMarshaller unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), this.getClass().getClassLoader());
+ UnMarshaller unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), this.getClass().getClassLoader(), configuration);
if(unmarshaller == null)
{
unmarshaller = MarshalFactory.getUnMarshaller(getDataType(), getSerializationType());
@@ -109,7 +109,7 @@
public Marshaller getMarshaller()
{
- Marshaller marshaller = MarshalFactory.getMarshaller(getLocator(), this.getClass().getClassLoader());
+ Marshaller marshaller = MarshalFactory.getMarshaller(getLocator(), this.getClass().getClassLoader(), configuration);
if(marshaller == null)
{
15 years, 9 months
JBoss Remoting SVN: r4898 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-23 23:45:24 -0400 (Mon, 23 Mar 2009)
New Revision: 4898
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ServerThread.java
Log:
JBREM-1102: Uses configuration when it calls MarshalFactory.getMarshaller() and MarshalFactory.getUnMarshaller().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ServerThread.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ServerThread.java 2009-03-24 03:44:39 UTC (rev 4897)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ServerThread.java 2009-03-24 03:45:24 UTC (rev 4898)
@@ -806,9 +806,15 @@
//TODO: -TME Need better way to get the unmarshaller (via config)
+ Map configMap = null;
+ if (invoker != null)
+ {
+ configMap = invoker.getConfiguration();
+ }
+
if (unmarshaller == null)
{
- unmarshaller = MarshalFactory.getUnMarshaller(locator, classLoader);
+ unmarshaller = MarshalFactory.getUnMarshaller(locator, classLoader, configMap);
}
if (unmarshaller == null)
{
@@ -817,7 +823,7 @@
if (marshaller == null)
{
- marshaller = MarshalFactory.getMarshaller(locator, classLoader);
+ marshaller = MarshalFactory.getMarshaller(locator, classLoader, configMap);
}
if (marshaller == null)
{
15 years, 9 months
JBoss Remoting SVN: r4897 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-23 23:44:39 -0400 (Mon, 23 Mar 2009)
New Revision: 4897
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/Connector.java
Log:
JBREM-1102: Uses configuration when it calls MarshalFactory.getMarshaller().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/Connector.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/Connector.java 2009-03-24 03:44:00 UTC (rev 4896)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/Connector.java 2009-03-24 03:44:39 UTC (rev 4897)
@@ -458,7 +458,7 @@
* have to be there. Otherwise, would not be loaded until first client actually reaches the
* target server invoker, where they would otherwise be loaded.
*/
- MarshalFactory.getMarshaller(locator, this.getClass().getClassLoader());
+ MarshalFactory.getMarshaller(locator, this.getClass().getClassLoader(), configuration);
Connector marshallerLoader = null;
InvokerLocator loaderLocator = MarshallLoaderFactory.convertLocator(locator);
15 years, 9 months
JBoss Remoting SVN: r4896 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/rmi.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-23 23:44:00 -0400 (Mon, 23 Mar 2009)
New Revision: 4896
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java
Log:
JBREM-1102: Uses configuration when it calls MarshalFactory.getMarshaller() and MarshalFactory.getUnMarshaller().
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java 2009-03-24 03:42:09 UTC (rev 4895)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/rmi/RMIServerInvoker.java 2009-03-24 03:44:00 UTC (rev 4896)
@@ -116,8 +116,8 @@
log.debug("Binding registry to " + "remoting/RMIServerInvoker/" + bindPort);
registry.rebind("remoting/RMIServerInvoker/" + bindPort, this);
- unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), this.getClass().getClassLoader());
- marshaller = MarshalFactory.getMarshaller(getLocator(), this.getClass().getClassLoader());
+ unmarshaller = MarshalFactory.getUnMarshaller(getLocator(), this.getClass().getClassLoader(), configuration);
+ marshaller = MarshalFactory.getMarshaller(getLocator(), this.getClass().getClassLoader(), configuration);
}
15 years, 9 months
JBoss Remoting SVN: r4895 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall: config and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-23 23:42:09 -0400 (Mon, 23 Mar 2009)
New Revision: 4895
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/
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/ConfigurationMapTestParent.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java
Log:
JBREM-1102: New unit tests.
Added: 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 (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/BisocketConfigurationMapTestCase.java 2009-03-24 03:42:09 UTC (rev 4895)
@@ -0,0 +1,170 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+import java.util.HashMap;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+
+/**
+ * Unit tests for JBREM-1102.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class BisocketConfigurationMapTestCase extends ConfigurationMapTestParent
+{
+ private static Logger log = Logger.getLogger(BisocketConfigurationMapTestCase.class);
+
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+ public void testDatatypeConfigWithCallbacks() 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");
+ 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");
+ 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(16));
+ assertTrue(ConfigTestUnmarshaller.ok(12));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+ assertEquals(1, callbackHandler.counter);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testFQNConfigWithCallbacks() 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);
+
+ // 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());
+ 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(8));
+ assertTrue(ConfigTestUnmarshaller.ok(6));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+ assertEquals(1, callbackHandler.counter);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected TestInvocationHandler getInvocationHandler()
+ {
+ return new BisocketTestInvocationHandler();
+ }
+
+
+ static class BisocketTestInvocationHandler extends TestInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ try
+ {
+ callbackHandler.handleCallback(new Callback("callback"));
+ }
+ catch (HandleCallbackException e)
+ {
+ log.error("Error sending callback", e);
+ }
+ }
+ }
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int counter;
+
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ counter++;
+ log.info("received callback");
+ }
+ }
+}
+
Added: 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 (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/ConfigurationMapTestParent.java 2009-03-24 03:42:09 UTC (rev 4895)
@@ -0,0 +1,379 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.remoting.marshall.config;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.Serializable;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+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.marshal.MarshalFactory;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.serializable.SerializableMarshaller;
+import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-1102.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 20, 2009
+ * </p>
+ */
+public abstract class ConfigurationMapTestParent extends TestCase
+{
+ private static Logger log = Logger.getLogger(ConfigurationMapTestParent.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+
+ ConfigTestMarshaller.reset();
+ ConfigTestUnmarshaller.reset();
+ LocatorTestMarshaller.reset();
+ LocatorTestUnmarshaller.reset();
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testDatatypeConfig() 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");
+ 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");
+ 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(6));
+ assertTrue(ConfigTestUnmarshaller.ok(4));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testFQNConfig() 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);
+
+ // 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());
+ 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(3));
+ assertTrue(ConfigTestUnmarshaller.ok(2));
+ assertTrue(LocatorTestMarshaller.ok());
+ assertTrue(LocatorTestUnmarshaller.ok());
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected abstract String getTransport();
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(String parameter, Map extraConfig) throws Exception
+ {
+ log.info("parameter: " + parameter);
+ log.info("extraConfig: " + extraConfig);
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port + "/?" + parameter;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ if (extraConfig != null)
+ {
+ config.putAll(extraConfig);
+ }
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = getInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ protected TestInvocationHandler getInvocationHandler()
+ {
+ return new TestInvocationHandler();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ public static class ConfigTestMarshaller extends SerializableMarshaller
+ {
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean wrote;
+
+ public void write(Object dataObject, OutputStream output, int version) throws IOException
+ {
+ log.info(this + "writing Wrapper");
+ super.write(new Wrapper(dataObject), output, version);
+ wrote = true;
+ }
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned ConfigTestMarshaller");
+// log.info("cloned ConfigTestMarshaller", new Exception());
+ return new ConfigTestMarshaller();
+ }
+
+ public static boolean ok(int count)
+ {
+ return wrote && cloned == count;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ wrote = false;
+ }
+ }
+
+ public static class LocatorTestMarshaller extends ConfigTestMarshaller
+ {
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean wrote;
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned LocatorTestMarshaller");
+ return new LocatorTestMarshaller();
+ }
+
+ public static boolean ok()
+ {
+ return !wrote && cloned == 0;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ wrote = false;
+ }
+ }
+
+ public static class ConfigTestUnmarshaller extends SerializableUnMarshaller
+ {
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean read;
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned ConfigTestUnmarshaller");
+// log.info("cloned ConfigTestUnmarshaller", new Exception());
+ ConfigTestUnmarshaller unmarshaller = new ConfigTestUnmarshaller();
+ unmarshaller.setClassLoader(this.customClassLoader);
+ return unmarshaller;
+ }
+
+ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
+ {
+ Object o = super.read(inputStream, metadata, version);
+ if (!(o instanceof Wrapper))
+ {
+ throw new IOException("expected Wrapper");
+ }
+ log.info(this + "read Wrapper");
+ read = true;
+ return ((Wrapper)o).wrappee;
+ }
+
+ public static boolean ok(int count)
+ {
+ return read && cloned == count;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ read = false;
+ }
+ }
+
+
+ public static class LocatorTestUnmarshaller extends ConfigTestUnmarshaller
+ {
+ private static final long serialVersionUID = 1L;
+ public static int cloned;
+ public static boolean read;
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ cloned++;
+ log.info("cloned LocatorTestUnmarshaller");
+ ConfigTestUnmarshaller unmarshaller = new LocatorTestUnmarshaller();
+ unmarshaller.setClassLoader(this.customClassLoader);
+ return unmarshaller;
+ }
+
+ public static boolean ok()
+ {
+ return !read && cloned == 0;
+ }
+
+ public static void reset()
+ {
+ cloned = 0;
+ read = false;
+ }
+ }
+
+
+ static class Wrapper implements Serializable
+ {
+ private static final long serialVersionUID = 1L;
+ public Object wrappee;
+
+ public Wrapper(Object o)
+ {
+ wrappee = o;
+ }
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/HttpConfigurationMapTestCase.java 2009-03-24 03:42:09 UTC (rev 4895)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+/**
+ * Unit tests for JBREM-1102.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class HttpConfigurationMapTestCase extends ConfigurationMapTestParent
+{
+ protected String getTransport()
+ {
+ return "http";
+ }
+}
+
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/RMIConfigurationMapTestCase.java 2009-03-24 03:42:09 UTC (rev 4895)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+/**
+ * Unit tests for JBREM-1102.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class RMIConfigurationMapTestCase extends ConfigurationMapTestParent
+{
+ protected String getTransport()
+ {
+ return "rmi";
+ }
+}
+
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/marshall/config/SocketConfigurationMapTestCase.java 2009-03-24 03:42:09 UTC (rev 4895)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.remoting.marshall.config;
+
+/**
+ * Unit tests for JBREM-1102.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class SocketConfigurationMapTestCase extends ConfigurationMapTestParent
+{
+ protected String getTransport()
+ {
+ return "socket";
+ }
+}
+
15 years, 9 months
JBoss Remoting SVN: r4894 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/callback: params and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-23 21:38:40 -0400 (Mon, 23 Mar 2009)
New Revision: 4894
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/callback/params/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java
Log:
JBREM-1084: New unit tests.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java 2009-03-24 01:38:40 UTC (rev 4894)
@@ -0,0 +1,464 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.test.remoting.callback.params;
+
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.Client;
+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.Callback;
+import org.jboss.remoting.callback.CallbackPoller;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-1084.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Jan 17, 2009
+ * </p>
+ */
+public class UseAllParamsTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(UseAllParamsTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testUseAllParamsDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("callbackPollPeriod", "333");
+ clientConfig.put("maxErrorCount", "444");
+ 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 callback polling.
+ TestCallbackHandler handler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put("maxErrorCount", "555");
+ client.addListener(handler, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555);
+
+ client.removeListener(handler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllParamsFalseinLocator() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222&useAllParams=false";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("callbackPollPeriod", "333");
+ clientConfig.put("maxErrorCount", "444");
+ 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 callback polling.
+ TestCallbackHandler handler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put("maxErrorCount", "555");
+ client.addListener(handler, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555);
+
+ client.removeListener(handler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllParamsFalseinConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("callbackPollPeriod", "333");
+ clientConfig.put("maxErrorCount", "444");
+ clientConfig.put(Client.USE_ALL_PARAMS, "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 callback polling.
+ TestCallbackHandler handler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put("maxErrorCount", "555");
+ client.addListener(handler, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555);
+
+ client.removeListener(handler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllParamsFalseinMetadata() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("callbackPollPeriod", "333");
+ clientConfig.put("maxErrorCount", "444");
+ 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 callback polling.
+ TestCallbackHandler handler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put("maxErrorCount", "555");
+ metadata.put(Client.USE_ALL_PARAMS, "false");
+ client.addListener(handler, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, false, CallbackPoller.DEFAULT_POLL_PERIOD, 555);
+
+ client.removeListener(handler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllParamsTrueInLocator() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222&useAllParams=true";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("callbackPollPeriod", "333");
+ clientConfig.put("maxErrorCount", "444");
+ 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 callback polling.
+ TestCallbackHandler handler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put("maxErrorCount", "555");
+ client.addListener(handler, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, true, 333, 555);
+
+ client.removeListener(handler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllParamsTrueInConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("callbackPollPeriod", "333");
+ clientConfig.put("maxErrorCount", "444");
+ 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 callback polling.
+ TestCallbackHandler handler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put("maxErrorCount", "555");
+ client.addListener(handler, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, true, 333, 555);
+
+ client.removeListener(handler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseAllParamsTrueInMetadata() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI + "&blockingMode=blocking&callbackPollPeriod=111&maxErrorCount=222";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("callbackPollPeriod", "333");
+ clientConfig.put("maxErrorCount", "444");
+ 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 callback polling.
+ TestCallbackHandler handler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put("maxErrorCount", "555");
+ metadata.put(Client.USE_ALL_PARAMS, "true");
+ client.addListener(handler, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, true, 333, 555);
+
+ client.removeListener(handler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void testParameters(Client client,
+ boolean blockingExpected,
+ long callbackPollPeriodExpected,
+ int maxErrorCountExpected)
+ throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
+ {
+ Field field = Client.class.getDeclaredField("callbackPollers");
+ field.setAccessible(true);
+ Map pollers = (Map) field.get(client);
+ assertEquals(1, pollers.size());
+ CallbackPoller poller = (CallbackPoller) pollers.values().iterator().next();
+ field = CallbackPoller.class.getDeclaredField("blocking");
+ field.setAccessible(true);
+ boolean blocking = ((Boolean)field.get(poller)).booleanValue();
+ field = CallbackPoller.class.getDeclaredField("pollPeriod");
+ field.setAccessible(true);
+ long callbackPollPeriod = ((Long) field.get(poller)).longValue();
+ field = CallbackPoller.class.getDeclaredField("maxErrorCount");
+ field.setAccessible(true);
+ int maxErrorCount = ((Integer) field.get(poller)).intValue();
+ log.info("blocking: " + blocking);
+ log.info("callbackPollPeriod: " + callbackPollPeriod);
+ log.info("maxErrorCount: " + maxErrorCount);
+ assertEquals(blockingExpected, blocking);
+ assertEquals(callbackPollPeriodExpected, callbackPollPeriod);
+ assertEquals(maxErrorCountExpected, maxErrorCount);
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "/?" + metadata;
+ }
+ else
+ {
+ locatorURI += "/?" + "x=y";
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ log.info("received callback");
+ }
+ }
+}
\ No newline at end of file
15 years, 9 months
JBoss Remoting SVN: r4893 - remoting2/branches/2.x/src/main/org/jboss/remoting/callback.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-03-23 21:29:15 -0400 (Mon, 23 Mar 2009)
New Revision: 4893
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackPoller.java
Log:
JBREM-1084: If "useAllParams" parameter is set to "true", uses InvokerLocator parameters and Client's configuration map.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackPoller.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackPoller.java 2009-03-24 01:13:38 UTC (rev 4892)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/callback/CallbackPoller.java 2009-03-24 01:29:15 UTC (rev 4893)
@@ -32,6 +32,7 @@
import org.jboss.logging.Logger;
import org.jboss.remoting.Client;
import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.transport.ClientInvoker;
/**
* CallbackPoller is used to simulate push callbacks on transports that don't support
@@ -120,7 +121,7 @@
private boolean running;
private int maxErrorCount = -1;
private int errorCount;
-
+ private boolean useAllParams;
private ArrayList toHandleList = new ArrayList();
private ArrayList toAcknowledgeList = new ArrayList();
@@ -582,145 +583,170 @@
private void configureParameters()
{
- if (metadata != null)
+ Map config = new HashMap();
+ ClientInvoker invoker = client.getInvoker();
+ if (invoker != null)
{
- Object val = metadata.get(ServerInvoker.BLOCKING_MODE);
- if (val != null)
+ config.putAll(invoker.getLocator().getParameters());
+ }
+ config.putAll(client.getConfiguration());
+ config.putAll(metadata);
+
+ Object val = config.get(Client.USE_ALL_PARAMS);
+ if (val != null)
+ {
+ if (val instanceof String)
{
- if (val instanceof String)
+ useAllParams = Boolean.valueOf((String) val).booleanValue();
+ }
+ else
+ {
+ log.warn("Value for " + Client.USE_ALL_PARAMS + " must be of type " +
+ String.class.getName() + " and is " + val.getClass().getName());
+ }
+ }
+ log.debug(this + ": useAllParams: " + useAllParams);
+ if (!useAllParams)
+ {
+ config = metadata;
+ }
+
+ val = config.get(ServerInvoker.BLOCKING_MODE);
+ if (val != null)
+ {
+ if (val instanceof String)
+ {
+ if (ServerInvoker.BLOCKING.equals(val))
{
- if (ServerInvoker.BLOCKING.equals(val))
- {
- blocking = true;
- synchronizedShutdown = false;
- }
- else if (ServerInvoker.NONBLOCKING.equals(val))
- {
- blocking = false;
- synchronizedShutdown = true;
- }
- else
- {
- log.warn("Value for " + ServerInvoker.BLOCKING_MODE +
- " configuration is " + val + ". Must be either " +
- ServerInvoker.BLOCKING + " or " + ServerInvoker.NONBLOCKING +
- ". Using " + ServerInvoker.BLOCKING + ".");
- }
+ blocking = true;
+ synchronizedShutdown = false;
}
+ else if (ServerInvoker.NONBLOCKING.equals(val))
+ {
+ blocking = false;
+ synchronizedShutdown = true;
+ }
else
{
log.warn("Value for " + ServerInvoker.BLOCKING_MODE +
- " configuration must be of type " + String.class.getName() +
- " and is of type " + val.getClass().getName());
+ " configuration is " + val + ". Must be either " +
+ ServerInvoker.BLOCKING + " or " + ServerInvoker.NONBLOCKING +
+ ". Using " + ServerInvoker.BLOCKING + ".");
}
}
-
- // Default blocking mode on server is nonblocking.
- if (blocking)
- metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
-
- val = metadata.get(ServerInvoker.BLOCKING_TIMEOUT);
- if (val != null)
+ else
{
- if (val instanceof String)
- {
- try
- {
- int blockingTimeout = Integer.parseInt((String) val);
- metadata.put(ServerInvoker.TIMEOUT, Integer.toString(blockingTimeout));
- }
- catch (NumberFormatException e)
- {
- log.warn("Error converting " + ServerInvoker.BLOCKING_TIMEOUT + " to type long. " + e.getMessage());
- }
- }
- else
- {
- log.warn("Value for " + ServerInvoker.BLOCKING_TIMEOUT + " configuration must be of type " + String.class.getName() +
- " and is " + val.getClass().getName());
- }
+ log.warn("Value for " + ServerInvoker.BLOCKING_MODE +
+ " configuration must be of type " + String.class.getName() +
+ " and is of type " + val.getClass().getName());
}
-
- val = metadata.get(SYNCHRONIZED_SHUTDOWN);
- if (val != null)
+ }
+
+ // Default blocking mode on server is nonblocking.
+ if (blocking)
+ metadata.put(ServerInvoker.BLOCKING_MODE, ServerInvoker.BLOCKING);
+
+ val = config.get(ServerInvoker.BLOCKING_TIMEOUT);
+ if (val != null)
+ {
+ if (val instanceof String)
{
- if (val instanceof String)
+ try
{
- synchronizedShutdown = Boolean.valueOf((String) val).booleanValue();
+ int blockingTimeout = Integer.parseInt((String) val);
+ metadata.put(ServerInvoker.TIMEOUT, Integer.toString(blockingTimeout));
}
- else
+ catch (NumberFormatException e)
{
- log.warn("Value for " + SYNCHRONIZED_SHUTDOWN + " must be of type " + String.class.getName() +
- " and is " + val.getClass().getName());
+ log.warn("Error converting " + ServerInvoker.BLOCKING_TIMEOUT + " to type long. " + e.getMessage());
}
}
-
- val = metadata.get(CALLBACK_POLL_PERIOD);
- if (val != null)
+ else
{
- if (val instanceof String)
+ log.warn("Value for " + ServerInvoker.BLOCKING_TIMEOUT + " configuration must be of type " + String.class.getName() +
+ " and is " + val.getClass().getName());
+ }
+ }
+
+ val = config.get(SYNCHRONIZED_SHUTDOWN);
+ if (val != null)
+ {
+ if (val instanceof String)
+ {
+ synchronizedShutdown = Boolean.valueOf((String) val).booleanValue();
+ }
+ else
+ {
+ log.warn("Value for " + SYNCHRONIZED_SHUTDOWN + " must be of type " + String.class.getName() +
+ " and is " + val.getClass().getName());
+ }
+ }
+
+ val = config.get(CALLBACK_POLL_PERIOD);
+ if (val != null)
+ {
+ if (val instanceof String)
+ {
+ try
{
- try
- {
- pollPeriod = Long.parseLong((String) val);
- }
- catch (NumberFormatException e)
- {
- log.warn("Error converting " + CALLBACK_POLL_PERIOD + " to type long. " + e.getMessage());
- }
+ pollPeriod = Long.parseLong((String) val);
}
- else
+ catch (NumberFormatException e)
{
- log.warn("Value for " + CALLBACK_POLL_PERIOD + " configuration must be of type " + String.class.getName() +
- " and is " + val.getClass().getName());
+ log.warn("Error converting " + CALLBACK_POLL_PERIOD + " to type long. " + e.getMessage());
}
}
- val = metadata.get(CALLBACK_SCHEDULE_MODE);
- if (val != null)
+ else
{
- if (val instanceof String)
+ log.warn("Value for " + CALLBACK_POLL_PERIOD + " configuration must be of type " + String.class.getName() +
+ " and is " + val.getClass().getName());
+ }
+ }
+ val = config.get(CALLBACK_SCHEDULE_MODE);
+ if (val != null)
+ {
+ if (val instanceof String)
+ {
+ if (SCHEDULE_FIXED_DELAY.equals(val) || SCHEDULE_FIXED_RATE.equals(val))
{
- if (SCHEDULE_FIXED_DELAY.equals(val) || SCHEDULE_FIXED_RATE.equals(val))
- {
- scheduleMode = (String) val;
- }
- else
- {
- log.warn("Unrecognized value for " + CALLBACK_SCHEDULE_MODE + ": " + val);
- log.warn("Using " + scheduleMode);
- }
+ scheduleMode = (String) val;
}
else
{
- log.warn("Value for " + CALLBACK_SCHEDULE_MODE + " must be of type " + String.class.getName() +
- " and is " + val.getClass().getName());
+ log.warn("Unrecognized value for " + CALLBACK_SCHEDULE_MODE + ": " + val);
+ log.warn("Using " + scheduleMode);
}
}
- val = metadata.get(MAX_ERROR_COUNT);
- if (val != null)
+ else
{
- if (val instanceof String)
+ log.warn("Value for " + CALLBACK_SCHEDULE_MODE + " must be of type " + String.class.getName() +
+ " and is " + val.getClass().getName());
+ }
+ }
+ val = config.get(MAX_ERROR_COUNT);
+ if (val != null)
+ {
+ if (val instanceof String)
+ {
+ try
{
- try
- {
- maxErrorCount = Integer.parseInt((String) val);
- }
- catch (NumberFormatException e)
- {
- log.warn("Error converting " + MAX_ERROR_COUNT + " to type int. " + e.getMessage());
- }
+ maxErrorCount = Integer.parseInt((String) val);
}
- else
+ catch (NumberFormatException e)
{
- log.warn("Value for " + MAX_ERROR_COUNT + " configuration must be of type " + String.class.getName() +
- " and is " + val.getClass().getName());
+ log.warn("Error converting " + MAX_ERROR_COUNT + " to type int. " + e.getMessage());
}
}
- if (metadata.get(REPORT_STATISTICS) != null)
+ else
{
- reportStatistics = true;
+ log.warn("Value for " + MAX_ERROR_COUNT + " configuration must be of type " + String.class.getName() +
+ " and is " + val.getClass().getName());
}
}
+ if (config.get(REPORT_STATISTICS) != null)
+ {
+ reportStatistics = true;
+ }
}
15 years, 9 months