+ @Test
+ public void clientGetFollowsRedirect() throws InterruptedException, ExecutionException, IOException {
+ Future<Optional<Data>> data = fcpClient.clientGet().uri("USK@foo/bar").execute();
+ connectAndAssert(() -> matchesFcpMessage("ClientGet", "URI=USK@foo/bar"));
+ replyWithRedirect("USK@foo/baz");
+ readMessage(() -> matchesFcpMessage("ClientGet", "URI=USK@foo/baz"));
+ replyWithAllData(identifier, "Hello", "text/plain;charset=utf-8");
+ verifyData(data.get());
+ }
+
+ @Test
+ public void clientGetNotifiesListenersOnRedirect() throws IOException, ExecutionException, InterruptedException {
+ List<String> redirects = new ArrayList<>();
+ Future<Optional<Data>> data = fcpClient.clientGet().onRedirect(redirects::add).uri("USK@foo/bar").execute();
+ connectAndAssert(() -> matchesFcpMessage("ClientGet", "URI=USK@foo/bar"));
+ replyWithRedirect("USK@foo/baz");
+ readMessage(() -> matchesFcpMessage("ClientGet", "URI=USK@foo/baz"));
+ replyWithRedirect("USK@foo/quux");
+ readMessage(() -> matchesFcpMessage("ClientGet", "URI=USK@foo/quux"));
+ replyWithAllData(identifier, "Hello", "text/plain;charset=utf-8");
+ verifyData(data.get());
+ assertThat(redirects, contains("USK@foo/baz", "USK@foo/quux"));
+ }
+