Skip to content

Commit

Permalink
[RESTEASY-1680] Making testMultipleDataFields more robust
Browse files Browse the repository at this point in the history
  • Loading branch information
asoldano committed Sep 27, 2017
1 parent 74166f6 commit 00ef0fe
Showing 1 changed file with 4 additions and 2 deletions.
Expand Up @@ -3,6 +3,8 @@
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
Expand Down Expand Up @@ -258,7 +260,7 @@ public void testMultipleDataFields() throws Exception
{ {
final CountDownLatch latch = new CountDownLatch(7); final CountDownLatch latch = new CountDownLatch(7);
final AtomicInteger errors = new AtomicInteger(0); final AtomicInteger errors = new AtomicInteger(0);
final List<String> results = new ArrayList<String>(); final SortedSet<String> results = new TreeSet<String>();
Client client = ClientBuilder.newBuilder().build(); Client client = ClientBuilder.newBuilder().build();
WebTarget target = client.target(generateURL("/service/server-sent-events")); WebTarget target = client.target(generateURL("/service/server-sent-events"));
SseEventSource msgEventSource = SseEventSource.target(target).build(); SseEventSource msgEventSource = SseEventSource.target(target).build();
Expand Down Expand Up @@ -293,7 +295,7 @@ public void testMultipleDataFields() throws Exception
} }
Assert.assertFalse("SseEventSource is not closed", msgEventSource.isOpen()); Assert.assertFalse("SseEventSource is not closed", msgEventSource.isOpen());
Assert.assertTrue("5 messages are expected, but is : " + results.size(), results.size() == 7); Assert.assertTrue("5 messages are expected, but is : " + results.size(), results.size() == 7);
String[] lines = results.get(1).split("\n"); String[] lines = results.toArray(new String[]{})[1].split("\n");
Assert.assertTrue("3 data fields are expected, but is : " + lines.length, lines.length == 3); Assert.assertTrue("3 data fields are expected, but is : " + lines.length, lines.length == 3);
Assert.assertEquals("expect second data field value is : " + lines[1], "data1b", lines[1]); Assert.assertEquals("expect second data field value is : " + lines[1], "data1b", lines[1]);


Expand Down

0 comments on commit 00ef0fe

Please sign in to comment.