From: David ‘Bombe’ Roden Date: Tue, 29 Jul 2014 15:41:09 +0000 (+0200) Subject: Add test for the second USK callback. X-Git-Tag: 0.9-rc1^2~3^2~205 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=37ead157c846aa94d1c24996d21d40925c2d8d40;p=Sone.git Add test for the second USK callback. --- diff --git a/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java b/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java index 644c9fe..44820d4 100644 --- a/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java +++ b/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java @@ -2,6 +2,7 @@ package net.pterodactylus.sone.core; import static freenet.keys.InsertableClientSSK.createRandom; import static freenet.node.RequestStarter.INTERACTIVE_PRIORITY_CLASS; +import static freenet.node.RequestStarter.PREFETCH_PRIORITY_CLASS; import static java.lang.System.currentTimeMillis; import static java.util.concurrent.TimeUnit.DAYS; import static java.util.concurrent.TimeUnit.SECONDS; @@ -335,6 +336,26 @@ public class FreenetInterfaceTest { } @Test + public void callbackForNormalUskUsesDifferentPriorities() { + Callback callback = mock(Callback.class); + FreenetURI uri = createRandom(randomSource, "test-0").getURI().uskForSSK(); + freenetInterface.registerUsk(uri, callback); + assertThat(callbackCaptor.getValue().getPollingPriorityNormal(), is(PREFETCH_PRIORITY_CLASS)); + assertThat(callbackCaptor.getValue().getPollingPriorityProgress(), is(INTERACTIVE_PRIORITY_CLASS)); + } + + @Test + public void callbackForNormalUskForwardsImportantParameters() throws MalformedURLException { + Callback callback = mock(Callback.class); + FreenetURI uri = createRandom(randomSource, "test-0").getURI().uskForSSK(); + freenetInterface.registerUsk(uri, callback); + USK key = mock(USK.class); + when(key.getURI()).thenReturn(uri); + callbackCaptor.getValue().onFoundEdition(3, key, null, null, false, (short) 0, null, true, true); + verify(callback).editionFound(eq(uri), eq(3L), eq(true), eq(true)); + } + + @Test public void fetchedRetainsUriAndFetchResult() { FreenetURI freenetUri = mock(FreenetURI.class); FetchResult fetchResult = mock(FetchResult.class);