Add test for the second USK callback.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 29 Jul 2014 15:41:09 +0000 (17:41 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Tue, 29 Jul 2014 15:41:09 +0000 (17:41 +0200)
src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java

index 644c9fe..44820d4 100644 (file)
@@ -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);