cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject cxf git commit: CXF-5855: removing duplicated SSE test cases
Date Thu, 22 Sep 2016 00:34:29 GMT
Repository: cxf
Updated Branches:
  refs/heads/master 5a57f4a89 -> f66dea949


CXF-5855: removing duplicated SSE test cases


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

Branch: refs/heads/master
Commit: f66dea949bdc3f136084115aca4e514bad426380
Parents: 5a57f4a
Author: reta <drreta@gmail.com>
Authored: Wed Sep 21 20:34:10 2016 -0400
Committer: reta <drreta@gmail.com>
Committed: Wed Sep 21 20:34:10 2016 -0400

----------------------------------------------------------------------
 .../cxf/systest/jaxrs/sse/AbstractSseTest.java  | 21 --------------------
 .../apache/cxf/systest/jaxrs/sse/BookStore.java | 21 +++++++++++++++-----
 2 files changed, 16 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/f66dea94/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/AbstractSseTest.java
----------------------------------------------------------------------
diff --git a/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/AbstractSseTest.java
b/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/AbstractSseTest.java
index bf93da6..80d5cde 100644
--- a/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/AbstractSseTest.java
+++ b/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/AbstractSseTest.java
@@ -45,27 +45,6 @@ public abstract class AbstractSseTest extends AbstractBusClientServerTestBase
{
     private final ObjectMapper mapper = new ObjectMapper();
     
     @Test
-    public void testBooksStreamIsReturned() throws JsonProcessingException {
-        Response r = createWebClient("/rest/api/bookstore/sse/100").get();
-        assertEquals(Status.OK.getStatusCode(), r.getStatus());
-        
-        final String response = r.readEntity(String.class);
-        assertThat(response, containsString("id: 1"));
-        assertThat(response, containsString("data: " + toJson("New Book #1", 1)));
-        
-        assertThat(response, containsString("id: 2"));
-        assertThat(response, containsString("data: " + toJson("New Book #2", 2)));
-        
-        assertThat(response, containsString("id: 3"));
-        assertThat(response, containsString("data: " + toJson("New Book #3", 3)));
-        
-        assertThat(response, containsString("id: 4"));
-        assertThat(response, containsString("data: " + toJson("New Book #4", 4)));
-        
-        r.close();
-    }
-    
-    @Test
     public void testBooksStreamIsReturnedFromLastEventId() throws JsonProcessingException
{
         Response r = createWebClient("/rest/api/bookstore/sse/100")
             .header(HttpHeaders.LAST_EVENT_ID_HEADER, 150)

http://git-wip-us.apache.org/repos/asf/cxf/blob/f66dea94/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
----------------------------------------------------------------------
diff --git a/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
b/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
index 6af5a1f..d7a8b57 100644
--- a/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
+++ b/systests/rs-sse/src/test/java/org/apache/cxf/systest/jaxrs/sse/BookStore.java
@@ -40,8 +40,13 @@ import javax.ws.rs.sse.SseBroadcaster;
 import javax.ws.rs.sse.SseContext;
 import javax.ws.rs.sse.SseEventOutput;
 
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 @Path("/api/bookstore")
 public class BookStore {
+    private static final Logger LOG = LoggerFactory.getLogger(BookStore.class);
+
     private final CountDownLatch latch = new CountDownLatch(2);
     private final AtomicReference<SseBroadcaster> broadcaster = 
         new AtomicReference<SseBroadcaster>();
@@ -84,8 +89,8 @@ public class BookStore {
                     output.write(createStatsEvent(sseContext.newEvent().name("book"), id
+ 4));
                     Thread.sleep(200);
                     output.close();
-                } catch (final InterruptedException | IOException e) {
-                    e.printStackTrace();
+                } catch (final InterruptedException | IOException ex) {
+                    LOG.error("Communication error", ex);
                 }
             }
         }.start();
@@ -117,9 +122,15 @@ public class BookStore {
     
     @POST
     @Path("broadcast/close")
-    public void stop() throws InterruptedException {
-        // Await a least 2 clients to be broadcasted over 
-        latch.await(2, TimeUnit.SECONDS);
+    public void stop() {
+        try {
+            // Await a least 2 clients to be broadcasted over 
+            if (!latch.await(2, TimeUnit.SECONDS)) {
+                LOG.warn("Not enough clients have been connected, closing broadcaster anyway");
+            }
+        } catch (final InterruptedException ex) {
+            LOG.error("Wait has been interrupted", ex);
+        }
         
         if (broadcaster.get() != null) {
             broadcaster.get().close();


Mime
View raw message