public void subscriptionWorks() throws InterruptedException, ExecutionException, IOException {
Future<Optional<UskSubscription>> 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);
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");
}
}