cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject cxf git commit: [CXF-6318] Execute JAXRS WebSocket systests with and without atmosphere
Date Wed, 25 Mar 2015 22:58:17 GMT
Repository: cxf
Updated Branches:
  refs/heads/3.0.x-fixes fa3a3cba6 -> 27dd4216b


[CXF-6318] Execute JAXRS WebSocket systests with and without atmosphere


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/27dd4216
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/27dd4216
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/27dd4216

Branch: refs/heads/3.0.x-fixes
Commit: 27dd4216bcf72e0a4589aa92583c3e2293305cd7
Parents: fa3a3cb
Author: Akitoshi Yoshida <ay@apache.org>
Authored: Wed Mar 25 18:12:45 2015 +0100
Committer: Akitoshi Yoshida <ay@apache.org>
Committed: Wed Mar 25 23:57:29 2015 +0100

----------------------------------------------------------------------
 .../websocket/WebSocketDestinationFactory.java  |  8 ++-
 systests/jaxrs/pom.xml                          | 17 +++----
 .../jaxrs/websocket/BookServerWebSocket.java    | 12 ++++-
 ...RSClientServerWebSocketNoAtmosphereTest.java | 51 +++++++++++++++++++
 ...ntServerWebSocketSpringNoAtmosphereTest.java | 52 ++++++++++++++++++++
 ...erWebSocketSpringWebAppNoAtmosphereTest.java | 45 +++++++++++++++++
 ...RSClientServerWebSocketSpringWebAppTest.java | 13 ++---
 .../jaxrs_websocket/beans-embedded2.xml         | 48 ++++++++++++++++++
 8 files changed, 225 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
index f4f2d51..db18aea 100644
--- a/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
+++ b/rt/transports/websocket/src/main/java/org/apache/cxf/transport/websocket/WebSocketDestinationFactory.java
@@ -23,6 +23,7 @@ import java.lang.reflect.Constructor;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.common.util.SystemPropertyAction;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.DestinationFactory;
 import org.apache.cxf.transport.DestinationFactoryManager;
@@ -43,6 +44,9 @@ public class WebSocketDestinationFactory implements HttpDestinationFactory
{
     private static final Constructor<?> ATMOSPHERE_WEBSOCKET_JETTY_DESTINATION_CTR
= 
         probeConstructor("org.apache.cxf.transport.websocket.atmosphere.AtmosphereWebSocketJettyDestination");
   
 
+    private final boolean atmosphereDisabled = Boolean.valueOf(
+        SystemPropertyAction.getPropertyOrNull("org.apache.cxf.transport.websocket.atmosphere.disabled"));
+
     private static boolean probeClass(String name) {
         try {
             Class.forName(name, true, WebSocketDestinationFactory.class.getClassLoader());
@@ -68,7 +72,7 @@ public class WebSocketDestinationFactory implements HttpDestinationFactory
{
             // for the embedded mode, we stick to jetty
             JettyHTTPServerEngineFactory serverEngineFactory = bus
                 .getExtension(JettyHTTPServerEngineFactory.class);
-            if (ATMOSPHERE_AVAILABLE) {
+            if (ATMOSPHERE_AVAILABLE && !atmosphereDisabled) {
                 // use atmosphere if available
                 return createJettyHTTPDestination(ATMOSPHERE_WEBSOCKET_JETTY_DESTINATION_CTR,
                                                   bus, registry, endpointInfo, serverEngineFactory);
@@ -81,7 +85,7 @@ public class WebSocketDestinationFactory implements HttpDestinationFactory
{
             registry = getDestinationRegistry(bus);
             
             // choose atmosphere if available, otherwise assume jetty is available
-            if (ATMOSPHERE_AVAILABLE) {
+            if (ATMOSPHERE_AVAILABLE && !atmosphereDisabled) {
                 // use atmosphere if available
                 return new AtmosphereWebSocketServletDestination(bus, registry,
                                                                  endpointInfo, endpointInfo.getAddress());

http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/systests/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index 7f2bb17..4a06934 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -445,6 +445,13 @@
             	</exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <!-- activate atmosphere. Its use can be disabled by setting
+                 org.apache.cxf.transport.websocket.atmosphere.disabled to "true" -->
+            <groupId>org.atmosphere</groupId>
+            <artifactId>atmosphere-runtime</artifactId>
+            <version>${cxf.atmosphere.version}</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>
@@ -499,15 +506,5 @@
                 </dependency>
             </dependencies>
         </profile>
-        <profile>
-            <id>atmosphere</id>
-            <dependencies>
-                <dependency>
-                    <groupId>org.atmosphere</groupId>
-                    <artifactId>atmosphere-runtime</artifactId>
-                    <version>${cxf.atmosphere.version}</version>
-                </dependency>
-            </dependencies>
-        </profile>
     </profiles>
 </project>

http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookServerWebSocket.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookServerWebSocket.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookServerWebSocket.java
index 33c1b52..9d38a66 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookServerWebSocket.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookServerWebSocket.java
@@ -32,10 +32,20 @@ public class BookServerWebSocket extends AbstractBusTestServerBase {
     public static final String PORT = allocatePort(BookServerWebSocket.class, 1);
     public static final String PORT_SPRING = allocatePort(BookServerWebSocket.class, 2);
     public static final String PORT_WAR = allocatePort(BookServerWebSocket.class, 3);
+    public static final String PORT2 = allocatePort(BookServerWebSocket.class, 4);
+    public static final String PORT2_SPRING = allocatePort(BookServerWebSocket.class, 5);
+    public static final String PORT2_WAR = allocatePort(BookServerWebSocket.class, 6);
      
     org.apache.cxf.endpoint.Server server;
     
+    private String port;
+
     public BookServerWebSocket() {
+        this(PORT);
+    }
+
+    public BookServerWebSocket(String port) {
+        this.port = port;
     }
     
     protected void run() {
@@ -47,7 +57,7 @@ public class BookServerWebSocket extends AbstractBusTestServerBase {
         sf.setProvider(new StreamingResponseProvider<Book>());
         sf.setResourceProvider(BookStoreWebSocket.class,
                                new SingletonResourceProvider(new BookStoreWebSocket(), true));
-        sf.setAddress("ws://localhost:" + PORT + "/websocket");
+        sf.setAddress("ws://localhost:" + port + "/websocket");
         server = sf.create();
 
         BusFactory.setDefaultBus(null);

http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketNoAtmosphereTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketNoAtmosphereTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketNoAtmosphereTest.java
new file mode 100644
index 0000000..9487ff0
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketNoAtmosphereTest.java
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.websocket;
+
+import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+
+
+/**
+ * JAXRSClientServerWebSocketTest without atmosphere
+ */
+public class JAXRSClientServerWebSocketNoAtmosphereTest extends JAXRSClientServerWebSocketTest
{
+    private static final String PORT = BookServerWebSocket.PORT2;
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        System.setProperty("org.apache.cxf.transport.websocket.atmosphere.disabled", "true");
+        AbstractResourceInfo.clearAllMaps();
+        assertTrue("server did not launch correctly", launchServer(new BookServerWebSocket(PORT)));
+        createStaticBus();
+    }
+
+    @AfterClass
+    public static void cleanup() {
+        System.clearProperty("org.apache.cxf.transport.websocket.atmosphere.disabled");
+    }
+
+    protected String getPort() {
+        return PORT;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringNoAtmosphereTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringNoAtmosphereTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringNoAtmosphereTest.java
new file mode 100644
index 0000000..561af3c
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringNoAtmosphereTest.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.websocket;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+/**
+ * JAXRSClientServerWebSocketSpringTest without atmosphere
+ */
+public class JAXRSClientServerWebSocketSpringNoAtmosphereTest extends JAXRSClientServerWebSocketSpringTest
{
+    private static final String PORT = BookServerWebSocket.PORT2_SPRING;
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        System.setProperty("org.apache.cxf.transport.websocket.atmosphere.disabled", "true");
+        @SuppressWarnings({ "unused", "resource" })
+        ApplicationContext appctxt = 
+            new ClassPathXmlApplicationContext(
+                JAXRSClientServerWebSocketSpringTest.class.getResource(
+                    "/jaxrs_websocket/beans-embedded2.xml").toString());
+    }
+
+    @AfterClass
+    public static void cleanup() {
+        System.clearProperty("org.apache.cxf.transport.websocket.atmosphere.disabled");
+    }
+
+    protected String getPort() {
+        return PORT;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppNoAtmosphereTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppNoAtmosphereTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppNoAtmosphereTest.java
new file mode 100644
index 0000000..1c5aa60
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppNoAtmosphereTest.java
@@ -0,0 +1,45 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxrs.websocket;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+
+/**
+ * JAXRSClientServerWebSocketSpringWebAppTest without atmosphere
+ */
+public class JAXRSClientServerWebSocketSpringWebAppNoAtmosphereTest extends JAXRSClientServerWebSocketSpringWebAppTest
{
+    private static final String PORT = BookServerWebSocket.PORT2_WAR;
+
+    @BeforeClass
+    public static void startServers() throws Exception {
+        System.setProperty("org.apache.cxf.transport.websocket.atmosphere.disabled", "true");
+        startServers(PORT);
+    }
+
+    @AfterClass
+    public static void cleanup() {
+        System.clearProperty("org.apache.cxf.transport.websocket.atmosphere.disabled");
+    }
+
+    protected String getPort() {
+        return PORT;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppTest.java
index 4b9ce4f..28d587b 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketSpringWebAppTest.java
@@ -23,11 +23,9 @@ import java.net.URISyntaxException;
 
 import org.apache.cxf.jaxrs.client.WebClient;
 import org.apache.cxf.systest.jaxrs.Book;
-import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
 import org.eclipse.jetty.server.handler.DefaultHandler;
 import org.eclipse.jetty.server.handler.HandlerCollection;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 import org.junit.AfterClass;
@@ -43,11 +41,11 @@ public class JAXRSClientServerWebSocketSpringWebAppTest extends JAXRSClientServe
 
     @BeforeClass
     public static void startServers() throws Exception {
-        server = new org.eclipse.jetty.server.Server();
-
-        SelectChannelConnector connector = new SelectChannelConnector();
-        connector.setPort(Integer.parseInt(BookServerWebSocket.PORT_WAR));
-        server.setConnectors(new Connector[] {connector});
+        startServers(PORT);
+    }
+    
+    protected static void startServers(String port) throws Exception {
+        server = new org.eclipse.jetty.server.Server(Integer.parseInt(port));
 
         WebAppContext webappcontext = new WebAppContext();
         String contextPath = null;
@@ -64,7 +62,6 @@ public class JAXRSClientServerWebSocketSpringWebAppTest extends JAXRSClientServe
         handlers.setHandlers(new Handler[] {webappcontext, new DefaultHandler()});
         server.setHandler(handlers);
         server.start();
-
     }
     
     @AfterClass

http://git-wip-us.apache.org/repos/asf/cxf/blob/27dd4216/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded2.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded2.xml b/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded2.xml
new file mode 100644
index 0000000..7ae676f
--- /dev/null
+++ b/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded2.xml
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+  
+  http://www.apache.org/licenses/LICENSE-2.0
+  
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<!-- START SNIPPET: beans -->
+<beans xmlns="http://www.springframework.org/schema/beans" 
+   xmlns:http="http://cxf.apache.org/transports/http/configuration"
+   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"

+   xmlns:jaxrs="http://cxf.apache.org/jaxrs" 
+   xmlns:cxf="http://cxf.apache.org/core" 
+   xsi:schemaLocation="
+   http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd

+   http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
+   http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd
+   http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+   http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
+    <import resource="classpath:META-INF/cxf/cxf.xml"/>
+    <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
+
+    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
+        
+    <bean class="org.apache.cxf.systest.jaxrs.websocket.BookStoreWebSocket" id="serviceBean"/>
+
+    <jaxrs:server id="bookservice" address="ws://localhost:${testutil.ports.org.apache.cxf.systest.jaxrs.websocket.BookServerWebSocket.5}/websocket">
+        <jaxrs:serviceBeans>
+            <ref bean="serviceBean"/>
+        </jaxrs:serviceBeans>
+        <jaxrs:providers>
+            <bean class="org.apache.cxf.jaxrs.provider.StreamingResponseProvider"/>
+        </jaxrs:providers>
+    </jaxrs:server>
+</beans>
+<!-- END SNIPPET: beans -->


Mime
View raw message