From ed3388477a517ec99e688d7e1c2c9859e21064a6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Wed, 17 Sep 2014 20:35:13 +0200 Subject: [PATCH] Add more tests for FreenetInterface. --- .../sone/core/FreenetInterfaceTest.java | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java b/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java index aa261f5..60c8344 100644 --- a/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java +++ b/src/test/java/net/pterodactylus/sone/core/FreenetInterfaceTest.java @@ -223,6 +223,42 @@ public class FreenetInterfaceTest { } @Test + public void registeringAnActiveUskWillSubscribeToItCorrectly() { + FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI().uskForSSK(); + final USKCallback uskCallback = mock(USKCallback.class); + freenetInterface.registerActiveUsk(freenetUri, uskCallback); + verify(uskManager).subscribe(any(USK.class), eq(uskCallback), eq(true), any(RequestClient.class)); + } + + @Test + public void registeringAnInactiveUskWillSubscribeToItCorrectly() { + FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI().uskForSSK(); + final USKCallback uskCallback = mock(USKCallback.class); + freenetInterface.registerPassiveUsk(freenetUri, uskCallback); + verify(uskManager).subscribe(any(USK.class), eq(uskCallback), eq(false), any(RequestClient.class)); + } + + @Test + public void registeringAnActiveNonUskWillNotSubscribeToAUsk() + throws MalformedURLException { + FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI(); + freenetInterface.registerActiveUsk(freenetUri, null); + verify(uskManager, never()).subscribe(any(USK.class), + any(USKCallback.class), anyBoolean(), + eq((RequestClient) highLevelSimpleClient)); + } + + @Test + public void registeringAnInactiveNonUskWillNotSubscribeToAUsk() + throws MalformedURLException { + FreenetURI freenetUri = createRandom(randomSource, "test-0").getURI(); + freenetInterface.registerPassiveUsk(freenetUri, null); + verify(uskManager, never()).subscribe(any(USK.class), + any(USKCallback.class), anyBoolean(), + eq((RequestClient) highLevelSimpleClient)); + } + + @Test public void unregisteringANotRegisteredUskDoesNothing() { FreenetURI freenetURI = createRandom(randomSource, "test-0").getURI().uskForSSK(); freenetInterface.unregisterUsk(freenetURI); -- 2.7.4