JBoss Remoting SVN: r5390 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-26 15:39:51 -0400 (Wed, 26 Aug 2009)
New Revision: 5390
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPMetadataConstants.java
Log:
JBREM-1145: Made use of new content type test optional.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPMetadataConstants.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPMetadataConstants.java 2009-08-26 19:39:29 UTC (rev 5389)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPMetadataConstants.java 2009-08-26 19:39:51 UTC (rev 5390)
@@ -65,8 +65,11 @@
/** Used to distinguish special case of payload of type String. */
public static final String REMOTING_CONTENT_TYPE = "remotingContentType";
+ public static final String REMOTING_CONTENT_TYPE_LC = "remotingcontenttype";
public static final String REMOTING_CONTENT_TYPE_STRING = "remotingContentTypeString";
public static final String REMOTING_CONTENT_TYPE_NON_STRING = "remotingContentTypeNonString";
+
+ public static final String USE_REMOTING_CONTENT_TYPE = "useRemotingContentType";
}
\ No newline at end of file
15 years, 3 months
JBoss Remoting SVN: r5389 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-26 15:39:29 -0400 (Wed, 26 Aug 2009)
New Revision: 5389
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
Log:
JBREM-1145: Made use of new content type test optional.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2009-08-26 19:38:14 UTC (rev 5388)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/http/HTTPClientInvoker.java 2009-08-26 19:39:29 UTC (rev 5389)
@@ -115,6 +115,7 @@
protected boolean noThrowOnError;
protected int numberOfCallAttempts = 1;
protected boolean unmarshalNullStream = true;
+ protected boolean useRemotingContentType = false;
private Object timeoutThreadPoolLock = new Object();
private ThreadPool timeoutThreadPool;
@@ -318,6 +319,8 @@
{
conn.setRequestProperty(HTTPMetadataConstants.CONTENTTYPE, WebUtil.getContentType(invocation));
}
+
+ metadata.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE, Boolean.toString(useRemotingContentType));
// set the remoting version
conn.setRequestProperty(HTTPMetadataConstants.REMOTING_VERSION_HEADER, new Integer(getVersion()).toString());
@@ -560,7 +563,7 @@
unmarshaller = new CompressingUnMarshaller(MarshalFactory.getUnMarshaller(SerializableUnMarshaller.DATATYPE));
}
- Map map = metadata == null ? headers : metadata;
+ Map map = metadata == null ? new HashMap(headers) : metadata;
// UnMarshaller may not be an HTTPUnMarshaller, in which case it
// can ignore this parameter.
@@ -571,6 +574,8 @@
map.put(HTTPUnMarshaller.PRESERVE_LINES, o);
}
+ map.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE, Boolean.toString(useRemotingContentType));
+
try
{
if (unmarshaller instanceof VersionedUnMarshaller)
@@ -584,6 +589,7 @@
}
catch (IOException e)
{
+ log.trace(this + " unable to read response", e);
if (-1 == is.read())
{
throw new EOFException();
@@ -1052,6 +1058,22 @@
val + " to a boolean value.");
}
}
+
+ val = configuration.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE);
+ if (val != null)
+ {
+ try
+ {
+ useRemotingContentType = Boolean.valueOf((String)val).booleanValue();
+ log.debug(this + " setting useRemotingContent to " + useRemotingContentType);
+ }
+ catch (Exception e)
+ {
+ log.warn(this + " could not convert " +
+ HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE + " value of " +
+ val + " to a boolean value.");
+ }
+ }
}
/**
15 years, 3 months
JBoss Remoting SVN: r5388 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-26 15:38:14 -0400 (Wed, 26 Aug 2009)
New Revision: 5388
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
Log:
JBREM-1145: Made use of new content type test optional.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java 2009-08-26 19:37:42 UTC (rev 5387)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/coyote/CoyoteInvoker.java 2009-08-26 19:38:14 UTC (rev 5388)
@@ -94,6 +94,8 @@
protected List protocolHandlers = new ArrayList();
protected String URIEncoding = null;
+
+ protected String useRemotingContentType = "false";
public CoyoteInvoker(InvokerLocator locator)
@@ -213,6 +215,17 @@
}
protocolHandlers.add(protocolHandler);
+
+ value = config.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE);
+ if (value != null && value instanceof String)
+ {
+ useRemotingContentType = (String) value;
+ }
+ else
+ {
+ log.warn(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE + " value should be a String: " + value);
+ }
+ log.debug(this + " useRemotingContentType: " + useRemotingContentType);
}
}
@@ -553,6 +566,7 @@
{
// must be POST or PUT
UnMarshaller unmarshaller = getUnMarshaller();
+ request.put(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE, useRemotingContentType);
Object obj = null;
if (unmarshaller instanceof VersionedUnMarshaller)
obj = ((VersionedUnMarshaller)unmarshaller).read(request.getInputStream(), request, version);
15 years, 3 months
JBoss Remoting SVN: r5387 - remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-26 15:37:42 -0400 (Wed, 26 Aug 2009)
New Revision: 5387
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java
Log:
JBREM-1145: Made use of new content type test optional.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java 2009-08-20 14:59:03 UTC (rev 5386)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/marshal/http/HTTPUnMarshaller.java 2009-08-26 19:37:42 UTC (rev 5387)
@@ -26,6 +26,7 @@
import org.jboss.remoting.marshal.UnMarshaller;
import org.jboss.remoting.marshal.serializable.SerializableUnMarshaller;
import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.remoting.transport.web.WebUtil;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -228,11 +229,56 @@
private boolean isBinaryData(Map metadata) throws IOException
{
+ String useRemotingContentType = (String) metadata.get(HTTPMetadataConstants.USE_REMOTING_CONTENT_TYPE);
+ if (Boolean.valueOf(useRemotingContentType).booleanValue())
+ {
+ return isBinaryDataNew(metadata);
+ }
+ else
+ {
+ return isBinaryDataOld(metadata);
+ }
+ }
+
+ private boolean isBinaryDataOld(Map metadata) throws IOException
+ {
+ if (log.isTraceEnabled()) log.trace(this + " using isBinaryDataOld()");
boolean isBinary = false;
if(metadata != null)
{
// need to get the content type
+ Object value = metadata.get("Content-Type");
+ if(value == null)
+ {
+ value = metadata.get("content-type");
+ }
+ if(value != null)
+ {
+ if(value instanceof List)
+ {
+ List valueList = (List) value;
+ if(valueList != null && valueList.size() > 0)
+ {
+ value = valueList.get(0);
+ }
+ }
+ isBinary = WebUtil.isBinary((String) value);
+ }
+ }
+
+ if (log.isTraceEnabled()) log.trace(this + " isBinary: " + isBinary);
+ return isBinary;
+ }
+
+ private boolean isBinaryDataNew(Map metadata) throws IOException
+ {
+ if (log.isTraceEnabled()) log.trace(this + " using isBinaryDataNew()");
+ boolean isBinary = true;
+
+ if(metadata != null)
+ {
+ // need to get the content type
String remotingContentType = null;
Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE);
if (o instanceof List)
@@ -245,11 +291,29 @@
}
else
{
- log.warn(this + " unrecognized remotingContentType: " + o);
+ o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_LC);
+ if (o instanceof List)
+ {
+ remotingContentType = (String) ((List) o).get(0);
+ }
+ else if (o instanceof String)
+ {
+ remotingContentType = (String) o;
+ }
+ else if (o != null)
+ {
+ log.debug(this + " unrecognized remotingContentType: " + o);
+ }
}
-
- isBinary = HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING.equals(remotingContentType);
+
+ if (log.isTraceEnabled()) log.trace(this + " remotingContentType: " + remotingContentType);
+ if (remotingContentType != null)
+ {
+ isBinary = HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING.equals(remotingContentType);
+ }
}
+
+ if (log.isTraceEnabled()) log.trace(this + " isBinary: " + isBinary);
return isBinary;
}
15 years, 3 months
JBoss Remoting SVN: r5386 - in remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl: marshal and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-20 10:59:03 -0400 (Thu, 20 Aug 2009)
New Revision: 5386
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java
Log:
JBREM-1145: New unit tests.
Added: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java 2009-08-20 14:59:03 UTC (rev 5386)
@@ -0,0 +1,69 @@
+/*
+ * 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.http.ssl.marshal;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker;
+import org.jboss.test.remoting.transport.http.marshal.HttpContentTypeTestCase;
+
+/*
+ * Unit tests for JBREM-1145
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Aug 19, 2009
+ * </p>
+ */
+public class HttpsContentTypeTestCase extends HttpContentTypeTestCase
+{
+ private static Logger log = Logger.getLogger(HttpsContentTypeTestCase.class);
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile();
+ log.info("keystore: " + keyStoreFilePath);
+ System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath);
+ System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server");
+ String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
+ log.info("truststore: " + trustStoreFilePath);
+ System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client");
+ }
+ super.setUp();
+ }
+
+ protected String getTransport()
+ {
+ return "https";
+ }
+
+ protected void addExtraClientConfig(Map config)
+ {
+ config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true");
+ }
+}
+
15 years, 3 months
JBoss Remoting SVN: r5385 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-20 10:58:21 -0400 (Thu, 20 Aug 2009)
New Revision: 5385
Added:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java
Removed:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java
Log:
JBREM-1145: Renamed ContentTypeTestCase to HttpContentTypeTestCase.
Deleted: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java 2009-08-20 14:57:27 UTC (rev 5384)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java 2009-08-20 14:58:21 UTC (rev 5385)
@@ -1,292 +0,0 @@
-/*
- * 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.http.marshal;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.marshal.MarshalFactory;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.marshal.http.HTTPMarshaller;
-import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-
-
-/**
- * Unit tests for JBREM-1145.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Aug 17, 2009
- * </p>
- */
-public class ContentTypeTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ContentTypeTestCase.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);
- }
-
- TestMarshaller.marshallers.clear();
- TestUnMarshaller.unmarshallers.clear();
- MarshalFactory.addMarshaller("test", new TestMarshaller(), new TestUnMarshaller());
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testOrdinaryInvocation() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- // Check remoting content type handling.
- assertEquals(6, TestMarshaller.marshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
- assertEquals(4, TestUnMarshaller.unmarshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
-
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testRawStringMessage() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- Map metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- assertEquals("abc", client.invoke("abc", metadata));
- log.info("connection is good");
-
- // Check remoting content type handling.
- assertEquals(6, TestMarshaller.marshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
- assertEquals(4, TestUnMarshaller.unmarshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
-
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- protected String getTransport()
- {
- return "http";
- }
-
-
- 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;
- locatorURI += "/?datatype=test";
- 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();
- 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
- {
- Map responseMap = invocation.getReturnPayload();
- responseMap.put(HTTPMetadataConstants.CONTENTTYPE, "text/html");
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
-
-
- static class TestMarshaller extends HTTPMarshaller
- {
- public static ArrayList marshallers = new ArrayList();
- private static final long serialVersionUID = -7528137229006015488L;
- public String type;
-
- public void write(Object dataObject, OutputStream output, int version) throws IOException
- {
- log.info(this + " writing " + dataObject);
- type = (dataObject instanceof String) ? HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING : HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING;
- super.write(dataObject, output, version);
- }
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- TestMarshaller marshaller = new TestMarshaller();
- marshallers.add(marshaller);
- log.info("returning " + marshaller);
- return marshaller;
- }
- }
-
- static class TestUnMarshaller extends HTTPUnMarshaller
- {
- public static ArrayList unmarshallers = new ArrayList();
- private static final long serialVersionUID = -6422222480047910351L;
- public String type;
-
- public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
- {
- Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE);
- if (o instanceof List)
- {
- type = (String) ((List) o).get(0);
- }
- else if (o instanceof String)
- {
- type = (String) o;
- }
- else
- {
- log.warn(this + " unrecognized remotingContentType: " + o);
- }
-
- o = super.read(inputStream, metadata, version);
- log.info(this + " read " + o);
- return o;
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- TestUnMarshaller unmarshaller = new TestUnMarshaller();
- unmarshallers.add(unmarshaller);
- unmarshaller.setClassLoader(this.customClassLoader);
- log.info("returning " + unmarshaller);
- return unmarshaller;
- }
- }
-}
\ No newline at end of file
Copied: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java (from rev 5360, remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java)
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java (rev 0)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java 2009-08-20 14:58:21 UTC (rev 5385)
@@ -0,0 +1,302 @@
+/*
+ * 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.http.marshal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.http.HTTPMarshaller;
+import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+
+
+/**
+ * Unit tests for JBREM-1145.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Aug 17, 2009
+ * </p>
+ */
+public class HttpContentTypeTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(HttpContentTypeTestCase.class);
+
+ protected 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);
+ }
+
+ TestMarshaller.marshallers.clear();
+ TestUnMarshaller.unmarshallers.clear();
+ MarshalFactory.addMarshaller("test", new TestMarshaller(), new TestUnMarshaller());
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testOrdinaryInvocation() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Check remoting content type handling.
+ validateOrdinaryInvocation();
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testRawStringMessage() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ Map metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ assertEquals("abc", client.invoke("abc", metadata));
+ log.info("connection is good");
+
+ // Check remoting content type handling.
+ validateRawStringMessage();
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void validateOrdinaryInvocation()
+ {
+ assertEquals(6, TestMarshaller.marshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
+ assertEquals(4, TestUnMarshaller.unmarshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
+ }
+
+
+ protected void validateRawStringMessage()
+ {
+ assertEquals(6, TestMarshaller.marshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
+ assertEquals(4, TestUnMarshaller.unmarshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
+ }
+
+
+ protected String getTransport()
+ {
+ return "http";
+ }
+
+
+ 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;
+ locatorURI += "/?datatype=test";
+ 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();
+ 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
+ {
+ Map responseMap = invocation.getReturnPayload();
+ responseMap.put(HTTPMetadataConstants.CONTENTTYPE, "text/html");
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ public static class TestMarshaller extends HTTPMarshaller
+ {
+ public static ArrayList marshallers = new ArrayList();
+ private static final long serialVersionUID = -7528137229006015488L;
+ public String type;
+
+ public void write(Object dataObject, OutputStream output, int version) throws IOException
+ {
+ log.info(this + " writing " + dataObject);
+ type = (dataObject instanceof String) ? HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING : HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING;
+ super.write(dataObject, output, version);
+ }
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ TestMarshaller marshaller = new TestMarshaller();
+ marshallers.add(marshaller);
+ log.info("returning " + marshaller);
+ return marshaller;
+ }
+ }
+
+ public static class TestUnMarshaller extends HTTPUnMarshaller
+ {
+ public static ArrayList unmarshallers = new ArrayList();
+ private static final long serialVersionUID = -6422222480047910351L;
+ public String type;
+
+ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
+ {
+ Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE);
+ if (o instanceof List)
+ {
+ type = (String) ((List) o).get(0);
+ }
+ else if (o instanceof String)
+ {
+ type = (String) o;
+ }
+ else
+ {
+ log.warn(this + " unrecognized remotingContentType: " + o);
+ }
+
+ o = super.read(inputStream, metadata, version);
+ log.info(this + " read " + o);
+ return o;
+ }
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ TestUnMarshaller unmarshaller = new TestUnMarshaller();
+ unmarshallers.add(unmarshaller);
+ unmarshaller.setClassLoader(this.customClassLoader);
+ log.info("returning " + unmarshaller);
+ return unmarshaller;
+ }
+ }
+}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java
___________________________________________________________________
Name: svn:mergeinfo
+
15 years, 3 months
JBoss Remoting SVN: r5384 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/ssl: marshal and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-20 10:57:27 -0400 (Thu, 20 Aug 2009)
New Revision: 5384
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java
Log:
JBREM-1145: New unit tests.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java 2009-08-20 14:57:27 UTC (rev 5384)
@@ -0,0 +1,69 @@
+/*
+ * 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.http.ssl.marshal;
+
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.transport.http.ssl.HTTPSClientInvoker;
+import org.jboss.test.remoting.transport.http.marshal.HttpContentTypeTestCase;
+
+/*
+ * Unit tests for JBREM-1145
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Aug 19, 2009
+ * </p>
+ */
+public class HttpsContentTypeTestCase extends HttpContentTypeTestCase
+{
+ private static Logger log = Logger.getLogger(HttpsContentTypeTestCase.class);
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile();
+ log.info("keystore: " + keyStoreFilePath);
+ System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath);
+ System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server");
+ String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
+ log.info("truststore: " + trustStoreFilePath);
+ System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client");
+ }
+ super.setUp();
+ }
+
+ protected String getTransport()
+ {
+ return "https";
+ }
+
+ protected void addExtraClientConfig(Map config)
+ {
+ config.put(HTTPSClientInvoker.IGNORE_HTTPS_HOST, "true");
+ }
+}
+
15 years, 3 months
JBoss Remoting SVN: r5383 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-20 10:56:44 -0400 (Thu, 20 Aug 2009)
New Revision: 5383
Removed:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java
Log:
JBREM-1145: Renamed ContentTypeTestCase to HttpContentTypeTestCase.
Deleted: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java 2009-08-20 14:56:09 UTC (rev 5382)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java 2009-08-20 14:56:44 UTC (rev 5383)
@@ -1,291 +0,0 @@
-/*
- * 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.http.marshal;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.marshal.MarshalFactory;
-import org.jboss.remoting.marshal.Marshaller;
-import org.jboss.remoting.marshal.UnMarshaller;
-import org.jboss.remoting.marshal.http.HTTPMarshaller;
-import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-
-
-/**
- * Unit tests for JBREM-1145.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Aug 17, 2009
- * </p>
- */
-public class ContentTypeTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ContentTypeTestCase.class);
-
- private static boolean firstTime = true;
-
- protected String host;
- protected int port;
- protected String locatorURI;
- protected InvokerLocator serverLocator;
- protected Connector connector;
- protected TestInvocationHandler invocationHandler;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
-
- TestMarshaller.marshallers.clear();
- TestUnMarshaller.unmarshallers.clear();
- MarshalFactory.addMarshaller("test", new TestMarshaller(), new TestUnMarshaller());
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testOrdinaryInvocation() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- // Check remoting content type handling.
- assertEquals(6, TestMarshaller.marshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
- assertEquals(4, TestUnMarshaller.unmarshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
-
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testRawStringMessage() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- Map metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- assertEquals("abc", client.invoke("abc", metadata));
- log.info("connection is good");
-
- // Check remoting content type handling.
- assertEquals(6, TestMarshaller.marshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
- assertEquals(4, TestUnMarshaller.unmarshallers.size());
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
- assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
-
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- protected String getTransport()
- {
- return "http";
- }
-
-
- 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;
- locatorURI += "/?datatype=test";
- 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();
- 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
- {
- Map responseMap = invocation.getReturnPayload();
- responseMap.put(HTTPMetadataConstants.CONTENTTYPE, "text/html");
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
-
-
- static class TestMarshaller extends HTTPMarshaller
- {
- public static ArrayList marshallers = new ArrayList();
- private static final long serialVersionUID = -7528137229006015488L;
- public String type;
-
- public void write(Object dataObject, OutputStream output, int version) throws IOException
- {
- log.info(this + " writing " + dataObject);
- type = (dataObject instanceof String) ? HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING : HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING;
- super.write(dataObject, output, version);
- }
-
- public Marshaller cloneMarshaller() throws CloneNotSupportedException
- {
- TestMarshaller marshaller = new TestMarshaller();
- marshallers.add(marshaller);
- log.info("returning " + marshaller);
- return marshaller;
- }
- }
-
- static class TestUnMarshaller extends HTTPUnMarshaller
- {
- public static ArrayList unmarshallers = new ArrayList();
- private static final long serialVersionUID = -6422222480047910351L;
- public String type;
-
- public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
- {
- Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE);
- if (o instanceof List)
- {
- type = (String) ((List) o).get(0);
- }
- else if (o instanceof String)
- {
- type = (String) o;
- }
- else
- {
- log.warn(this + " unrecognized remotingContentType: " + o);
- }
-
- o = super.read(inputStream, metadata, version);
- log.info(this + " read " + o);
- return o;
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- TestUnMarshaller unmarshaller = new TestUnMarshaller();
- unmarshallers.add(unmarshaller);
- unmarshaller.setClassLoader(this.customClassLoader);
- log.info("returning " + unmarshaller);
- return unmarshaller;
- }
- }
-}
\ No newline at end of file
15 years, 3 months
JBoss Remoting SVN: r5382 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-20 10:56:09 -0400 (Thu, 20 Aug 2009)
New Revision: 5382
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java
Log:
JBREM-1145: Renamed ContentTypeTestCase to HttpContentTypeTestCase.
Copied: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java (from rev 5361, remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/ContentTypeTestCase.java)
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java 2009-08-20 14:56:09 UTC (rev 5382)
@@ -0,0 +1,301 @@
+/*
+ * 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.http.marshal;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.marshal.MarshalFactory;
+import org.jboss.remoting.marshal.Marshaller;
+import org.jboss.remoting.marshal.UnMarshaller;
+import org.jboss.remoting.marshal.http.HTTPMarshaller;
+import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+
+
+/**
+ * Unit tests for JBREM-1145.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Aug 17, 2009
+ * </p>
+ */
+public class HttpContentTypeTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(HttpContentTypeTestCase.class);
+
+ protected static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(Level.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+
+ TestMarshaller.marshallers.clear();
+ TestUnMarshaller.unmarshallers.clear();
+ MarshalFactory.addMarshaller("test", new TestMarshaller(), new TestUnMarshaller());
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testOrdinaryInvocation() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Check remoting content type handling.
+ validateOrdinaryInvocation();
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testRawStringMessage() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ Map metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ assertEquals("abc", client.invoke("abc", metadata));
+ log.info("connection is good");
+
+ // Check remoting content type handling.
+ validateRawStringMessage();
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void validateOrdinaryInvocation()
+ {
+ assertEquals(6, TestMarshaller.marshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
+ assertEquals(4, TestUnMarshaller.unmarshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
+ }
+
+
+ protected void validateRawStringMessage()
+ {
+ assertEquals(6, TestMarshaller.marshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(3)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestMarshaller)TestMarshaller.marshallers.get(5)).type);
+ assertEquals(4, TestUnMarshaller.unmarshallers.size());
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(1)).type);
+ assertEquals(HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING, ((TestUnMarshaller)TestUnMarshaller.unmarshallers.get(3)).type);
+ }
+
+
+ protected String getTransport()
+ {
+ return "http";
+ }
+
+
+ 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;
+ locatorURI += "/?datatype=test";
+ 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();
+ 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
+ {
+ Map responseMap = invocation.getReturnPayload();
+ responseMap.put(HTTPMetadataConstants.CONTENTTYPE, "text/html");
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ public static class TestMarshaller extends HTTPMarshaller
+ {
+ public static ArrayList marshallers = new ArrayList();
+ private static final long serialVersionUID = -7528137229006015488L;
+ public String type;
+
+ public void write(Object dataObject, OutputStream output, int version) throws IOException
+ {
+ log.info(this + " writing " + dataObject);
+ type = (dataObject instanceof String) ? HTTPMetadataConstants.REMOTING_CONTENT_TYPE_STRING : HTTPMetadataConstants.REMOTING_CONTENT_TYPE_NON_STRING;
+ super.write(dataObject, output, version);
+ }
+
+ public Marshaller cloneMarshaller() throws CloneNotSupportedException
+ {
+ TestMarshaller marshaller = new TestMarshaller();
+ marshallers.add(marshaller);
+ log.info("returning " + marshaller);
+ return marshaller;
+ }
+ }
+
+ public static class TestUnMarshaller extends HTTPUnMarshaller
+ {
+ public static ArrayList unmarshallers = new ArrayList();
+ private static final long serialVersionUID = -6422222480047910351L;
+ public String type;
+
+ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
+ {
+ Object o = metadata.get(HTTPMetadataConstants.REMOTING_CONTENT_TYPE);
+ if (o instanceof List)
+ {
+ type = (String) ((List) o).get(0);
+ }
+ else if (o instanceof String)
+ {
+ type = (String) o;
+ }
+ else
+ {
+ log.warn(this + " unrecognized remotingContentType: " + o);
+ }
+
+ o = super.read(inputStream, metadata, version);
+ log.info(this + " read " + o);
+ return o;
+ }
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ TestUnMarshaller unmarshaller = new TestUnMarshaller();
+ unmarshallers.add(unmarshaller);
+ unmarshaller.setClassLoader(this.customClassLoader);
+ log.info("returning " + unmarshaller);
+ return unmarshaller;
+ }
+ }
+}
\ No newline at end of file
Property changes on: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java
___________________________________________________________________
Name: svn:mergeinfo
+
15 years, 3 months
JBoss Remoting SVN: r5381 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2009-08-19 22:05:04 -0400 (Wed, 19 Aug 2009)
New Revision: 5381
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java
Log:
JBREM-1147: Allow more initial writes for jdk 1.4.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java 2009-08-20 02:04:33 UTC (rev 5380)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java 2009-08-20 02:05:04 UTC (rev 5381)
@@ -88,7 +88,7 @@
public SSLTestServerSocketFactory() throws IOException
{
this.timeout = 5000;
- this.initialWrites = 2;
+ this.initialWrites = INITIAL_WRITES;
setupFactory();
}
public SSLTestServerSocketFactory(int timeout, int initialWrites) throws IOException
@@ -99,7 +99,7 @@
}
public ServerSocket createServerSocket() throws IOException
{
- ServerSocket ss = new SSLTestServerSocket(timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket()));
+ ServerSocket ss = SSLServerSocketFactory.getDefault().createServerSocket();
log.info("returning: " + ss);
return ss;
}
15 years, 3 months