Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 81C3717EFC for ; Wed, 25 Mar 2015 17:14:18 +0000 (UTC) Received: (qmail 81999 invoked by uid 500); 25 Mar 2015 17:14:15 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 81939 invoked by uid 500); 25 Mar 2015 17:14:15 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 81930 invoked by uid 99); 25 Mar 2015 17:14:15 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Mar 2015 17:14:15 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 472E9E1872; Wed, 25 Mar 2015 17:14:15 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ay@apache.org To: commits@cxf.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: [CXF-6318] Execute JAXRS WebSocket systests with and without atmosphere Date: Wed, 25 Mar 2015 17:14:15 +0000 (UTC) Repository: cxf Updated Branches: refs/heads/master 784bfda6a -> 702a4c175 [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/702a4c17 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/702a4c17 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/702a4c17 Branch: refs/heads/master Commit: 702a4c1759263d25ab62c0804ed61a77771f099a Parents: 784bfda Author: Akitoshi Yoshida Authored: Wed Mar 25 18:12:45 2015 +0100 Committer: Akitoshi Yoshida Committed: Wed Mar 25 18:12:45 2015 +0100 ---------------------------------------------------------------------- .../websocket/WebSocketDestinationFactory.java | 8 ++- systests/jaxrs/pom.xml | 19 +++---- .../jaxrs/websocket/BookServerWebSocket.java | 12 ++++- ...RSClientServerWebSocketNoAtmosphereTest.java | 51 +++++++++++++++++++ ...ntServerWebSocketSpringNoAtmosphereTest.java | 52 ++++++++++++++++++++ ...erWebSocketSpringWebAppNoAtmosphereTest.java | 45 +++++++++++++++++ ...RSClientServerWebSocketSpringWebAppTest.java | 7 ++- .../jaxrs_websocket/beans-embedded2.xml | 48 ++++++++++++++++++ 8 files changed, 226 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/702a4c17/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 a1938ae..fccc265 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; @@ -44,6 +45,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()); @@ -69,7 +73,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); @@ -87,7 +91,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/702a4c17/systests/jaxrs/pom.xml ---------------------------------------------------------------------- diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml index b908d64..9ad0914 100644 --- a/systests/jaxrs/pom.xml +++ b/systests/jaxrs/pom.xml @@ -472,7 +472,14 @@ jsonassert 1.2.3 test - + + + + org.atmosphere + atmosphere-runtime + ${cxf.atmosphere.version} + @@ -572,15 +579,5 @@ - - atmosphere - - - org.atmosphere - atmosphere-runtime - ${cxf.atmosphere.version} - - - http://git-wip-us.apache.org/repos/asf/cxf/blob/702a4c17/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()); 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/702a4c17/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/702a4c17/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/702a4c17/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/702a4c17/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 806661e..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 @@ -41,7 +41,11 @@ public class JAXRSClientServerWebSocketSpringWebAppTest extends JAXRSClientServe @BeforeClass public static void startServers() throws Exception { - server = new org.eclipse.jetty.server.Server(Integer.parseInt(BookServerWebSocket.PORT_WAR)); + 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; @@ -58,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/702a4c17/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 @@ + + + + + + + + + + + + + + + + + + + + +