From 858f093b9809bca0515536d3c774abc54ca0bfa4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 31 Jul 2014 21:14:01 +0200 Subject: [PATCH] Add test for Sone URI. --- .../net/pterodactylus/sone/core/SoneUriTest.java | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/core/SoneUriTest.java diff --git a/src/test/java/net/pterodactylus/sone/core/SoneUriTest.java b/src/test/java/net/pterodactylus/sone/core/SoneUriTest.java new file mode 100644 index 0000000..879da4a --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/core/SoneUriTest.java @@ -0,0 +1,38 @@ +package net.pterodactylus.sone.core; + +import static freenet.keys.InsertableClientSSK.createRandom; +import static net.pterodactylus.sone.core.SoneUri.create; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.nullValue; + +import freenet.crypt.DummyRandomSource; +import freenet.keys.FreenetURI; + +import org.junit.Test; + +/** + * Unit test for {@link SoneUri}. + * + * @author David ‘Bombe’ Roden + */ +public class SoneUriTest { + + @Test + public void callConstructorForIncreasedTestCoverage() { + new SoneUri(); + } + + @Test + public void returnedUriHasCorrectDocNameAndMetaStrings() { + FreenetURI uri = createRandom(new DummyRandomSource(), "test-0").getURI().uskForSSK(); + assertThat(create(uri.toString()).getDocName(), is("Sone")); + assertThat(create(uri.toString()).getAllMetaStrings(), is(new String[0])); + } + + @Test + public void malformedUriReturnsNull() { + assertThat(create("not a key"), nullValue()); + } + +} -- 2.7.4