JBoss Remoting SVN: r5421 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-01 20:33:01 -0400 (Tue, 01 Sep 2009)
New Revision: 5421
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java
Log:
JBREM-1101: Corrected copyright date.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java 2009-09-01 19:48:55 UTC (rev 5420)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java 2009-09-02 00:33:01 UTC (rev 5421)
@@ -30,7 +30,7 @@
* @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
* @version
* <p>
- * Copyright Mar 21, 2009
+ * Copyright Sep 1, 2009
* </p>
*/
public class ServletContentTypeTestClient extends ContentTypeTestCase
15 years, 3 months
JBoss Remoting SVN: r5420 - remoting2/branches/2.x.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-01 15:48:55 -0400 (Tue, 01 Sep 2009)
New Revision: 5420
Modified:
remoting2/branches/2.x/build.xml
Log:
JBREM-1101: Added tests.servlet.contenttype; JBREM-1145: added tests.servlet.marshal.
Modified: remoting2/branches/2.x/build.xml
===================================================================
--- remoting2/branches/2.x/build.xml 2009-09-01 19:38:47 UTC (rev 5419)
+++ remoting2/branches/2.x/build.xml 2009-09-01 19:48:55 UTC (rev 5420)
@@ -1696,6 +1696,8 @@
<antcall target="AS.start"/>
<antcall target="tests.servlet" inheritrefs="true"/>
<antcall target="tests.servlet.callback" inheritrefs="true"/>
+ <antcall target="tests.servlet.contenttype" inheritrefs="true"/>
+ <antcall target="tests.servlet.marshal" inheritrefs="true"/>
<antcall target="tests.servlet.marshal.config" inheritrefs="true"/>
<antcall target="tests.servlet.marshal.noconfig" inheritrefs="true"/>
<antcall target="tests.servlet.mbeanserver.jboss" inheritrefs="true"/>
@@ -1767,6 +1769,66 @@
<delete file="${jboss.deploy.dir}/remoting-servlet-service.xml"/>
</target>
+ <target name="tests.servlet.contenttype">
+ <copy file="${servlet.tests.dir}/contenttype/remoting-servlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <sleep seconds="2"/>
+ <copy todir="${jboss.deploy.dir}">
+ <fileset dir="${output.lib.dir}">
+ <include name="servlet-invoker.war/**"/>
+ </fileset>
+ </copy>
+ <copy file="${servlet.tests.dir}/contenttype/WEB-INF/web.xml"
+ todir="${jboss.deploy.dir}/servlet-invoker.war/WEB-INF" overwrite="true"/>
+ <sleep seconds="4"/>
+ <junit printsummary="true" fork="yes" includeantruntime="true">
+ <jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
+ <jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
+ <classpath>
+ <path refid="tests.classpath"/>
+ <pathelement location="${output.lib.dir}/jboss-remoting-tests.jar"/>
+ </classpath>
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+ extension="-java_serialization.xml"/>
+ <batchtest fork="yes" todir="${output.tests.results}" haltonfailure="no">
+ <fileset dir="${tests.compile.dir}">
+ <include name="**/remoting/transport/servlet/contenttype/*TestClient.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <delete dir="${jboss.deploy.dir}/servlet-invoker.war"/>
+ <delete file="${jboss.deploy.dir}/remoting-servlet-service.xml"/>
+ </target>
+
+ <target name="tests.servlet.marshal" depends="tests.servlet.config">
+ <copy file="${servlet.tests.dir}/marshal/remoting-servlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
+ <sleep seconds="2"/>
+ <copy todir="${jboss.deploy.dir}">
+ <fileset dir="${output.lib.dir}">
+ <include name="servlet-invoker.war/**"/>
+ </fileset>
+ </copy>
+ <copy file="${servlet.tests.dir}/marshal/WEB-INF/web.xml"
+ todir="${jboss.deploy.dir}/servlet-invoker.war/WEB-INF" overwrite="true"/>
+ <sleep seconds="4"/>
+ <junit printsummary="true" fork="yes" includeantruntime="true">
+ <jvmarg value="-Dloader.path=${output.lib.dir}/jboss-remoting-loading-tests.jar"/>
+ <jvmarg value="-D${remoting.metadata.key}=${metadata}"/>
+ <classpath>
+ <path refid="tests.classpath"/>
+ <pathelement location="${output.lib.dir}/jboss-remoting-tests.jar"/>
+ </classpath>
+ <formatter classname="org.jboss.ant.taskdefs.XMLJUnitMultipleResultFormatter"
+ extension="-java_serialization.xml"/>
+ <batchtest fork="yes" todir="${output.tests.results}" haltonfailure="no">
+ <fileset dir="${tests.compile.dir}">
+ <include name="**/remoting/transport/servlet/marshal/*TestClient.class"/>
+ </fileset>
+ </batchtest>
+ </junit>
+ <delete dir="${jboss.deploy.dir}/servlet-invoker.war"/>
+ <delete file="${jboss.deploy.dir}/remoting-servlet-service.xml"/>
+ </target>
+
<target name="tests.servlet.marshal.config">
<copy file="${servlet.tests.dir}/marshal/config/remoting-servlet-service.xml" todir="${jboss.deploy.dir}" overwrite="true"/>
<sleep seconds="2"/>
15 years, 3 months
JBoss Remoting SVN: r5419 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-01 15:38:47 -0400 (Tue, 01 Sep 2009)
New Revision: 5419
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
Log:
JBREM-1101: Updated alternative processRequest() method.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-09-01 19:34:01 UTC (rev 5418)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-09-01 19:38:47 UTC (rev 5419)
@@ -241,7 +241,14 @@
if(invocationResponse != null)
{
- response.setContentType(requestContentType);
+ if (isInvalidContentType(requestContentType))
+ {
+ log.warn("Ignoring invalid content-type from client: " + requestContentType);
+ }
+ else
+ {
+ response.setContentType(requestContentType);
+ }
int iContentLength = getContentLength(invocationResponse);
response.setContentLength(iContentLength);
ServletOutputStream outputStream = response.getOutputStream();
15 years, 3 months
JBoss Remoting SVN: r5418 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-01 15:34:01 -0400 (Tue, 01 Sep 2009)
New Revision: 5418
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
Log:
JBREM-1101: Checks that application supplied content-type doesn't have LF or CR.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-09-01 19:31:58 UTC (rev 5417)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/servlet/ServletServerInvoker.java 2009-09-01 19:34:01 UTC (rev 5418)
@@ -480,10 +480,20 @@
{
responseContentType = (String) responseMap.get("Content-Type");
}
- if(responseContentType == null)
+
+ if (responseContentType != null)
{
- responseContentType = responseObject == null ? requestContentType : WebUtil.getContentType(responseObject);
+ if (isInvalidContentType(responseContentType))
+ {
+ log.warn("Ignoring invalid content-type from ServerInvocationHandler: " + responseContentType);
+ responseContentType = WebUtil.getContentType(responseObject);
+ }
}
+ else
+ {
+ responseContentType = WebUtil.getContentType(responseObject);
+ }
+ log.info("responseContentType: " + responseContentType);
response.setContentType(responseContentType);
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
Marshaller marshaller = getMarshaller();
@@ -513,6 +523,11 @@
return retval;
}
+ static private boolean isInvalidContentType(String contentType)
+ {
+ return contentType.indexOf('\n') + contentType.indexOf('\r') > -2;
+ }
+
private boolean checkForNoExceptionReturn(Map headers)
{
boolean flag = false;
15 years, 3 months
JBoss Remoting SVN: r5417 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-01 15:31:58 -0400 (Tue, 01 Sep 2009)
New Revision: 5417
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java
Log:
JBREM-1101: Minor changes to implement the servlet version.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java 2009-09-01 19:29:45 UTC (rev 5416)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java 2009-09-01 19:31:58 UTC (rev 5417)
@@ -60,14 +60,14 @@
*/
public class ContentTypeTestCase extends TestCase
{
+ public static String CONTENT_TYPE = "test/testContentType";
+ public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y";
+ public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y";
+ public static String REQUEST = "testRequest";
+ public static String RESPONSE = "testResponse";
+
private static Logger log = Logger.getLogger(ContentTypeTestCase.class);
-
private static boolean firstTime = true;
- private static String CONTENT_TYPE = "test/testContentType";
- private static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y";
- private static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y";
- private static String REQUEST = "testRequest";
- private static String RESPONSE = "testResponse";
protected String host;
protected int port;
@@ -126,7 +126,7 @@
assertEquals(CONTENT_TYPE, contentType);
assertEquals(RESPONSE, response);
- connector.stop();
+ teardownServer();
log.info(getName() + " PASSES");
}
@@ -161,7 +161,7 @@
assertEquals(WebUtil.HTML, contentType);
assertEquals(RESPONSE, response);
- connector.stop();
+ teardownServer();
log.info(getName() + " PASSES");
}
@@ -196,7 +196,7 @@
assertEquals(WebUtil.HTML, contentType);
assertEquals(RESPONSE, response);
- connector.stop();
+ teardownServer();
log.info(getName() + " PASSES");
}
@@ -234,6 +234,15 @@
}
+ protected void teardownServer()
+ {
+ if (connector != null)
+ {
+ connector.stop();
+ }
+ }
+
+
static class TestInvocationHandler implements ServerInvocationHandler
{
String contentType;
15 years, 3 months
JBoss Remoting SVN: r5416 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/WEB-INF.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-01 15:29:45 -0400 (Tue, 01 Sep 2009)
New Revision: 5416
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/WEB-INF/web.xml
Log:
JBREM-1101: New unit tests.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/WEB-INF/web.xml
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/WEB-INF/web.xml 2009-09-01 19:29:27 UTC (rev 5415)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/preservelines/WEB-INF/web.xml 2009-09-01 19:29:45 UTC (rev 5416)
@@ -4,25 +4,65 @@
"http://java.sun.com/dtd/web-app_2_3.dtd">
<!-- The the JBossRemoting server invoker servlet web.xml descriptor
-$Id: web.xml 3291 2008-01-15 05:03:53Z ron.sigal(a)jboss.com $
+$Id: web.xml 4903 2009-03-24 07:33:10Z ron.sigal(a)jboss.com $
-->
<web-app>
<servlet>
- <servlet-name>ServerInvokerServlet</servlet-name>
+ <servlet-name>ServerInvokerServletOK</servlet-name>
<description>The ServerInvokerServlet receives requests via HTTP
protocol from within a web container and passes it onto the
ServletServerInvoker for processing.
</description>
<servlet-class>org.jboss.remoting.transport.servlet.web.ServerInvokerServlet</servlet-class>
<init-param>
- <param-name>invokerName</param-name>
- <param-value>jboss.remoting:host=localhost,port=8080,service=invoker,transport=servlet</param-value>
- <description>The servlet server invoker</description>
+ <param-name>locatorUrl</param-name>
+ <param-value>servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=OK</param-value>
+ <description>The servlet server invoker locator url</description>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
+
+ <servlet>
+ <servlet-name>ServerInvokerServletCR</servlet-name>
+ <description>The ServerInvokerServlet receives requests via HTTP
+ protocol from within a web container and passes it onto the
+ ServletServerInvoker for processing.
+ </description>
+ <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/?version=CR</param-value>
+ <description>The servlet server invoker locator url</description>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet>
+ <servlet-name>ServerInvokerServletLF</servlet-name>
+ <description>The ServerInvokerServlet receives requests via HTTP
+ protocol from within a web container and passes it onto the
+ ServletServerInvoker for processing.
+ </description>
+ <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/?version=LF</param-value>
+ <description>The servlet server invoker locator url</description>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
<servlet-mapping>
- <servlet-name>ServerInvokerServlet</servlet-name>
- <url-pattern>/ServerInvokerServlet/*</url-pattern>
+ <servlet-name>ServerInvokerServletOK</servlet-name>
+ <url-pattern>/ServerInvokerServlet/OK/*</url-pattern>
+ </servlet-mapping>
+ <servlet-mapping>
+ <servlet-name>ServerInvokerServletCR</servlet-name>
+ <url-pattern>/ServerInvokerServlet/CR/*</url-pattern>
</servlet-mapping>
-</web-app>
\ No newline at end of file
+ <servlet-mapping>
+ <servlet-name>ServerInvokerServletLF</servlet-name>
+ <url-pattern>/ServerInvokerServlet/LF/*</url-pattern>
+ </servlet-mapping>
+</web-app>
+
15 years, 3 months
JBoss Remoting SVN: r5415 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet: contenttype and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-09-01 15:29:27 -0400 (Tue, 01 Sep 2009)
New Revision: 5415
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerCR.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerLF.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerOK.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/remoting-servlet-service.xml
Log:
JBREM-1101: New unit tests.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/ServletContentTypeTestClient.java 2009-09-01 19:29:27 UTC (rev 5415)
@@ -0,0 +1,60 @@
+/*
+ * 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.contenttype;
+
+import org.apache.log4j.Logger;
+import org.jboss.test.remoting.transport.http.contenttype.ContentTypeTestCase;
+
+/**
+ * Unit tests for JBREM-1101.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Mar 21, 2009
+ * </p>
+ */
+public class ServletContentTypeTestClient extends ContentTypeTestCase
+{
+ protected static Logger log = Logger.getLogger(ServletContentTypeTestClient.class);
+
+ protected void setupServer(String contentType) throws Exception
+ {
+ locatorURI = "http://localhost:8080/servlet-invoker/ServerInvokerServlet";
+
+ if (CONTENT_TYPE.equals(contentType))
+ {
+ locatorURI += "/OK";
+ }
+ if (INVALID_CONTENT_TYPE_CR.equals(contentType))
+ {
+ locatorURI += "/CR";
+ }
+ else if (INVALID_CONTENT_TYPE_LF.equals(contentType))
+ {
+ locatorURI += "/LF";
+ }
+
+ log.info("setting InvokerLocator to " + locatorURI);
+ }
+}
+
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerCR.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerCR.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerCR.java 2009-09-01 19:29:27 UTC (rev 5415)
@@ -0,0 +1,64 @@
+/*
+ * 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.contenttype;
+
+import java.util.Map;
+
+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;
+
+/**
+ * For JBREM-1101 unit tests.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 1, 2009
+ * </p>
+ */
+public class TestInvocationHandlerCR implements ServerInvocationHandler
+{
+ public static String CONTENT_TYPE = "test/testContentType";
+ public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y";
+ public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y";
+ public static String REQUEST = "testRequest";
+ public static String RESPONSE = "testResponse";
+
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Map response = invocation.getReturnPayload();
+ if (response != null)
+ {
+ response.put("Content-Type", INVALID_CONTENT_TYPE_CR);
+ }
+ return RESPONSE;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+}
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerLF.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerLF.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerLF.java 2009-09-01 19:29:27 UTC (rev 5415)
@@ -0,0 +1,64 @@
+/*
+ * 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.contenttype;
+
+import java.util.Map;
+
+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;
+
+/**
+ * For JBREM-1101 unit tests.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 1, 2009
+ * </p>
+ */
+public class TestInvocationHandlerLF implements ServerInvocationHandler
+{
+ public static String CONTENT_TYPE = "test/testContentType";
+ public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y";
+ public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y";
+ public static String REQUEST = "testRequest";
+ public static String RESPONSE = "testResponse";
+
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Map response = invocation.getReturnPayload();
+ if (response != null)
+ {
+ response.put("Content-Type", INVALID_CONTENT_TYPE_CR);
+ }
+ return RESPONSE;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+}
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerOK.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerOK.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/TestInvocationHandlerOK.java 2009-09-01 19:29:27 UTC (rev 5415)
@@ -0,0 +1,64 @@
+/*
+ * 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.contenttype;
+
+import java.util.Map;
+
+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;
+
+/**
+ * For JBREM-1101 unit tests.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Sep 1, 2009
+ * </p>
+ */
+public class TestInvocationHandlerOK implements ServerInvocationHandler
+{
+ public static String CONTENT_TYPE = "test/testContentType";
+ public static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y";
+ public static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y";
+ public static String REQUEST = "testRequest";
+ public static String RESPONSE = "testResponse";
+
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Map response = invocation.getReturnPayload();
+ if (response != null)
+ {
+ response.put("Content-Type", CONTENT_TYPE);
+ }
+ return RESPONSE;
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+}
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/remoting-servlet-service.xml
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/remoting-servlet-service.xml (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/servlet/contenttype/remoting-servlet-service.xml 2009-09-01 19:29:27 UTC (rev 5415)
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:service=Connector,transport=Servlet,target=tests,version=OK"
+ display-name="Servlet transport Connector">
+
+ <attribute name="InvokerLocator">
+ servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=OK
+ </attribute>
+
+ <attribute name="Configuration">
+ <config>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.transport.servlet.contenttype.TestInvocationHandlerOK</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:service=Connector,transport=Servlet,target=tests,version=CR"
+ display-name="Servlet transport Connector">
+
+ <attribute name="InvokerLocator">
+ servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=CR
+ </attribute>
+
+ <attribute name="Configuration">
+ <config>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.transport.servlet.contenttype.TestInvocationHandlerCR</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+
+ <mbean code="org.jboss.remoting.transport.Connector"
+ name="jboss.remoting:service=Connector,transport=Servlet,target=tests,version=LF"
+ display-name="Servlet transport Connector">
+
+ <attribute name="InvokerLocator">
+ servlet://localhost:8080/servlet-invoker/ServerInvokerServlet/?version=LF
+ </attribute>
+
+ <attribute name="Configuration">
+ <config>
+ <handlers>
+ <handler subsystem="test">org.jboss.test.remoting.transport.servlet.contenttype.TestInvocationHandlerLF</handler>
+ </handlers>
+ </config>
+ </attribute>
+ </mbean>
+</server>
15 years, 3 months
JBoss Remoting SVN: r5414 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/contenttype.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-31 23:00:46 -0400 (Mon, 31 Aug 2009)
New Revision: 5414
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java
Log:
JBREM-1101: Added new test methods.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java 2009-09-01 03:00:06 UTC (rev 5413)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java 2009-09-01 03:00:46 UTC (rev 5414)
@@ -28,6 +28,7 @@
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
+import java.util.HashMap;
import java.util.Map;
import javax.management.MBeanServer;
@@ -42,15 +43,14 @@
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.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.web.WebUtil;
/**
- * Unit test for JBREM-653.
+ * Unit test for JBREM-653 and JBREM-1101.
*
* @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
* @version $Revision$
@@ -64,13 +64,17 @@
private static boolean firstTime = true;
private static String CONTENT_TYPE = "test/testContentType";
+ private static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y";
+ private static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y";
private static String REQUEST = "testRequest";
private static String RESPONSE = "testResponse";
- // remoting server connector
- private Connector connector;
- private InvokerLocator serverLocator;
- private TestInvocationHandler invocationHandler;
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
public void setUp() throws Exception
@@ -101,16 +105,7 @@
log.info("entering " + getName());
// Start server.
- String host = InetAddress.getLocalHost().getHostAddress();
- int port = PortUtil.findFreePort(host);
- String locatorURI = "http://" + host + ":" + port;
- serverLocator = new InvokerLocator(locatorURI);
- log.info("Starting remoting server with locator uri of: " + locatorURI);
- connector = new Connector(serverLocator);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("sample", invocationHandler);
- connector.start();
+ setupServer(CONTENT_TYPE);
// Send a message and receive a response using an HttpURLConnection.
URL url = new URL(locatorURI);
@@ -135,27 +130,129 @@
log.info(getName() + " PASSES");
}
+
+ /**
+ * Verifies that content-type with CR supplied by ServerInvocationHandler is discarded.
+ */
+ public void testInvalidContentTypeServerCR() throws Throwable
+ {
+ log.info("entering " + getName());
+ // Start server.
+ setupServer(INVALID_CONTENT_TYPE_CR);
+
+ // Send a message and receive a response using an HttpURLConnection.
+ URL url = new URL(locatorURI);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ byte[] requestBytes = REQUEST.getBytes();
+ OutputStream os = conn.getOutputStream();
+ os.write(requestBytes);
+ String contentType = conn.getContentType();
+ log.info("content-type: " + contentType);
+ InputStream is = conn.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String response = reader.readLine();
+ log.info("response: " + response);
+
+ // Verify that content-type is the default value.
+ log.info("content-type: " + contentType);
+ assertEquals(WebUtil.HTML, contentType);
+ assertEquals(RESPONSE, response);
+
+ connector.stop();
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Verifies that content-type with LF supplied by ServerInvocationHandler is discarded.
+ */
+ public void testInvalidContentTypeServerLF() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(INVALID_CONTENT_TYPE_LF);
+
+ // Send a message and receive a response using an HttpURLConnection.
+ URL url = new URL(locatorURI);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ byte[] requestBytes = REQUEST.getBytes();
+ OutputStream os = conn.getOutputStream();
+ os.write(requestBytes);
+ String contentType = conn.getContentType();
+ log.info("content-type: " + contentType);
+ InputStream is = conn.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String response = reader.readLine();
+ log.info("response: " + response);
+
+ // Verify that content-type is the default value.
+ log.info("content-type: " + contentType);
+ assertEquals(WebUtil.HTML, contentType);
+ assertEquals(RESPONSE, response);
+
+ connector.stop();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "http";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(String contentType) 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;
+ }
+ 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(contentType);
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
static class TestInvocationHandler implements ServerInvocationHandler
{
+ String contentType;
+ public TestInvocationHandler(String contentType)
+ {
+ this.contentType = contentType;
+ }
public void addListener(InvokerCallbackHandler callbackHandler) {}
public Object invoke(final InvocationRequest invocation) throws Throwable
{
Map response = invocation.getReturnPayload();
- response.put("Content-Type", CONTENT_TYPE);
+ if (response != null)
+ {
+ response.put("Content-Type", contentType);
+ }
return RESPONSE;
}
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, 4 months
JBoss Remoting SVN: r5413 - remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-31 23:00:06 -0400 (Mon, 31 Aug 2009)
New Revision: 5413
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
Log:
JBREM-1101: Checks that application supplied content-type doesn't have LF or CR.
Modified: remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
===================================================================
--- remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java 2009-09-01 02:54:00 UTC (rev 5412)
+++ remoting2/branches/2.2/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java 2009-09-01 03:00:06 UTC (rev 5413)
@@ -436,10 +436,42 @@
case Version.VERSION_2_2:
{
String responseContentType = (String) response.get("Content-Type");
- if(responseContentType == null)
+ if (responseContentType != null)
{
- responseContentType = responseObject == null ? req.getContentType() : WebUtil.getContentType(responseObject);
+ if (isInvalidContentType(responseContentType))
+ {
+ log.warn("Ignoring invalid content-type from ServerInvocationHandler: " + responseContentType);
+ if (responseObject == null)
+ {
+ responseContentType = req.getContentType();
+ if (isInvalidContentType(responseContentType))
+ {
+ log.warn("Ignoring invalid content-type from request: " + responseContentType);
+ responseContentType = WebUtil.getContentType(responseObject);
+ }
+ }
+ else
+ {
+ responseContentType = WebUtil.getContentType(responseObject);
+ }
+ }
}
+ else
+ {
+ if (responseObject == null)
+ {
+ responseContentType = req.getContentType();
+ if (isInvalidContentType(responseContentType))
+ {
+ log.warn("Ignoring invalid content-type from request: " + responseContentType);
+ responseContentType = WebUtil.getContentType(responseObject);
+ }
+ }
+ else
+ {
+ responseContentType = WebUtil.getContentType(responseObject);
+ }
+ }
res.setContentType(responseContentType);
if (responseObject instanceof String)
@@ -1046,4 +1078,9 @@
return new String(chars);
}
+
+ static private boolean isInvalidContentType(String contentType)
+ {
+ return contentType.indexOf('\n') + contentType.indexOf('\r') > -2;
+ }
}
15 years, 4 months
JBoss Remoting SVN: r5412 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-31 22:54:00 -0400 (Mon, 31 Aug 2009)
New Revision: 5412
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java
Log:
JBREM-1101: Added new test methods.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java 2009-09-01 02:52:51 UTC (rev 5411)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/contenttype/ContentTypeTestCase.java 2009-09-01 02:54:00 UTC (rev 5412)
@@ -28,6 +28,7 @@
import java.net.HttpURLConnection;
import java.net.InetAddress;
import java.net.URL;
+import java.util.HashMap;
import java.util.Map;
import javax.management.MBeanServer;
@@ -42,15 +43,14 @@
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.HandleCallbackException;
import org.jboss.remoting.callback.InvokerCallbackHandler;
import org.jboss.remoting.transport.Connector;
import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.web.WebUtil;
/**
- * Unit test for JBREM-653.
+ * Unit test for JBREM-653 and JBREM-1101.
*
* @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
* @version $Revision$
@@ -64,13 +64,17 @@
private static boolean firstTime = true;
private static String CONTENT_TYPE = "test/testContentType";
+ private static String INVALID_CONTENT_TYPE_CR = "test/x" + '\r' + "y";
+ private static String INVALID_CONTENT_TYPE_LF = "test/x" + '\n' + "y";
private static String REQUEST = "testRequest";
private static String RESPONSE = "testResponse";
- // remoting server connector
- private Connector connector;
- private InvokerLocator serverLocator;
- private TestInvocationHandler invocationHandler;
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
public void setUp() throws Exception
@@ -101,16 +105,7 @@
log.info("entering " + getName());
// Start server.
- String host = InetAddress.getLocalHost().getHostAddress();
- int port = PortUtil.findFreePort(host);
- String locatorURI = "http://" + host + ":" + port;
- serverLocator = new InvokerLocator(locatorURI);
- log.info("Starting remoting server with locator uri of: " + locatorURI);
- connector = new Connector(serverLocator);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("sample", invocationHandler);
- connector.start();
+ setupServer(CONTENT_TYPE);
// Send a message and receive a response using an HttpURLConnection.
URL url = new URL(locatorURI);
@@ -135,27 +130,129 @@
log.info(getName() + " PASSES");
}
+
+ /**
+ * Verifies that content-type with CR supplied by ServerInvocationHandler is discarded.
+ */
+ public void testInvalidContentTypeServerCR() throws Throwable
+ {
+ log.info("entering " + getName());
+ // Start server.
+ setupServer(INVALID_CONTENT_TYPE_CR);
+
+ // Send a message and receive a response using an HttpURLConnection.
+ URL url = new URL(locatorURI);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ byte[] requestBytes = REQUEST.getBytes();
+ OutputStream os = conn.getOutputStream();
+ os.write(requestBytes);
+ String contentType = conn.getContentType();
+ log.info("content-type: " + contentType);
+ InputStream is = conn.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String response = reader.readLine();
+ log.info("response: " + response);
+
+ // Verify that content-type is the default value.
+ log.info("content-type: " + contentType);
+ assertEquals(WebUtil.HTML, contentType);
+ assertEquals(RESPONSE, response);
+
+ connector.stop();
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Verifies that content-type with LF supplied by ServerInvocationHandler is discarded.
+ */
+ public void testInvalidContentTypeServerLF() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(INVALID_CONTENT_TYPE_LF);
+
+ // Send a message and receive a response using an HttpURLConnection.
+ URL url = new URL(locatorURI);
+ HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+ conn.setDoOutput(true);
+ conn.setDoInput(true);
+ byte[] requestBytes = REQUEST.getBytes();
+ OutputStream os = conn.getOutputStream();
+ os.write(requestBytes);
+ String contentType = conn.getContentType();
+ log.info("content-type: " + contentType);
+ InputStream is = conn.getInputStream();
+ BufferedReader reader = new BufferedReader(new InputStreamReader(is));
+ String response = reader.readLine();
+ log.info("response: " + response);
+
+ // Verify that content-type is the default value.
+ log.info("content-type: " + contentType);
+ assertEquals(WebUtil.HTML, contentType);
+ assertEquals(RESPONSE, response);
+
+ connector.stop();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "http";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(String contentType) 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;
+ }
+ 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(contentType);
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
static class TestInvocationHandler implements ServerInvocationHandler
{
+ String contentType;
+ public TestInvocationHandler(String contentType)
+ {
+ this.contentType = contentType;
+ }
public void addListener(InvokerCallbackHandler callbackHandler) {}
public Object invoke(final InvocationRequest invocation) throws Throwable
{
Map response = invocation.getReturnPayload();
- response.put("Content-Type", CONTENT_TYPE);
+ if (response != null)
+ {
+ response.put("Content-Type", contentType);
+ }
return RESPONSE;
}
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, 4 months