JBoss Remoting SVN: r3546 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket: ssl/config and 1 other directory.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 16:35:37 -0500 (Fri, 29 Feb 2008)
New Revision: 3546
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java
Log:
JBREM-703: Treat receiveBufferSize, sendBufferSize, and trafficClass as suggestions.
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java 2008-02-29 21:34:13 UTC (rev 3545)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java 2008-02-29 21:35:37 UTC (rev 3546)
@@ -174,13 +174,23 @@
{
assertTrue(s.getKeepAlive());
assertTrue(s.getOOBInline());
- assertEquals(2345, s.getReceiveBufferSize());
- assertEquals(3456, s.getSendBufferSize());
+ suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize");
+ suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize");
assertEquals(4567, s.getSoLinger());
- assertEquals(0, s.getTrafficClass());
+ suggestEquals(0, s.getTrafficClass(), "trafficClass");
}
+ protected void suggestEquals(int i1, int i2, String s)
+ {
+ if (i1 != i2)
+ {
+ log.warn(s + " has not been set: expected " + i1 + ", got " + i2);
+ log.warn("note that setting \"" + s + "\" is just a suggestion to the underlying network code");
+ }
+ }
+
+
protected String getTransport()
{
return "socket";
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java 2008-02-29 21:34:13 UTC (rev 3545)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java 2008-02-29 21:35:37 UTC (rev 3546)
@@ -146,13 +146,23 @@
{
assertTrue(s.getKeepAlive());
assertTrue(s.getOOBInline());
- assertEquals(2345, s.getReceiveBufferSize());
- assertEquals(3456, s.getSendBufferSize());
+ suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize");
+ suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize");
assertEquals(4567, s.getSoLinger());
- assertEquals(0, s.getTrafficClass());
+ suggestEquals(0, s.getTrafficClass(), "trafficClass");
}
+ protected void suggestEquals(int i1, int i2, String s)
+ {
+ if (i1 != i2)
+ {
+ log.warn(s + " has not been set: expected " + i1 + ", got " + i2);
+ log.warn("note that setting \"" + s + "\" is just a suggestion to the underlying network code");
+ }
+ }
+
+
protected String getTransport()
{
return "socket";
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java 2008-02-29 21:34:13 UTC (rev 3545)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java 2008-02-29 21:35:37 UTC (rev 3546)
@@ -109,10 +109,10 @@
protected void doSocketTest(Socket s) throws SocketException
{
assertTrue(s.getKeepAlive());
- assertEquals(2345, s.getReceiveBufferSize());
- assertEquals(3456, s.getSendBufferSize());
+ suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize");
+ suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize");
assertEquals(4567, s.getSoLinger());
- assertEquals(0, s.getTrafficClass());
+ suggestEquals(0, s.getTrafficClass(), "trafficClass");
assertTrue(s instanceof SSLSocket);
SSLSocket ss = (SSLSocket) s;
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java 2008-02-29 21:34:13 UTC (rev 3545)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java 2008-02-29 21:35:37 UTC (rev 3546)
@@ -126,10 +126,10 @@
protected void doSocketTest(Socket s) throws SocketException
{
assertTrue(s.getKeepAlive());
- assertEquals(2345, s.getReceiveBufferSize());
- assertEquals(3456, s.getSendBufferSize());
+ suggestEquals(2345, s.getReceiveBufferSize(), "receiveBufferSize");
+ suggestEquals(3456, s.getSendBufferSize(), "sendBufferSize");
assertEquals(4567, s.getSoLinger());
- assertEquals(0, s.getTrafficClass());
+ suggestEquals(0, s.getTrafficClass(), "trafficClass");
assertTrue(s instanceof SSLSocket);
SSLSocket ss = (SSLSocket) s;
16 years, 10 months
JBoss Remoting SVN: r3545 - remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 16:34:13 -0500 (Fri, 29 Feb 2008)
New Revision: 3545
Modified:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java
Log:
JBREM-703: Changed "sslsocket" to "sslbisocket".
Modified: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java 2008-02-29 21:34:13 UTC (rev 3545)
@@ -38,6 +38,6 @@
{
protected String getTransport()
{
- return "sslsocket";
+ return "sslbisocket";
}
}
\ No newline at end of file
16 years, 10 months
JBoss Remoting SVN: r3544 - in remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport: bisocket/ssl/config and 2 other directories.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:27:41 -0500 (Fri, 29 Feb 2008)
New Revision: 3544
Added:
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketServerSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketServerSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java
remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java
Log:
JBREM-703: New unit test.
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketServerSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketServerSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketServerSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,43 @@
+/*
+* 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.configuration;
+
+import org.jboss.test.remoting.transport.socket.configuration.SocketServerSocketConfigurationTestCase;
+
+
+/**
+ * Unit test for JBREM-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class BisocketServerSocketConfigurationTestCase
+extends SocketServerSocketConfigurationTestCase
+{
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/configuration/BisocketSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,43 @@
+/*
+* 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.configuration;
+
+import org.jboss.test.remoting.transport.socket.configuration.SocketSocketConfigurationTestCase;
+
+
+/**
+ * Unit test for JBREM-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class BisocketSocketConfigurationTestCase
+extends SocketSocketConfigurationTestCase
+{
+ protected String getTransport()
+ {
+ return "bisocket";
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketServerSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketServerSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketServerSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,54 @@
+/*
+* 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.config;
+
+import org.jboss.remoting.transport.socket.SocketServerInvoker;
+import org.jboss.remoting.transport.sslbisocket.SSLBisocketServerInvoker;
+import org.jboss.test.remoting.transport.socket.ssl.config.SSLSocketServerSocketConfigurationTestCase;
+
+
+/**
+ * Unit test for JBREM-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class SSLBisocketServerSocketConfigurationTestCase
+extends SSLSocketServerSocketConfigurationTestCase
+{
+ protected String getTransport()
+ {
+ return "sslbisocket";
+ }
+
+ protected void configureServerInvoker(SocketServerInvoker invoker)
+ {
+ super.configureServerInvoker(invoker);
+ SSLBisocketServerInvoker sslInvoker = (SSLBisocketServerInvoker) invoker;
+ sslInvoker.setEnabledCipherSuites(cipherSuites);
+ sslInvoker.setEnabledProtocols(protocols);
+ sslInvoker.setEnableSessionCreation(true);
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/bisocket/ssl/config/SSLBisocketSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,43 @@
+/*
+* 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.config;
+
+import org.jboss.test.remoting.transport.socket.ssl.config.SSLSocketSocketConfigurationTestCase;
+
+
+/**
+ * Unit test for JBREM-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class SSLBisocketSocketConfigurationTestCase
+extends SSLSocketSocketConfigurationTestCase
+{
+ protected String getTransport()
+ {
+ return "sslsocket";
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketServerSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,265 @@
+/*
+* 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.socket.configuration;
+
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.HashMap;
+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.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+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-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class SocketServerSocketConfigurationTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(SocketServerSocketConfigurationTestCase.class);
+
+ protected static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testConfigureByConfigMap() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(true);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker();
+ Field field = SocketServerInvoker.class.getDeclaredField("clientpool");
+ field.setAccessible(true);
+ LRUPool pool = (LRUPool) field.get(invoker);
+ Set keys = pool.getContents();
+ assertEquals(1, keys.size());
+ ServerThread t = (ServerThread) keys.iterator().next();
+ field = ServerThread.class.getDeclaredField("socket");
+ field.setAccessible(true);
+ Socket socket = (Socket) field.get(t);
+ doSocketTest(socket);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ public void testConfigureBySetter() throws Throwable
+ {
+ log.info("entering " + getName());
+
+ // Start server.
+ setupServer(false);
+
+ // Create client.
+ InvokerLocator clientLocator = new InvokerLocator(locatorURI);
+ HashMap clientConfig = new HashMap();
+ clientConfig.put(InvokerLocator.FORCE_REMOTE, "true");
+ addExtraClientConfig(clientConfig);
+ Client client = new Client(clientLocator, clientConfig);
+ client.connect();
+ log.info("client is connected");
+
+ // Test connections.
+ assertEquals("abc", client.invoke("abc"));
+ log.info("connection is good");
+
+ SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker();
+ Field field = SocketServerInvoker.class.getDeclaredField("clientpool");
+ field.setAccessible(true);
+ LRUPool pool = (LRUPool) field.get(invoker);
+ Set keys = pool.getContents();
+ assertEquals(1, keys.size());
+ ServerThread t = (ServerThread) keys.iterator().next();
+ field = ServerThread.class.getDeclaredField("socket");
+ field.setAccessible(true);
+ Socket socket = (Socket) field.get(t);
+ doSocketTest(socket);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void doSocketTest(Socket s) throws SocketException
+ {
+ assertTrue(s.getKeepAlive());
+ assertTrue(s.getOOBInline());
+ assertEquals(2345, s.getReceiveBufferSize());
+ assertEquals(3456, s.getSendBufferSize());
+ assertEquals(4567, s.getSoLinger());
+ assertEquals(0, s.getTrafficClass());
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer(boolean useConfigMap) throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ serverLocator = new InvokerLocator(locatorURI);
+ log.info("Starting remoting server with locator uri of: " + locatorURI);
+ HashMap config = new HashMap();
+ config.put(InvokerLocator.FORCE_REMOTE, "true");
+ if (useConfigMap)
+ {
+ addServerSocketConfig(config);
+ }
+ addExtraServerConfig(config);
+ connector = new Connector(serverLocator, config);
+ connector.create();
+ if (!useConfigMap)
+ {
+ SocketServerInvoker invoker = (SocketServerInvoker) connector.getServerInvoker();
+ configureServerInvoker(invoker);
+ }
+ invocationHandler = new TestInvocationHandler();
+ connector.addInvocationHandler("test", invocationHandler);
+ connector.start();
+ }
+
+
+ protected void addServerSocketConfig(Map config)
+ {
+ config.put("keepAlive", "true");
+ config.put("oOBInline", "true");
+ config.put("receiveBufferSize", "2345");
+ config.put("sendBufferSize", "3456");
+ config.put("soLinger", "true");
+ config.put("soLingerDuration", "4567");
+ config.put("trafficClass", "0");
+ }
+
+
+ protected void configureServerInvoker(SocketServerInvoker invoker)
+ {
+ invoker.setReceiveBufferSize(12345);
+
+ invoker.setKeepAlive(true);
+ invoker.setOOBInline(true);
+ invoker.setReceiveBufferSize(2345);
+ invoker.setSendBufferSize(3456);
+ invoker.setSoLinger(true);
+ invoker.setSoLingerDuration(4567);
+ invoker.setTrafficClass(0);
+ }
+
+
+ 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
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/configuration/SocketSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,202 @@
+/*
+* 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.socket.configuration;
+
+import java.lang.reflect.Field;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+
+import junit.framework.TestCase;
+
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.jboss.logging.XLevel;
+import org.jboss.remoting.Client;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.transport.Connector;
+import org.jboss.remoting.transport.PortUtil;
+import org.jboss.remoting.transport.socket.MicroSocketClientInvoker;
+import org.jboss.remoting.transport.socket.SocketWrapper;
+
+
+/**
+ * Unit test for JBREM-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class SocketSocketConfigurationTestCase extends TestCase
+{
+ private static Logger log = Logger.getLogger(SocketSocketConfigurationTestCase.class);
+
+ protected static boolean firstTime = true;
+
+ protected String host;
+ protected int port;
+ protected String locatorURI;
+ protected InvokerLocator serverLocator;
+ protected Connector connector;
+ protected TestInvocationHandler invocationHandler;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ firstTime = false;
+ Logger.getLogger("org.jboss.remoting").setLevel(XLevel.INFO);
+ Logger.getLogger("org.jboss.test.remoting").setLevel(Level.INFO);
+ String pattern = "[%d{ABSOLUTE}] [%t] %5p (%F:%L) - %m%n";
+ PatternLayout layout = new PatternLayout(pattern);
+ ConsoleAppender consoleAppender = new ConsoleAppender(layout);
+ Logger.getRootLogger().addAppender(consoleAppender);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ public void testConfigureByConfigMap() 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");
+ setupClient(clientConfig);
+ 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");
+
+ assertTrue(client.getInvoker() instanceof MicroSocketClientInvoker);
+ MicroSocketClientInvoker invoker = (MicroSocketClientInvoker) client.getInvoker();
+ Field field = MicroSocketClientInvoker.class.getDeclaredField("pool");
+ field.setAccessible(true);
+ LinkedList pool = (LinkedList) field.get(invoker);
+ assertTrue(pool.size() > 0);
+ SocketWrapper socketWrapper = (SocketWrapper) pool.get(0);
+ Socket socket = socketWrapper.getSocket();
+ doSocketTest(socket);
+
+ client.disconnect();
+ shutdownServer();
+ log.info(getName() + " PASSES");
+ }
+
+
+ protected void setupClient(Map config)
+ {
+ config.put("keepAlive", "true");
+ config.put("oOBInline", "true");
+ config.put("receiveBufferSize", "2345");
+ config.put("sendBufferSize", "3456");
+ config.put("soLinger", "true");
+ config.put("soLingerDuration", "4567");
+ config.put("trafficClass", "0");
+ }
+
+
+ protected void doSocketTest(Socket s) throws SocketException
+ {
+ assertTrue(s.getKeepAlive());
+ assertTrue(s.getOOBInline());
+ assertEquals(2345, s.getReceiveBufferSize());
+ assertEquals(3456, s.getSendBufferSize());
+ assertEquals(4567, s.getSoLinger());
+ assertEquals(0, s.getTrafficClass());
+ }
+
+
+ protected String getTransport()
+ {
+ return "socket";
+ }
+
+
+ protected void addExtraClientConfig(Map config) {}
+ protected void addExtraServerConfig(Map config) {}
+
+
+ protected void setupServer() throws Exception
+ {
+ host = InetAddress.getLocalHost().getHostAddress();
+ port = PortUtil.findFreePort(host);
+ locatorURI = getTransport() + "://" + host + ":" + port;
+ 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) {}
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketServerSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,193 @@
+/*
+* 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.socket.ssl.config;
+
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.HashSet;
+import java.util.Map;
+
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.security.SSLSocketBuilder;
+import org.jboss.remoting.transport.socket.SocketServerInvoker;
+import org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker;
+import org.jboss.test.remoting.transport.socket.configuration.SocketServerSocketConfigurationTestCase;
+
+
+/**
+ * Unit test for JBREM-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class SSLSocketServerSocketConfigurationTestCase
+extends SocketServerSocketConfigurationTestCase
+{
+ private static Logger log = Logger.getLogger(SSLSocketServerSocketConfigurationTestCase.class);
+
+ static protected String[] cipherSuites;
+ static protected String[] protocols;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ super.setUp();
+
+ SSLSocket s = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
+
+ String[] strings = s.getSupportedCipherSuites();
+ log.info("supported cipher suites: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ strings = s.getEnabledCipherSuites();
+ log.info("enabled cipher suites: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ strings = s.getSupportedProtocols();
+ log.info("supported protocols: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ strings = s.getEnabledProtocols();
+ log.info("enabled protocols: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+
+ strings = s.getSupportedCipherSuites();
+ int len = strings.length - 1;
+ cipherSuites = new String[len];
+ for (int i = 0; i < len; i++)
+ cipherSuites[i] = strings[i];
+
+ strings = s.getSupportedProtocols();
+ len = strings.length - 1;
+ protocols = new String[len];
+ for (int i = 0; i < len; i++)
+ protocols[i] = strings[i];
+
+ log.info("using cipherSuites: ");
+ for (int i = 0; i < cipherSuites.length; i++)
+ log.info(" " + cipherSuites[i]);
+ log.info("using protocols: ");
+ for (int i = 0; i < protocols.length; i++)
+ log.info(" " + protocols[i]);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ protected void doSocketTest(Socket s) throws SocketException
+ {
+ assertTrue(s.getKeepAlive());
+ assertEquals(2345, s.getReceiveBufferSize());
+ assertEquals(3456, s.getSendBufferSize());
+ assertEquals(4567, s.getSoLinger());
+ assertEquals(0, s.getTrafficClass());
+
+ assertTrue(s instanceof SSLSocket);
+ SSLSocket ss = (SSLSocket) s;
+ assertTrue(ss.getEnableSessionCreation());
+
+ log.info("actual enabledCipherSuites: ");
+ String[] strings = ss.getEnabledCipherSuites();
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ assertEquals(cipherSuites, ss.getEnabledCipherSuites());
+ assertEquals(protocols, ss.getEnabledProtocols());
+ }
+
+
+ protected void assertEquals(String[] strings1, String[] strings2)
+ {
+ HashSet set1 = new HashSet();
+ for (int i = 0; i < strings1.length; i++)
+ set1.add(strings1[i]);
+ HashSet set2 = new HashSet();
+ for (int i = 0; i < strings2.length; i++)
+ set2.add(strings2[i]);
+ assertEquals(set1, set2);
+ }
+
+
+ protected String getTransport()
+ {
+ return "sslsocket";
+ }
+
+
+ protected void addExtraClientConfig(Map config)
+ {
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
+ String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
+ }
+
+
+ protected void addExtraServerConfig(Map config)
+ {
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS");
+ String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server");
+ }
+
+
+ protected void addServerSocketConfig(Map config)
+ {
+ super.addServerSocketConfig(config);
+ config.put("enabledCipherSuites", cipherSuites);
+ config.put("enabledProtocols", protocols);
+ config.put("enableSessionCreation", "true");
+ }
+
+
+ protected void configureServerInvoker(SocketServerInvoker invoker)
+ {
+ super.configureServerInvoker(invoker);
+ if (invoker instanceof SSLSocketServerInvoker)
+ {
+ SSLSocketServerInvoker sslInvoker = (SSLSocketServerInvoker) invoker;
+ sslInvoker.setEnabledCipherSuites(cipherSuites);
+ sslInvoker.setEnabledProtocols(protocols);
+ sslInvoker.setEnableSessionCreation(true);
+ }
+ }
+
+
+ protected void shutdownServer() throws Exception
+ {
+ if (connector != null)
+ connector.stop();
+ }
+}
\ No newline at end of file
Added: remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java
===================================================================
--- remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java (rev 0)
+++ remoting2/branches/2.x/src/tests/org/jboss/test/remoting/transport/socket/ssl/config/SSLSocketSocketConfigurationTestCase.java 2008-02-29 08:27:41 UTC (rev 3544)
@@ -0,0 +1,181 @@
+/*
+* 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.socket.ssl.config;
+
+import java.net.Socket;
+import java.net.SocketException;
+import java.util.HashSet;
+import java.util.Map;
+
+import javax.management.MBeanServer;
+import javax.net.ssl.SSLSocket;
+import javax.net.ssl.SSLSocketFactory;
+
+import org.apache.log4j.Logger;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.Callback;
+import org.jboss.remoting.callback.HandleCallbackException;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.remoting.security.SSLSocketBuilder;
+import org.jboss.remoting.transport.socket.SocketServerInvoker;
+import org.jboss.remoting.transport.sslsocket.SSLSocketServerInvoker;
+import org.jboss.test.remoting.transport.socket.configuration.SocketServerSocketConfigurationTestCase;
+import org.jboss.test.remoting.transport.socket.configuration.SocketSocketConfigurationTestCase;
+
+
+/**
+ * Unit test for JBREM-703.
+ *
+ * @author <a href="ron.sigal(a)jboss.com">Ron Sigal</a>
+ * @version $Revision: 1.1 $
+ * <p>
+ * Copyright Feb 28, 2008
+ * </p>
+ */
+public class SSLSocketSocketConfigurationTestCase
+extends SocketSocketConfigurationTestCase
+{
+ private static Logger log = Logger.getLogger(SSLSocketSocketConfigurationTestCase.class);
+
+ static protected String[] cipherSuites;
+ static protected String[] protocols;
+
+
+ public void setUp() throws Exception
+ {
+ if (firstTime)
+ {
+ super.setUp();
+
+ SSLSocket s = (SSLSocket) SSLSocketFactory.getDefault().createSocket();
+
+ String[] strings = s.getSupportedCipherSuites();
+ log.info("supported cipher suites: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ strings = s.getEnabledCipherSuites();
+ log.info("enabled cipher suites: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ strings = s.getSupportedProtocols();
+ log.info("supported protocols: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ strings = s.getEnabledProtocols();
+ log.info("enabled protocols: ");
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+
+ strings = s.getSupportedCipherSuites();
+ int len = strings.length - 1;
+ cipherSuites = new String[len];
+ for (int i = 0; i < len; i++)
+ cipherSuites[i] = strings[i];
+
+ strings = s.getSupportedProtocols();
+ len = strings.length - 1;
+ protocols = new String[len];
+ for (int i = 0; i < len; i++)
+ protocols[i] = strings[i];
+
+ log.info("using cipherSuites: ");
+ for (int i = 0; i < cipherSuites.length; i++)
+ log.info(" " + cipherSuites[i]);
+ log.info("using protocols: ");
+ for (int i = 0; i < protocols.length; i++)
+ log.info(" " + protocols[i]);
+ }
+ }
+
+
+ public void tearDown()
+ {
+ }
+
+
+ protected void setupClient(Map config)
+ {
+ super.setupClient(config);
+ config.put("enabledCipherSuites", cipherSuites);
+ config.put("enabledProtocols", protocols);
+ config.put("enableSessionCreation", "true");
+ }
+
+
+ protected void doSocketTest(Socket s) throws SocketException
+ {
+ assertTrue(s.getKeepAlive());
+ assertEquals(2345, s.getReceiveBufferSize());
+ assertEquals(3456, s.getSendBufferSize());
+ assertEquals(4567, s.getSoLinger());
+ assertEquals(0, s.getTrafficClass());
+
+ assertTrue(s instanceof SSLSocket);
+ SSLSocket ss = (SSLSocket) s;
+ assertTrue(ss.getEnableSessionCreation());
+
+ log.info("actual enabledCipherSuites: ");
+ String[] strings = ss.getEnabledCipherSuites();
+ for (int i = 0; i < strings.length; i++)
+ log.info(" " + strings[i]);
+ assertEquals(cipherSuites, ss.getEnabledCipherSuites());
+ assertEquals(protocols, ss.getEnabledProtocols());
+ }
+
+
+ protected void assertEquals(String[] strings1, String[] strings2)
+ {
+ HashSet set1 = new HashSet();
+ for (int i = 0; i < strings1.length; i++)
+ set1.add(strings1[i]);
+ HashSet set2 = new HashSet();
+ for (int i = 0; i < strings2.length; i++)
+ set2.add(strings2[i]);
+ assertEquals(set1, set2);
+ }
+
+
+ protected String getTransport()
+ {
+ return "sslsocket";
+ }
+
+
+ protected void addExtraClientConfig(Map config)
+ {
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_TYPE, "JKS");
+ String trustStoreFilePath = this.getClass().getResource("../.truststore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_FILE_PATH, trustStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_TRUST_STORE_PASSWORD, "unit-tests-client");
+ }
+
+
+ protected void addExtraServerConfig(Map config)
+ {
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_TYPE, "JKS");
+ String keyStoreFilePath = this.getClass().getResource("../.keystore").getFile();
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_FILE_PATH, keyStoreFilePath);
+ config.put(SSLSocketBuilder.REMOTING_KEY_STORE_PASSWORD, "unit-tests-server");
+ }
+}
\ No newline at end of file
16 years, 10 months
JBoss Remoting SVN: r3543 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:25:33 -0500 (Fri, 29 Feb 2008)
New Revision: 3543
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServerInvoker.java
Log:
JBREM-703: Added configuration for remaining ssl socket parameters.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServerInvoker.java 2008-02-29 08:24:59 UTC (rev 3542)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketServerInvoker.java 2008-02-29 08:25:33 UTC (rev 3543)
@@ -22,11 +22,15 @@
package org.jboss.remoting.transport.sslsocket;
+import org.jboss.logging.Logger;
import org.jboss.remoting.InvokerLocator;
import org.jboss.remoting.transport.socket.SocketServerInvoker;
-
import javax.net.ServerSocketFactory;
+import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLServerSocketFactory;
+
+import java.net.ServerSocket;
+import java.net.SocketException;
import java.util.Map;
/**
@@ -34,7 +38,12 @@
*/
public class SSLSocketServerInvoker extends SocketServerInvoker implements SSLSocketServerInvokerMBean
{
+ private static final Logger log = Logger.getLogger(SSLSocketServerInvoker.class);
+ protected String[] enabledCipherSuites;
+ protected String[] enabledProtocols;
+ protected boolean enableSessionCreation = true;
+
public SSLSocketServerInvoker(InvokerLocator locator)
{
super(locator);
@@ -45,9 +54,75 @@
super(locator, configuration);
}
+ public void setOOBInline(boolean inline)
+ {
+ log.warn("Ignored: sending urgent data is not supported by SSLSockets");
+ }
+
+ public String[] getEnabledCipherSuites()
+ {
+ return enabledCipherSuites;
+ }
+
+ public void setEnabledCipherSuites(String[] enabledCipherSuites)
+ {
+ this.enabledCipherSuites = enabledCipherSuites;
+ }
+
+ public String[] getEnabledProtocols()
+ {
+ return enabledProtocols;
+ }
+
+ public void setEnabledProtocols(String[] enabledProtocols)
+ {
+ this.enabledProtocols = enabledProtocols;
+ }
+
+ public boolean isEnableSessionCreation()
+ {
+ return enableSessionCreation;
+ }
+
+ public void setEnableSessionCreation(boolean enableSessionCreation)
+ {
+ this.enableSessionCreation = enableSessionCreation;
+ }
+
+ protected void setup() throws Exception
+ {
+ super.setup();
+
+ Object o = configuration.get("enabledCipherSuites");
+ if (o instanceof String[])
+ setEnabledCipherSuites((String[]) o);
+
+ o = configuration.get("enabledProtocols");
+ if (o instanceof String[])
+ setEnabledProtocols((String[]) o);
+ }
+
protected ServerSocketFactory getDefaultServerSocketFactory()
{
return SSLServerSocketFactory.getDefault();
}
+ protected void configureServerSocket(ServerSocket ss) throws SocketException
+ {
+ super.configureServerSocket(ss);
+
+ if (ss instanceof SSLServerSocket)
+ {
+ SSLServerSocket sss = (SSLServerSocket) ss;
+ if (enabledCipherSuites != null)
+ {
+ sss.setEnabledCipherSuites(enabledCipherSuites);
+ }
+ if (enabledProtocols != null)
+ {
+ sss.setEnabledProtocols(enabledProtocols);
+ }
+ sss.setEnableSessionCreation(enableSessionCreation);
+ }
+ }
}
\ No newline at end of file
16 years, 10 months
JBoss Remoting SVN: r3542 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:24:59 -0500 (Fri, 29 Feb 2008)
New Revision: 3542
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java
Log:
JBREM-703: Added configuration for remaining ssl socket parameters.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java 2008-02-29 08:24:27 UTC (rev 3541)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslsocket/SSLSocketClientInvoker.java 2008-02-29 08:24:59 UTC (rev 3542)
@@ -36,6 +36,7 @@
import java.io.IOException;
import java.net.Socket;
import java.net.InetSocketAddress;
+import java.net.SocketException;
import java.util.Map;
/**
@@ -45,6 +46,10 @@
{
private static final Logger log = Logger.getLogger(SSLSocketClientInvoker.class);
private static final boolean isTraceEnabled = log.isTraceEnabled();
+
+ protected String[] enabledCipherSuites;
+ protected String[] enabledProtocols;
+ protected boolean enableSessionCreation = true;
public SSLSocketClientInvoker(InvokerLocator locator) throws IOException
{
@@ -74,6 +79,54 @@
}
}
+ public void setOOBInline(boolean inline)
+ {
+ log.warn("Ignored: sending urgent data is not supported by SSLSockets");
+ }
+
+ public String[] getEnabledCipherSuites()
+ {
+ return enabledCipherSuites;
+ }
+
+ public void setEnabledCipherSuites(String[] enabledCipherSuites)
+ {
+ this.enabledCipherSuites = enabledCipherSuites;
+ }
+
+ public String[] getEnabledProtocols()
+ {
+ return enabledProtocols;
+ }
+
+ public void setEnabledProtocols(String[] enabledProtocols)
+ {
+ this.enabledProtocols = enabledProtocols;
+ }
+
+ public boolean isEnableSessionCreation()
+ {
+ return enableSessionCreation;
+ }
+
+ public void setEnableSessionCreation(boolean enableSessionCreation)
+ {
+ this.enableSessionCreation = enableSessionCreation;
+ }
+
+ protected void setup() throws Exception
+ {
+ super.setup();
+
+ Object o = configuration.get("enabledCipherSuites");
+ if (o instanceof String[])
+ setEnabledCipherSuites((String[]) o);
+
+ o = configuration.get("enabledProtocols");
+ if (o instanceof String[])
+ setEnabledProtocols((String[]) o);
+ }
+
protected SocketFactory createSocketFactory(Map configuration)
{
SocketFactory sf = super.createSocketFactory(configuration);
@@ -115,7 +168,7 @@
Socket s = sf.createSocket();
- s.setReuseAddress(getReuseAddress());
+ configureSocket(s);
InetSocketAddress inetAddr = new InetSocketAddress(address, port);
if (timeout < 0)
@@ -141,6 +194,32 @@
return s;
}
+
+ protected void configureSocket(Socket s) throws SocketException
+ {
+ s.setReuseAddress(getReuseAddress());
+
+ if (keepAliveSet) s.setKeepAlive(keepAlive);
+ if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize);
+ if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize);
+ if (soLingerSet &&
+ soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration);
+ if (trafficClass > -1) s.setTrafficClass(trafficClass);
+
+ if (s instanceof SSLSocket)
+ {
+ SSLSocket ss = (SSLSocket) s;
+ if (enabledCipherSuites != null)
+ {
+ ss.setEnabledCipherSuites(enabledCipherSuites);
+ }
+ if (enabledProtocols != null)
+ {
+ ss.setEnabledProtocols(enabledProtocols);
+ }
+ ss.setEnableSessionCreation(enableSessionCreation);
+ }
+ }
private void establishHandshake(SSLSocket sslSocket, HandshakeCompletedListener listener)
throws IOException
16 years, 10 months
JBoss Remoting SVN: r3541 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:24:27 -0500 (Fri, 29 Feb 2008)
New Revision: 3541
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketServerInvoker.java
Log:
JBREM-703: Added configuration for remaining ssl socket parameters.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketServerInvoker.java 2008-02-29 08:23:54 UTC (rev 3540)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketServerInvoker.java 2008-02-29 08:24:27 UTC (rev 3541)
@@ -31,8 +31,11 @@
import javax.net.ServerSocketFactory;
import javax.net.SocketFactory;
+import javax.net.ssl.SSLServerSocket;
import javax.net.ssl.SSLServerSocketFactory;
import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.SocketException;
import java.util.Map;
/**
@@ -46,6 +49,10 @@
private static final Logger log = Logger.getLogger(SSLBisocketServerInvoker.class);
+ protected String[] enabledCipherSuites;
+ protected String[] enabledProtocols;
+ protected boolean enableSessionCreation = true;
+
public SSLBisocketServerInvoker(InvokerLocator locator)
{
super(locator);
@@ -60,7 +67,42 @@
{
return SSLServerSocketFactory.getDefault();
}
+
+ public void setOOBInline(boolean inline)
+ {
+ log.warn("Ignored: sending urgent data is not supported by SSLSockets");
+ }
+
+ public String[] getEnabledCipherSuites()
+ {
+ return enabledCipherSuites;
+ }
+ public void setEnabledCipherSuites(String[] enabledCipherSuites)
+ {
+ this.enabledCipherSuites = enabledCipherSuites;
+ }
+
+ public String[] getEnabledProtocols()
+ {
+ return enabledProtocols;
+ }
+
+ public void setEnabledProtocols(String[] enabledProtocols)
+ {
+ this.enabledProtocols = enabledProtocols;
+ }
+
+ public boolean isEnableSessionCreation()
+ {
+ return enableSessionCreation;
+ }
+
+ public void setEnableSessionCreation(boolean enableSessionCreation)
+ {
+ this.enableSessionCreation = enableSessionCreation;
+ }
+
protected ServerSocketFactory createServerSocketFactory() throws IOException
{
if (isCallbackServer)
@@ -72,6 +114,15 @@
protected void setup() throws Exception
{
super.setup();
+
+ Object o = configuration.get("enabledCipherSuites");
+ if (o instanceof String[])
+ setEnabledCipherSuites((String[]) o);
+
+ o = configuration.get("enabledProtocols");
+ if (o instanceof String[])
+ setEnabledProtocols((String[]) o);
+
if (isCallbackServer)
{
socketFactory = createSocketFactory(configuration);
@@ -106,4 +157,23 @@
return sf;
}
+
+ protected void configureServerSocket(ServerSocket ss) throws SocketException
+ {
+ super.configureServerSocket(ss);
+
+ if (ss instanceof SSLServerSocket)
+ {
+ SSLServerSocket sss = (SSLServerSocket) ss;
+ if (enabledCipherSuites != null)
+ {
+ sss.setEnabledCipherSuites(enabledCipherSuites);
+ }
+ if (enabledProtocols != null)
+ {
+ sss.setEnabledProtocols(enabledProtocols);
+ }
+ sss.setEnableSessionCreation(enableSessionCreation);
+ }
+ }
}
\ No newline at end of file
16 years, 10 months
JBoss Remoting SVN: r3540 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:23:54 -0500 (Fri, 29 Feb 2008)
New Revision: 3540
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketClientInvoker.java
Log:
JBREM-703: Added configuration for remaining ssl socket parameters.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketClientInvoker.java 2008-02-29 08:23:09 UTC (rev 3539)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/sslbisocket/SSLBisocketClientInvoker.java 2008-02-29 08:23:54 UTC (rev 3540)
@@ -25,6 +25,7 @@
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
+import java.net.SocketException;
import java.util.Map;
import javax.net.SocketFactory;
@@ -47,6 +48,10 @@
{
private static final Logger log = Logger.getLogger(SSLBisocketClientInvoker.class);
+ protected String[] enabledCipherSuites;
+ protected String[] enabledProtocols;
+ protected boolean enableSessionCreation = true;
+
public SSLBisocketClientInvoker(InvokerLocator locator) throws IOException
{
super(locator);
@@ -75,6 +80,54 @@
}
}
+ public void setOOBInline(boolean inline)
+ {
+ log.warn("Ignored: sending urgent data is not supported by SSLSockets");
+ }
+
+ public String[] getEnabledCipherSuites()
+ {
+ return enabledCipherSuites;
+ }
+
+ public void setEnabledCipherSuites(String[] enabledCipherSuites)
+ {
+ this.enabledCipherSuites = enabledCipherSuites;
+ }
+
+ public String[] getEnabledProtocols()
+ {
+ return enabledProtocols;
+ }
+
+ public void setEnabledProtocols(String[] enabledProtocols)
+ {
+ this.enabledProtocols = enabledProtocols;
+ }
+
+ public boolean isEnableSessionCreation()
+ {
+ return enableSessionCreation;
+ }
+
+ public void setEnableSessionCreation(boolean enableSessionCreation)
+ {
+ this.enableSessionCreation = enableSessionCreation;
+ }
+
+ protected void setup() throws Exception
+ {
+ super.setup();
+
+ Object o = configuration.get("enabledCipherSuites");
+ if (o instanceof String[])
+ setEnabledCipherSuites((String[]) o);
+
+ o = configuration.get("enabledProtocols");
+ if (o instanceof String[])
+ setEnabledProtocols((String[]) o);
+ }
+
protected SocketFactory createSocketFactory(Map configuration)
{
SocketFactory sf = super.createSocketFactory(configuration);
@@ -117,7 +170,7 @@
Socket s = sf.createSocket();
- s.setReuseAddress(getReuseAddress());
+ configureSocket(s);
InetSocketAddress inetAddr = new InetSocketAddress(address, port);
if (timeout < 0)
@@ -144,6 +197,32 @@
return s;
}
+ protected void configureSocket(Socket s) throws SocketException
+ {
+ s.setReuseAddress(getReuseAddress());
+
+ if (keepAliveSet) s.setKeepAlive(keepAlive);
+ if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize);
+ if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize);
+ if (soLingerSet &&
+ soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration);
+ if (trafficClass > -1) s.setTrafficClass(trafficClass);
+
+ if (s instanceof SSLSocket)
+ {
+ SSLSocket ss = (SSLSocket) s;
+ if (enabledCipherSuites != null)
+ {
+ ss.setEnabledCipherSuites(enabledCipherSuites);
+ }
+ if (enabledProtocols != null)
+ {
+ ss.setEnabledProtocols(enabledProtocols);
+ }
+ ss.setEnableSessionCreation(enableSessionCreation);
+ }
+ }
+
private void establishHandshake(SSLSocket sslSocket, HandshakeCompletedListener listener)
throws IOException
{
16 years, 10 months
JBoss Remoting SVN: r3539 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:23:09 -0500 (Fri, 29 Feb 2008)
New Revision: 3539
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
Log:
JBREM-703: Added configuration for remaining socket parameters.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java 2008-02-29 08:21:41 UTC (rev 3538)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketServerInvoker.java 2008-02-29 08:23:09 UTC (rev 3539)
@@ -66,7 +66,7 @@
static int clientCount = 0;
- private Properties props = new Properties();
+ protected Properties props = new Properties();
private static int BACKLOG_DEFAULT = 200;
protected static int MAX_POOL_SIZE_DEFAULT = 300;
@@ -98,6 +98,20 @@
protected Object serverSocketFactoryLock = new Object();
protected boolean reuseAddress = true;
+ protected int receiveBufferSize = -1;
+
+ /**
+ * More socket configuration parameters.
+ */
+ protected boolean keepAlive;
+ protected boolean keepAliveSet;
+ protected boolean oOBInline;
+ protected boolean oOBInlineSet;
+ protected int sendBufferSize = -1;
+ protected boolean soLinger;
+ protected boolean soLingerSet;
+ protected int soLingerDuration = -1;
+ protected int trafficClass = -1;
// defaults to -1 as to not have idle timeouts
protected int idleTimeout = -1;
@@ -270,10 +284,12 @@
log.warn("Unable to create unbound ServerSocket: cannot set reuseAddress to true",e);
ss = factory.createServerSocket(serverBindPort, backlog, bindAddress);
+ configureServerSocket(ss);
return ss;
}
ss.setReuseAddress(getReuseAddress());
+ configureServerSocket(ss);
InetSocketAddress address = new InetSocketAddress(bindAddress, serverBindPort);
ss.bind(address, backlog);
return ss;
@@ -294,6 +310,7 @@
{
ss = factory.createServerSocket();
ss.setReuseAddress(getReuseAddress());
+ configureServerSocket(ss);
InetSocketAddress address = new InetSocketAddress(inetAddress, home.port);
ss.bind(address, backlog);
if (log.isDebugEnabled()) log.debug(this + " created " + ss);
@@ -306,6 +323,7 @@
try
{
ss = factory.createServerSocket(home.port, backlog, inetAddress);
+ configureServerSocket(ss);
}
catch (IOException e2)
{
@@ -326,6 +344,14 @@
serverSockets.add(ss);
}
}
+
+ protected void configureServerSocket(ServerSocket ss) throws SocketException
+ {
+ if (receiveBufferSize != -1)
+ {
+ ss.setReceiveBufferSize(receiveBufferSize);
+ }
+ }
protected String getThreadName(int i)
{
@@ -416,6 +442,17 @@
log.debug(this + " exiting");
}
+
+ public int getReceiveBufferSize()
+ {
+ return receiveBufferSize;
+ }
+
+ public void setReceiveBufferSize(int receiveBufferSize)
+ {
+ this.receiveBufferSize = receiveBufferSize;
+ }
+
/**
* Indicates if SO_REUSEADDR is enabled on server sockets
* Default is true.
@@ -436,6 +473,69 @@
this.reuseAddress = reuse;
}
+ public boolean isKeepAlive()
+ {
+ return keepAlive;
+ }
+
+ public void setKeepAlive(boolean keepAlive)
+ {
+ this.keepAlive = keepAlive;
+ keepAliveSet = true;
+ }
+
+ public boolean isOOBInline()
+ {
+ return oOBInline;
+ }
+
+ public void setOOBInline(boolean inline)
+ {
+ oOBInline = inline;
+ oOBInlineSet = true;
+ }
+
+ public int getSendBufferSize()
+ {
+ return sendBufferSize;
+ }
+
+ public void setSendBufferSize(int sendBufferSize)
+ {
+ this.sendBufferSize = sendBufferSize;
+ }
+
+ public boolean isSoLinger()
+ {
+ return soLinger;
+ }
+
+ public int getSoLingerDuration()
+ {
+ return soLingerDuration;
+ }
+
+ public void setSoLinger(boolean soLinger)
+ {
+ this.soLinger = soLinger;
+ soLingerSet = true;
+ }
+
+ public void setSoLingerDuration(int soLingerDuration)
+ {
+ this.soLingerDuration = soLingerDuration;
+ }
+
+ public int getTrafficClass()
+ {
+ return trafficClass;
+ }
+
+ public void setTrafficClass(int trafficClass)
+ {
+ this.trafficClass = trafficClass;
+ }
+
/**
* @return Value of property serverBindPort.
* @jmx:managed-attribute
@@ -560,7 +660,19 @@
}
}
-
+ protected void configureSocket(Socket s) throws SocketException
+ {
+ s.setReuseAddress(getReuseAddress());
+
+ if (keepAliveSet) s.setKeepAlive(keepAlive);
+ if (oOBInlineSet) s.setOOBInline(oOBInline);
+ if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize);
+ if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize);
+ if (soLingerSet &&
+ soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration);
+ if (trafficClass > -1) s.setTrafficClass(trafficClass);
+ }
+
/**
* The acceptor thread should spend as little time as possbile doing any kind of operation, and
* under no circumstances should perform IO on the new socket, which can potentially block and
@@ -872,6 +984,7 @@
// should grab a worker thread and delegate all subsequent work to it. This is what
// processInvocation() does.
+ configureSocket(socket);
processInvocation(socket);
}
catch (SSLException e)
16 years, 10 months
JBoss Remoting SVN: r3538 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:21:41 -0500 (Fri, 29 Feb 2008)
New Revision: 3538
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
Log:
JBREM-703: Added configuration for remaining socket parameters.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-02-29 08:21:21 UTC (rev 3537)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java 2008-02-29 08:21:41 UTC (rev 3538)
@@ -184,7 +184,7 @@
s = new Socket();
}
- s.setReuseAddress(getReuseAddress());
+ configureSocket(s);
InetSocketAddress inetAddr = new InetSocketAddress(address, port);
if (timeout < 0)
16 years, 10 months
JBoss Remoting SVN: r3537 - remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket.
by jboss-remoting-commits@lists.jboss.org
Author: ron.sigal(a)jboss.com
Date: 2008-02-29 03:21:21 -0500 (Fri, 29 Feb 2008)
New Revision: 3537
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
Log:
JBREM-703: Added configuration for remaining socket parameters.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-02-29 04:04:36 UTC (rev 3536)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java 2008-02-29 08:21:21 UTC (rev 3537)
@@ -222,6 +222,20 @@
*/
protected ServerAddress address;
protected Home home;
+
+ /**
+ * Socket configuration parameters.
+ */
+ protected boolean keepAlive;
+ protected boolean keepAliveSet;
+ protected boolean oOBInline;
+ protected boolean oOBInlineSet;
+ protected int receiveBufferSize = - 1;
+ protected int sendBufferSize = -1;
+ protected boolean soLinger;
+ protected boolean soLingerSet;
+ protected int soLingerDuration = -1;
+ protected int trafficClass = -1;
// Constructors ---------------------------------------------------------------------------------
@@ -287,6 +301,79 @@
reuseAddress = reuse;
}
+ public boolean isKeepAlive()
+ {
+ return keepAlive;
+ }
+
+ public void setKeepAlive(boolean keepAlive)
+ {
+ this.keepAlive = keepAlive;
+ keepAliveSet = true;
+ }
+
+ public boolean isOOBInline()
+ {
+ return oOBInline;
+ }
+
+ public void setOOBInline(boolean inline)
+ {
+ oOBInline = inline;
+ oOBInlineSet = true;
+ }
+
+ public int getReceiveBufferSize()
+ {
+ return receiveBufferSize;
+ }
+
+ public void setReceiveBufferSize(int receiveBufferSize)
+ {
+ this.receiveBufferSize = receiveBufferSize;
+ }
+
+ public int getSendBufferSize()
+ {
+ return sendBufferSize;
+ }
+
+ public void setSendBufferSize(int sendBufferSize)
+ {
+ this.sendBufferSize = sendBufferSize;
+ }
+
+ public boolean isSoLinger()
+ {
+ return soLinger;
+ }
+
+ public int getSoLingerDuration()
+ {
+ return soLingerDuration;
+ }
+
+ public void setSoLinger(boolean soLinger)
+ {
+ this.soLinger = soLinger;
+ soLingerSet = true;
+ }
+
+ public void setSoLingerDuration(int soLingerDuration)
+ {
+ this.soLingerDuration = soLingerDuration;
+ }
+
+ public int getTrafficClass()
+ {
+ return trafficClass;
+ }
+
+ public void setTrafficClass(int trafficClass)
+ {
+ this.trafficClass = trafficClass;
+ }
+
public synchronized void disconnect()
{
log.debug(this + " disconnecting ...");
@@ -1010,11 +1097,24 @@
protected Socket createSocket(String address, int port, int timeout) throws IOException
{
Socket s = new Socket();
- s.setReuseAddress(getReuseAddress());
+ configureSocket(s);
InetSocketAddress inetAddr = new InetSocketAddress(address, port);
s.connect(inetAddr);
return s;
}
+
+ protected void configureSocket(Socket s) throws SocketException
+ {
+ s.setReuseAddress(getReuseAddress());
+
+ if (keepAliveSet) s.setKeepAlive(keepAlive);
+ if (oOBInlineSet) s.setOOBInline(oOBInline);
+ if (receiveBufferSize > -1) s.setReceiveBufferSize(receiveBufferSize);
+ if (sendBufferSize > -1) s.setSendBufferSize(sendBufferSize);
+ if (soLingerSet &&
+ soLingerDuration > 0) s.setSoLinger(soLinger, soLingerDuration);
+ if (trafficClass > -1) s.setTrafficClass(trafficClass);
+ }
protected SocketWrapper getPooledConnection()
{
16 years, 10 months