Repository: cxf Updated Branches: refs/heads/master 30a9e0570 -> 764404893
[CXF-5339] Adding one more test for now Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/76440489 Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/76440489 Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/76440489 Branch: refs/heads/master Commit: 764404893044c6b11491eb083b220bdf575ed2a1 Parents: 30a9e05 Author: Sergey Beryozkin <[email protected]> Authored: Thu Feb 27 17:31:12 2014 +0000 Committer: Sergey Beryozkin <[email protected]> Committed: Thu Feb 27 17:31:12 2014 +0000 ---------------------------------------------------------------------- .../jaxrs/websocket/BookStoreWebSocket.java | 11 ++++++++++ .../JAXRSClientServerWebSocketTest.java | 21 +++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/76440489/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookStoreWebSocket.java ---------------------------------------------------------------------- diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookStoreWebSocket.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookStoreWebSocket.java index f3eb0fb..40ffee3 100644 --- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookStoreWebSocket.java +++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookStoreWebSocket.java @@ -23,6 +23,7 @@ package org.apache.cxf.systest.jaxrs.websocket; import java.io.IOException; import java.io.OutputStream; +import javax.servlet.http.HttpServletResponse; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -30,6 +31,7 @@ import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.Produces; import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; import javax.ws.rs.core.StreamingOutput; import org.apache.cxf.systest.jaxrs.Book; @@ -45,6 +47,15 @@ public class BookStoreWebSocket { } @GET + @Path("/booknames/servletstream") + @Produces("text/plain") + public void getBookNameStream(@Context HttpServletResponse response) throws Exception { + OutputStream os = response.getOutputStream(); + os.write("CXF in Action".getBytes()); + os.flush(); + } + + @GET @Path("/books/{id}") @Produces("application/xml") public Book getBook(@PathParam("id") long id) { http://git-wip-us.apache.org/repos/asf/cxf/blob/76440489/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 fea4898..ec2bceb 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 @@ -57,7 +57,7 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB assertEquals(1, received.size()); String value = new String(received.get(0)); assertEquals("CXF in Action", value); - + // call another GET service wsclient.reset(1); wsclient.sendMessage("GET /web/bookstore/books/123".getBytes()); @@ -91,6 +91,25 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB @Test @Ignore + public void testBookWithWebSocketServletStream() throws Exception { + String address = "ws://localhost:" + PORT + "/web/bookstore"; + + WebSocketTestClient wsclient = new WebSocketTestClient(address, 1); + wsclient.connect(); + try { + wsclient.sendMessage("GET /web/bookstore/booknames/servletstream".getBytes()); + assertTrue("one book must be returned", wsclient.await(3)); + List<byte[]> received = wsclient.getReceivedBytes(); + assertEquals(1, received.size()); + String value = new String(received.get(0)); + assertEquals("CXF in Action", value); + } finally { + wsclient.close(); + } + } + + @Test + @Ignore public void testWrongMethod() throws Exception { String address = "ws://localhost:" + PORT + "/web/bookstore";
