JBoss Remoting SVN: r6020 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:34:49 -0400 (Wed, 04 Aug 2010)
New Revision: 6020
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure/RMICallbackConnectionFailureTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure/RMICallbackConnectionFailureTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure/RMICallbackConnectionFailureTestCase.java 2010-08-05 01:33:42 UTC (rev 6019)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure/RMICallbackConnectionFailureTestCase.java 2010-08-05 01:34:49 UTC (rev 6020)
@@ -1,45 +1,45 @@
-
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.rmi.connectionfailure;
-
-import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent;
-
-/**
- * Unit test for JBREM-873.
- *
- * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Dec 10, 2007
- * </p>
- */
-public class RMICallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent
-{
- protected String getTransport()
- {
- return "rmi";
- }
-}
-
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.rmi.connectionfailure;
+
+import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent;
+
+/**
+ * Unit test for JBREM-873.
+ *
+ * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Dec 10, 2007
+ * </p>
+ */
+public class RMICallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent
+{
+ protected String getTransport()
+ {
+ return "rmi";
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/rmi/connectionfailure/RMICallbackConnectionFailureTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6019 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:33:42 -0400 (Wed, 04 Aug 2010)
New Revision: 6019
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java 2010-08-05 01:33:13 UTC (rev 6018)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java 2010-08-05 01:33:42 UTC (rev 6019)
@@ -1,44 +1,44 @@
-
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.socketfactory;
-
-import org.jboss.test.remoting.socketfactory.SSLSocketFactoryClassNameTestRoot;
-
-
-/**
- * Unit test for JBREM-1014.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jul 18, 2008
- * </p>
- */
-public class SSLSocketFactoryClassNameTestCase extends SSLSocketFactoryClassNameTestRoot
-{
- protected String getTransport()
- {
- return "https";
- }
-}
-
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.socketfactory;
+
+import org.jboss.test.remoting.socketfactory.SSLSocketFactoryClassNameTestRoot;
+
+
+/**
+ * Unit test for JBREM-1014.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jul 18, 2008
+ * </p>
+ */
+public class SSLSocketFactoryClassNameTestCase extends SSLSocketFactoryClassNameTestRoot
+{
+ protected String getTransport()
+ {
+ return "https";
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6018 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:33:13 -0400 (Wed, 04 Aug 2010)
New Revision: 6018
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: 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 2010-08-05 01:32:41 UTC (rev 6017)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java 2010-08-05 01:33:13 UTC (rev 6018)
@@ -1,69 +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");
- }
-}
-
+/*
+ * 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");
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/ssl/marshal/HttpsContentTypeTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6017 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:32:41 -0400 (Wed, 04 Aug 2010)
New Revision: 6017
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/socketfactory/SocketFactoryClassNameTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/socketfactory/SocketFactoryClassNameTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/socketfactory/SocketFactoryClassNameTestCase.java 2010-08-05 01:32:09 UTC (rev 6016)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/socketfactory/SocketFactoryClassNameTestCase.java 2010-08-05 01:32:41 UTC (rev 6017)
@@ -1,22 +1,22 @@
-package org.jboss.test.remoting.transport.http.socketfactory;
-
-import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot;
-
-
-/**
- *
- * Unit test for JBREM-1014.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jul 18, 2008
- * </p>
- */
-public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot
-{
- protected String getTransport()
- {
- return "http";
- }
+package org.jboss.test.remoting.transport.http.socketfactory;
+
+import org.jboss.test.remoting.socketfactory.SocketFactoryClassNameTestRoot;
+
+
+/**
+ *
+ * Unit test for JBREM-1014.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jul 18, 2008
+ * </p>
+ */
+public class SocketFactoryClassNameTestCase extends SocketFactoryClassNameTestRoot
+{
+ protected String getTransport()
+ {
+ return "http";
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/socketfactory/SocketFactoryClassNameTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6016 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/query.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:32:09 -0400 (Wed, 04 Aug 2010)
New Revision: 6016
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/query/URLQueryTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/query/URLQueryTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/query/URLQueryTestCase.java 2010-08-05 01:31:42 UTC (rev 6015)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/query/URLQueryTestCase.java 2010-08-05 01:32:09 UTC (rev 6016)
@@ -1,166 +1,166 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.query;
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-
-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.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-
-import junit.framework.TestCase;
-
-/**
- * Unit test for JBREM-1027.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Aug 28, 2008
- * </p>
- */
-public class URLQueryTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(URLQueryTestCase.class);
-
- private static boolean firstTime = true;
- protected static final String QUERY = "a=y&b=z";
-
- protected String host;
- protected int port;
- protected String locatorURI;
- protected InvokerLocator serverLocator;
- protected Connector connector;
- protected TestInvocationHandler invocationHandler;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testQueryInRequestMap() 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.
- Object response = client.invoke("abc");
- log.info("response: " + response);
- assertEquals(QUERY, response);
-
- 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 + "/?" + QUERY;
- 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 requestMap = invocation.getRequestPayload();
- log.info("query: " + requestMap.get(HTTPMetadataConstants.QUERY));
- return requestMap.get(HTTPMetadataConstants.QUERY);
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.query;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+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.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+
+import junit.framework.TestCase;
+
+/**
+ * Unit test for JBREM-1027.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Aug 28, 2008
+ * </p>
+ */
+public class URLQueryTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(URLQueryTestCase.class);
+
+ private static boolean firstTime = true;
+ protected static final String QUERY = "a=y&b=z";
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testQueryInRequestMap() 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.
+ Object response = client.invoke("abc");
+ log.info("response: " + response);
+ assertEquals(QUERY, response);
+
+ 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 + "/?" + QUERY;
+ 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 requestMap = invocation.getRequestPayload();
+ log.info("query: " + requestMap.get(HTTPMetadataConstants.QUERY));
+ return requestMap.get(HTTPMetadataConstants.QUERY);
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/query/URLQueryTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6015 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/proxy.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:31:42 -0400 (Wed, 04 Aug 2010)
New Revision: 6015
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java 2010-08-05 01:31:17 UTC (rev 6014)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java 2010-08-05 01:31:42 UTC (rev 6015)
@@ -1,295 +1,295 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.proxy;
-
-import java.io.DataOutputStream;
-import java.io.EOFException;
-import java.io.InputStreamReader;
-import java.net.InetAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.util.Base64;
-
-
-/**
- * Unit test for JBREM-1050.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Oct 29, 2008
- * </p>
- */
-public class ProxyAuthenticationTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ProxyAuthenticationTestCase.class);
-
- private static boolean firstTime = true;
- private static String syspropAuth = "Basic " + Base64.encodeBytes("sysprop:abc".getBytes());
- private static String metadataAuth = "Basic " + Base64.encodeBytes("metadata:xyz".getBytes());
-
- protected TestHttpServer server;
-
-
- 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);
- };
- }
-
-
- /**
- * Tests behavior with proxy and authorization information stored in system properties.
- */
- public void testProxySyspropAuthSysprop() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Set system properties.
- System.setProperty("http.proxyHost", server.host);
- System.setProperty("http.proxyPort", Integer.toString(server.port));
- System.setProperty("proxySet", "true");
- System.setProperty("http.proxy.username", "sysprop");
- System.setProperty("http.proxy.password", "abc");
-
- // Create invocation metadata map.
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
-
- // Run test.
- doTest(metadata, syspropAuth);
- log.info(getName() + " PASSES");
- }
-
-
- /**
- * Tests behavior with proxy information stored in system properties
- * and authorization information stored in system properties and in overriding
- * invocation metadata map..
- */
- public void testProxySyspropAuthMeta() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Set system properties.
- System.setProperty("http.proxyHost", server.host);
- System.setProperty("http.proxyPort", Integer.toString(server.port));
- System.setProperty("proxySet", "true");
- System.setProperty("http.proxy.username", "sysprop");
- System.setProperty("http.proxy.password", "abc");
-
- // Create invocation metadata map.
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("http.proxy.username", "metadata");
- metadata.put("http.proxy.password", "xyz");
-
- // Run test.
- doTest(metadata, metadataAuth);
- log.info(getName() + " PASSES");
- }
-
-
- /**
- * Tests behavior with proxy information stored in invocation metadata map
- * and authorization information stored in system properties.
- */
- public void testProxyMetaAuthSysprop() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Set system properties.
- System.setProperty("http.proxy.username", "sysprop");
- System.setProperty("http.proxy.password", "abc");
-
- // Create invocation metadata map.
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("http.proxyHost", server.host);
- metadata.put("http.proxyPort", Integer.toString(server.port));
-
- // Run test.
- doTest(metadata, syspropAuth);
- log.info(getName() + " PASSES");
- }
-
-
- /**
- * Tests behavior with proxy information stored in invocation metadata map
- * and authorization information stored in system properties and overriding
- * invocation metadata map.
- */
- public void testProxyMetaAuthMeta() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Set system properties.
- System.setProperty("http.proxy.username", "sysprop");
- System.setProperty("http.proxy.password", "abc");
-
- // Create invocation metadata map.
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("http.proxyHost", server.host);
- metadata.put("http.proxyPort", Integer.toString(server.port));
- metadata.put("http.proxy.username", "metadata");
- metadata.put("http.proxy.password", "xyz");
-
- // Run test.
- doTest(metadata, metadataAuth);
- log.info(getName() + " PASSES");
- }
-
-
- protected void setupServer() throws Exception
- {
- server = new TestHttpServer();
- server.start();
- synchronized (TestHttpServer.class)
- {
- TestHttpServer.class.wait();
- }
- log.info("started server");
- }
-
-
- protected void doTest(Map metadata, String auth) throws Throwable
- {
- // Create client.
- String locatorURI = "http://" + server.host + ":" + server.port;
- log.info("connecting to " + locatorURI);
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- Client client = new Client(clientLocator, config);
- client.connect();
- log.info("client is connected");
- client.invoke("abc", metadata);
-
- // Verify correct authorization was sent.
- assertEquals(auth, server.auth);
- client.disconnect();
- }
-
-
- static class TestHttpServer extends Thread
- {
- public String host;
- public int port;
- public String auth;
-
- public void run()
- {
- try
- {
- log.info("starting HTTP server");
- InetAddress localHost = InetAddress.getLocalHost();
- final ServerSocket ss = new ServerSocket(0, 100, localHost);
- host = localHost.getHostAddress();
- port = ss.getLocalPort();
- synchronized (TestHttpServer.class)
- {
- TestHttpServer.class.notify();
- }
- Socket s = ss.accept();
-
- InputStreamReader ir = new InputStreamReader(s.getInputStream());
- char[] cbuf = new char[1024];
- int len = ir.read(cbuf);
- String request = String.copyValueOf(cbuf, 0, len);
- log.info("Request:");
- System.out.println();
- System.out.println(request);
- System.out.println();
- auth = getAuth(request);
-
- DataOutputStream dos = new DataOutputStream(s.getOutputStream());
- dos.writeBytes("HTTP/1.1 200 OK" + "\r\n");
- dos.writeBytes("Server: testServer");
- dos.writeBytes("Content-Type: text/html" + "\r\n");
- dos.writeBytes("Content-Length: 0\r\n");
- dos.writeBytes("Connection: close\r\n");
- dos.writeBytes("\r\n");
-
- ir.close();
- dos.close();
- s.close();
- ss.close();
- }
- catch (EOFException e1)
- {
- log.info("end of file");
- }
- catch (Exception e2)
- {
- log.error("error", e2);
- }
- }
-
- private String getAuth(String request)
- {
- String auth = null;
- String[] tokens = request.split("[\r\n]+");
- for (int i = 0; i < tokens.length; i++)
- {
- if (tokens[i].startsWith("Proxy-Authorization"))
- {
- auth = tokens[i].split(":[ ]*")[1];
- break;
- }
- }
- return auth;
- }
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.proxy;
+
+import java.io.DataOutputStream;
+import java.io.EOFException;
+import java.io.InputStreamReader;
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.util.Base64;
+
+
+/**
+ * Unit test for JBREM-1050.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Oct 29, 2008
+ * </p>
+ */
+public class ProxyAuthenticationTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(ProxyAuthenticationTestCase.class);
+
+ private static boolean firstTime = true;
+ private static String syspropAuth = "Basic " + Base64.encodeBytes("sysprop:abc".getBytes());
+ private static String metadataAuth = "Basic " + Base64.encodeBytes("metadata:xyz".getBytes());
+
+ protected TestHttpServer server;
+
+
+ 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);
+ };
+ }
+
+
+ /**
+ * Tests behavior with proxy and authorization information stored in system properties.
+ */
+ public void testProxySyspropAuthSysprop() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Set system properties.
+ System.setProperty("http.proxyHost", server.host);
+ System.setProperty("http.proxyPort", Integer.toString(server.port));
+ System.setProperty("proxySet", "true");
+ System.setProperty("http.proxy.username", "sysprop");
+ System.setProperty("http.proxy.password", "abc");
+
+ // Create invocation metadata map.
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+
+ // Run test.
+ doTest(metadata, syspropAuth);
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Tests behavior with proxy information stored in system properties
+ * and authorization information stored in system properties and in overriding
+ * invocation metadata map..
+ */
+ public void testProxySyspropAuthMeta() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Set system properties.
+ System.setProperty("http.proxyHost", server.host);
+ System.setProperty("http.proxyPort", Integer.toString(server.port));
+ System.setProperty("proxySet", "true");
+ System.setProperty("http.proxy.username", "sysprop");
+ System.setProperty("http.proxy.password", "abc");
+
+ // Create invocation metadata map.
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("http.proxy.username", "metadata");
+ metadata.put("http.proxy.password", "xyz");
+
+ // Run test.
+ doTest(metadata, metadataAuth);
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Tests behavior with proxy information stored in invocation metadata map
+ * and authorization information stored in system properties.
+ */
+ public void testProxyMetaAuthSysprop() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Set system properties.
+ System.setProperty("http.proxy.username", "sysprop");
+ System.setProperty("http.proxy.password", "abc");
+
+ // Create invocation metadata map.
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("http.proxyHost", server.host);
+ metadata.put("http.proxyPort", Integer.toString(server.port));
+
+ // Run test.
+ doTest(metadata, syspropAuth);
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Tests behavior with proxy information stored in invocation metadata map
+ * and authorization information stored in system properties and overriding
+ * invocation metadata map.
+ */
+ public void testProxyMetaAuthMeta() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Set system properties.
+ System.setProperty("http.proxy.username", "sysprop");
+ System.setProperty("http.proxy.password", "abc");
+
+ // Create invocation metadata map.
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("http.proxyHost", server.host);
+ metadata.put("http.proxyPort", Integer.toString(server.port));
+ metadata.put("http.proxy.username", "metadata");
+ metadata.put("http.proxy.password", "xyz");
+
+ // Run test.
+ doTest(metadata, metadataAuth);
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void setupServer() throws Exception
+ {
+ server = new TestHttpServer();
+ server.start();
+ synchronized (TestHttpServer.class)
+ {
+ TestHttpServer.class.wait();
+ }
+ log.info("started server");
+ }
+
+
+ protected void doTest(Map metadata, String auth) throws Throwable
+ {
+ // Create client.
+ String locatorURI = "http://" + server.host + ":" + server.port;
+ log.info("connecting to " + locatorURI);
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ Client client = new Client(clientLocator, config);
+ client.connect();
+ log.info("client is connected");
+ client.invoke("abc", metadata);
+
+ // Verify correct authorization was sent.
+ assertEquals(auth, server.auth);
+ client.disconnect();
+ }
+
+
+ static class TestHttpServer extends Thread
+ {
+ public String host;
+ public int port;
+ public String auth;
+
+ public void run()
+ {
+ try
+ {
+ log.info("starting HTTP server");
+ InetAddress localHost = InetAddress.getLocalHost();
+ final ServerSocket ss = new ServerSocket(0, 100, localHost);
+ host = localHost.getHostAddress();
+ port = ss.getLocalPort();
+ synchronized (TestHttpServer.class)
+ {
+ TestHttpServer.class.notify();
+ }
+ Socket s = ss.accept();
+
+ InputStreamReader ir = new InputStreamReader(s.getInputStream());
+ char[] cbuf = new char[1024];
+ int len = ir.read(cbuf);
+ String request = String.copyValueOf(cbuf, 0, len);
+ log.info("Request:");
+ System.out.println();
+ System.out.println(request);
+ System.out.println();
+ auth = getAuth(request);
+
+ DataOutputStream dos = new DataOutputStream(s.getOutputStream());
+ dos.writeBytes("HTTP/1.1 200 OK" + "\r\n");
+ dos.writeBytes("Server: testServer");
+ dos.writeBytes("Content-Type: text/html" + "\r\n");
+ dos.writeBytes("Content-Length: 0\r\n");
+ dos.writeBytes("Connection: close\r\n");
+ dos.writeBytes("\r\n");
+
+ ir.close();
+ dos.close();
+ s.close();
+ ss.close();
+ }
+ catch (EOFException e1)
+ {
+ log.info("end of file");
+ }
+ catch (Exception e2)
+ {
+ log.error("error", e2);
+ }
+ }
+
+ private String getAuth(String request)
+ {
+ String auth = null;
+ String[] tokens = request.split("[\r\n]+");
+ for (int i = 0; i < tokens.length; i++)
+ {
+ if (tokens[i].startsWith("Proxy-Authorization"))
+ {
+ auth = tokens[i].split(":[ ]*")[1];
+ break;
+ }
+ }
+ return auth;
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/proxy/ProxyAuthenticationTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6014 - 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: 2010-08-04 21:31:17 -0400 (Wed, 04 Aug 2010)
New Revision: 6014
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java 2010-08-05 01:30:48 UTC (rev 6013)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/marshal/HttpContentTypeTestCase.java 2010-08-05 01:31:17 UTC (rev 6014)
@@ -1,429 +1,429 @@
-/*
- * 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 testOrdinaryInvocationDefault() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(false, false);
-
- // Create client.
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- log.info("connecting to: " + serverLocator);
- Client client = new Client(serverLocator, clientConfig);
- client.connect();
- log.info("client is connected to " + serverLocator);
-
- // Do invocation.
- Object o = client.invoke("abc");
-
- // Show that an InvocationResponse was incorrectly returned as a Strin..
- assertTrue(o instanceof String);
- String result = (String) o;
- assertTrue(result.indexOf("org.jboss.remoting.InvocationResponse") >= 0);
-
- // Check remoting content type handling.
- validateOrdinaryInvocation(client);
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testOrdinaryInvocationRemotingContentTypeFalse() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, false);
-
- // Create client.
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(serverLocator, clientConfig);
- client.connect();
- log.info("client is connected to " + serverLocator);
-
- // Do invocation.
- Object o = client.invoke("abc");
-
- // Show that an InvocationResponse was incorrectly returned as a String.
- assertTrue(o instanceof String);
- String result = (String) o;
- assertTrue(result.indexOf("org.jboss.remoting.InvocationResponse") >= 0);
-
- // Check remoting content type handling.
- validateOrdinaryInvocation(client);
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testOrdinaryInvocationRemotingContentTypeTrue() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, true);
-
- // Create client.
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(serverLocator, clientConfig);
- client.connect();
- log.info("client is connected to " + serverLocator);
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- // Check remoting content type handling.
- validateOrdinaryInvocation(client);
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testRawStringMessageDefault() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(false, false);
-
- // Create client.
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(serverLocator, clientConfig);
- client.connect();
- log.info("client is connected to " + serverLocator);
-
- // 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);
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testRawStringMessageRemotingContentTypeFalse() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, false);
-
- // Create client.
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(serverLocator, clientConfig);
- client.connect();
- log.info("client is connected to " + serverLocator);
-
- // 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);
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testRawStringMessageRemotingContentTypeTrue() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, true);
-
- // Create client.
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(serverLocator, clientConfig);
- client.connect();
- log.info("client is connected to " + serverLocator);
-
- // 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);
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- protected void validateOrdinaryInvocation(Client client) throws Throwable
- {
- 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(Client client) throws Throwable
- {
- 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(boolean addUseRemotingContentType, boolean useRemotingContentType) 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;
- }
- if (addUseRemotingContentType)
- {
- locatorURI += "&useRemotingContentType=" + useRemotingContentType;
- }
- 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;
- }
- }
+/*
+ * 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 testOrdinaryInvocationDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, false);
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ log.info("connecting to: " + serverLocator);
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to " + serverLocator);
+
+ // Do invocation.
+ Object o = client.invoke("abc");
+
+ // Show that an InvocationResponse was incorrectly returned as a Strin..
+ assertTrue(o instanceof String);
+ String result = (String) o;
+ assertTrue(result.indexOf("org.jboss.remoting.InvocationResponse") >= 0);
+
+ // Check remoting content type handling.
+ validateOrdinaryInvocation(client);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testOrdinaryInvocationRemotingContentTypeFalse() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, false);
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to " + serverLocator);
+
+ // Do invocation.
+ Object o = client.invoke("abc");
+
+ // Show that an InvocationResponse was incorrectly returned as a String.
+ assertTrue(o instanceof String);
+ String result = (String) o;
+ assertTrue(result.indexOf("org.jboss.remoting.InvocationResponse") >= 0);
+
+ // Check remoting content type handling.
+ validateOrdinaryInvocation(client);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testOrdinaryInvocationRemotingContentTypeTrue() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, true);
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to " + serverLocator);
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Check remoting content type handling.
+ validateOrdinaryInvocation(client);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testRawStringMessageDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, false);
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to " + serverLocator);
+
+ // 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);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testRawStringMessageRemotingContentTypeFalse() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, false);
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to " + serverLocator);
+
+ // 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);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testRawStringMessageRemotingContentTypeTrue() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, true);
+
+ // Create client.
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(serverLocator, clientConfig);
+ client.connect();
+ log.info("client is connected to " + serverLocator);
+
+ // 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);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void validateOrdinaryInvocation(Client client) throws Throwable
+ {
+ 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(Client client) throws Throwable
+ {
+ 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(boolean addUseRemotingContentType, boolean useRemotingContentType) 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;
+ }
+ if (addUseRemotingContentType)
+ {
+ locatorURI += "&useRemotingContentType=" + useRemotingContentType;
+ }
+ 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:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6013 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/lines.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:30:48 -0400 (Wed, 04 Aug 2010)
New Revision: 6013
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/lines/HttpLinePreservationTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/lines/HttpLinePreservationTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/lines/HttpLinePreservationTestCase.java 2010-08-05 01:30:19 UTC (rev 6012)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/lines/HttpLinePreservationTestCase.java 2010-08-05 01:30:48 UTC (rev 6013)
@@ -1,411 +1,411 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.lines;
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-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.http.HTTPUnMarshaller;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-import org.jboss.remoting.transport.web.WebUtil;
-
-
-/**
- *
- * Unit tests for JBREM-809.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Feb 8, 2008
- * </p>
- */
-public class HttpLinePreservationTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(HttpLinePreservationTestCase.class);
-
- private static boolean firstTime = true;
-
- protected String host;
- protected int port;
- protected String locatorURI;
- protected InvokerLocator serverLocator;
- protected Connector connector;
- protected TestInvocationHandler invocationHandler;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testLinePreservationClientConfig() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, "true");
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- Properties headerProps = new Properties();
- headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
- HashMap metadata = new HashMap();
- metadata.put("HEADER", headerProps);
- metadata.put(Client.RAW, "true");
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789").append("\r\n");
- String message = sb.toString();
- assertEquals(message, client.invoke(message, metadata));
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testLinePreservationClientMetadata() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, "true");
-
- // 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");
-
- Properties headerProps = new Properties();
- headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
- HashMap metadata = new HashMap();
- metadata.put("HEADER", headerProps);
- metadata.put(Client.RAW, "true");
- metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "true");
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789");
- String message = sb.toString();
- assertEquals(message, client.invoke(message, metadata));
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testNoLinePreservationClientConfigServerConfig() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, "false");
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- Properties headerProps = new Properties();
- headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
- HashMap metadata = new HashMap();
- metadata.put("HEADER", headerProps);
- metadata.put(Client.RAW, "true");
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789").append("\r\n");
- String sent = sb.toString();
- sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789");
- String received = sb.toString();
- assertEquals(received, client.invoke(sent, metadata));
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testNoLinePreservationClientMetadataServerConfig() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(true, "false");
-
- // 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");
-
- Properties headerProps = new Properties();
- headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
- HashMap metadata = new HashMap();
- metadata.put("HEADER", headerProps);
- metadata.put(Client.RAW, "true");
- metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789").append("\r\n");
- String sent = sb.toString();
- sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789");
- String received = sb.toString();
- assertEquals(received, client.invoke(sent, metadata));
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testNoLinePreservationClientConfigServerDefault() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(false, null);
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- Properties headerProps = new Properties();
- headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
- HashMap metadata = new HashMap();
- metadata.put("HEADER", headerProps);
- metadata.put(Client.RAW, "true");
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789").append("\r\n");
- String sent = sb.toString();
- sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789");
- String received = sb.toString();
- assertEquals(received, client.invoke(sent, metadata));
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testNoLinePreservationClientMetadataServerDefault() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(false, null);
-
- // 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");
-
- Properties headerProps = new Properties();
- headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
- HashMap metadata = new HashMap();
- metadata.put("HEADER", headerProps);
- metadata.put(Client.RAW, "true");
- metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789").append("\r\n");
- String sent = sb.toString();
- sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789");
- String received = sb.toString();
- assertEquals(received, client.invoke(sent, metadata));
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testNoLinePreservationClientServerDefault() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer(false, null);
-
- // 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");
-
- Properties headerProps = new Properties();
- headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
- HashMap metadata = new HashMap();
- metadata.put("HEADER", headerProps);
- metadata.put(Client.RAW, "true");
-
- StringBuffer sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789").append("\r\n");
- String sent = sb.toString();
- sb = new StringBuffer();
- for (int i = 0; i < 1000; i++)
- sb.append("0123456789");
- String received = sb.toString();
- assertEquals(received, client.invoke(sent, metadata));
-
- 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(boolean addConfig, String preserveLines) throws Exception
- {
- host = InetAddress.getLocalHost().getHostAddress();
- port = PortUtil.findFreePort(host);
- locatorURI = getTransport() + "://" + host + ":" + port;
- serverLocator = new InvokerLocator(locatorURI);
- log.info("Starting remoting server with locator uri of: " + locatorURI);
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
-
- if (addConfig)
- {
- config.put(HTTPUnMarshaller.PRESERVE_LINES, preserveLines);
- }
-
- addExtraServerConfig(config);
- connector = new Connector(serverLocator, config);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("test", invocationHandler);
- connector.start();
- }
-
-
- protected void shutdownServer() throws Exception
- {
- if (connector != null)
- connector.stop();
- }
-
-
- static class TestInvocationHandler implements ServerInvocationHandler
- {
- public void addListener(InvokerCallbackHandler callbackHandler) {}
- public Object invoke(final InvocationRequest invocation) throws Throwable
- {
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.lines;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+
+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.http.HTTPUnMarshaller;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+import org.jboss.remoting.transport.web.WebUtil;
+
+
+/**
+ *
+ * Unit tests for JBREM-809.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 8, 2008
+ * </p>
+ */
+public class HttpLinePreservationTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(HttpLinePreservationTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testLinePreservationClientConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, "true");
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ Properties headerProps = new Properties();
+ headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
+ HashMap metadata = new HashMap();
+ metadata.put("HEADER", headerProps);
+ metadata.put(Client.RAW, "true");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789").append("\r\n");
+ String message = sb.toString();
+ assertEquals(message, client.invoke(message, metadata));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testLinePreservationClientMetadata() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, "true");
+
+ // 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");
+
+ Properties headerProps = new Properties();
+ headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
+ HashMap metadata = new HashMap();
+ metadata.put("HEADER", headerProps);
+ metadata.put(Client.RAW, "true");
+ metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "true");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789");
+ String message = sb.toString();
+ assertEquals(message, client.invoke(message, metadata));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNoLinePreservationClientConfigServerConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, "false");
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ Properties headerProps = new Properties();
+ headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
+ HashMap metadata = new HashMap();
+ metadata.put("HEADER", headerProps);
+ metadata.put(Client.RAW, "true");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789").append("\r\n");
+ String sent = sb.toString();
+ sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789");
+ String received = sb.toString();
+ assertEquals(received, client.invoke(sent, metadata));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNoLinePreservationClientMetadataServerConfig() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true, "false");
+
+ // 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");
+
+ Properties headerProps = new Properties();
+ headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
+ HashMap metadata = new HashMap();
+ metadata.put("HEADER", headerProps);
+ metadata.put(Client.RAW, "true");
+ metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789").append("\r\n");
+ String sent = sb.toString();
+ sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789");
+ String received = sb.toString();
+ assertEquals(received, client.invoke(sent, metadata));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNoLinePreservationClientConfigServerDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, null);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ clientConfig.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ Properties headerProps = new Properties();
+ headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
+ HashMap metadata = new HashMap();
+ metadata.put("HEADER", headerProps);
+ metadata.put(Client.RAW, "true");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789").append("\r\n");
+ String sent = sb.toString();
+ sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789");
+ String received = sb.toString();
+ assertEquals(received, client.invoke(sent, metadata));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNoLinePreservationClientMetadataServerDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, null);
+
+ // 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");
+
+ Properties headerProps = new Properties();
+ headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
+ HashMap metadata = new HashMap();
+ metadata.put("HEADER", headerProps);
+ metadata.put(Client.RAW, "true");
+ metadata.put(HTTPUnMarshaller.PRESERVE_LINES, "false");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789").append("\r\n");
+ String sent = sb.toString();
+ sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789");
+ String received = sb.toString();
+ assertEquals(received, client.invoke(sent, metadata));
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNoLinePreservationClientServerDefault() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false, null);
+
+ // 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");
+
+ Properties headerProps = new Properties();
+ headerProps.put(HTTPMetadataConstants.CONTENTTYPE, WebUtil.PLAIN);
+ HashMap metadata = new HashMap();
+ metadata.put("HEADER", headerProps);
+ metadata.put(Client.RAW, "true");
+
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789").append("\r\n");
+ String sent = sb.toString();
+ sb = new StringBuffer();
+ for (int i = 0; i < 1000; i++)
+ sb.append("0123456789");
+ String received = sb.toString();
+ assertEquals(received, client.invoke(sent, metadata));
+
+ 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(boolean addConfig, String preserveLines) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+
+ if (addConfig)
+ {
+ config.put(HTTPUnMarshaller.PRESERVE_LINES, preserveLines);
+ }
+
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/lines/HttpLinePreservationTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6012 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/headers.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:30:19 -0400 (Wed, 04 Aug 2010)
New Revision: 6012
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/headers/ResponseCodeTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/headers/ResponseCodeTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/headers/ResponseCodeTestCase.java 2010-08-05 01:29:40 UTC (rev 6011)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/headers/ResponseCodeTestCase.java 2010-08-05 01:30:19 UTC (rev 6012)
@@ -1,214 +1,214 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.headers;
-
-import java.net.InetAddress;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.Callback;
-import org.jboss.remoting.callback.HandleCallbackException;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.transport.http.HTTPMetadataConstants;
-
-/**
- * Unit test for JBREM-728.
- *
- * @author <a href="mailto:ron.sigal@jboss.com">Ron Sigal</a>
- * <p>
- * Copyright (c) November 24, 2007
- * </p>
- *
- */
-public class ResponseCodeTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ResponseCodeTestCase.class);
-
- private static boolean firstTime = true;
-
- protected static String RESPONSE_KEY = "responseKey";
- protected static String RESPONSE_VALUE = "responseValue";
- protected static String RETURN_RESPONSE_HEADER = "returnResponseHeader";
-
- 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.TRACE);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testResponseHeaders() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Create client.
- InvokerLocator clientLocator1 = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator1, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- HashMap metadata = new HashMap();
- assertEquals(RETURN_RESPONSE_HEADER, client.invoke(RETURN_RESPONSE_HEADER, metadata));
- log.info("connection is good");
- log.info("metadata: " + metadata);
- log.info("metadata type: " + metadata.getClass());
-
- // Verify that all entries in the HTTPMetadataConstants.RESPONSE_HEADERS value
- // also appear in metadata map.
- Object o = metadata.remove(HTTPMetadataConstants.RESPONSE_HEADERS);
- assertTrue(o instanceof Map);
- Map responseHeaders = (Map) o;
- Set responseHeadersEntries = responseHeaders.entrySet();
- Set metadataEntries = metadata.entrySet();
-
- Iterator it = responseHeadersEntries.iterator();
- while (it.hasNext())
- {
- Map.Entry entry = (Map.Entry) it.next();
- log.info("entry: " + entry);
- if (entry.getKey() == null)
- continue;
- assertTrue("metadata does not contain entry " + entry, metadataEntries.contains(entry));
- }
-
- // Verify response map entry generated in invocation handler
- // was added as a response header.
- assertTrue(responseHeaders.keySet().contains(RESPONSE_KEY));
- assertTrue(responseHeaders.get(RESPONSE_KEY) instanceof Collection);
- List responses = (List) responseHeaders.get(RESPONSE_KEY);
- assertTrue(responses.size() == 1);
- assertEquals(RESPONSE_VALUE, responses.get(0));
-
- 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;
- 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
- {
- if (RETURN_RESPONSE_HEADER.equals(invocation.getParameter()))
- invocation.getReturnPayload().put(RESPONSE_KEY, RESPONSE_VALUE);
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
-
-
- static class TestCallbackHandler implements InvokerCallbackHandler
- {
- public void handleCallback(Callback callback) throws HandleCallbackException
- {
- log.info("received callback");
- }
- }
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.headers;
+
+import java.net.InetAddress;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.http.HTTPMetadataConstants;
+
+/**
+ * Unit test for JBREM-728.
+ *
+ * @author <a href="mailto:ron.sigal@jboss.com">Ron Sigal</a>
+ * <p>
+ * Copyright (c) November 24, 2007
+ * </p>
+ *
+ */
+public class ResponseCodeTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(ResponseCodeTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected static String RESPONSE_KEY = "responseKey";
+ protected static String RESPONSE_VALUE = "responseValue";
+ protected static String RETURN_RESPONSE_HEADER = "returnResponseHeader";
+
+ 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.TRACE);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testResponseHeaders() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator1 = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator1, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ HashMap metadata = new HashMap();
+ assertEquals(RETURN_RESPONSE_HEADER, client.invoke(RETURN_RESPONSE_HEADER, metadata));
+ log.info("connection is good");
+ log.info("metadata: " + metadata);
+ log.info("metadata type: " + metadata.getClass());
+
+ // Verify that all entries in the HTTPMetadataConstants.RESPONSE_HEADERS value
+ // also appear in metadata map.
+ Object o = metadata.remove(HTTPMetadataConstants.RESPONSE_HEADERS);
+ assertTrue(o instanceof Map);
+ Map responseHeaders = (Map) o;
+ Set responseHeadersEntries = responseHeaders.entrySet();
+ Set metadataEntries = metadata.entrySet();
+
+ Iterator it = responseHeadersEntries.iterator();
+ while (it.hasNext())
+ {
+ Map.Entry entry = (Map.Entry) it.next();
+ log.info("entry: " + entry);
+ if (entry.getKey() == null)
+ continue;
+ assertTrue("metadata does not contain entry " + entry, metadataEntries.contains(entry));
+ }
+
+ // Verify response map entry generated in invocation handler
+ // was added as a response header.
+ assertTrue(responseHeaders.keySet().contains(RESPONSE_KEY));
+ assertTrue(responseHeaders.get(RESPONSE_KEY) instanceof Collection);
+ List responses = (List) responseHeaders.get(RESPONSE_KEY);
+ assertTrue(responses.size() == 1);
+ assertEquals(RESPONSE_VALUE, responses.get(0));
+
+ 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;
+ 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
+ {
+ if (RETURN_RESPONSE_HEADER.equals(invocation.getParameter()))
+ invocation.getReturnPayload().put(RESPONSE_KEY, RESPONSE_VALUE);
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ log.info("received callback");
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/headers/ResponseCodeTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months
JBoss Remoting SVN: r6011 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/connectionfailure.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:29:40 -0400 (Wed, 04 Aug 2010)
New Revision: 6011
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/connectionfailure/HttpCallbackConnectionFailureTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/connectionfailure/HttpCallbackConnectionFailureTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/connectionfailure/HttpCallbackConnectionFailureTestCase.java 2010-08-05 01:29:09 UTC (rev 6010)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/connectionfailure/HttpCallbackConnectionFailureTestCase.java 2010-08-05 01:29:40 UTC (rev 6011)
@@ -1,45 +1,45 @@
-
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2005, JBoss Inc., and individual contributors as indicated
-* by the @authors tag. See the copyright.txt 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.connectionfailure;
-
-import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent;
-
-/**
- * Unit test for JBREM-873.
- *
- * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Dec 10, 2007
- * </p>
- */
-public class HttpCallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent
-{
- protected String getTransport()
- {
- return "http";
- }
-}
-
+
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt 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.connectionfailure;
+
+import org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent;
+
+/**
+ * Unit test for JBREM-873.
+ *
+ * org.jboss.test.remoting.callback.connectionfailure.CallbackConnectionFailureTestParent.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Dec 10, 2007
+ * </p>
+ */
+public class HttpCallbackConnectionFailureTestCase extends CallbackConnectionFailureTestParent
+{
+ protected String getTransport()
+ {
+ return "http";
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/connectionfailure/HttpCallbackConnectionFailureTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
13 years, 9 months