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] Reintroducing BookStoreWebSocket
Date Thu, 27 Feb 2014 16:38:22 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 1ab9f70d4 -> e3d15f85f


[CXF-5339] Reintroducing BookStoreWebSocket


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

Branch: refs/heads/master
Commit: e3d15f85f872c67b51dc0657164ed3f2447151b2
Parents: 1ab9f70
Author: Sergey Beryozkin <sberyozkin@talend.com>
Authored: Thu Feb 27 16:38:04 2014 +0000
Committer: Sergey Beryozkin <sberyozkin@talend.com>
Committed: Thu Feb 27 16:38:04 2014 +0000

----------------------------------------------------------------------
 .../org/apache/cxf/systest/jaxrs/BookStore.java | 26 +-----
 .../jaxrs/websocket/BookServerWebSocket.java    |  7 +-
 .../jaxrs/websocket/BookStoreWebSocket.java     | 88 ++++++++++++++++++++
 .../JAXRSClientServerWebSocketTest.java         |  2 +-
 4 files changed, 93 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/e3d15f85/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
index 1168ad8..4e20efb 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/BookStore.java
@@ -1318,31 +1318,7 @@ public class BookStore {
     public Long echoBookId(long theBookId) {
         return new Long(theBookId);
     }
-    
-    @GET
-    @Path("/bookbought")
-    @Produces("text/*")
-    public StreamingOutput getBookBought() {
-        return new StreamingOutput() {
-            public void write(final OutputStream out) throws IOException, WebApplicationException
{
-                out.write(("Today: " + new java.util.Date()).getBytes());
-                // just for testing, using a thread
-                new Thread(new Runnable() {
-                    public void run() {
-                        try {
-                            for (int r = 2, i = 1; i <= 5; r *= 2, i++) {
-                                Thread.sleep(500);
-                                out.write(Integer.toString(r).getBytes());
-                            }
-                        } catch (Exception e) {
-                            e.printStackTrace();
-                        }
-                    }
-                }).start();
-            }
-        };
-    }
-    
+       
     @POST
     @Path("/booksecho")
     @Consumes("text/plain")

http://git-wip-us.apache.org/repos/asf/cxf/blob/e3d15f85/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 b704f68..7084406 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
@@ -26,7 +26,6 @@ import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
 import org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider;
-import org.apache.cxf.systest.jaxrs.BookStore;
 import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
 import org.apache.cxf.transport.http_jetty.JettyHTTPDestination;
     
@@ -52,9 +51,9 @@ public class BookServerWebSocket extends AbstractBusTestServerBase {
         setBus(bus);
         JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
         sf.setBus(bus);
-        sf.setResourceClasses(BookStore.class);
-        sf.setResourceProvider(BookStore.class,
-                               new SingletonResourceProvider(new BookStore(), true));
+        sf.setResourceClasses(BookStoreWebSocket.class);
+        sf.setResourceProvider(BookStoreWebSocket.class,
+                               new SingletonResourceProvider(new BookStoreWebSocket(), true));
         sf.setAddress("http://localhost:" + PORT + "/");
         server = sf.create();
         ((JettyHTTPDestination)server.getDestination())

http://git-wip-us.apache.org/repos/asf/cxf/blob/e3d15f85/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
new file mode 100644
index 0000000..8a36e84
--- /dev/null
+++ b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/websocket/BookStoreWebSocket.java
@@ -0,0 +1,88 @@
+/**
+ * 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 java.io.IOException;
+import java.io.OutputStream;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+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.StreamingOutput;
+
+import org.apache.cxf.systest.jaxrs.Book;
+
+@Path("/bookstore")
+public class BookStoreWebSocket {
+    
+    @GET
+    @Path("/booknames")
+    @Produces("text/plain")
+    public byte[] getBookName() {
+        return "CXF in Action".getBytes();
+    }
+    
+    @GET
+    @Path("/books/{id}")
+    @Produces("application/xml")
+    public Book getBook(@PathParam("id") long id) {
+        return new Book("CXF in Action", id);
+    }
+    
+    @POST
+    @Path("/booksplain")
+    @Consumes("text/plain")
+    @Produces("text/plain")
+    public Long echoBookId(long theBookId) {
+        return new Long(theBookId);
+    }
+    
+    @GET
+    @Path("/bookbought")
+    @Produces("text/*")
+    public StreamingOutput getBookBought() {
+        return new StreamingOutput() {
+            public void write(final OutputStream out) throws IOException, WebApplicationException
{
+                out.write(("Today: " + new java.util.Date()).getBytes());
+                // just for testing, using a thread
+                new Thread(new Runnable() {
+                    public void run() {
+                        try {
+                            for (int r = 2, i = 1; i <= 5; r *= 2, i++) {
+                                Thread.sleep(500);
+                                out.write(Integer.toString(r).getBytes());
+                            }
+                        } catch (Exception e) {
+                            e.printStackTrace();
+                        }
+                    }
+                }).start();
+            }
+        };
+    }
+    
+}
+
+

http://git-wip-us.apache.org/repos/asf/cxf/blob/e3d15f85/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 3568a00..b7b8884 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
@@ -50,7 +50,7 @@ public class JAXRSClientServerWebSocketTest extends AbstractBusClientServerTestB
         wsclient.connect();
         try {
             // call the GET service
-            wsclient.sendMessage("GET /bookstore/booknames/123".getBytes());
+            wsclient.sendMessage("GET /bookstore/booknames".getBytes());
             assertTrue("one book must be returned", wsclient.await(3));
             List<byte[]> received = wsclient.getReceivedBytes();
             assertEquals(1, received.size());


Mime
View raw message