JBoss Remoting SVN: r4839 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-INF.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-18 00:41:01 -0500 (Sun, 18 Jan 2009)
New Revision: 4839
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-INF/web.xml
Log:
JBREM-139, JBREM-1079: Reorganized servlet unit tests and added .../callback/CallbackTestClient.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-INF/web.xml
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-INF/web.xml 2009-01-18 05:40:30 UTC (rev 4838)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/WEB-INF/web.xml 2009-01-18 05:41:01 UTC (rev 4839)
@@ -16,7 +16,7 @@
<servlet-class>org.jboss.remoting.transport.servlet.web.ServerInvokerServlet</servlet-class>
<init-param>
<param-name>locatorUrl</param-name>
- <param-value>sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet</param-value>
+ <param-value>sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet/?createUniqueObjectName=true</param-value>
<description>The servlet server invoker locator url</description>
<!--
<param-name>locatorUrl</param-name>
15 years, 10 months
JBoss Remoting SVN: r4838 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-18 00:40:30 -0500 (Sun, 18 Jan 2009)
New Revision: 4838
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/keystore
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-sslservlet-service.xml
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/server.xml
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/truststore
Removed:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/.keystore
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/.truststore
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-servlet-invoker-service.xml
Log:
JBREM-139, JBREM-1079: Reorganized servlet unit tests and added .../callback/CallbackTestClient.
Deleted: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/.keystore
===================================================================
(Binary files differ)
Deleted: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/.truststore
===================================================================
(Binary files differ)
Copied: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/keystore (from rev 4674, remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/.keystore)
===================================================================
(Binary files differ)
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/keystore
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
Deleted: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-servlet-invoker-service.xml
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-servlet-invoker-service.xml 2009-01-18 05:40:05 UTC (rev 4837)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-servlet-invoker-service.xml 2009-01-18 05:40:30 UTC (rev 4838)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<server>
-
- <mbean code="org.jboss.remoting.transport.Connector"
- name="jboss.remoting:service=Connector,transport=SSLServlet"
- display-name="Servlet transport Connector">
-
- <attribute name="InvokerLocator">
- sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet
- </attribute>
-
- <attribute name="Configuration">
- <config>
- <handlers>
- <handler subsystem="test">org.jboss.test.remoting.transport.web.WebInvocationHandler</handler>
- </handlers>
- </config>
- </attribute>
- </mbean>
-
-
-</server>
Copied: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-sslservlet-service.xml (from rev 4674, remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-servlet-invoker-service.xml)
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-sslservlet-service.xml (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-sslservlet-service.xml 2009-01-18 05:40:30 UTC (rev 4838)
@@ -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=SSLServlet,target=tests"
+ display-name="Servlet transport Connector">
+
+ <attribute name="InvokerLocator">
+ sslservlet://localhost:8443/servlet-invoker/ServerInvokerServlet/?createUniqueObjectName=true
+ </attribute>
+
+ <attribute name="Configuration">
+ <config>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.transport.web.WebInvocationHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/remoting-sslservlet-service.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/server.xml
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/server.xml (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/server.xml 2009-01-18 05:40:30 UTC (rev 4838)
@@ -0,0 +1,169 @@
+<Server>
+
+ <!--APR library loader. Documentation at /docs/apr.html -->
+ <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
+ <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
+ <Listener className="org.apache.catalina.core.JasperListener" />
+
+ <!-- Use a custom version of StandardService that allows the
+ connectors to be started independent of the normal lifecycle
+ start to allow web apps to be deployed before starting the
+ connectors.
+ -->
+ <Service name="jboss.web">
+
+ <!-- A "Connector" represents an endpoint by which requests are received
+ and responses are returned. Documentation at :
+ Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
+ Java AJP Connector: /docs/config/ajp.html
+ APR (HTTP/AJP) Connector: /docs/apr.html
+ Define a non-SSL HTTP/1.1 Connector on port 8080
+ -->
+ <Connector port="8080" address="${jboss.bind.address}"
+ maxThreads="250" maxHttpHeaderSize="8192"
+ emptySessionPath="true" protocol="HTTP/1.1"
+ enableLookups="false" redirectPort="8443" acceptCount="100"
+ connectionTimeout="20000" disableUploadTimeout="true" />
+
+ <!-- Define a SSL HTTP/1.1 Connector on port 8443
+ This connector uses the JSSE configuration, when using APR, the
+ connector should be using the OpenSSL style configuration
+ described in the APR documentation -->
+ <!---->
+ <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
+ maxThreads="150" scheme="https" secure="true"
+ clientAuth="false" sslProtocol="TLS"
+ keystoreFile="${jboss.server.home.dir}/conf/keystore"
+ keystorePass="unit-tests-server"/>
+ <!---->
+
+ <!-- Define an AJP 1.3 Connector on port 8009 -->
+ <Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
+ emptySessionPath="true" enableLookups="false" redirectPort="8443" />
+
+ <Engine name="jboss.web" defaultHost="localhost">
+
+ <!-- The JAAS based authentication and authorization realm implementation
+ that is compatible with the jboss 3.2.x realm implementation.
+ - certificatePrincipal : the class name of the
+ org.jboss.security.auth.certs.CertificatePrincipal impl
+ used for mapping X509[] cert chains to a Princpal.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ -->
+ <Realm className="org.jboss.web.tomcat.security.JBossSecurityMgrRealm"
+ certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
+ allRolesMode="authOnly"
+ />
+ <!-- A subclass of JBossSecurityMgrRealm that uses the authentication
+ behavior of JBossSecurityMgrRealm, but overrides the authorization
+ checks to use JACC permissions with the current java.security.Policy
+ to determine authorized access.
+ - allRolesMode : how to handle an auth-constraint with a role-name=*,
+ one of strict, authOnly, strictAuthOnly
+ + strict = Use the strict servlet spec interpretation which requires
+ that the user have one of the web-app/security-role/role-name
+ + authOnly = Allow any authenticated user
+ + strictAuthOnly = Allow any authenticated user only if there are no
+ web-app/security-roles
+ <Realm className="org.jboss.web.tomcat.security.JaccAuthorizationRealm"
+ certificatePrincipal="org.jboss.security.auth.certs.SubjectDNMapping"
+ allRolesMode="authOnly"
+ />
+ -->
+
+ <Host name="localhost"
+ autoDeploy="false" deployOnStartup="false" deployXML="false"
+ configClass="org.jboss.web.tomcat.security.config.JBossContextConfig"
+ >
+
+ <!-- Uncomment to enable request dumper. This Valve "logs interesting
+ contents from the specified Request (before processing) and the
+ corresponding Response (after processing). It is especially useful
+ in debugging problems related to headers and cookies."
+ -->
+ <!--
+ <Valve className="org.apache.catalina.valves.RequestDumperValve" />
+ -->
+
+ <!-- Access logger -->
+ <!--
+ <Valve className="org.apache.catalina.valves.AccessLogValve"
+ prefix="localhost_access_log." suffix=".log"
+ pattern="common" directory="${jboss.server.home.dir}/log"
+ resolveHosts="false" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host. Does not provide SSO across a cluster.
+
+ If this valve is used, do not use the JBoss ClusteredSingleSignOn
+ valve shown below.
+
+ A new configuration attribute is available beginning with
+ release 4.0.4:
+
+ cookieDomain configures the domain to which the SSO cookie
+ will be scoped (i.e. the set of hosts to
+ which the cookie will be presented). By default
+ the cookie is scoped to "/", meaning the host
+ that presented it. Set cookieDomain to a
+ wider domain (e.g. "xyz.com") to allow an SSO
+ to span more than one hostname.
+ -->
+ <!--
+ <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
+ -->
+
+ <!-- Uncomment to enable single sign-on across web apps
+ deployed to this host AND to all other hosts in the cluster.
+
+ If this valve is used, do not use the standard Tomcat SingleSignOn
+ valve shown above.
+
+ Valve uses a JBossCache instance to support SSO credential
+ caching and replication across the cluster. The JBossCache
+ instance must be configured separately. By default, the valve
+ shares a JBossCache with the service that supports HttpSession
+ replication. See the "jboss-web-cluster-service.xml" file in the
+ server/all/deploy directory for cache configuration details.
+
+ Besides the attributes supported by the standard Tomcat
+ SingleSignOn valve (see the Tomcat docs), this version also
+ supports the following attributes:
+
+ cookieDomain see above
+
+ treeCacheName JMX ObjectName of the JBossCache MBean used to
+ support credential caching and replication across
+ the cluster. If not set, the default value is
+ "jboss.cache:service=TomcatClusteringCache", the
+ standard ObjectName of the JBossCache MBean used
+ to support session replication.
+ -->
+ <!--
+ <Valve className="org.jboss.web.tomcat.service.sso.ClusteredSingleSignOn" />
+ -->
+
+ <!-- Check for unclosed connections and transaction terminated checks
+ in servlets/jsps.
+
+ Important: The dependency on the CachedConnectionManager
+ in META-INF/jboss-service.xml must be uncommented, too
+ -->
+ <Valve className="org.jboss.web.tomcat.service.jca.CachedConnectionValve"
+ cachedConnectionManagerObjectName="jboss.jca:service=CachedConnectionManager"
+ transactionManagerObjectName="jboss:service=TransactionManager" />
+
+ </Host>
+
+ </Engine>
+
+ </Service>
+
+</Server>
\ No newline at end of file
Copied: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/truststore (from rev 4674, remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/.truststore)
===================================================================
(Binary files differ)
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/ssl/truststore
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Name: svn:mergeinfo
+
15 years, 10 months
JBoss Remoting SVN: r4837 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-18 00:40:05 -0500 (Sun, 18 Jan 2009)
New Revision: 4837
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF/web.xml
Log:
JBREM-139, JBREM-1079: Reorganized servlet unit tests and added .../callback/CallbackTestClient.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF/web.xml
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF/web.xml 2009-01-18 05:39:50 UTC (rev 4836)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/WEB-INF/web.xml 2009-01-18 05:40:05 UTC (rev 4837)
@@ -16,13 +16,8 @@
<servlet-class>org.jboss.remoting.transport.servlet.web.ServerInvokerServlet</servlet-class>
<init-param>
<param-name>locatorUrl</param-name>
- <param-value>servlet://localhost:8080/servlet-invoker/ServerInvokerServlet</param-value>
+ <param-value>servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?createUniqueObjectName=true&useAllParams=true&blockingMode=blocking</param-value>
<description>The servlet server invoker locator url</description>
- <!--
- <param-name>locatorUrl</param-name>
- <param-value>servlet://localhost:8080/servlet-invoker/ServerInvokerServlet</param-value>
- <description>The servlet server invoker locator url</description>
- -->
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
15 years, 10 months
JBoss Remoting SVN: r4836 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet: callback and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-18 00:39:50 -0500 (Sun, 18 Jan 2009)
New Revision: 4836
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/CallbackTestClient.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/TestInvocationHandler.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/remoting-servlet-service.xml
Log:
JBREM-139, JBREM-1079: Reorganized servlet unit tests and added .../callback/CallbackTestClient.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/CallbackTestClient.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/CallbackTestClient.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/CallbackTestClient.java 2009-01-18 05:39:50 UTC (rev 4836)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.callback;
+
+import java.util.HashMap;
+
+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.InvokerLocator;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+
+
+/**
+ * Unit test for pull callbacks over servlet transport: JBREM-1079.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Jan 16, 2009
+ * </p>
+ */
+public class CallbackTestClient extends TestCase
+{
+ private static Logger log = Logger.getLogger(CallbackTestClient.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);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testMethod() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Create client.
+ locatorURI = "servlet://localhost:8080/servlet-invoker/ServerInvokerServlet";
+ locatorURI += "/?createUniqueObjectName=true&useAllParams=true&blockingMode=blocking";
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connection.
+ log.info("result: " + client.invoke("abc"));
+ assertEquals(null, client.invoke("abc"));
+ log.info("connection is good");
+
+ // Install client side callback handlers.
+ TestCallbackHandler callbackHandler1 = new TestCallbackHandler();
+ TestCallbackHandler callbackHandler2 = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ client.addListener(callbackHandler1, metadata);
+ client.addListener(callbackHandler2, metadata);
+
+ // Request callbacks.
+ int COUNT = 100;
+ for (int i = 0; i < COUNT; i++)
+ {
+ client.invoke("callback");
+ }
+
+ log.info("sleeping for 2000 ms");
+ Thread.sleep(2000);
+ log.info("waking up");
+
+ // Verify all callbacks arrived.
+ assertEquals(COUNT, callbackHandler1.counter);
+ assertEquals(COUNT, callbackHandler1.counter);
+
+ client.removeListener(callbackHandler1);
+ client.removeListener(callbackHandler2);
+ client.disconnect();
+ log.info(getName() + " PASSES");
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int counter;
+
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ counter++;
+ }
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/TestInvocationHandler.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/TestInvocationHandler.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/TestInvocationHandler.java 2009-01-18 05:39:50 UTC (rev 4836)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.callback;
+
+import java.util.HashSet;
+import java.util.Iterator;
+
+import javax.management.MBeanServer;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+
+public class TestInvocationHandler implements ServerInvocationHandler
+{
+ private static Logger log = Logger.getLogger(TestInvocationHandler.class);
+ private HashSet listeners = new HashSet();
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ listeners.add(callbackHandler);
+ log.info("added " + callbackHandler);
+ }
+
+ public Object invoke(InvocationRequest invocation) throws Throwable
+ {
+ log.debug("invocation: " + invocation.getParameter());
+ Iterator it = listeners.iterator();
+ Callback callback = new Callback("callback");
+ while (it.hasNext())
+ {
+ InvokerCallbackHandler handler = (InvokerCallbackHandler) it.next();
+ handler.handleCallback(callback);
+ log.debug("sent callback to " + handler);
+ }
+ return null;
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ listeners.remove(callbackHandler);
+ log.info("removed " + callbackHandler);
+ }
+
+ public void setInvoker(ServerInvoker invoker)
+ {
+ }
+
+ public void setMBeanServer(MBeanServer server)
+ {
+ }
+}
+
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/remoting-servlet-service.xml
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/remoting-servlet-service.xml (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/callback/remoting-servlet-service.xml 2009-01-18 05:39:50 UTC (rev 4836)
@@ -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/?createUniqueObjectName=true&useAllParams=true&blockingMode=blocking
+ </attribute>
+
+ <attribute name="Configuration">
+ <config>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.transport.servlet.callback.TestInvocationHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
15 years, 10 months
JBoss Remoting SVN: r4835 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-18 00:38:57 -0500 (Sun, 18 Jan 2009)
New Revision: 4835
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-service.xml
Removed:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-server-invoker-service.xml
Log:
JBREM-139, JBREM-1079: Reorganized servlet unit tests and added .../callback/CallbackTestClient.
Deleted: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-server-invoker-service.xml
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-server-invoker-service.xml 2009-01-18 04:48:53 UTC (rev 4834)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-server-invoker-service.xml 2009-01-18 05:38:57 UTC (rev 4835)
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-<server>
-
- <mbean code="org.jboss.remoting.transport.Connector"
- name="jboss.remoting:service=Connector,transport=SSLServlet"
- display-name="Servlet transport Connector">
-
- <attribute name="InvokerLocator">
- servlet://localhost:8080/servlet-invoker/ServerInvokerServlet
- </attribute>
-
- <attribute name="Configuration">
- <config>
- <handlers>
- <handler subsystem="test">org.jboss.test.remoting.transport.web.WebInvocationHandler</handler>
- </handlers>
- </config>
- </attribute>
- </mbean>
-
-
-</server>
Copied: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-service.xml (from rev 4674, remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-server-invoker-service.xml)
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-service.xml (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-service.xml 2009-01-18 05:38:57 UTC (rev 4835)
@@ -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/?createUniqueObjectName=true
+ </attribute>
+
+ <attribute name="Configuration">
+ <config>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.transport.web.WebInvocationHandler</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+
+</server>
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/servlet/remoting-servlet-service.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
15 years, 10 months
JBoss Remoting SVN: r4834 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection: params and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-17 23:48:53 -0500 (Sat, 17 Jan 2009)
New Revision: 4834
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java
Log:
JBREM-1082: New unit test.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/connection/params/UseLocatorParamsTestCase.java 2009-01-18 04:48:53 UTC (rev 4834)
@@ -0,0 +1,470 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.connection.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.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.ConnectionListener;
+import org.jboss.remoting.ConnectionValidator;
+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.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-1082.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Jan 17, 2009
+ * </p>
+ */
+public class UseLocatorParamsTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(UseLocatorParamsTestCase.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);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testUseLocatorParamsDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "333");
+ clientConfig.put("validatorPingTimeout", "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.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put("validatorPingTimeout", "555");
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, 333, 555, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseLocatorParamsFalseInLocator() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=false";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "333");
+ clientConfig.put("validatorPingTimeout", "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.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put("validatorPingTimeout", "555");
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, 333, 555, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseLocatorParamsFalseInConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "333");
+ clientConfig.put("validatorPingTimeout", "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.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put("validatorPingTimeout", "555");
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, 333, 555, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseLocatorParamsFalseInMetadata() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "333");
+ clientConfig.put("validatorPingTimeout", "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.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put("validatorPingTimeout", "555");
+ metadata.put(Client.USE_ALL_PARAMS, "false");
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, 333, 555, true);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseLocatorParamsTrueInLocator() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ clientLocatorURI += "&" + Client.USE_ALL_PARAMS + "=true";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "333");
+ clientConfig.put("validatorPingTimeout", "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.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put("validatorPingTimeout", "555");
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, 333, 555, false);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseLocatorParamsTrueInConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "333");
+ clientConfig.put("validatorPingTimeout", "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.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put("validatorPingTimeout", "555");
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, 333, 555, false);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testUseLocatorParamsTrueInMetadata() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ String clientLocatorURI = locatorURI;
+ clientLocatorURI += "&validatorPingPeriod=111&validatorPingTimeout=222&tieToLease=false";
+ InvokerLocator clientLocator = new InvokerLocator(clientLocatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put("validatorPingPeriod", "333");
+ clientConfig.put("validatorPingTimeout", "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.
+ TestConnectionListener listener = new TestConnectionListener();
+ HashMap metadata = new HashMap();
+ metadata.put("validatorPingTimeout", "555");
+ metadata.put(Client.USE_ALL_PARAMS, "true");
+ client.addConnectionListener(listener, metadata);
+
+ // Test setting of parameters in CallbackPoller.
+ testParameters(client, 333, 555, false);
+
+ client.removeConnectionListener(listener);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void testParameters(Client client,
+ int pingPeriodExpected,
+ int pingTimeoutExpected,
+ boolean tieToLeaseExpected)
+ throws SecurityException, NoSuchFieldException, IllegalArgumentException, IllegalAccessException
+ {
+ Field field = Client.class.getDeclaredField("connectionValidator");
+ field.setAccessible(true);
+ ConnectionValidator validator = (ConnectionValidator) field.get(client);
+ field = ConnectionValidator.class.getDeclaredField("pingPeriod");
+ field.setAccessible(true);
+ long pingPeriod = ((Long)field.get(validator)).longValue();
+ field = ConnectionValidator.class.getDeclaredField("pingTimeout");
+ field.setAccessible(true);
+ int pingTimeout = ((Integer) field.get(validator)).intValue();
+ field = ConnectionValidator.class.getDeclaredField("tieToLease");
+ field.setAccessible(true);
+ boolean tieToLease = ((Boolean) field.get(validator)).booleanValue();
+ log.info("pingPeriod: " + pingPeriod);
+ log.info("pingTimeout: " + pingTimeout);
+ log.info("tieToLease: " + tieToLease);
+ assertEquals(pingPeriodExpected, pingPeriod);
+ assertEquals(pingTimeoutExpected, pingTimeout);
+ assertEquals(tieToLeaseExpected, tieToLease);
+ }
+
+
+ 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 TestConnectionListener implements ConnectionListener
+ {
+ public void handleConnectionException(Throwable throwable, Client client)
+ {
+ }
+ }
+}
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r4833 - in remoting2/branches/2.2/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-01-17 23:45:21 -0500 (Sat, 17 Jan 2009)
New Revision: 4833
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/params/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java
Log:
JBREM-1084: New unit test.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/callback/params/UseAllParamsTestCase.java 2009-01-18 04:45:21 UTC (rev 4833)
@@ -0,0 +1,465 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, 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.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.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(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);
+ }
+ }
+
+
+ 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, 10 months
JBoss Remoting SVN: r4832 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/servlet.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-17 23:38:58 -0500 (Sat, 17 Jan 2009)
New Revision: 4832
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
Log:
JBREM-1079: (1) If "createUniqueObjectName" is "true", uses super.getMBeanObjectName(); (2) if invocation comes from Remoting client and wasn't a lease query, wraps response in an InvocationResponse; (3) doesn't send 204 to Remoting client unless method was HEAD
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-01-18 04:22:42 UTC (rev 4831)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-01-18 04:38:58 UTC (rev 4832)
@@ -60,25 +60,74 @@
*/
public class ServletServerInvoker extends WebServerInvoker implements ServletServerInvokerMBean
{
+ public static final String UNWRAP_SINGLETON_ARRAYS = "unwrapSingletonArrays";
+ public static final String CREATE_UNIQUE_OBJECT_NAME = "createUniqueObjectName";
+
private static final Logger log = Logger.getLogger(ServletServerInvoker.class);
+
+ private boolean unwrapSingletonArrays;
+ private boolean createUniqueObjectName;
public ServletServerInvoker(InvokerLocator locator)
{
super(locator);
+ init();
}
public ServletServerInvoker(InvokerLocator locator, Map configuration)
{
super(locator, configuration);
+ init();
}
protected String getDefaultDataType()
{
return HTTPMarshaller.DATATYPE;
}
-
+
+ protected void init()
+ {
+ Object val = configuration.get(UNWRAP_SINGLETON_ARRAYS);
+ if (val != null)
+ {
+ try
+ {
+ unwrapSingletonArrays = Boolean.valueOf((String)val).booleanValue();
+ log.debug(this + " setting unwrapSingletonArrays to " + unwrapSingletonArrays);
+ }
+ catch (Exception e)
+ {
+ log.warn(this + " could not convert " +
+ UNWRAP_SINGLETON_ARRAYS + " value of " +
+ val + " to a boolean value.");
+ }
+ }
+
+ val = configuration.get(CREATE_UNIQUE_OBJECT_NAME);
+ if (val != null)
+ {
+ try
+ {
+ createUniqueObjectName = Boolean.valueOf((String)val).booleanValue();
+ log.debug(this + " setting createUniqueObjectName to " + createUniqueObjectName);
+ }
+ catch (Exception e)
+ {
+ log.warn(this + " could not convert " +
+ CREATE_UNIQUE_OBJECT_NAME + " value of " +
+ val + " to a boolean value.");
+ }
+ }
+ }
+
public String getMBeanObjectName()
{
+ if (createUniqueObjectName)
+ {
+ log.trace("returning (from super) " + super.getMBeanObjectName());
+ return super.getMBeanObjectName();
+ }
+ log.trace("returning (from here) jboss.remoting:service=invoker,transport=servlet");
return "jboss.remoting:service=invoker,transport=servlet";
}
@@ -96,7 +145,36 @@
}
Map urlParams = request.getParameterMap();
- metadata.putAll(urlParams);
+ if (unwrapSingletonArrays)
+ {
+ Iterator it = urlParams.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ Object value = urlParams.get(key);
+ String[] valueArray = (String[]) value;
+ if (valueArray.length == 1)
+ {
+ value = valueArray[0];
+ }
+ metadata.put(key, value);
+ }
+ }
+ else
+ {
+ metadata.putAll(urlParams);
+ }
+
+ if(log.isTraceEnabled())
+ {
+ log.trace("metadata:");
+ Iterator it = metadata.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ log.trace(" " + key + ": " + metadata.get(key));
+ }
+ }
String requestContentType = request.getContentType();
@@ -173,6 +251,14 @@
throws ServletException, IOException
{
byte[] retval = new byte[0];
+
+ // Check if client is HTTPClientInvoker
+ boolean isRemotingUserAgent = false;
+ String userAgent = request.getHeader(HTTPMetadataConstants.REMOTING_USER_AGENT);
+ if (userAgent != null)
+ {
+ isRemotingUserAgent = userAgent.startsWith("JBossRemoting");
+ }
Map metadata = new HashMap();
@@ -186,61 +272,88 @@
}
Map urlParams = request.getParameterMap();
- metadata.putAll(urlParams);
+ if (unwrapSingletonArrays)
+ {
+ Iterator it = urlParams.keySet().iterator();
+ while (it.hasNext())
+ {
+ Object key = it.next();
+ Object value = urlParams.get(key);
+ String[] valueArray = (String[]) value;
+ if (valueArray.length == 1)
+ {
+ value = valueArray[0];
+ }
+ metadata.put(key, value);
+ }
+ }
+ else
+ {
+ metadata.putAll(urlParams);
+ }
metadata.put(HTTPMetadataConstants.METHODTYPE, request.getMethod());
- metadata.put(HTTPMetadataConstants.PATH, request.getPathTranslated());
+ String path = request.getPathTranslated();
+ if (path != null)
+ metadata.put(HTTPMetadataConstants.PATH, path);
String requestContentType = request.getContentType();
try
{
- Object invocationResponse = null;
-
- ServletInputStream inputStream = request.getInputStream();
- UnMarshaller unmarshaller = getUnMarshaller();
- Object obj = null;
- if (unmarshaller instanceof VersionedUnMarshaller)
- obj = ((VersionedUnMarshaller)unmarshaller).read(new ByteArrayInputStream(requestByte), metadata, Version.getDefaultVersion());
- else
- obj = unmarshaller.read(new ByteArrayInputStream(requestByte), metadata);
- inputStream.close();
-
+ InvocationRequest invocationRequest = null;
+ Object responseObject = null;
boolean isError = false;
- InvocationRequest invocationRequest = null;
- if(obj instanceof InvocationRequest)
+ String method = request.getMethod();
+ if (method.equals("GET") || method.equals("HEAD") || (method.equals("OPTIONS") && request.getContentLength() <= 0))
{
- invocationRequest = (InvocationRequest) obj;
+ invocationRequest = createNewInvocationRequest(metadata, null);
}
else
{
- if(WebUtil.isBinary(requestContentType))
+ ServletInputStream inputStream = request.getInputStream();
+ UnMarshaller unmarshaller = getUnMarshaller();
+ Object obj = null;
+ if (unmarshaller instanceof VersionedUnMarshaller)
+ obj = ((VersionedUnMarshaller)unmarshaller).read(new ByteArrayInputStream(requestByte), metadata, Version.getDefaultVersion());
+ else
+ obj = unmarshaller.read(new ByteArrayInputStream(requestByte), metadata);
+ inputStream.close();
+
+ if(obj instanceof InvocationRequest)
{
- invocationRequest = getInvocationRequest(metadata, obj);
+ invocationRequest = (InvocationRequest) obj;
}
else
{
- invocationRequest = createNewInvocationRequest(metadata, obj);
+ if(WebUtil.isBinary(requestContentType))
+ {
+ invocationRequest = getInvocationRequest(metadata, obj);
+ }
+ else
+ {
+ invocationRequest = createNewInvocationRequest(metadata, obj);
+ }
}
}
try
{
// call transport on the subclass, get the result to handback
- invocationResponse = invoke(invocationRequest);
+ responseObject = invoke(invocationRequest);
}
catch(Throwable ex)
{
log.debug("Error thrown calling invoke on server invoker.", ex);
- invocationResponse = ex;
+ responseObject = ex;
if (checkForExceptionReturn(metadata))
{
String sessionId = invocationRequest.getSessionId();
ServletThrowable st = new ServletThrowable(ex);
- invocationResponse = new InvocationResponse(sessionId, st, true, null);
+ responseObject = new InvocationResponse(sessionId, st, true, null);
}
else
{
@@ -249,16 +362,19 @@
}
//Start with response code of 204 (no content), then if is a return from handler, change to 200 (ok)
- int status = 204;
- if(invocationResponse != null)
+ int status = 200;
+ if(responseObject != null)
{
if(isError)
{
- response.sendError(500, "Error occurred processing invocation request. ");
+ status = 500;
}
- else
+ }
+ else
+ {
+ if (!isRemotingUserAgent || "HEAD".equals(request.getMethod()))
{
- status = 200;
+ status = 204;
}
}
@@ -284,21 +400,25 @@
- // can't set message anymore as is depricated
+ // can't set message anymore as is deprecated
response.setStatus(status);
+
+ if (isRemotingUserAgent && !(invocationRequest instanceof CreatedInvocationRequest))
+ {
+ responseObject = new InvocationResponse(invocationRequest.getSessionId(),
+ responseObject, isError, responseMap);
+ }
- if(invocationResponse != null)
+ if(responseObject != null)
{
- String responseContentType = invocationResponse == null ? requestContentType : WebUtil.getContentType(invocationResponse);
+ String responseContentType = responseObject == null ? requestContentType : WebUtil.getContentType(responseObject);
response.setContentType(responseContentType);
- //int iContentLength = getContentLength(invocationResponse);
- //response.setContentLength(iContentLength);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Marshaller marshaller = getMarshaller();
if (marshaller instanceof VersionedMarshaller)
- ((VersionedMarshaller) marshaller).write(invocationResponse, outputStream, Version.getDefaultVersion());
+ ((VersionedMarshaller) marshaller).write(responseObject, outputStream, Version.getDefaultVersion());
else
- marshaller.write(invocationResponse, outputStream);
+ marshaller.write(responseObject, outputStream);
retval = outputStream.toByteArray();
response.setContentLength(retval.length);
}
15 years, 10 months
JBoss Remoting SVN: r4831 - 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-01-17 23:22:42 -0500 (Sat, 17 Jan 2009)
New Revision: 4831
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/web/WebServerInvoker.java
Log:
JBREM-1079: createNewInvocationRequest() creates a CreatedInvocationRequest for lease queries.
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-01-18 04:20:28 UTC (rev 4830)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/web/WebServerInvoker.java 2009-01-18 04:22:42 UTC (rev 4831)
@@ -131,11 +131,11 @@
if(isLeasQuery)
{
addLeaseInfo(responseMap);
- request = new InvocationRequest(sessionId, subSystem, "$PING$", null, responseMap, null);
+ request = new CreatedInvocationRequest(sessionId, subSystem, "$PING$", null, responseMap, null);
}
else
{
- request = new InvocationRequest(sessionId, subSystem, payload, metadata, null, null);
+ request = new CreatedInvocationRequest(sessionId, subSystem, payload, metadata, null, null);
}
request.setReturnPayload(responseMap);
return request;
@@ -233,4 +233,11 @@
}
}
+ static protected class CreatedInvocationRequest extends InvocationRequest
+ {
+ public CreatedInvocationRequest(String sessionId, String subsystem, Object arg, Map requestPayload, Map returnPayload, InvokerLocator locator)
+ {
+ super(sessionId, subsystem, arg, requestPayload, returnPayload, locator);
+ }
+ }
}
\ No newline at end of file
15 years, 10 months
JBoss Remoting SVN: r4830 - remoting2/branches/2.2/src/main/org/jboss/remoting/callback.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-01-17 23:20:28 -0500 (Sat, 17 Jan 2009)
New Revision: 4830
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
Log:
JBREM-1081: destroy() no longer sets callbackClient and callbackStore to null.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-01-18 04:18:44 UTC (rev 4829)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/callback/ServerInvokerCallbackHandler.java 2009-01-18 04:20:28 UTC (rev 4830)
@@ -1009,13 +1009,11 @@
if(callBackClient != null)
{
callBackClient.disconnect();
- callBackClient = null;
}
if(callbackStore != null)
{
callbackStore.purgeFiles();
- callbackStore = null;
}
}
15 years, 10 months