JBoss Remoting SVN: r6010 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/chunked.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:29:09 -0400 (Wed, 04 Aug 2010)
New Revision: 6010
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedUnmarshallingTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedUnmarshallingTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedUnmarshallingTestCase.java 2010-08-05 01:28:36 UTC (rev 6009)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/chunked/ChunkedUnmarshallingTestCase.java 2010-08-05 01:29:09 UTC (rev 6010)
@@ -1,192 +1,192 @@
-/*
-* 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.chunked;
-
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.ServerInvocationHandler;
-import org.jboss.remoting.ServerInvoker;
-import org.jboss.remoting.callback.Callback;
-import org.jboss.remoting.callback.HandleCallbackException;
-import org.jboss.remoting.callback.InvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-
-
-/**
- * Unit test for JBREM-1037.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Aug 8, 2008
- * </p>
- */
-public class ChunkedUnmarshallingTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ChunkedUnmarshallingTestCase.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 testChunkedTransmission() 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.
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- String message = "abcdefghijklmnopqrstuvwxyz";
- assertEquals(message, client.invoke(message, metadata));
- log.info("connection is good");
- assertTrue(invocationHandler.isChunked);
- log.info("invocation was sent chunked");
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- protected String getTransport()
- {
- return "http";
- }
-
-
- protected void addExtraClientConfig(Map config) {}
- protected void addExtraServerConfig(Map config) {}
-
-
- protected void setupServer() throws Exception
- {
- host = InetAddress.getLocalHost().getHostAddress();
- port = PortUtil.findFreePort(host);
- locatorURI = getTransport() + "://" + host + ":" + port;
- locatorURI += "/?chunkedLength=10";
- String metadata = System.getProperty("remoting.metadata");
- if (metadata != null)
- {
- locatorURI += "&" + metadata;
- }
- serverLocator = new InvokerLocator(locatorURI);
- log.info("Starting remoting server with locator uri of: " + locatorURI);
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraServerConfig(config);
- connector = new Connector(serverLocator, config);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("test", invocationHandler);
- connector.start();
- }
-
-
- protected void shutdownServer() throws Exception
- {
- if (connector != null)
- connector.stop();
- }
-
-
- static class TestInvocationHandler implements ServerInvocationHandler
- {
- boolean isChunked;
-
- public void addListener(InvokerCallbackHandler callbackHandler) {}
- public Object invoke(final InvocationRequest invocation) throws Throwable
- {
- Map requestMap = invocation.getRequestPayload();
- if (requestMap != null)
- {
- String transferEncoding = (String) requestMap.get("transfer-encoding");
- isChunked = "chunked".equalsIgnoreCase(transferEncoding);
- }
- 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.chunked;
+
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+
+
+/**
+ * Unit test for JBREM-1037.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Aug 8, 2008
+ * </p>
+ */
+public class ChunkedUnmarshallingTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(ChunkedUnmarshallingTestCase.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 testChunkedTransmission() 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.
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ String message = "abcdefghijklmnopqrstuvwxyz";
+ assertEquals(message, client.invoke(message, metadata));
+ log.info("connection is good");
+ assertTrue(invocationHandler.isChunked);
+ log.info("invocation was sent chunked");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "http";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?chunkedLength=10";
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "&" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ boolean isChunked;
+
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ Map requestMap = invocation.getRequestPayload();
+ if (requestMap != null)
+ {
+ String transferEncoding = (String) requestMap.get("transfer-encoding");
+ isChunked = "chunked".equalsIgnoreCase(transferEncoding);
+ }
+ 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/chunked/ChunkedUnmarshallingTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6009 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:28:36 -0400 (Wed, 04 Aug 2010)
New Revision: 6009
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/EmptyURITestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/NullInputStreamTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/EmptyURITestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/EmptyURITestCase.java 2010-08-05 01:27:37 UTC (rev 6008)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/EmptyURITestCase.java 2010-08-05 01:28:36 UTC (rev 6009)
@@ -1,222 +1,222 @@
-/*
- * 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;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.management.MBeanServer;
-
-import junit.framework.TestCase;
-
-import org.apache.log4j.ConsoleAppender;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.jboss.logging.XLevel;
-import org.jboss.remoting.CannotConnectException;
-import org.jboss.remoting.Client;
-import org.jboss.remoting.InvocationRequest;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.InvokerRegistry;
-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.ServerFactory;
-import org.jboss.remoting.transport.coyote.CoyoteInvoker;
-import org.jboss.remoting.transport.http.TransportClientFactory;
-
-
-/**
- * Unit test for JBREM-1168.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Dec 13, 2009
- */
-public class EmptyURITestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(EmptyURITestCase.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);
-
- InvokerRegistry.registerInvokerFactories("http", TransportClientFactory.class, TestCoyoteInvokerFactory.class);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testEmptyURI() 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.
- try
- {
- Object response = client.invoke("abc");
- fail("expected CannotConnectException, got: " + response);
- }
- catch (CannotConnectException e)
- {
- String message = e.getMessage();
- assertTrue("expected CannotConnectException message to contain \"Invalid URI\"", message != null && message.indexOf("Invalid URI") > 0);
- log.info("got expected CannotConnectException");
- }
- catch (Throwable t)
- {
- fail("expected CannotConnectException, got: " + t);
- }
-
- 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;
- String metadata = System.getProperty("remoting.metadata");
- if (metadata != null)
- {
- locatorURI += "/?" + metadata;
- }
- serverLocator = new InvokerLocator(locatorURI);
- log.info("Starting remoting server with locator uri of: " + locatorURI);
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraServerConfig(config);
- connector = new Connector(serverLocator, config);
- connector.create();
- invocationHandler = new TestInvocationHandler();
- connector.addInvocationHandler("test", invocationHandler);
- connector.start();
- }
-
-
- protected void shutdownServer() throws Exception
- {
- if (connector != null)
- connector.stop();
- }
-
-
- static class TestInvocationHandler implements ServerInvocationHandler
- {
- public void addListener(InvokerCallbackHandler callbackHandler) {}
- public Object invoke(final InvocationRequest invocation) throws Throwable
- {
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
-
- static public class TestCoyoteInvokerFactory implements ServerFactory
- {
- public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException
- {
- return new TestCoyoteInvoker(locator, config);
- }
- public boolean supportsSSL()
- {
- return false;
- }
- }
-
-
- static class TestCoyoteInvoker extends CoyoteInvoker
- {
- public TestCoyoteInvoker(InvokerLocator locator)
- {
- super(locator);
- }
-
- public TestCoyoteInvoker(InvokerLocator locator, Map configuration)
- {
- super(locator, configuration);
- }
-
- public void service(org.apache.coyote.Request req, org.apache.coyote.Response res) throws Exception
- {
- byte[] b = new byte[]{};
- req.requestURI().setBytes(b, 0, 0);
- log.info(this + ".service()");
- super.service(req, res);
- }
- }
+/*
+ * 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;
+
+import java.io.IOException;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.CannotConnectException;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.InvokerRegistry;
+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.ServerFactory;
+import org.jboss.remoting.transport.coyote.CoyoteInvoker;
+import org.jboss.remoting.transport.http.TransportClientFactory;
+
+
+/**
+ * Unit test for JBREM-1168.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Dec 13, 2009
+ */
+public class EmptyURITestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(EmptyURITestCase.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);
+
+ InvokerRegistry.registerInvokerFactories("http", TransportClientFactory.class, TestCoyoteInvokerFactory.class);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testEmptyURI() 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.
+ try
+ {
+ Object response = client.invoke("abc");
+ fail("expected CannotConnectException, got: " + response);
+ }
+ catch (CannotConnectException e)
+ {
+ String message = e.getMessage();
+ assertTrue("expected CannotConnectException message to contain \"Invalid URI\"", message != null && message.indexOf("Invalid URI") > 0);
+ log.info("got expected CannotConnectException");
+ }
+ catch (Throwable t)
+ {
+ fail("expected CannotConnectException, got: " + t);
+ }
+
+ 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;
+ String metadata = System.getProperty("remoting.metadata");
+ if (metadata != null)
+ {
+ locatorURI += "/?" + metadata;
+ }
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+
+
+ static class TestInvocationHandler implements ServerInvocationHandler
+ {
+ public void addListener(InvokerCallbackHandler callbackHandler) {}
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+ static public class TestCoyoteInvokerFactory implements ServerFactory
+ {
+ public ServerInvoker createServerInvoker(InvokerLocator locator, Map config) throws IOException
+ {
+ return new TestCoyoteInvoker(locator, config);
+ }
+ public boolean supportsSSL()
+ {
+ return false;
+ }
+ }
+
+
+ static class TestCoyoteInvoker extends CoyoteInvoker
+ {
+ public TestCoyoteInvoker(InvokerLocator locator)
+ {
+ super(locator);
+ }
+
+ public TestCoyoteInvoker(InvokerLocator locator, Map configuration)
+ {
+ super(locator, configuration);
+ }
+
+ public void service(org.apache.coyote.Request req, org.apache.coyote.Response res) throws Exception
+ {
+ byte[] b = new byte[]{};
+ req.requestURI().setBytes(b, 0, 0);
+ log.info(this + ".service()");
+ super.service(req, res);
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/EmptyURITestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/NullInputStreamTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/NullInputStreamTestCase.java 2010-08-05 01:27:37 UTC (rev 6008)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/NullInputStreamTestCase.java 2010-08-05 01:28:36 UTC (rev 6009)
@@ -1,507 +1,507 @@
-/*
-* 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;
-
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-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 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.CannotConnectException;
-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.UnMarshaller;
-import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.http.HTTPClientInvoker;
-import org.jboss.remoting.transport.http.WebServerError;
-
-
-/**
- * Unit test for JBREM-1052.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Oct 27, 2008
- * </p>
- */
-public class NullInputStreamTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(NullInputStreamTestCase.class);
-
- private static boolean firstTime = true;
-
- protected String host;
- protected int port;
- protected String locatorURI;
- protected InvokerLocator serverLocator;
- protected Connector connector;
- protected Client client;
- 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);
- }
-
- TestUnMarshaller.clear();
- }
-
-
- public void tearDown()
- {
- if (client != null)
- {
- client.disconnect();
- }
- if (connector != null)
- {
- connector.destroy();
- }
- }
-
-
- /**
- * Tests default behavior with POST method.
- */
- public void testDefaultBehaviorPost() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
- boolean ok = false;
-
-
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("TYPE", "POST");
-
- try
- {
- log.info("response: " + makeInvocation(config, metadata));
- fail("expected WebServerError");
- }
- catch (WebServerError e)
- {
- log.info("received expected WebServerError");
- ok = true;
- }
-
- assertTrue(ok);
- assertTrue(TestUnMarshaller.enteredRead);
- assertTrue(TestUnMarshaller.streamIsNull);
-
- log.info(getName() + " PASSES");
- }
-
-
- /**
- * Tests default behavior with HEAD method.
- */
- public void testDefaultBehaviorHead() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
- boolean ok = false;
-
-
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("TYPE", "HEAD");
-
- try
- {
- log.info("response: " + makeInvocation(config, metadata));
- fail("expected WebServerError");
- }
- catch (WebServerError e)
- {
- log.info("received expected WebServerError");
- ok = true;
- }
-
- assertTrue(ok);
- assertTrue(TestUnMarshaller.enteredRead);
- assertTrue(TestUnMarshaller.streamIsNull);
-
- log.info(getName() + " PASSES");
- }
-
-
- /**
- * Tests behavior with unmarshallNullStream == true and with POST method.
- */
- public void testUnmarshalNullStreamTruePost() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
- boolean ok = false;
-
-
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "true");
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("TYPE", "POST");
-
- try
- {
- log.info("response: " + makeInvocation(config, metadata));
- fail("expected WebServerError");
- }
- catch (WebServerError e)
- {
- log.info("received expected WebServerError");
- ok = true;
- }
-
- assertTrue(ok);
- assertTrue(TestUnMarshaller.enteredRead);
- assertTrue(TestUnMarshaller.streamIsNull);
-
- log.info(getName() + " PASSES");
- }
-
-
- /**
- * Tests behavior with unmarshallNullStream == true and with HEAD method.
- */
- public void testUnmarshalNullStreamTrueHead() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
- boolean ok = false;
-
-
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "true");
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("TYPE", "HEAD");
-
- try
- {
- log.info("response: " + makeInvocation(config, metadata));
- fail("expected WebServerError");
- }
- catch (WebServerError e)
- {
- log.info("received expected WebServerError");
- ok = true;
- }
-
- assertTrue(ok);
- assertTrue(TestUnMarshaller.enteredRead);
- assertTrue(TestUnMarshaller.streamIsNull);
-
- log.info(getName() + " PASSES");
- }
-
-
- /**
- * Tests behavior with unmarshallNullStream == false and with POST method.
- */
- public void testUnmarshalNullStreamFalsePost() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
- boolean ok = false;
-
-
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "false");
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("TYPE", "POST");
-
- try
- {
- log.info("response: " + makeInvocation(config, metadata));
- fail("expected WebServerError");
- }
- catch (WebServerError e)
- {
- log.info("received expected WebServerError");
- ok = true;
- }
-
- assertTrue(ok);
- assertFalse(TestUnMarshaller.enteredRead);
-
- log.info(getName() + " PASSES");
- }
-
-
-
- /**
- * Tests behavior with unmarshallNullStream == false and with HEAD method.
- */
- public void testUnmarshalNullStreamFalseHead() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
- boolean ok = false;
-
-
- HashMap config = new HashMap();
- config.put(InvokerLocator.FORCE_REMOTE, "true");
- config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "false");
- HashMap metadata = new HashMap();
- metadata.put(Client.RAW, "true");
- metadata.put("TYPE", "HEAD");
-
- try
- {
- log.info("response: " + makeInvocation(config, metadata));
- fail("expected WebServerError");
- }
- catch (WebServerError e)
- {
- log.info("received expected WebServerError");
- ok = true;
- }
-
- assertTrue(ok);
- assertFalse(TestUnMarshaller.enteredRead);
-
- log.info(getName() + " PASSES");
- }
-
-
- protected Object makeInvocation(HashMap config, HashMap metadata) throws Throwable
- {
- // Create client.
- locatorURI = "http://" + host + ":" + port;
- locatorURI += "/?unmarshaller=" + TestUnMarshaller.class.getName();
- log.info("connecting to " + locatorURI);
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- Client client = new Client(clientLocator, config);
- client.connect();
- log.info("client is connected");
-
- Object response = null;
- for (int i = 0; i < 3; i++)
- {
- try
- {
- response = client.invoke("abc", metadata);
- break;
- }
- catch (CannotConnectException e)
- {
- log.info("cannot connect", e);
-
- }
- }
-
- return response;
- }
-
-
- protected void setupServer() throws Exception
- {
- log.info("setupServer()");
- InetAddress localHost = InetAddress.getLocalHost();
- final ServerSocket ss = new ServerSocket(0, 100, localHost);
- ss.setSoTimeout(5000);
- host = localHost.getHostAddress();
- port = ss.getLocalPort();
- new AcceptThread(ss).start();
- log.info("started server");
- }
-
-
- 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) {}
- }
-
- public static class TestUnMarshaller extends HTTPUnMarshaller
- {
- /** The serialVersionUID */
- private static final long serialVersionUID = 1L;
-
- public static boolean enteredRead;
- public static boolean streamIsNull;
-
- public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
- {
- enteredRead = true;
- streamIsNull = (inputStream == null);
- log.info("entered TestUnMarshaller.read()");
- if (inputStream != null)
- {
- return super.read(inputStream, metadata, version);
- }
- else
- {
- return null;
- }
- }
-
- public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
- {
- HTTPUnMarshaller unmarshaller = new TestUnMarshaller();
- unmarshaller.setClassLoader(customClassLoader);
- return unmarshaller;
- }
-
- public static void clear()
- {
- enteredRead = false;
- streamIsNull = false;
- }
- }
-
-
- public static class AcceptThread extends Thread
- {
- ServerSocket ss;
-
- public AcceptThread(ServerSocket ss)
- {
- this.ss = ss;
- setDaemon(true);
- }
-
- public void run()
- {
- log.info("starting AcceptThread");
- while (true)
- {
- try
- {
- new WorkerThread(ss.accept()).start();
- }
- catch (Exception e)
- {
- log.error("AcceptThread erroe", e);
- }
- }
- }
- }
-
-
- public static class WorkerThread extends Thread
- {
- Socket s;
-
- public WorkerThread(Socket s)
- {
- this.s = s;
- setDaemon(true);
- }
-
- public void run()
- {
- try
- {
- log.info("starting WorkerThread");
- InputStreamReader ir = new InputStreamReader(s.getInputStream());
- char[] cbuf = new char[1024];
- int len = ir.read(cbuf);
- log.info("available: " + s.getInputStream().available());
- log.info("len: " + len);
- log.info("Request:");
- System.out.println();
- System.out.println(String.copyValueOf(cbuf, 0, len));
- System.out.println();
-
- DataOutputStream dos = new DataOutputStream(s.getOutputStream());
- dos.writeBytes("HTTP/1.1 500 error" + "\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();
- }
- catch (Exception e)
- {
- log.error("WorkerThread error", e);
- }
- }
- }
+/*
+* 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;
+
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+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 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.CannotConnectException;
+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.UnMarshaller;
+import org.jboss.remoting.marshal.http.HTTPUnMarshaller;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.http.HTTPClientInvoker;
+import org.jboss.remoting.transport.http.WebServerError;
+
+
+/**
+ * Unit test for JBREM-1052.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Oct 27, 2008
+ * </p>
+ */
+public class NullInputStreamTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(NullInputStreamTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected Client client;
+ 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);
+ }
+
+ TestUnMarshaller.clear();
+ }
+
+
+ public void tearDown()
+ {
+ if (client != null)
+ {
+ client.disconnect();
+ }
+ if (connector != null)
+ {
+ connector.destroy();
+ }
+ }
+
+
+ /**
+ * Tests default behavior with POST method.
+ */
+ public void testDefaultBehaviorPost() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+ boolean ok = false;
+
+
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("TYPE", "POST");
+
+ try
+ {
+ log.info("response: " + makeInvocation(config, metadata));
+ fail("expected WebServerError");
+ }
+ catch (WebServerError e)
+ {
+ log.info("received expected WebServerError");
+ ok = true;
+ }
+
+ assertTrue(ok);
+ assertTrue(TestUnMarshaller.enteredRead);
+ assertTrue(TestUnMarshaller.streamIsNull);
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Tests default behavior with HEAD method.
+ */
+ public void testDefaultBehaviorHead() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+ boolean ok = false;
+
+
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("TYPE", "HEAD");
+
+ try
+ {
+ log.info("response: " + makeInvocation(config, metadata));
+ fail("expected WebServerError");
+ }
+ catch (WebServerError e)
+ {
+ log.info("received expected WebServerError");
+ ok = true;
+ }
+
+ assertTrue(ok);
+ assertTrue(TestUnMarshaller.enteredRead);
+ assertTrue(TestUnMarshaller.streamIsNull);
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Tests behavior with unmarshallNullStream == true and with POST method.
+ */
+ public void testUnmarshalNullStreamTruePost() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+ boolean ok = false;
+
+
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "true");
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("TYPE", "POST");
+
+ try
+ {
+ log.info("response: " + makeInvocation(config, metadata));
+ fail("expected WebServerError");
+ }
+ catch (WebServerError e)
+ {
+ log.info("received expected WebServerError");
+ ok = true;
+ }
+
+ assertTrue(ok);
+ assertTrue(TestUnMarshaller.enteredRead);
+ assertTrue(TestUnMarshaller.streamIsNull);
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Tests behavior with unmarshallNullStream == true and with HEAD method.
+ */
+ public void testUnmarshalNullStreamTrueHead() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+ boolean ok = false;
+
+
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "true");
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("TYPE", "HEAD");
+
+ try
+ {
+ log.info("response: " + makeInvocation(config, metadata));
+ fail("expected WebServerError");
+ }
+ catch (WebServerError e)
+ {
+ log.info("received expected WebServerError");
+ ok = true;
+ }
+
+ assertTrue(ok);
+ assertTrue(TestUnMarshaller.enteredRead);
+ assertTrue(TestUnMarshaller.streamIsNull);
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ /**
+ * Tests behavior with unmarshallNullStream == false and with POST method.
+ */
+ public void testUnmarshalNullStreamFalsePost() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+ boolean ok = false;
+
+
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "false");
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("TYPE", "POST");
+
+ try
+ {
+ log.info("response: " + makeInvocation(config, metadata));
+ fail("expected WebServerError");
+ }
+ catch (WebServerError e)
+ {
+ log.info("received expected WebServerError");
+ ok = true;
+ }
+
+ assertTrue(ok);
+ assertFalse(TestUnMarshaller.enteredRead);
+
+ log.info(getName() + " PASSES");
+ }
+
+
+
+ /**
+ * Tests behavior with unmarshallNullStream == false and with HEAD method.
+ */
+ public void testUnmarshalNullStreamFalseHead() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+ boolean ok = false;
+
+
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ config.put(HTTPClientInvoker.UNMARSHAL_NULL_STREAM, "false");
+ HashMap metadata = new HashMap();
+ metadata.put(Client.RAW, "true");
+ metadata.put("TYPE", "HEAD");
+
+ try
+ {
+ log.info("response: " + makeInvocation(config, metadata));
+ fail("expected WebServerError");
+ }
+ catch (WebServerError e)
+ {
+ log.info("received expected WebServerError");
+ ok = true;
+ }
+
+ assertTrue(ok);
+ assertFalse(TestUnMarshaller.enteredRead);
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected Object makeInvocation(HashMap config, HashMap metadata) throws Throwable
+ {
+ // Create client.
+ locatorURI = "http://" + host + ":" + port;
+ locatorURI += "/?unmarshaller=" + TestUnMarshaller.class.getName();
+ log.info("connecting to " + locatorURI);
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ Client client = new Client(clientLocator, config);
+ client.connect();
+ log.info("client is connected");
+
+ Object response = null;
+ for (int i = 0; i < 3; i++)
+ {
+ try
+ {
+ response = client.invoke("abc", metadata);
+ break;
+ }
+ catch (CannotConnectException e)
+ {
+ log.info("cannot connect", e);
+
+ }
+ }
+
+ return response;
+ }
+
+
+ protected void setupServer() throws Exception
+ {
+ log.info("setupServer()");
+ InetAddress localHost = InetAddress.getLocalHost();
+ final ServerSocket ss = new ServerSocket(0, 100, localHost);
+ ss.setSoTimeout(5000);
+ host = localHost.getHostAddress();
+ port = ss.getLocalPort();
+ new AcceptThread(ss).start();
+ log.info("started server");
+ }
+
+
+ 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) {}
+ }
+
+ public static class TestUnMarshaller extends HTTPUnMarshaller
+ {
+ /** The serialVersionUID */
+ private static final long serialVersionUID = 1L;
+
+ public static boolean enteredRead;
+ public static boolean streamIsNull;
+
+ public Object read(InputStream inputStream, Map metadata, int version) throws IOException, ClassNotFoundException
+ {
+ enteredRead = true;
+ streamIsNull = (inputStream == null);
+ log.info("entered TestUnMarshaller.read()");
+ if (inputStream != null)
+ {
+ return super.read(inputStream, metadata, version);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public UnMarshaller cloneUnMarshaller() throws CloneNotSupportedException
+ {
+ HTTPUnMarshaller unmarshaller = new TestUnMarshaller();
+ unmarshaller.setClassLoader(customClassLoader);
+ return unmarshaller;
+ }
+
+ public static void clear()
+ {
+ enteredRead = false;
+ streamIsNull = false;
+ }
+ }
+
+
+ public static class AcceptThread extends Thread
+ {
+ ServerSocket ss;
+
+ public AcceptThread(ServerSocket ss)
+ {
+ this.ss = ss;
+ setDaemon(true);
+ }
+
+ public void run()
+ {
+ log.info("starting AcceptThread");
+ while (true)
+ {
+ try
+ {
+ new WorkerThread(ss.accept()).start();
+ }
+ catch (Exception e)
+ {
+ log.error("AcceptThread erroe", e);
+ }
+ }
+ }
+ }
+
+
+ public static class WorkerThread extends Thread
+ {
+ Socket s;
+
+ public WorkerThread(Socket s)
+ {
+ this.s = s;
+ setDaemon(true);
+ }
+
+ public void run()
+ {
+ try
+ {
+ log.info("starting WorkerThread");
+ InputStreamReader ir = new InputStreamReader(s.getInputStream());
+ char[] cbuf = new char[1024];
+ int len = ir.read(cbuf);
+ log.info("available: " + s.getInputStream().available());
+ log.info("len: " + len);
+ log.info("Request:");
+ System.out.println();
+ System.out.println(String.copyValueOf(cbuf, 0, len));
+ System.out.println();
+
+ DataOutputStream dos = new DataOutputStream(s.getOutputStream());
+ dos.writeBytes("HTTP/1.1 500 error" + "\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();
+ }
+ catch (Exception e)
+ {
+ log.error("WorkerThread error", e);
+ }
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/http/NullInputStreamTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6008 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/connector.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:27:37 -0400 (Wed, 04 Aug 2010)
New Revision: 6008
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/connector/ObjectNameWithZeroesAddressTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/connector/ObjectNameWithZeroesAddressTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/connector/ObjectNameWithZeroesAddressTestCase.java 2010-08-05 01:27:09 UTC (rev 6007)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/connector/ObjectNameWithZeroesAddressTestCase.java 2010-08-05 01:27:37 UTC (rev 6008)
@@ -1,175 +1,175 @@
-/*
-* 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.connector;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.management.MBeanServer;
-import javax.management.MBeanServerFactory;
-import javax.management.ObjectInstance;
-import javax.management.ObjectName;
-
-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.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;
-
-
-/**
- * Unit test for JBREM-910.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Feb 25, 2008
- * </p>
- */
-public class ObjectNameWithZeroesAddressTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ObjectNameWithZeroesAddressTestCase.class);
-
- private static boolean firstTime = true;
-
- protected String host;
- protected int port;
- protected String locatorURI;
- protected InvokerLocator serverLocator;
- protected Connector connector;
- protected TestInvocationHandler invocationHandler;
- protected MBeanServer mbeanServer;
-
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- firstTime = false;
- Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
- Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
- String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
- PatternLayout layout = new PatternLayout(pattern);
- ConsoleAppender consoleAppender = new ConsoleAppender(layout);
- Logger.getRootLogger().addAppender(consoleAppender);
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testMethod() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- log.info("Updated locator: " + connector.getInvokerLocator());
- ServerInvoker invoker = connector.getServerInvoker();
- String name = invoker.getMBeanObjectName();
- ObjectName objectName = new ObjectName(name);
- log.info("objectName:" + objectName);
- printMBeans();
- assertTrue(mbeanServer.isRegistered(objectName));
- shutdownServer();
- printMBeans();
- assertFalse(mbeanServer.isRegistered(objectName));
-
- log.info(getName() + " PASSES");
- }
-
-
- protected void printMBeans()
- {
- log.info("MBean count: " + mbeanServer.getMBeanCount());
- Set mbeans = mbeanServer.queryMBeans(null, null);
- Iterator it = mbeans.iterator();
- int i = 0;
- while (it.hasNext())
- {
- ObjectInstance mbean = (ObjectInstance) it.next();
- log.info("MBean " + i++ + ": " + mbean.getObjectName());
- }
- }
-
-
- protected String getTransport()
- {
- return "socket";
- }
-
-
- protected void addExtraClientConfig(Map config) {}
- protected void addExtraServerConfig(Map config) {}
-
-
- protected void setupServer() throws Exception
- {
- locatorURI = getTransport() + "://0.0.0.0:5555";
- 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);
- mbeanServer = MBeanServerFactory.createMBeanServer();
- connector = new Connector(serverLocator, config);
- connector.preRegister(mbeanServer, new ObjectName("remoting:service=connector"));
- 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.connector;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import javax.management.MBeanServer;
+import javax.management.MBeanServerFactory;
+import javax.management.ObjectInstance;
+import javax.management.ObjectName;
+
+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.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;
+
+
+/**
+ * Unit test for JBREM-910.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 25, 2008
+ * </p>
+ */
+public class ObjectNameWithZeroesAddressTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(ObjectNameWithZeroesAddressTestCase.class);
+
+ private static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+ protected MBeanServer mbeanServer;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testMethod() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ log.info("Updated locator: " + connector.getInvokerLocator());
+ ServerInvoker invoker = connector.getServerInvoker();
+ String name = invoker.getMBeanObjectName();
+ ObjectName objectName = new ObjectName(name);
+ log.info("objectName:" + objectName);
+ printMBeans();
+ assertTrue(mbeanServer.isRegistered(objectName));
+ shutdownServer();
+ printMBeans();
+ assertFalse(mbeanServer.isRegistered(objectName));
+
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void printMBeans()
+ {
+ log.info("MBean count: " + mbeanServer.getMBeanCount());
+ Set mbeans = mbeanServer.queryMBeans(null, null);
+ Iterator it = mbeans.iterator();
+ int i = 0;
+ while (it.hasNext())
+ {
+ ObjectInstance mbean = (ObjectInstance) it.next();
+ log.info("MBean " + i++ + ": " + mbean.getObjectName());
+ }
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ locatorURI = getTransport() + "://0.0.0.0:5555";
+ 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);
+ mbeanServer = MBeanServerFactory.createMBeanServer();
+ connector = new Connector(serverLocator, config);
+ connector.preRegister(mbeanServer, new ObjectName("remoting:service=connector"));
+ 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/connector/ObjectNameWithZeroesAddressTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6007 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:27:09 -0400 (Wed, 04 Aug 2010)
New Revision: 6007
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2010-08-05 01:26:37 UTC (rev 6006)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java 2010-08-05 01:27:09 UTC (rev 6007)
@@ -1,341 +1,341 @@
-/*
-* 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.bisocket.timertask;
-
-import java.lang.reflect.Field;
-import java.net.InetAddress;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.Timer;
-import java.util.TimerTask;
-
-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.callback.ServerInvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.transport.bisocket.Bisocket;
-import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
-import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
-
-
-/**
- * Unit test for JBREM-1005.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Jun 26, 2008
- * </p>
- */
-public class TimerTaskTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(TimerTaskTestCase.class);
-
- private static boolean firstTime = true;
- private static boolean purgeMethodAvailable;
-
- 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);
-
- try
- {
- Timer.class.getDeclaredMethod("purge", new Class[]{});
- purgeMethodAvailable = true;
- }
- catch (Exception e)
- {
- log.info("Timer.purge() is not available: must be running with jdk 1.4");
- }
- }
- }
-
-
- public void tearDown()
- {
- }
-
-
- public void testZeroPingFrequency() throws Throwable
- {
- log.info("entering " + getName());
-
- if (!purgeMethodAvailable)
- {
- log.info(getName() + " PASSES (trivially)");
- return;
- }
-
- // Start server.
- setupServer("0");
-
- // 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();
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- // Set up callback handler.
- TestCallbackHandler callbackHandler = new TestCallbackHandler();
- HashMap metadata = new HashMap();
- metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
- client.addListener(callbackHandler, metadata);
- assertEquals(1, callbackHandler.counter);
-
- // Verify ControlMonitorTimerTask is not created.
- Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
- assertEquals(1, callbackConnectors.size());
- Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
- Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
- field.setAccessible(true);
- BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
- TimerTask timerTask = (TimerTask) field.get(serverInvoker);
- assertNull(timerTask);
- log.info("ControlMonitorTimerTask was not created");
-
- // Verify PingTimerTask is not created.
- field = ServerInvoker.class.getDeclaredField("callbackHandlers");
- field.setAccessible(true);
- serverInvoker = (BisocketServerInvoker) connector.getServerInvoker();
- Map callbackHandlers = (Map) field.get(serverInvoker);
- assertEquals(1, callbackHandlers.size());
- Object o = callbackHandlers.values().iterator().next();
- Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
- BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
- field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
- field.setAccessible(true);
- timerTask = (TimerTask) field.get(clientInvoker);
- assertNull(timerTask);
- log.info("PingTimerTask was not created");
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- public void testNonZeroPingFrequency() throws Throwable
- {
- log.info("entering " + getName());
-
- if (!purgeMethodAvailable)
- {
- log.info(getName() + " PASSES (trivially)");
- return;
- }
-
- // Start server.
- setupServer("20");
-
- // 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();
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- // Set up callback handler.
- TestCallbackHandler callbackHandler = new TestCallbackHandler();
- HashMap metadata = new HashMap();
- metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
- client.addListener(callbackHandler, metadata);
- assertEquals(1, callbackHandler.counter);
-
- // Verify ControlMonitorTimerTask is created.
- Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
- assertEquals(1, callbackConnectors.size());
- Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
- Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
- field.setAccessible(true);
- BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
- TimerTask timerTask = (TimerTask) field.get(serverInvoker);
- assertNotNull(timerTask);
- log.info("ControlMonitorTimerTask was created");
-
- // Verify PingTimerTask is created.
- field = ServerInvoker.class.getDeclaredField("callbackHandlers");
- field.setAccessible(true);
- BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) connector.getServerInvoker();
- Map callbackHandlers = (Map) field.get(callbackServerInvoker);
- assertEquals(1, callbackHandlers.size());
- Object o = callbackHandlers.values().iterator().next();
- Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
- BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
- field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
- field.setAccessible(true);
- timerTask = (TimerTask) field.get(clientInvoker);
- assertNotNull(timerTask);
- log.info("PingTimerTask was created");
-
- // Get count of ControlMonitorTimerTasks.
- field = BisocketServerInvoker.class.getDeclaredField("timer");
- field.setAccessible(true);
- Timer timer = (Timer) field.get(null);
- field = Timer.class.getDeclaredField("queue");
- field.setAccessible(true);
- Object taskQueue = field.get(timer);
- Field serverTimerfield = taskQueue.getClass().getDeclaredField("size");
- serverTimerfield.setAccessible(true);
- int serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
- log.info("ControlMonitorTimerTasks: " + serverSize);
-
- // Get count of PingTimerTasks.
- field = BisocketClientInvoker.class.getDeclaredField("timer");
- field.setAccessible(true);
- timer = (Timer) field.get(null);
- field = Timer.class.getDeclaredField("queue");
- field.setAccessible(true);
- taskQueue = field.get(timer);
- Field clientTimerfield = taskQueue.getClass().getDeclaredField("size");
- clientTimerfield.setAccessible(true);
- int clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
- log.info("PingTimerTasks: " + clientSize);
-
- // Shut down callback connection and verify TimerTasks are removed from
- // Timer queue.
- client.removeListener(callbackHandler);
- serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
- log.info("ControlMonitorTimerTasks: " + serverSize);
- assertEquals(0, serverSize);
- clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
- log.info("PingTimerTasks: " + clientSize);
- assertEquals(0, clientSize);
-
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- protected String getTransport()
- {
- return "bisocket";
- }
-
-
- protected void addExtraClientConfig(Map config) {}
- protected void addExtraServerConfig(Map config) {}
-
-
- protected void setupServer(String pingFrequency) throws Exception
- {
- host = InetAddress.getLocalHost().getHostAddress();
- port = PortUtil.findFreePort(host);
- locatorURI = getTransport() + "://" + host + ":" + port;
- locatorURI += "/?" + Bisocket.PING_FREQUENCY + "=" + pingFrequency;
- 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)
- {
- try
- {
- callbackHandler.handleCallback(new Callback("callback"));
- }
- catch (HandleCallbackException e)
- {
- log.error("Unable to send callback", e);
- }
- }
- public Object invoke(final InvocationRequest invocation) throws Throwable
- {
- return invocation.getParameter();
- }
- public void removeListener(InvokerCallbackHandler callbackHandler) {}
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
-
-
- static class TestCallbackHandler implements InvokerCallbackHandler
- {
- public int counter;
- public void handleCallback(Callback callback) throws HandleCallbackException
- {
- counter++;
- 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.bisocket.timertask;
+
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+import java.util.Timer;
+import java.util.TimerTask;
+
+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.callback.ServerInvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.bisocket.Bisocket;
+import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
+import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
+
+
+/**
+ * Unit test for JBREM-1005.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Jun 26, 2008
+ * </p>
+ */
+public class TimerTaskTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(TimerTaskTestCase.class);
+
+ private static boolean firstTime = true;
+ private static boolean purgeMethodAvailable;
+
+ 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);
+
+ try
+ {
+ Timer.class.getDeclaredMethod("purge", new Class[]{});
+ purgeMethodAvailable = true;
+ }
+ catch (Exception e)
+ {
+ log.info("Timer.purge() is not available: must be running with jdk 1.4");
+ }
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testZeroPingFrequency() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ if (!purgeMethodAvailable)
+ {
+ log.info(getName() + " PASSES (trivially)");
+ return;
+ }
+
+ // Start server.
+ setupServer("0");
+
+ // 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();
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Set up callback handler.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata);
+ assertEquals(1, callbackHandler.counter);
+
+ // Verify ControlMonitorTimerTask is not created.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ assertEquals(1, callbackConnectors.size());
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
+ field.setAccessible(true);
+ BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
+ TimerTask timerTask = (TimerTask) field.get(serverInvoker);
+ assertNull(timerTask);
+ log.info("ControlMonitorTimerTask was not created");
+
+ // Verify PingTimerTask is not created.
+ field = ServerInvoker.class.getDeclaredField("callbackHandlers");
+ field.setAccessible(true);
+ serverInvoker = (BisocketServerInvoker) connector.getServerInvoker();
+ Map callbackHandlers = (Map) field.get(serverInvoker);
+ assertEquals(1, callbackHandlers.size());
+ Object o = callbackHandlers.values().iterator().next();
+ Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
+ BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
+ field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
+ field.setAccessible(true);
+ timerTask = (TimerTask) field.get(clientInvoker);
+ assertNull(timerTask);
+ log.info("PingTimerTask was not created");
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testNonZeroPingFrequency() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ if (!purgeMethodAvailable)
+ {
+ log.info(getName() + " PASSES (trivially)");
+ return;
+ }
+
+ // Start server.
+ setupServer("20");
+
+ // 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();
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Set up callback handler.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata);
+ assertEquals(1, callbackHandler.counter);
+
+ // Verify ControlMonitorTimerTask is created.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ assertEquals(1, callbackConnectors.size());
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ Field field = BisocketServerInvoker.class.getDeclaredField("controlMonitorTimerTask");
+ field.setAccessible(true);
+ BisocketServerInvoker serverInvoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
+ TimerTask timerTask = (TimerTask) field.get(serverInvoker);
+ assertNotNull(timerTask);
+ log.info("ControlMonitorTimerTask was created");
+
+ // Verify PingTimerTask is created.
+ field = ServerInvoker.class.getDeclaredField("callbackHandlers");
+ field.setAccessible(true);
+ BisocketServerInvoker callbackServerInvoker = (BisocketServerInvoker) connector.getServerInvoker();
+ Map callbackHandlers = (Map) field.get(callbackServerInvoker);
+ assertEquals(1, callbackHandlers.size());
+ Object o = callbackHandlers.values().iterator().next();
+ Client callbackClient = ((ServerInvokerCallbackHandler) o).getCallbackClient();
+ BisocketClientInvoker clientInvoker = (BisocketClientInvoker) callbackClient.getInvoker();
+ field = BisocketClientInvoker.class.getDeclaredField("pingTimerTask");
+ field.setAccessible(true);
+ timerTask = (TimerTask) field.get(clientInvoker);
+ assertNotNull(timerTask);
+ log.info("PingTimerTask was created");
+
+ // Get count of ControlMonitorTimerTasks.
+ field = BisocketServerInvoker.class.getDeclaredField("timer");
+ field.setAccessible(true);
+ Timer timer = (Timer) field.get(null);
+ field = Timer.class.getDeclaredField("queue");
+ field.setAccessible(true);
+ Object taskQueue = field.get(timer);
+ Field serverTimerfield = taskQueue.getClass().getDeclaredField("size");
+ serverTimerfield.setAccessible(true);
+ int serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
+ log.info("ControlMonitorTimerTasks: " + serverSize);
+
+ // Get count of PingTimerTasks.
+ field = BisocketClientInvoker.class.getDeclaredField("timer");
+ field.setAccessible(true);
+ timer = (Timer) field.get(null);
+ field = Timer.class.getDeclaredField("queue");
+ field.setAccessible(true);
+ taskQueue = field.get(timer);
+ Field clientTimerfield = taskQueue.getClass().getDeclaredField("size");
+ clientTimerfield.setAccessible(true);
+ int clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
+ log.info("PingTimerTasks: " + clientSize);
+
+ // Shut down callback connection and verify TimerTasks are removed from
+ // Timer queue.
+ client.removeListener(callbackHandler);
+ serverSize = ((Integer) serverTimerfield.get(taskQueue)).intValue();
+ log.info("ControlMonitorTimerTasks: " + serverSize);
+ assertEquals(0, serverSize);
+ clientSize = ((Integer) clientTimerfield.get(taskQueue)).intValue();
+ log.info("PingTimerTasks: " + clientSize);
+ assertEquals(0, clientSize);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(String pingFrequency) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ locatorURI += "/?" + Bisocket.PING_FREQUENCY + "=" + pingFrequency;
+ 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)
+ {
+ try
+ {
+ callbackHandler.handleCallback(new Callback("callback"));
+ }
+ catch (HandleCallbackException e)
+ {
+ log.error("Unable to send callback", e);
+ }
+ }
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ return invocation.getParameter();
+ }
+ public void removeListener(InvokerCallbackHandler callbackHandler) {}
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int counter;
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ counter++;
+ log.info("received callback");
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timertask/TimerTaskTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6006 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:26:37 -0400 (Wed, 04 Aug 2010)
New Revision: 6006
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketDefaultTimeoutTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketWriteTimeoutTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketDefaultTimeoutTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketDefaultTimeoutTestCase.java 2010-08-05 01:25:58 UTC (rev 6005)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketDefaultTimeoutTestCase.java 2010-08-05 01:26:37 UTC (rev 6006)
@@ -1,96 +1,96 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.bisocket.timeout;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.transport.ClientFactory;
-import org.jboss.remoting.transport.ClientInvoker;
-import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
-import org.jboss.remoting.transport.socket.ServerAddress;
-import org.jboss.test.remoting.transport.socket.timeout.SocketDefaultTimeoutTestCase;
-
-
-/**
- * Unit tests for JBREM-1188.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Feb 16, 2010
- */
-public class BisocketDefaultTimeoutTestCase extends SocketDefaultTimeoutTestCase
-{
- private static Logger log = Logger.getLogger(BisocketDefaultTimeoutTestCase.class);
-
-
- protected Class getClientFactoryClass()
- {
- return TestBisocketClientFactory.class;
- }
-
-
- protected Class getClientInvokerClass()
- {
- return TestBisocketClientInvoker.class;
- }
-
-
- public static class TestBisocketClientFactory implements ClientFactory
- {
- public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException
- {
- ClientInvoker clientInvoker = new TestBisocketClientInvoker(locator, config);
- log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker);
- return clientInvoker;
- }
- public boolean supportsSSL()
- {
- return false;
- }
- }
-
-
- public static class TestBisocketClientInvoker extends BisocketClientInvoker
- {
- public TestBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException
- {
- super(locator, configuration);
- }
- public TestBisocketClientInvoker(InvokerLocator locator) throws IOException
- {
- super(locator);
- }
- public ServerAddress getServerAddress()
- {
- return address;
- }
- public String toString()
- {
- return "TestBisocketClientInvoker";
- }
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.bisocket.timeout;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.ClientFactory;
+import org.jboss.remoting.transport.ClientInvoker;
+import org.jboss.remoting.transport.bisocket.BisocketClientInvoker;
+import org.jboss.remoting.transport.socket.ServerAddress;
+import org.jboss.test.remoting.transport.socket.timeout.SocketDefaultTimeoutTestCase;
+
+
+/**
+ * Unit tests for JBREM-1188.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 16, 2010
+ */
+public class BisocketDefaultTimeoutTestCase extends SocketDefaultTimeoutTestCase
+{
+ private static Logger log = Logger.getLogger(BisocketDefaultTimeoutTestCase.class);
+
+
+ protected Class getClientFactoryClass()
+ {
+ return TestBisocketClientFactory.class;
+ }
+
+
+ protected Class getClientInvokerClass()
+ {
+ return TestBisocketClientInvoker.class;
+ }
+
+
+ public static class TestBisocketClientFactory implements ClientFactory
+ {
+ public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException
+ {
+ ClientInvoker clientInvoker = new TestBisocketClientInvoker(locator, config);
+ log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker);
+ return clientInvoker;
+ }
+ public boolean supportsSSL()
+ {
+ return false;
+ }
+ }
+
+
+ public static class TestBisocketClientInvoker extends BisocketClientInvoker
+ {
+ public TestBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException
+ {
+ super(locator, configuration);
+ }
+ public TestBisocketClientInvoker(InvokerLocator locator) throws IOException
+ {
+ super(locator);
+ }
+ public ServerAddress getServerAddress()
+ {
+ return address;
+ }
+ public String toString()
+ {
+ return "TestBisocketClientInvoker";
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketDefaultTimeoutTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketWriteTimeoutTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketWriteTimeoutTestCase.java 2010-08-05 01:25:58 UTC (rev 6005)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketWriteTimeoutTestCase.java 2010-08-05 01:26:37 UTC (rev 6006)
@@ -1,41 +1,41 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, 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.bisocket.timeout;
-
-import org.jboss.test.remoting.transport.socket.timeout.WriteTimeoutTestParent;
-
-/**
- * Unit tests for JBREM-1120.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Rev$
- * <p>
- * Copyright Apr 22, 2009
- * </p>
- */
-public class BisocketWriteTimeoutTestCase extends WriteTimeoutTestParent
-{
- protected String getTransport()
- {
- return "bisocket";
- }
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.bisocket.timeout;
+
+import org.jboss.test.remoting.transport.socket.timeout.WriteTimeoutTestParent;
+
+/**
+ * Unit tests for JBREM-1120.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Apr 22, 2009
+ * </p>
+ */
+public class BisocketWriteTimeoutTestCase extends WriteTimeoutTestParent
+{
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+}
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/timeout/BisocketWriteTimeoutTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6005 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:25:58 -0400 (Wed, 04 Aug 2010)
New Revision: 6005
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool/ServerThreadReuseTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool/ServerThreadReuseTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool/ServerThreadReuseTestCase.java 2010-08-05 01:25:20 UTC (rev 6004)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool/ServerThreadReuseTestCase.java 2010-08-05 01:25:58 UTC (rev 6005)
@@ -1,260 +1,260 @@
-/*
-* 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.bisocket.threadpool;
-
-import java.lang.reflect.Field;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.util.HashMap;
-import java.util.HashSet;
-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.callback.ServerInvokerCallbackHandler;
-import org.jboss.remoting.transport.Connector;
-import org.jboss.remoting.transport.PortUtil;
-import org.jboss.remoting.transport.bisocket.Bisocket;
-import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
-import org.jboss.remoting.transport.socket.LRUPool;
-import org.jboss.remoting.transport.socket.ServerThread;
-import org.jboss.remoting.transport.socket.SocketServerInvoker;
-
-
-/**
- * Unit test for JBREM-938.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Mar 22, 2008
- * </p>
- */
-public class ServerThreadReuseTestCase extends TestCase
-{
- private static Logger log = Logger.getLogger(ServerThreadReuseTestCase.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 testServerThreadReuse() throws Throwable
- {
- log.info("entering " + getName());
-
- // Start server.
- setupServer();
-
- // Create client.
- InvokerLocator clientLocator = new InvokerLocator(locatorURI);
- HashMap clientConfig = new HashMap();
- clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
- addExtraClientConfig(clientConfig);
- Client client = new Client(clientLocator, clientConfig);
- client.connect();
- log.info("client is connected");
-
- // Test connections.
- assertEquals("abc", client.invoke("abc"));
- log.info("connection is good");
-
- // Add callback handler.
- TestCallbackHandler callbackHandler = new TestCallbackHandler();
- HashMap metadata = new HashMap();
- metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
- client.addListener(callbackHandler, metadata, null, true);
- client.invoke("callback");
- assertEquals(1, callbackHandler.counter);
- log.info("first callback successful");
-
- // Get callback server thread pools.
- Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
- assertEquals(1, callbackConnectors.size());
- Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
- BisocketServerInvoker invoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
- Field field = SocketServerInvoker.class.getDeclaredField("threadpool");
- field.setAccessible(true);
- List threadpool = (List) field.get(invoker);
- field = SocketServerInvoker.class.getDeclaredField("clientpool");
- field.setAccessible(true);
- LRUPool clientpool = (LRUPool) field.get(invoker);
- assertEquals(0, threadpool.size());
- assertEquals(1, clientpool.size());
-
- // Kill worker thread's socket.
- Set clientpoolContents = clientpool.getContents();
- ServerThread serverThread1 = (ServerThread) clientpoolContents.iterator().next();
- field = ServerThread.class.getDeclaredField("socket");
- field.setAccessible(true);
- Socket socket = (Socket) field.get(serverThread1);
- socket.close();
- Thread.sleep(4000);
- assertEquals(1, threadpool.size());
- assertEquals(0, clientpool.size());
-
- // Make second callback and verify that worker thread gets reused.
- client.invoke("callback");
- assertEquals(2, callbackHandler.counter);
- log.info("second callback successful");
- assertEquals(0, threadpool.size());
- assertEquals(1, clientpool.size());
- clientpoolContents = clientpool.getContents();
- ServerThread serverThread2 = (ServerThread) clientpoolContents.iterator().next();
- assertEquals(serverThread2, serverThread1);
- log.info("ServerThread was reused");
-
- client.removeListener(callbackHandler);
- client.disconnect();
- shutdownServer();
- log.info(getName() + " PASSES");
- }
-
-
- protected String getTransport()
- {
- return "bisocket";
- }
-
-
- 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
- {
- HashSet callbackHandlers = new HashSet();
-
- public void addListener(InvokerCallbackHandler callbackHandler)
- {
- callbackHandlers.add(callbackHandler);
- }
-
- public Object invoke(final InvocationRequest invocation) throws Throwable
- {
- String command = (String) invocation.getParameter();
-
- if ("callback".equals(command))
- {
- Callback callback = new Callback("callback");
- Iterator it = callbackHandlers.iterator();
- while (it.hasNext())
- {
- ServerInvokerCallbackHandler handler;
- handler = (ServerInvokerCallbackHandler) it.next();
- handler.handleCallback(callback);
- }
- }
-
- return command;
- }
-
- public void removeListener(InvokerCallbackHandler callbackHandler)
- {
- callbackHandlers.remove(callbackHandler);
- }
-
-
- public void setMBeanServer(MBeanServer server) {}
- public void setInvoker(ServerInvoker invoker) {}
- }
-
-
- static class TestCallbackHandler implements InvokerCallbackHandler
- {
- public int counter;
-
- public void handleCallback(Callback callback) throws HandleCallbackException
- {
- counter++;
- 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.bisocket.threadpool;
+
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.util.HashMap;
+import java.util.HashSet;
+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.callback.ServerInvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.bisocket.Bisocket;
+import org.jboss.remoting.transport.bisocket.BisocketServerInvoker;
+import org.jboss.remoting.transport.socket.LRUPool;
+import org.jboss.remoting.transport.socket.ServerThread;
+import org.jboss.remoting.transport.socket.SocketServerInvoker;
+
+
+/**
+ * Unit test for JBREM-938.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Mar 22, 2008
+ * </p>
+ */
+public class ServerThreadReuseTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(ServerThreadReuseTestCase.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 testServerThreadReuse() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer();
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ // Add callback handler.
+ TestCallbackHandler callbackHandler = new TestCallbackHandler();
+ HashMap metadata = new HashMap();
+ metadata.put(Bisocket.IS_CALLBACK_SERVER, "true");
+ client.addListener(callbackHandler, metadata, null, true);
+ client.invoke("callback");
+ assertEquals(1, callbackHandler.counter);
+ log.info("first callback successful");
+
+ // Get callback server thread pools.
+ Set callbackConnectors = client.getCallbackConnectors(callbackHandler);
+ assertEquals(1, callbackConnectors.size());
+ Connector callbackConnector = (Connector) callbackConnectors.iterator().next();
+ BisocketServerInvoker invoker = (BisocketServerInvoker) callbackConnector.getServerInvoker();
+ Field field = SocketServerInvoker.class.getDeclaredField("threadpool");
+ field.setAccessible(true);
+ List threadpool = (List) field.get(invoker);
+ field = SocketServerInvoker.class.getDeclaredField("clientpool");
+ field.setAccessible(true);
+ LRUPool clientpool = (LRUPool) field.get(invoker);
+ assertEquals(0, threadpool.size());
+ assertEquals(1, clientpool.size());
+
+ // Kill worker thread's socket.
+ Set clientpoolContents = clientpool.getContents();
+ ServerThread serverThread1 = (ServerThread) clientpoolContents.iterator().next();
+ field = ServerThread.class.getDeclaredField("socket");
+ field.setAccessible(true);
+ Socket socket = (Socket) field.get(serverThread1);
+ socket.close();
+ Thread.sleep(4000);
+ assertEquals(1, threadpool.size());
+ assertEquals(0, clientpool.size());
+
+ // Make second callback and verify that worker thread gets reused.
+ client.invoke("callback");
+ assertEquals(2, callbackHandler.counter);
+ log.info("second callback successful");
+ assertEquals(0, threadpool.size());
+ assertEquals(1, clientpool.size());
+ clientpoolContents = clientpool.getContents();
+ ServerThread serverThread2 = (ServerThread) clientpoolContents.iterator().next();
+ assertEquals(serverThread2, serverThread1);
+ log.info("ServerThread was reused");
+
+ client.removeListener(callbackHandler);
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+
+
+ 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
+ {
+ HashSet callbackHandlers = new HashSet();
+
+ public void addListener(InvokerCallbackHandler callbackHandler)
+ {
+ callbackHandlers.add(callbackHandler);
+ }
+
+ public Object invoke(final InvocationRequest invocation) throws Throwable
+ {
+ String command = (String) invocation.getParameter();
+
+ if ("callback".equals(command))
+ {
+ Callback callback = new Callback("callback");
+ Iterator it = callbackHandlers.iterator();
+ while (it.hasNext())
+ {
+ ServerInvokerCallbackHandler handler;
+ handler = (ServerInvokerCallbackHandler) it.next();
+ handler.handleCallback(callback);
+ }
+ }
+
+ return command;
+ }
+
+ public void removeListener(InvokerCallbackHandler callbackHandler)
+ {
+ callbackHandlers.remove(callbackHandler);
+ }
+
+
+ public void setMBeanServer(MBeanServer server) {}
+ public void setInvoker(ServerInvoker invoker) {}
+ }
+
+
+ static class TestCallbackHandler implements InvokerCallbackHandler
+ {
+ public int counter;
+
+ public void handleCallback(Callback callback) throws HandleCallbackException
+ {
+ counter++;
+ log.info("received callback");
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/threadpool/ServerThreadReuseTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6004 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:25:20 -0400 (Wed, 04 Aug 2010)
New Revision: 6004
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketDefaultTimeoutTestCase.java
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketWriteTimeoutTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketDefaultTimeoutTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketDefaultTimeoutTestCase.java 2010-08-05 01:24:44 UTC (rev 6003)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketDefaultTimeoutTestCase.java 2010-08-05 01:25:20 UTC (rev 6004)
@@ -1,96 +1,96 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2010, 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.bisocket.ssl.timeout;
-
-import java.io.IOException;
-import java.util.Map;
-
-import org.apache.log4j.Logger;
-import org.jboss.remoting.InvokerLocator;
-import org.jboss.remoting.transport.ClientFactory;
-import org.jboss.remoting.transport.ClientInvoker;
-import org.jboss.remoting.transport.socket.ServerAddress;
-import org.jboss.remoting.transport.sslbisocket.SSLBisocketClientInvoker;
-import org.jboss.test.remoting.transport.socket.timeout.SocketDefaultTimeoutTestCase;
-
-
-/**
- * Unit tests for JBREM-1188.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Feb 16, 2010
- */
-public class SSLBisocketDefaultTimeoutTestCase extends SocketDefaultTimeoutTestCase
-{
- private static Logger log = Logger.getLogger(SSLBisocketDefaultTimeoutTestCase.class);
-
-
- protected Class getClientFactoryClass()
- {
- return TestSSLBisocketClientFactory.class;
- }
-
-
- protected Class getClientInvokerClass()
- {
- return TestSSLBisocketClientInvoker.class;
- }
-
-
- public static class TestSSLBisocketClientFactory implements ClientFactory
- {
- public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException
- {
- ClientInvoker clientInvoker = new TestSSLBisocketClientInvoker(locator, config);
- log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker);
- return clientInvoker;
- }
- public boolean supportsSSL()
- {
- return true;
- }
- }
-
-
- public static class TestSSLBisocketClientInvoker extends SSLBisocketClientInvoker
- {
- public TestSSLBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException
- {
- super(locator, configuration);
- }
- public TestSSLBisocketClientInvoker(InvokerLocator locator) throws IOException
- {
- super(locator);
- }
- public ServerAddress getServerAddress()
- {
- return address;
- }
- public String toString()
- {
- return "TestSSLBisocketClientInvoker";
- }
- }
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2010, 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.bisocket.ssl.timeout;
+
+import java.io.IOException;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.transport.ClientFactory;
+import org.jboss.remoting.transport.ClientInvoker;
+import org.jboss.remoting.transport.socket.ServerAddress;
+import org.jboss.remoting.transport.sslbisocket.SSLBisocketClientInvoker;
+import org.jboss.test.remoting.transport.socket.timeout.SocketDefaultTimeoutTestCase;
+
+
+/**
+ * Unit tests for JBREM-1188.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 16, 2010
+ */
+public class SSLBisocketDefaultTimeoutTestCase extends SocketDefaultTimeoutTestCase
+{
+ private static Logger log = Logger.getLogger(SSLBisocketDefaultTimeoutTestCase.class);
+
+
+ protected Class getClientFactoryClass()
+ {
+ return TestSSLBisocketClientFactory.class;
+ }
+
+
+ protected Class getClientInvokerClass()
+ {
+ return TestSSLBisocketClientInvoker.class;
+ }
+
+
+ public static class TestSSLBisocketClientFactory implements ClientFactory
+ {
+ public ClientInvoker createClientInvoker(InvokerLocator locator, Map config) throws IOException
+ {
+ ClientInvoker clientInvoker = new TestSSLBisocketClientInvoker(locator, config);
+ log.info("TestClientFaotory.createClientInvoker() returning " + clientInvoker);
+ return clientInvoker;
+ }
+ public boolean supportsSSL()
+ {
+ return true;
+ }
+ }
+
+
+ public static class TestSSLBisocketClientInvoker extends SSLBisocketClientInvoker
+ {
+ public TestSSLBisocketClientInvoker(InvokerLocator locator, Map configuration) throws IOException
+ {
+ super(locator, configuration);
+ }
+ public TestSSLBisocketClientInvoker(InvokerLocator locator) throws IOException
+ {
+ super(locator);
+ }
+ public ServerAddress getServerAddress()
+ {
+ return address;
+ }
+ public String toString()
+ {
+ return "TestSSLBisocketClientInvoker";
+ }
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketDefaultTimeoutTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketWriteTimeoutTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketWriteTimeoutTestCase.java 2010-08-05 01:24:44 UTC (rev 6003)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketWriteTimeoutTestCase.java 2010-08-05 01:25:20 UTC (rev 6004)
@@ -1,41 +1,41 @@
-/*
-* JBoss, Home of Professional Open Source
-* Copyright 2009, 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.bisocket.ssl.timeout;
-
-import org.jboss.test.remoting.transport.socket.timeout.SSLWriteTimeoutTestParent;
-
-/**
- * Unit tests for JBREM-1120.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Rev$
- * <p>
- * Copyright Apr 22, 2009
- * </p>
- */
-public class SSLBisocketWriteTimeoutTestCase extends SSLWriteTimeoutTestParent
-{
- protected String getTransport()
- {
- return "sslbisocket";
- }
-}
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2009, 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.bisocket.ssl.timeout;
+
+import org.jboss.test.remoting.transport.socket.timeout.SSLWriteTimeoutTestParent;
+
+/**
+ * Unit tests for JBREM-1120.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Rev$
+ * <p>
+ * Copyright Apr 22, 2009
+ * </p>
+ */
+public class SSLBisocketWriteTimeoutTestCase extends SSLWriteTimeoutTestParent
+{
+ protected String getTransport()
+ {
+ return "sslbisocket";
+ }
+}
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/timeout/SSLBisocketWriteTimeoutTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6003 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socketfactory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:24:44 -0400 (Wed, 04 Aug 2010)
New Revision: 6003
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/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/bisocket/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java 2010-08-05 01:24:14 UTC (rev 6002)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java 2010-08-05 01:24:44 UTC (rev 6003)
@@ -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.bisocket.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 "sslbisocket";
- }
-}
-
+
+/*
+* 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.bisocket.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 "sslbisocket";
+ }
+}
+
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/socketfactory/SSLSocketFactoryClassNameTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6002 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:24:14 -0400 (Wed, 04 Aug 2010)
New Revision: 6002
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java 2010-08-05 01:23:41 UTC (rev 6001)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java 2010-08-05 01:24:14 UTC (rev 6002)
@@ -1,425 +1,425 @@
-/*
- * 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.bisocket.ssl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.UnknownHostException;
-
-import javax.net.ServerSocketFactory;
-import javax.net.ssl.HandshakeCompletedListener;
-import javax.net.ssl.SSLServerSocket;
-import javax.net.ssl.SSLServerSocketFactory;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.SSLSocket;
-
-import org.jboss.logging.Logger;
-import org.jboss.remoting.security.SSLSocketBuilder;
-import org.jboss.test.remoting.transport.bisocket.BisocketControlConnectionReplacementTestCase;
-
-/**
- * Unit test for JBREM-1147.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version
- * <p>
- * Copyright Aug 14, 2009
- * </p>
- */
-public class SSLBisocketControlConnectionReplacementTestCase extends BisocketControlConnectionReplacementTestCase
-{
- private static Logger log = Logger.getLogger(SSLBisocketControlConnectionReplacementTestCase.class);
-
- public void setUp() throws Exception
- {
- if (firstTime)
- {
- String keyStoreFilePath = getClass().getResource(".keystore").getFile();
- System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath);
- System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server");
- String trustStoreFilePath = getClass().getResource(".truststore").getFile();
- System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
- System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client");
- }
- super.setUp();
- }
-
- protected String getTransport()
- {
- return "sslbisocket";
- }
-
- protected String getServerSocketName()
- {
- return SSLTestServerSocketFactory.class.getName();
- }
-
- static public class SSLTestServerSocketFactory extends ServerSocketFactory
- {
- int timeout;
- ServerSocketFactory factory;
- int initialWrites;
-
- public SSLTestServerSocketFactory() throws IOException
- {
- this.timeout = 5000;
- this.initialWrites = INITIAL_WRITES;
- setupFactory();
- }
- public SSLTestServerSocketFactory(int timeout, int initialWrites) throws IOException
- {
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- setupFactory();
- }
- public ServerSocket createServerSocket() throws IOException
- {
- ServerSocket ss = SSLServerSocketFactory.getDefault().createServerSocket();
- log.info("returning: " + ss);
- return ss;
- }
- public ServerSocket createServerSocket(int port) throws IOException
- {
- ServerSocket ss = null;
- if (port != secondaryServerSocketPort)
- {
- ss = SSLServerSocketFactory.getDefault().createServerSocket(port);
- }
- else
- {
- ss = new SSLTestServerSocket(port, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket()));
- }
- log.info("returning: " + ss);
- return ss;
- }
-
- public ServerSocket createServerSocket(int port, int backlog) throws IOException
- {
- ServerSocket ss = null;
- if (port != secondaryServerSocketPort)
- {
- ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog);
- }
- else
- {
- ss = new SSLTestServerSocket(port, backlog, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket()));
- }
- log.info("returning: " + ss);
- return ss;
- }
-
- public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
- {
- ServerSocket ss = null;
- if (port != secondaryServerSocketPort)
- {
- ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog, ifAddress);
- }
- else
- {
- ss = new SSLTestServerSocket(port, backlog, ifAddress, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket()));
- }
- log.info("returning: " + ss);
- return ss;
- }
-
- protected void setupFactory() throws IOException
- {
- SSLSocketBuilder sslSocketBuilder = new SSLSocketBuilder();
- sslSocketBuilder.setUseSSLServerSocketFactory(false);
- factory = sslSocketBuilder.createSSLServerSocketFactory();
- }
- }
-
-
- static class SSLTestServerSocket extends SSLServerSocket
- {
- int timeout;
- int initialWrites;
- SSLServerSocket serverSocket;
-
- public SSLTestServerSocket(int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
- {
- super();
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.serverSocket = serverSocket;
- }
- public SSLTestServerSocket(int port, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
- {
- super(port);
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.serverSocket = serverSocket;
- bind(new InetSocketAddress(port), 50);
- }
- public SSLTestServerSocket(int port, int backlog, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
- {
- super(port, backlog);
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.serverSocket = serverSocket;
- bind(new InetSocketAddress(port), backlog);
- }
- public SSLTestServerSocket(int port, int backlog, InetAddress bindAddr, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
- {
- super(port, backlog, bindAddr);
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.serverSocket = serverSocket;
- bind(new InetSocketAddress(bindAddr, port), 50);
- }
- public Socket accept() throws IOException
- {
- SSLSocket s1 = (SSLSocket) serverSocket.accept();
- Socket s2 = new SSLTestSocket(timeout, initialWrites, s1);
- return s2;
- }
- public void bind(SocketAddress endpoint, int backlog) throws IOException
- {
- log.info("serverSocket: " + serverSocket);
- if (serverSocket != null) log.info("bound: " + serverSocket.isBound());
- if (serverSocket != null && !serverSocket.isBound())
- {
- log.info("binding " + serverSocket);
- serverSocket.bind(endpoint, backlog);
- }
- }
- public String toString()
- {
- return "SSLTestServerSocket[" + serverSocket.toString() + "]";
- }
- public boolean getEnableSessionCreation()
- {
- return serverSocket.getEnableSessionCreation();
- }
- public String[] getEnabledCipherSuites()
- {
- return serverSocket.getEnabledCipherSuites();
- }
- public String[] getEnabledProtocols()
- {
- return serverSocket.getEnabledProtocols();
- }
- public boolean getNeedClientAuth()
- {
- return serverSocket.getNeedClientAuth();
- }
- public String[] getSupportedCipherSuites()
- {
- return serverSocket.getSupportedCipherSuites();
- }
- public String[] getSupportedProtocols()
- {
- return serverSocket.getSupportedProtocols();
- }
- public boolean getUseClientMode()
- {
- return serverSocket.getUseClientMode();
- }
- public boolean getWantClientAuth()
- {
- return serverSocket.getWantClientAuth();
- }
- public void setEnableSessionCreation(boolean arg0)
- {
- serverSocket.setEnableSessionCreation(arg0);
- }
- public void setEnabledCipherSuites(String[] arg0)
- {
- serverSocket.setEnabledCipherSuites(arg0);
- }
- public void setEnabledProtocols(String[] arg0)
- {
- serverSocket.setEnabledProtocols(arg0);
- }
- public void setNeedClientAuth(boolean arg0)
- {
- serverSocket.setNeedClientAuth(arg0);
- }
- public void setUseClientMode(boolean arg0)
- {
- serverSocket.setUseClientMode(arg0);
- }
- public void setWantClientAuth(boolean arg0)
- {
- serverSocket.setWantClientAuth(arg0);
- }
- }
-
- static class SSLTestSocket extends SSLSocket
- {
- int timeout;
- int initialWrites;
- SSLSocket socket;
- SocketAddress endpoint;
-
- public SSLTestSocket(int timeout, int initialWrites, SSLSocket socket)
- {
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.socket = socket;
- }
- public SSLTestSocket(String host, int port, int timeout, int initialWrites, SSLSocket socket) throws UnknownHostException, IOException
- {
- super(host, port);
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.socket = socket;
- connect(new InetSocketAddress(host, port), timeout);
- }
- public SSLTestSocket(InetAddress address, int port, int timeout, int initialWrites, SSLSocket socket) throws IOException
- {
- super(address, port);
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.socket = socket;
- connect(new InetSocketAddress(address, port), timeout);
- }
- public SSLTestSocket(String host, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException
- {
- super(host, port, localAddr, localPort);
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.socket = socket;
- bind(new InetSocketAddress(localAddr, localPort));
- connect(new InetSocketAddress(host, port), timeout);
- }
- public SSLTestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException
- {
- super(address, port, localAddr, localPort);
- this.timeout = timeout;
- this.initialWrites = initialWrites;
- this.socket = socket;
- bind(new InetSocketAddress(localAddr, localPort));
- connect(new InetSocketAddress(address, port), timeout);
- }
- public String toString()
- {
- return "SSLTestSocket[" + socket.toString() + "]";
- }
- public InputStream getInputStream() throws IOException
- {
- return socket.getInputStream();
- }
- public OutputStream getOutputStream() throws IOException
- {
- return new TestOutputStream(socket.getOutputStream(), timeout, initialWrites);
- }
- public void addHandshakeCompletedListener(HandshakeCompletedListener listener)
- {
- socket.addHandshakeCompletedListener(listener);
- }
- public void bind(SocketAddress bindpoint) throws IOException
- {
- if (socket != null)
- socket.bind(bindpoint);
- }
- public void connect(SocketAddress endpoint) throws IOException
- {
- if (socket != null)
- socket.connect(endpoint);
- }
- public void connect(SocketAddress endpoint, int timeout) throws IOException
- {
- socket.connect(endpoint, timeout);
- }
- public boolean getEnableSessionCreation()
- {
- return socket.getEnableSessionCreation();
- }
- public String[] getEnabledCipherSuites()
- {
- return socket.getEnabledCipherSuites();
- }
- public String[] getEnabledProtocols()
- {
- return socket.getEnabledProtocols();
- }
- public InetAddress getInetAddress()
- {
- return socket.getInetAddress();
- }
- public boolean getNeedClientAuth()
- {
- return socket.getNeedClientAuth();
- }
- public SSLSession getSession()
- {
- return socket.getSession();
- }
- public String[] getSupportedCipherSuites()
- {
- return socket.getSupportedCipherSuites();
- }
- public String[] getSupportedProtocols()
- {
- return socket.getSupportedProtocols();
- }
- public boolean getUseClientMode()
- {
- return socket.getUseClientMode();
- }
- public boolean getWantClientAuth()
- {
- return socket.getWantClientAuth();
- }
- public void removeHandshakeCompletedListener(HandshakeCompletedListener listener)
- {
- socket.removeHandshakeCompletedListener(listener);
- }
- public void setEnableSessionCreation(boolean flag)
- {
- socket.setEnableSessionCreation(flag);
- }
- public void setEnabledCipherSuites(String[] suites)
- {
- socket.setEnabledCipherSuites(suites);
- }
- public void setEnabledProtocols(String[] protocols)
- {
- socket.setEnabledProtocols(protocols);
- }
- public void setNeedClientAuth(boolean need)
- {
- socket.setNeedClientAuth(need);
- }
- public void setUseClientMode(boolean mode)
- {
- socket.setUseClientMode(mode);
- }
- public void setWantClientAuth(boolean want)
- {
- socket.setWantClientAuth(want);
- }
- public void startHandshake() throws IOException
- {
- socket.startHandshake();
- }
- }
-}
+/*
+ * 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.bisocket.ssl;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.net.SocketAddress;
+import java.net.UnknownHostException;
+
+import javax.net.ServerSocketFactory;
+import javax.net.ssl.HandshakeCompletedListener;
+import javax.net.ssl.SSLServerSocket;
+import javax.net.ssl.SSLServerSocketFactory;
+import javax.net.ssl.SSLSession;
+import javax.net.ssl.SSLSocket;
+
+import org.jboss.logging.Logger;
+import org.jboss.remoting.security.SSLSocketBuilder;
+import org.jboss.test.remoting.transport.bisocket.BisocketControlConnectionReplacementTestCase;
+
+/**
+ * Unit test for JBREM-1147.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version
+ * <p>
+ * Copyright Aug 14, 2009
+ * </p>
+ */
+public class SSLBisocketControlConnectionReplacementTestCase extends BisocketControlConnectionReplacementTestCase
+{
+ private static Logger log = Logger.getLogger(SSLBisocketControlConnectionReplacementTestCase.class);
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ String keyStoreFilePath = getClass().getResource(".keystore").getFile();
+ System.setProperty("javax.net.ssl.keyStore", keyStoreFilePath);
+ System.setProperty("javax.net.ssl.keyStorePassword", "unit-tests-server");
+ String trustStoreFilePath = getClass().getResource(".truststore").getFile();
+ System.setProperty("javax.net.ssl.trustStore", trustStoreFilePath);
+ System.setProperty("javax.net.ssl.trustStorePassword", "unit-tests-client");
+ }
+ super.setUp();
+ }
+
+ protected String getTransport()
+ {
+ return "sslbisocket";
+ }
+
+ protected String getServerSocketName()
+ {
+ return SSLTestServerSocketFactory.class.getName();
+ }
+
+ static public class SSLTestServerSocketFactory extends ServerSocketFactory
+ {
+ int timeout;
+ ServerSocketFactory factory;
+ int initialWrites;
+
+ public SSLTestServerSocketFactory() throws IOException
+ {
+ this.timeout = 5000;
+ this.initialWrites = INITIAL_WRITES;
+ setupFactory();
+ }
+ public SSLTestServerSocketFactory(int timeout, int initialWrites) throws IOException
+ {
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ setupFactory();
+ }
+ public ServerSocket createServerSocket() throws IOException
+ {
+ ServerSocket ss = SSLServerSocketFactory.getDefault().createServerSocket();
+ log.info("returning: " + ss);
+ return ss;
+ }
+ public ServerSocket createServerSocket(int port) throws IOException
+ {
+ ServerSocket ss = null;
+ if (port != secondaryServerSocketPort)
+ {
+ ss = SSLServerSocketFactory.getDefault().createServerSocket(port);
+ }
+ else
+ {
+ ss = new SSLTestServerSocket(port, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket()));
+ }
+ log.info("returning: " + ss);
+ return ss;
+ }
+
+ public ServerSocket createServerSocket(int port, int backlog) throws IOException
+ {
+ ServerSocket ss = null;
+ if (port != secondaryServerSocketPort)
+ {
+ ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog);
+ }
+ else
+ {
+ ss = new SSLTestServerSocket(port, backlog, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket()));
+ }
+ log.info("returning: " + ss);
+ return ss;
+ }
+
+ public ServerSocket createServerSocket(int port, int backlog, InetAddress ifAddress) throws IOException
+ {
+ ServerSocket ss = null;
+ if (port != secondaryServerSocketPort)
+ {
+ ss = SSLServerSocketFactory.getDefault().createServerSocket(port, backlog, ifAddress);
+ }
+ else
+ {
+ ss = new SSLTestServerSocket(port, backlog, ifAddress, timeout, initialWrites, ((SSLServerSocket) factory.createServerSocket()));
+ }
+ log.info("returning: " + ss);
+ return ss;
+ }
+
+ protected void setupFactory() throws IOException
+ {
+ SSLSocketBuilder sslSocketBuilder = new SSLSocketBuilder();
+ sslSocketBuilder.setUseSSLServerSocketFactory(false);
+ factory = sslSocketBuilder.createSSLServerSocketFactory();
+ }
+ }
+
+
+ static class SSLTestServerSocket extends SSLServerSocket
+ {
+ int timeout;
+ int initialWrites;
+ SSLServerSocket serverSocket;
+
+ public SSLTestServerSocket(int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
+ {
+ super();
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.serverSocket = serverSocket;
+ }
+ public SSLTestServerSocket(int port, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
+ {
+ super(port);
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.serverSocket = serverSocket;
+ bind(new InetSocketAddress(port), 50);
+ }
+ public SSLTestServerSocket(int port, int backlog, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
+ {
+ super(port, backlog);
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.serverSocket = serverSocket;
+ bind(new InetSocketAddress(port), backlog);
+ }
+ public SSLTestServerSocket(int port, int backlog, InetAddress bindAddr, int timeout, int initialWrites, SSLServerSocket serverSocket) throws IOException
+ {
+ super(port, backlog, bindAddr);
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.serverSocket = serverSocket;
+ bind(new InetSocketAddress(bindAddr, port), 50);
+ }
+ public Socket accept() throws IOException
+ {
+ SSLSocket s1 = (SSLSocket) serverSocket.accept();
+ Socket s2 = new SSLTestSocket(timeout, initialWrites, s1);
+ return s2;
+ }
+ public void bind(SocketAddress endpoint, int backlog) throws IOException
+ {
+ log.info("serverSocket: " + serverSocket);
+ if (serverSocket != null) log.info("bound: " + serverSocket.isBound());
+ if (serverSocket != null && !serverSocket.isBound())
+ {
+ log.info("binding " + serverSocket);
+ serverSocket.bind(endpoint, backlog);
+ }
+ }
+ public String toString()
+ {
+ return "SSLTestServerSocket[" + serverSocket.toString() + "]";
+ }
+ public boolean getEnableSessionCreation()
+ {
+ return serverSocket.getEnableSessionCreation();
+ }
+ public String[] getEnabledCipherSuites()
+ {
+ return serverSocket.getEnabledCipherSuites();
+ }
+ public String[] getEnabledProtocols()
+ {
+ return serverSocket.getEnabledProtocols();
+ }
+ public boolean getNeedClientAuth()
+ {
+ return serverSocket.getNeedClientAuth();
+ }
+ public String[] getSupportedCipherSuites()
+ {
+ return serverSocket.getSupportedCipherSuites();
+ }
+ public String[] getSupportedProtocols()
+ {
+ return serverSocket.getSupportedProtocols();
+ }
+ public boolean getUseClientMode()
+ {
+ return serverSocket.getUseClientMode();
+ }
+ public boolean getWantClientAuth()
+ {
+ return serverSocket.getWantClientAuth();
+ }
+ public void setEnableSessionCreation(boolean arg0)
+ {
+ serverSocket.setEnableSessionCreation(arg0);
+ }
+ public void setEnabledCipherSuites(String[] arg0)
+ {
+ serverSocket.setEnabledCipherSuites(arg0);
+ }
+ public void setEnabledProtocols(String[] arg0)
+ {
+ serverSocket.setEnabledProtocols(arg0);
+ }
+ public void setNeedClientAuth(boolean arg0)
+ {
+ serverSocket.setNeedClientAuth(arg0);
+ }
+ public void setUseClientMode(boolean arg0)
+ {
+ serverSocket.setUseClientMode(arg0);
+ }
+ public void setWantClientAuth(boolean arg0)
+ {
+ serverSocket.setWantClientAuth(arg0);
+ }
+ }
+
+ static class SSLTestSocket extends SSLSocket
+ {
+ int timeout;
+ int initialWrites;
+ SSLSocket socket;
+ SocketAddress endpoint;
+
+ public SSLTestSocket(int timeout, int initialWrites, SSLSocket socket)
+ {
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.socket = socket;
+ }
+ public SSLTestSocket(String host, int port, int timeout, int initialWrites, SSLSocket socket) throws UnknownHostException, IOException
+ {
+ super(host, port);
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.socket = socket;
+ connect(new InetSocketAddress(host, port), timeout);
+ }
+ public SSLTestSocket(InetAddress address, int port, int timeout, int initialWrites, SSLSocket socket) throws IOException
+ {
+ super(address, port);
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.socket = socket;
+ connect(new InetSocketAddress(address, port), timeout);
+ }
+ public SSLTestSocket(String host, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException
+ {
+ super(host, port, localAddr, localPort);
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.socket = socket;
+ bind(new InetSocketAddress(localAddr, localPort));
+ connect(new InetSocketAddress(host, port), timeout);
+ }
+ public SSLTestSocket(InetAddress address, int port, InetAddress localAddr, int localPort, int timeout, int initialWrites, SSLSocket socket) throws IOException
+ {
+ super(address, port, localAddr, localPort);
+ this.timeout = timeout;
+ this.initialWrites = initialWrites;
+ this.socket = socket;
+ bind(new InetSocketAddress(localAddr, localPort));
+ connect(new InetSocketAddress(address, port), timeout);
+ }
+ public String toString()
+ {
+ return "SSLTestSocket[" + socket.toString() + "]";
+ }
+ public InputStream getInputStream() throws IOException
+ {
+ return socket.getInputStream();
+ }
+ public OutputStream getOutputStream() throws IOException
+ {
+ return new TestOutputStream(socket.getOutputStream(), timeout, initialWrites);
+ }
+ public void addHandshakeCompletedListener(HandshakeCompletedListener listener)
+ {
+ socket.addHandshakeCompletedListener(listener);
+ }
+ public void bind(SocketAddress bindpoint) throws IOException
+ {
+ if (socket != null)
+ socket.bind(bindpoint);
+ }
+ public void connect(SocketAddress endpoint) throws IOException
+ {
+ if (socket != null)
+ socket.connect(endpoint);
+ }
+ public void connect(SocketAddress endpoint, int timeout) throws IOException
+ {
+ socket.connect(endpoint, timeout);
+ }
+ public boolean getEnableSessionCreation()
+ {
+ return socket.getEnableSessionCreation();
+ }
+ public String[] getEnabledCipherSuites()
+ {
+ return socket.getEnabledCipherSuites();
+ }
+ public String[] getEnabledProtocols()
+ {
+ return socket.getEnabledProtocols();
+ }
+ public InetAddress getInetAddress()
+ {
+ return socket.getInetAddress();
+ }
+ public boolean getNeedClientAuth()
+ {
+ return socket.getNeedClientAuth();
+ }
+ public SSLSession getSession()
+ {
+ return socket.getSession();
+ }
+ public String[] getSupportedCipherSuites()
+ {
+ return socket.getSupportedCipherSuites();
+ }
+ public String[] getSupportedProtocols()
+ {
+ return socket.getSupportedProtocols();
+ }
+ public boolean getUseClientMode()
+ {
+ return socket.getUseClientMode();
+ }
+ public boolean getWantClientAuth()
+ {
+ return socket.getWantClientAuth();
+ }
+ public void removeHandshakeCompletedListener(HandshakeCompletedListener listener)
+ {
+ socket.removeHandshakeCompletedListener(listener);
+ }
+ public void setEnableSessionCreation(boolean flag)
+ {
+ socket.setEnableSessionCreation(flag);
+ }
+ public void setEnabledCipherSuites(String[] suites)
+ {
+ socket.setEnabledCipherSuites(suites);
+ }
+ public void setEnabledProtocols(String[] protocols)
+ {
+ socket.setEnabledProtocols(protocols);
+ }
+ public void setNeedClientAuth(boolean need)
+ {
+ socket.setNeedClientAuth(need);
+ }
+ public void setUseClientMode(boolean mode)
+ {
+ socket.setUseClientMode(mode);
+ }
+ public void setWantClientAuth(boolean want)
+ {
+ socket.setWantClientAuth(want);
+ }
+ public void startHandshake() throws IOException
+ {
+ socket.startHandshake();
+ }
+ }
+}
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/SSLBisocketControlConnectionReplacementTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months
JBoss Remoting SVN: r6001 - remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2010-08-04 21:23:41 -0400 (Wed, 04 Aug 2010)
New Revision: 6001
Modified:
remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketClientPoolWithSemaphoreTestCase.java
Log:
JBREM-1241: Added svn:eol-style subversion property.
Modified: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketClientPoolWithSemaphoreTestCase.java
===================================================================
--- remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketClientPoolWithSemaphoreTestCase.java 2010-08-05 01:22:58 UTC (rev 6000)
+++ remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketClientPoolWithSemaphoreTestCase.java 2010-08-05 01:23:41 UTC (rev 6001)
@@ -1,42 +1,42 @@
-/*
-* 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.bisocket.socketpool;
-
-import org.jboss.test.remoting.transport.socket.socketpool.SocketClientPoolWithSemaphoreTestCase;
-
-
-/**
- * Unit test for JBREM-845.
- *
- * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
- * @version $Revision: 1.1 $
- * <p>
- * Copyright Nov 30, 2007
- * </p>
- */
-public class BisocketClientPoolWithSemaphoreTestCase extends SocketClientPoolWithSemaphoreTestCase
-{
- public String getTransport()
- {
- return "bisocket";
- }
+/*
+* 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.bisocket.socketpool;
+
+import org.jboss.test.remoting.transport.socket.socketpool.SocketClientPoolWithSemaphoreTestCase;
+
+
+/**
+ * Unit test for JBREM-845.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Nov 30, 2007
+ * </p>
+ */
+public class BisocketClientPoolWithSemaphoreTestCase extends SocketClientPoolWithSemaphoreTestCase
+{
+ public String getTransport()
+ {
+ return "bisocket";
+ }
}
\ No newline at end of file
Property changes on: remoting2/branches/2.2/src/tests/org/jboss/test/remoting/transport/bisocket/socketpool/BisocketClientPoolWithSemaphoreTestCase.java
___________________________________________________________________
Name: svn:eol-style
+ native
14 years, 3 months