Skip to content

Commit

Permalink
CXF-5855: restructured SSE test cases to stabilize them (attempt jboss#2
Browse files Browse the repository at this point in the history
)
  • Loading branch information
reta committed Sep 23, 2016
1 parent 46e7e8b commit 7e2b6f2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,21 @@
package org.apache.cxf.systest.jaxrs.sse;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;

import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

import com.fasterxml.jackson.core.JsonProcessingException;

import org.junit.Test;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.hasItems;

public abstract class AbstractBroadcasterSseTest extends AbstractSseBaseTest {
@Test
Expand Down Expand Up @@ -61,4 +66,15 @@ public void testBooksStreamIsBroadcasted() throws Exception {
r.close();
}
}

@Test
public void testBooksAreReturned() throws JsonProcessingException {
Response r = createWebClient("/rest/api/bookstore", MediaType.APPLICATION_JSON).get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());

final Book[] books = r.readEntity(Book[].class);
assertThat(Arrays.asList(books), hasItems(new Book("New Book #1", 1), new Book("New Book #2", 2)));

r.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
*/
package org.apache.cxf.systest.jaxrs.sse;

import java.util.Arrays;

import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;

Expand All @@ -30,7 +27,6 @@
import org.junit.Test;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.CoreMatchers.hasItems;

public abstract class AbstractSseTest extends AbstractSseBaseTest {
@Test
Expand All @@ -55,15 +51,4 @@ public void testBooksStreamIsReturnedFromLastEventId() throws JsonProcessingExce

r.close();
}

@Test
public void testBooksAreReturned() throws JsonProcessingException {
Response r = createWebClient("/rest/api/bookstore", MediaType.APPLICATION_JSON).get();
assertEquals(Status.OK.getStatusCode(), r.getStatus());

final Book[] books = r.readEntity(Book[].class);
assertThat(Arrays.asList(books), hasItems(new Book("New Book #1", 1), new Book("New Book #2", 2)));

r.close();
}
}

0 comments on commit 7e2b6f2

Please sign in to comment.