cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject git commit: [CXF-5339] Adding a test confirming WebSocket transport is not blocking a regular HTTP path
Date Wed, 12 Mar 2014 17:11:26 GMT
Repository: cxf
Updated Branches:
  refs/heads/master c25a5c905 -> 6069d724d


[CXF-5339] Adding a test confirming WebSocket transport is not blocking a regular HTTP path


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

Branch: refs/heads/master
Commit: 6069d724d9799533e7ee7fa5c0c770a7684295d0
Parents: c25a5c9
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Wed Mar 12 17:11:08 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Wed Mar 12 17:11:08 2014 +0000

----------------------------------------------------------------------
 .../jaxrs/websocket/BookServerWebSocket.java    |  2 +-
 ...RSClientServerWebSocketSpringWebAppTest.java | 12 ++++++++++
 .../JAXRSClientServerWebSocketTest.java         | 24 +++++++++++---------
 .../resources/jaxrs_websocket/WEB-INF/beans.xml |  8 ++++++-
 .../jaxrs_websocket/beans-embedded.xml          |  2 +-
 5 files changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/6069d724/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 32bbb7a..5938f09 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
@@ -44,7 +44,7 @@ public class BookServerWebSocket extends AbstractBusTestServerBase {
         sf.setResourceClasses(BookStoreWebSocket.class, BookStorePerRequest.class);
         sf.setResourceProvider(BookStoreWebSocket.class,
                                new SingletonResourceProvider(new BookStoreWebSocket(), true));
-        sf.setAddress("ws://localhost:" + PORT + "/");
+        sf.setAddress("ws://localhost:" + PORT + "/websocket");
         server = sf.create();
 
         BusFactory.setDefaultBus(null);

http://git-wip-us.apache.org/repos/asf/cxf/blob/6069d724/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 b6d20a9..ce6291b 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
@@ -21,6 +21,8 @@ package org.apache.cxf.systest.jaxrs.websocket;
 
 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;
@@ -29,6 +31,7 @@ import org.eclipse.jetty.server.nio.SelectChannelConnector;
 import org.eclipse.jetty.webapp.WebAppContext;
 
 import org.junit.BeforeClass;
+import org.junit.Test;
 
 /**
  * JAXRSClientServerWebSocket test with jaxrs:server using the jetty webapp server.
@@ -60,6 +63,15 @@ public class JAXRSClientServerWebSocketSpringWebAppTest extends JAXRSClientServe
         server.start();
 
     }
+    
+    @Test
+    public void testGetBookHTTP() throws Exception {
+        String address = "http://localhost:" + getPort() + "/http/web/bookstore/books/1";
+        WebClient wc = WebClient.create(address);
+        wc.accept("application/xml");
+        Book book = wc.get(Book.class);
+        assertEquals(1L, book.getId());
+    }
 
     protected String getPort() {
         return PORT;

http://git-wip-us.apache.org/repos/asf/cxf/blob/6069d724/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketTest.java
b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketTest.java
index b437af1..a445f9a 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketTest.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/JAXRSClientServerWebSocketTest.java
@@ -39,13 +39,13 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
     
     @Test
     public void testBookWithWebSocket() throws Exception {
-        String address = "ws://localhost:" + getPort() + "/web/bookstore";
+        String address = "ws://localhost:" + getPort() + "/websocket/web/bookstore";
 
         WebSocketTestClient wsclient = new WebSocketTestClient(address, 1);
         wsclient.connect();
         try {
             // call the GET service
-            wsclient.sendMessage("GET /web/bookstore/booknames".getBytes());
+            wsclient.sendMessage("GET /websocket/web/bookstore/booknames".getBytes());
             assertTrue("one book must be returned", wsclient.await(3));
             List<byte[]> received = wsclient.getReceivedBytes();
             assertEquals(1, received.size());
@@ -57,7 +57,7 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
             
             // call another GET service
             wsclient.reset(1);
-            wsclient.sendMessage("GET /web/bookstore/books/123".getBytes());
+            wsclient.sendMessage("GET /websocket/web/bookstore/books/123".getBytes());
             assertTrue("response expected", wsclient.await(3));
             received = wsclient.getReceivedBytes();
             resp = new Response(received.get(0));
@@ -68,7 +68,9 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
             
             // call the POST service
             wsclient.reset(1);
-            wsclient.sendMessage("POST /web/bookstore/booksplain\r\nContent-Type: text/plain\r\n\r\n123".getBytes());
+            wsclient.sendMessage(
+                "POST /websocket/web/bookstore/booksplain\r\nContent-Type: text/plain\r\n\r\n123"
+                    .getBytes());
             assertTrue("response expected", wsclient.await(3));
             received = wsclient.getReceivedBytes();
             resp = new Response(received.get(0));
@@ -79,7 +81,7 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
             
             // call the GET service returning a continous stream output
             wsclient.reset(6);
-            wsclient.sendMessage("GET /web/bookstore/bookbought".getBytes());
+            wsclient.sendMessage("GET /websocket/web/bookstore/bookbought".getBytes());
             assertTrue("response expected", wsclient.await(5));
             received = wsclient.getReceivedBytes();
             assertEquals(6, received.size());
@@ -101,12 +103,12 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
     
     @Test
     public void testBookWithWebSocketServletStream() throws Exception {
-        String address = "ws://localhost:" + getPort() + "/web/bookstore";
+        String address = "ws://localhost:" + getPort() + "/websocket/web/bookstore";
 
         WebSocketTestClient wsclient = new WebSocketTestClient(address, 1);
         wsclient.connect();
         try {
-            wsclient.sendMessage("GET /web/bookstore/booknames/servletstream".getBytes());
+            wsclient.sendMessage("GET /websocket/web/bookstore/booknames/servletstream".getBytes());
             assertTrue("one book must be returned", wsclient.await(3));
             List<byte[]> received = wsclient.getReceivedBytes();
             assertEquals(1, received.size());
@@ -122,13 +124,13 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
     
     @Test
     public void testWrongMethod() throws Exception {
-        String address = "ws://localhost:" + getPort() + "/web/bookstore";
+        String address = "ws://localhost:" + getPort() + "/websocket/web/bookstore";
 
         WebSocketTestClient wsclient = new WebSocketTestClient(address, 1);
         wsclient.connect();
         try {
             // call the GET service using POST
-            wsclient.sendMessage("POST /web/bookstore/booknames".getBytes());
+            wsclient.sendMessage("POST /websocket/web/bookstore/booknames".getBytes());
             assertTrue("error response expected", wsclient.await(3));
             List<byte[]> received = wsclient.getReceivedBytes();
             assertEquals(1, received.size());
@@ -141,13 +143,13 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
     
     @Test
     public void testPathRestriction() throws Exception {
-        String address = "ws://localhost:" + getPort() + "/web/bookstore";
+        String address = "ws://localhost:" + getPort() + "/websocket/web/bookstore";
 
         WebSocketTestClient wsclient = new WebSocketTestClient(address, 1);
         wsclient.connect();
         try {
             // call the GET service over the different path
-            wsclient.sendMessage("GET /bookstore2".getBytes());
+            wsclient.sendMessage("GET /websocket/bookstore2".getBytes());
             assertTrue("error response expected", wsclient.await(3));
             List<byte[]> received = wsclient.getReceivedBytes();
             assertEquals(1, received.size());

http://git-wip-us.apache.org/repos/asf/cxf/blob/6069d724/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/beans.xml
index 45701db..ee215be 100644
--- a/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/beans.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs_websocket/WEB-INF/beans.xml
@@ -36,10 +36,16 @@
 
     <bean class="org.apache.cxf.systest.jaxrs.websocket.BookStoreWebSocket" id="serviceBean"/>
 
-    <jaxrs:server id="bookservice" address="/" transportId="http://cxf.apache.org/transports/websockt">
+    <jaxrs:server id="bookserviceWS" address="/websocket" transportId="http://cxf.apache.org/transports/websockt">
         <jaxrs:serviceBeans>
             <ref bean="serviceBean"/>
         </jaxrs:serviceBeans>
     </jaxrs:server>
+    <jaxrs:server id="bookserviceHTTP" address="/http">
+        <jaxrs:serviceBeans>
+            <ref bean="serviceBean"/>
+        </jaxrs:serviceBeans>
+    </jaxrs:server>
+    
 </beans>
 <!-- END SNIPPET: beans -->

http://git-wip-us.apache.org/repos/asf/cxf/blob/6069d724/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded.xml b/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded.xml
index dfb3fd3..fb4206b 100644
--- a/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded.xml
+++ b/systests/jaxrs/src/test/resources/jaxrs_websocket/beans-embedded.xml
@@ -36,7 +36,7 @@
         
     <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.2}/">
+    <jaxrs:server id="bookservice" address="ws://localhost:${testutil.ports.org.apache.cxf.systest.jaxrs.websocket.BookServerWebSocket.2}/websocket">
         <jaxrs:serviceBeans>
             <ref bean="serviceBean"/>
         </jaxrs:serviceBeans>


Mime
View raw message