From 0baa2578d55abb039b5fc2eea39b811c9d01d402 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:47:15 +0200 Subject: [PATCH] Add test for multiple listeners on one subscription --- .../fcp/quelaton/DefaultFcpClientTest.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java index dae4111..c37b5e0 100644 --- a/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java +++ b/src/test/java/net/pterodactylus/fcp/quelaton/DefaultFcpClientTest.java @@ -2310,6 +2310,24 @@ public class DefaultFcpClientTest { assertThat(edition.get(), is(24)); } + @Test + public void subscriptionUpdatesMultipleTimes() throws InterruptedException, ExecutionException, IOException { + Future> uskSubscription = fcpClient.subscribeUsk().uri(URI).execute(); + connectAndAssert(() -> matchesFcpMessage("SubscribeUSK", "URI=" + URI, "EndMessage")); + replyWithSubscribed(); + assertThat(uskSubscription.get().get().getUri(), is(URI)); + AtomicInteger edition = new AtomicInteger(); + CountDownLatch updated = new CountDownLatch(2); + uskSubscription.get().get().onUpdate(e -> { + edition.set(e); + updated.countDown(); + }); + uskSubscription.get().get().onUpdate(e -> updated.countDown()); + sendUpdateNotification(23); + assertThat("updated in time", updated.await(5, TimeUnit.SECONDS), is(true)); + assertThat(edition.get(), is(23)); + } + private void replyWithSubscribed() throws IOException { fcpServer.writeLine( "SubscribedUSK", -- 2.7.4