Index: /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/socket/tcp/SSLNoDelaySocketFactory.java
===================================================================
--- /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/socket/tcp/SSLNoDelaySocketFactory.java (revision 0)
+++ /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/socket/tcp/SSLNoDelaySocketFactory.java (working copy)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.wsf.stack.cxf.client.socket.tcp;
+
+import javax.net.ssl.SSLSocketFactory;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+/**
+ * A wrapper SocketFactory implementation that will call setTcpNoDelay(true) whenever createSocket() is called. This
+ * is done as a feature for the JIRA issue: JBWS-3745.
+ *
+ * @author navssurtani
+ */
+public class SSLNoDelaySocketFactory extends SSLSocketFactory
+{
+
+ private final SSLSocketFactory targetFactory;
+
+ public SSLNoDelaySocketFactory(SSLSocketFactory targetFactory)
+ {
+ this.targetFactory = targetFactory;
+ }
+
+
+ @Override
+ public String[] getDefaultCipherSuites()
+ {
+ return targetFactory.getDefaultCipherSuites();
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites()
+ {
+ return targetFactory.getSupportedCipherSuites();
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ Socket toReturn = targetFactory.createSocket();
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException
+ {
+ Socket toReturn = targetFactory.createSocket(socket, s, i, b);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(String s, int i) throws IOException, UnknownHostException
+ {
+ Socket toReturn = targetFactory.createSocket(s, i);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(String s, int i, InetAddress inetAddress, int i2) throws IOException, UnknownHostException
+ {
+ Socket toReturn = targetFactory.createSocket(s, i, inetAddress, i2);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress inetAddress, int i) throws IOException
+ {
+ Socket toReturn = targetFactory.createSocket(inetAddress, i);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress2, int i2) throws IOException
+ {
+ Socket toReturn = targetFactory.createSocket(inetAddress, i, inetAddress2, i2);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+}
Index: /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml (revision 18158)
+++ /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml (working copy)
@@ -109,7 +109,16 @@
-
+
+
+
+
+
+
+
+
+
Index: /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SSLNoDelaySocketFactoryTestCase.java
===================================================================
--- /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SSLNoDelaySocketFactoryTestCase.java (revision 0)
+++ /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SSLNoDelaySocketFactoryTestCase.java (working copy)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import junit.framework.Test;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.jboss.wsf.stack.cxf.client.socket.tcp.SSLNoDelaySocketFactory;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.junit.After;
+import org.junit.Before;
+
+import javax.net.ssl.SSLSocketFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+
+/**
+ * Simple test case for {@link org.jboss.wsf.stack.cxf.client.socket.tcp.SSLNoDelaySocketFactory}
+ *
+ * We will get an {@link javax.net.ssl.SSLSocketFactory} from the client. This should be an instance of an
+ * SSLNoDelaySocketFactory. Once we have this we will simply create the socket and check if the tcp no delay flag has
+ * been enabled.
+ *
+ * @author navssurtani
+ */
+public class SSLNoDelaySocketFactoryTestCase extends JBossWSTest
+{
+ /* The name of the .war file that we are going to deploy */
+ private static final String WAR_NAME = "jaxws-cxf-jbws3745.war";
+
+ /* The SocketFactory instance that will be used to get hold of the socket to be tested */
+ private SSLSocketFactory fromClient = null;
+
+ /* The Socket that we will use to test if tcpNoDelay is enabled or not */
+ private Socket toTest = null;
+
+ /* Server and client port numbers */
+ private static int SERVER_PORT = 8080;
+ private static int CLIENT_PORT = 8880;
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(SSLNoDelaySocketFactoryTestCase.class, "");
+ }
+
+ @Before
+ public void setUp() throws Exception
+ {
+ // First we need the client parameters
+ Client client = ClientProxy.getClient(getPort());
+ HTTPConduit conduit = (HTTPConduit) client.getConduit();
+ TLSClientParameters tls = conduit.getTlsClientParameters();
+
+ // Now we need to build the socket factory
+ SSLSocketFactory defaultSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
+ SSLNoDelaySocketFactory noDelay = new SSLNoDelaySocketFactory(defaultSocketFactory);
+
+ // Now set the socket factory and make a simple check.
+ tls.setSSLSocketFactory(noDelay);
+ fromClient = tls.getSSLSocketFactory();
+ assertEquals(fromClient.getClass(), SSLNoDelaySocketFactory.class);
+ }
+
+ @After
+ public void cleanUp() throws IOException, InterruptedException
+ {
+ if (toTest != null)
+ toTest.close();
+ }
+
+ public void testCreateSocket0() throws Exception
+ {
+ toTest = fromClient.createSocket();
+ assertTrue(toTest.getTcpNoDelay());
+ }
+
+ public void testCreateSocket1() throws Exception
+ {
+ toTest = fromClient.createSocket(getServerHost(), SERVER_PORT);
+ assertTrue(toTest.getTcpNoDelay());
+ }
+
+ public void testCreateSocket3() throws Exception
+ {
+ toTest = fromClient.createSocket(InetAddress.getByName(getServerHost()), SERVER_PORT);
+ assertTrue(toTest.getTcpNoDelay());
+ }
+
+ private SimpleService getPort() throws Exception
+ {
+ deploy(WAR_NAME);
+ QName qname = new QName("http://org.jboss.ws/jaxws/cxf/jbws3745", "SimpleService");
+ Service service = Service.create(qname);
+ return service.getPort(SimpleService.class);
+ }
+}
Index: /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleService.java
===================================================================
--- /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleService.java (revision 0)
+++ /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleService.java (working copy)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import javax.jws.WebService;
+
+/**
+ * A simple, dummy web service
+ *
+ * @author navssurtani
+ */
+@WebService (name = "SimpleService", targetNamespace = "http://org.jboss.ws.jaxws/cxf/jbws3745",
+ serviceName = "simple")
+public interface SimpleService
+{
+ public String sayHi();
+}
Index: /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServiceImpl.java
===================================================================
--- /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServiceImpl.java (revision 0)
+++ /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServiceImpl.java (working copy)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import javax.jws.WebService;
+
+/**
+ * Implementation for {@link org.jboss.test.ws.jaxws.cxf.jbws3745.SimpleService}
+ *
+ * @author navssurtani
+ */
+@WebService (name = "SimpleService", targetNamespace = "http://org.jboss.ws.jaxws/cxf/jbws3745",
+ serviceName = "simple")
+public class SimpleServiceImpl implements SimpleService
+{
+ @Override
+ public String sayHi()
+ {
+ return "Hi!";
+ }
+}
Index: /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServlet.java
===================================================================
--- /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServlet.java (revision 0)
+++ /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServlet.java (working copy)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import org.jboss.ws.common.utils.AddressUtils;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.xml.ws.Endpoint;
+
+/**
+ * Servlet for this test case.
+ *
+ * Same thing as {@link org.jboss.test.ws.jaxws.cxf.endpoint.TestServlet}
+ *
+ * @author navssurtani
+ */
+public class SimpleServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = -2137273317393754516L;
+ private Endpoint endpoint;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ String hostName = toIPv6URLFormat(System.getProperty("jboss.bind.address", "localhost"));
+ String serviceURL = "http://" + hostName + ":8080/SimpleService";
+ endpoint = Endpoint.publish(serviceURL, new SimpleServiceImpl());
+ }
+
+ @Override
+ public void destroy()
+ {
+ endpoint.stop();
+ }
+
+ private String toIPv6URLFormat(final String host)
+ {
+ boolean isIPv6URLFormatted = false;
+ if (host.startsWith("[") && host.endsWith("]")) {
+ isIPv6URLFormatted = true;
+ }
+ //return IPv6 URL formatted address
+ if (isIPv6URLFormatted) {
+ return host;
+ } else {
+ return AddressUtils.isValidIPv6Address(host) ? "[" + host + "]" : host;
+ }
+ }
+}
Index: /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3745/web.xml
===================================================================
--- /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3745/web.xml (revision 0)
+++ /home/navssurtani/jboss/webservices/cxf-3.1.2-branch/modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3745/web.xml (working copy)
@@ -0,0 +1,18 @@
+
+
+
+
+
+ SimpleService
+ org.jboss.test.ws.jaxws.cxf.jbws3745.SimpleServlet
+
+
+
+ SimpleService
+ /SimpleService
+
+
+
\ No newline at end of file
Index: modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/socket/tcp/SSLNoDelaySocketFactory.java
===================================================================
--- modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/socket/tcp/SSLNoDelaySocketFactory.java (revision 0)
+++ modules/client/src/main/java/org/jboss/wsf/stack/cxf/client/socket/tcp/SSLNoDelaySocketFactory.java (working copy)
@@ -0,0 +1,106 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.wsf.stack.cxf.client.socket.tcp;
+
+import javax.net.ssl.SSLSocketFactory;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+import java.net.UnknownHostException;
+
+/**
+ * A wrapper SocketFactory implementation that will call setTcpNoDelay(true) whenever createSocket() is called. This
+ * is done as a feature for the JIRA issue: JBWS-3745.
+ *
+ * @author navssurtani
+ */
+public class SSLNoDelaySocketFactory extends SSLSocketFactory
+{
+
+ private final SSLSocketFactory targetFactory;
+
+ public SSLNoDelaySocketFactory(SSLSocketFactory targetFactory)
+ {
+ this.targetFactory = targetFactory;
+ }
+
+
+ @Override
+ public String[] getDefaultCipherSuites()
+ {
+ return targetFactory.getDefaultCipherSuites();
+ }
+
+ @Override
+ public String[] getSupportedCipherSuites()
+ {
+ return targetFactory.getSupportedCipherSuites();
+ }
+
+ @Override
+ public Socket createSocket() throws IOException {
+ Socket toReturn = targetFactory.createSocket();
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(Socket socket, String s, int i, boolean b) throws IOException
+ {
+ Socket toReturn = targetFactory.createSocket(socket, s, i, b);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(String s, int i) throws IOException, UnknownHostException
+ {
+ Socket toReturn = targetFactory.createSocket(s, i);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(String s, int i, InetAddress inetAddress, int i2) throws IOException, UnknownHostException
+ {
+ Socket toReturn = targetFactory.createSocket(s, i, inetAddress, i2);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress inetAddress, int i) throws IOException
+ {
+ Socket toReturn = targetFactory.createSocket(inetAddress, i);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+
+ @Override
+ public Socket createSocket(InetAddress inetAddress, int i, InetAddress inetAddress2, int i2) throws IOException
+ {
+ Socket toReturn = targetFactory.createSocket(inetAddress, i, inetAddress2, i2);
+ toReturn.setTcpNoDelay(true);
+ return toReturn;
+ }
+}
Index: modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml
===================================================================
--- modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml (revision 18158)
+++ modules/testsuite/cxf-tests/scripts/cxf-jars-jaxws.xml (working copy)
@@ -109,7 +109,16 @@
-
+
+
+
+
+
+
+
+
+
Index: modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SSLNoDelaySocketFactoryTestCase.java
===================================================================
--- modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SSLNoDelaySocketFactoryTestCase.java (revision 0)
+++ modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SSLNoDelaySocketFactoryTestCase.java (working copy)
@@ -0,0 +1,122 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import junit.framework.Test;
+import org.apache.cxf.configuration.jsse.TLSClientParameters;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.jboss.wsf.stack.cxf.client.socket.tcp.SSLNoDelaySocketFactory;
+import org.jboss.wsf.test.JBossWSTest;
+import org.jboss.wsf.test.JBossWSTestSetup;
+import org.junit.After;
+import org.junit.Before;
+
+import javax.net.ssl.SSLSocketFactory;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import java.io.IOException;
+import java.net.InetAddress;
+import java.net.Socket;
+
+/**
+ * Simple test case for {@link org.jboss.wsf.stack.cxf.client.socket.tcp.SSLNoDelaySocketFactory}
+ *
+ * We will get an {@link javax.net.ssl.SSLSocketFactory} from the client. This should be an instance of an
+ * SSLNoDelaySocketFactory. Once we have this we will simply create the socket and check if the tcp no delay flag has
+ * been enabled.
+ *
+ * @author navssurtani
+ */
+public class SSLNoDelaySocketFactoryTestCase extends JBossWSTest
+{
+ /* The name of the .war file that we are going to deploy */
+ private static final String WAR_NAME = "jaxws-cxf-jbws3745.war";
+
+ /* The SocketFactory instance that will be used to get hold of the socket to be tested */
+ private SSLSocketFactory fromClient = null;
+
+ /* The Socket that we will use to test if tcpNoDelay is enabled or not */
+ private Socket toTest = null;
+
+ /* Server and client port numbers */
+ private static int SERVER_PORT = 8080;
+ private static int CLIENT_PORT = 8880;
+
+ public static Test suite()
+ {
+ return new JBossWSTestSetup(SSLNoDelaySocketFactoryTestCase.class, "");
+ }
+
+ @Before
+ public void setUp() throws Exception
+ {
+ // First we need the client parameters
+ Client client = ClientProxy.getClient(getPort());
+ HTTPConduit conduit = (HTTPConduit) client.getConduit();
+ TLSClientParameters tls = conduit.getTlsClientParameters();
+
+ // Now we need to build the socket factory
+ SSLSocketFactory defaultSocketFactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
+ SSLNoDelaySocketFactory noDelay = new SSLNoDelaySocketFactory(defaultSocketFactory);
+
+ // Now set the socket factory and make a simple check.
+ tls.setSSLSocketFactory(noDelay);
+ fromClient = tls.getSSLSocketFactory();
+ assertEquals(fromClient.getClass(), SSLNoDelaySocketFactory.class);
+ }
+
+ @After
+ public void cleanUp() throws IOException, InterruptedException
+ {
+ if (toTest != null)
+ toTest.close();
+ }
+
+ public void testCreateSocket0() throws Exception
+ {
+ toTest = fromClient.createSocket();
+ assertTrue(toTest.getTcpNoDelay());
+ }
+
+ public void testCreateSocket1() throws Exception
+ {
+ toTest = fromClient.createSocket(getServerHost(), SERVER_PORT);
+ assertTrue(toTest.getTcpNoDelay());
+ }
+
+ public void testCreateSocket3() throws Exception
+ {
+ toTest = fromClient.createSocket(InetAddress.getByName(getServerHost()), SERVER_PORT);
+ assertTrue(toTest.getTcpNoDelay());
+ }
+
+ private SimpleService getPort() throws Exception
+ {
+ deploy(WAR_NAME);
+ QName qname = new QName("http://org.jboss.ws/jaxws/cxf/jbws3745", "SimpleService");
+ Service service = Service.create(qname);
+ return service.getPort(SimpleService.class);
+ }
+}
Index: modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleService.java
===================================================================
--- modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleService.java (revision 0)
+++ modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleService.java (working copy)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import javax.jws.WebService;
+
+/**
+ * A simple, dummy web service
+ *
+ * @author navssurtani
+ */
+@WebService (name = "SimpleService", targetNamespace = "http://org.jboss.ws.jaxws/cxf/jbws3745",
+ serviceName = "simple")
+public interface SimpleService
+{
+ public String sayHi();
+}
Index: modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServiceImpl.java
===================================================================
--- modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServiceImpl.java (revision 0)
+++ modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServiceImpl.java (working copy)
@@ -0,0 +1,41 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import javax.jws.WebService;
+
+/**
+ * Implementation for {@link org.jboss.test.ws.jaxws.cxf.jbws3745.SimpleService}
+ *
+ * @author navssurtani
+ */
+@WebService (name = "SimpleService", targetNamespace = "http://org.jboss.ws.jaxws/cxf/jbws3745",
+ serviceName = "simple")
+public class SimpleServiceImpl implements SimpleService
+{
+ @Override
+ public String sayHi()
+ {
+ return "Hi!";
+ }
+}
Index: modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServlet.java
===================================================================
--- modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServlet.java (revision 0)
+++ modules/testsuite/cxf-tests/src/test/java/org/jboss/test/ws/jaxws/cxf/jbws3745/SimpleServlet.java (working copy)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2013, 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.ws.jaxws.cxf.jbws3745;
+
+import org.jboss.ws.common.utils.AddressUtils;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.xml.ws.Endpoint;
+
+/**
+ * Servlet for this test case.
+ *
+ * Same thing as {@link org.jboss.test.ws.jaxws.cxf.endpoint.TestServlet}
+ *
+ * @author navssurtani
+ */
+public class SimpleServlet extends HttpServlet
+{
+
+ private static final long serialVersionUID = -2137273317393754516L;
+ private Endpoint endpoint;
+
+ @Override
+ public void init(ServletConfig config) throws ServletException
+ {
+ String hostName = toIPv6URLFormat(System.getProperty("jboss.bind.address", "localhost"));
+ String serviceURL = "http://" + hostName + ":8080/SimpleService";
+ endpoint = Endpoint.publish(serviceURL, new SimpleServiceImpl());
+ }
+
+ @Override
+ public void destroy()
+ {
+ endpoint.stop();
+ }
+
+ private String toIPv6URLFormat(final String host)
+ {
+ boolean isIPv6URLFormatted = false;
+ if (host.startsWith("[") && host.endsWith("]")) {
+ isIPv6URLFormatted = true;
+ }
+ //return IPv6 URL formatted address
+ if (isIPv6URLFormatted) {
+ return host;
+ } else {
+ return AddressUtils.isValidIPv6Address(host) ? "[" + host + "]" : host;
+ }
+ }
+}
Index: modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3745/web.xml
===================================================================
--- modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3745/web.xml (revision 0)
+++ modules/testsuite/cxf-tests/src/test/resources/jaxws/cxf/jbws3745/web.xml (working copy)
@@ -0,0 +1,18 @@
+
+
+
+
+
+ SimpleService
+ org.jboss.test.ws.jaxws.cxf.jbws3745.SimpleServlet
+
+
+
+ SimpleService
+ /SimpleService
+
+
+
\ No newline at end of file