From 40912425cfa63fea9dcb669fb0c31837e5c8a2e4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Sat, 22 Aug 2015 18:46:53 +0200 Subject: [PATCH] Refactoring --- .../fcp/quelaton/DefaultFcpClientTest.java | 29 ++++++++++++---------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index 4e5eb84..dae4111 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -2296,13 +2296,7 @@ public class DefaultFcpClientTest { public void subscriptionWorks() throws InterruptedException, ExecutionException, IOException { Future> uskSubscription = fcpClient.subscribeUsk().uri(URI).execute(); connectAndAssert(() -> matchesFcpMessage("SubscribeUSK", "URI=" + URI, "EndMessage")); - fcpServer.writeLine( - "SubscribedUSK", - "Identifier=" + identifier, - "URI=" + URI, - "DontPoll=false", - "EndMessage" - ); + replyWithSubscribed(); assertThat(uskSubscription.get().get().getUri(), is(URI)); AtomicInteger edition = new AtomicInteger(); CountDownLatch updated = new CountDownLatch(2); @@ -2310,22 +2304,31 @@ public class DefaultFcpClientTest { edition.set(e); updated.countDown(); }); + sendUpdateNotification(23); + sendUpdateNotification(24); + assertThat("updated in time", updated.await(5, TimeUnit.SECONDS), is(true)); + assertThat(edition.get(), is(24)); + } + + private void replyWithSubscribed() throws IOException { fcpServer.writeLine( - "SubscribedUSKUpdate", + "SubscribedUSK", "Identifier=" + identifier, "URI=" + URI, - "Edition=23", + "DontPoll=false", "EndMessage" ); + } + + private void sendUpdateNotification(int edition, String... additionalLines) throws IOException { fcpServer.writeLine( "SubscribedUSKUpdate", "Identifier=" + identifier, "URI=" + URI, - "Edition=24", - "EndMessage" + "Edition=" + edition ); - assertThat("updated in time", updated.await(5, TimeUnit.SECONDS), is(true)); - assertThat(edition.get(), is(24)); + fcpServer.writeLine(additionalLines); + fcpServer.writeLine("EndMessage"); } } -- 2.7.4