From: David ‘Bombe’ Roden Date: Thu, 31 Jul 2014 19:14:01 +0000 (+0200) Subject: Add test for Sone URI. X-Git-Tag: 0.9-rc1^2~3^2~189 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=858f093b9809bca0515536d3c774abc54ca0bfa4;p=Sone.git Add test for Sone URI. --- 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()); + } + +}