You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2014/03/13 17:38:49 UTC
git commit: Add a test validating websocket endpoint can accept pure
HTTP requests
Repository: cxf
Updated Branches:
refs/heads/master 21b959991 -> 9d4ddb5a8
Add a test validating websocket endpoint can accept pure HTTP requests
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/9d4ddb5a
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/9d4ddb5a
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/9d4ddb5a
Branch: refs/heads/master
Commit: 9d4ddb5a84bf3636d3e604fabf55d0b3ab507744
Parents: 21b9599
Author: Sergey Beryozkin <sb...@talend.com>
Authored: Thu Mar 13 16:38:19 2014 +0000
Committer: Sergey Beryozkin <sb...@talend.com>
Committed: Thu Mar 13 16:38:19 2014 +0000
----------------------------------------------------------------------
...RSClientServerWebSocketSpringWebAppTest.java | 9 ++++++
.../JAXRSClientServerWebSocketTest.java | 30 ++++++++++++++++++++
2 files changed, 39 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/9d4ddb5a/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 ce6291b..002a42c 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
@@ -72,6 +72,15 @@ public class JAXRSClientServerWebSocketSpringWebAppTest extends JAXRSClientServe
Book book = wc.get(Book.class);
assertEquals(1L, book.getId());
}
+
+ @Test
+ public void testGetBookHTTPFromWebSocketEndpoint() throws Exception {
+ String address = "http://localhost:" + getPort() + "/websocket/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/9d4ddb5a/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 0231123..9aad879 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
@@ -21,7 +21,9 @@ package org.apache.cxf.systest.jaxrs.websocket;
import java.util.List;
+import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
+import org.apache.cxf.systest.jaxrs.Book;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.junit.BeforeClass;
@@ -102,6 +104,34 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
}
@Test
+ public void testBookWithWebSocketAndHTTP() throws Exception {
+ String address = "ws://localhost:" + getPort() + "/websocket/web/bookstore";
+
+ WebSocketTestClient wsclient = new WebSocketTestClient(address, 1);
+ wsclient.connect();
+ try {
+ // call the GET service
+ wsclient.sendMessage("GET /websocket/web/bookstore/booknames".getBytes());
+ assertTrue("one book must be returned", wsclient.await(3));
+ List<Object> received = wsclient.getReceived();
+ assertEquals(1, received.size());
+ Response resp = new Response(received.get(0));
+ assertEquals(200, resp.getStatusCode());
+ assertEquals("text/plain", resp.getContentType());
+ String value = resp.getTextEntity();
+ assertEquals("CXF in Action", value);
+
+ WebClient wc = WebClient.create("http://localhost:" + getPort() + "/websocket/web/bookstore/books/1");
+ wc.accept("application/xml");
+ Book book = wc.get(Book.class);
+ assertEquals(1L, book.getId());
+
+ } finally {
+ wsclient.close();
+ }
+ }
+
+ @Test
public void testBookWithWebSocketServletStream() throws Exception {
String address = "ws://localhost:" + getPort() + "/websocket/web/bookstore";