Add test for Sone URI.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 31 Jul 2014 19:14:01 +0000 (21:14 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 31 Jul 2014 19:14:01 +0000 (21:14 +0200)
src/test/java/net/pterodactylus/sone/core/SoneUriTest.java [new file with mode: 0644]

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 (file)
index 0000000..879da4a
--- /dev/null
@@ -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 <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+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());
+       }
+
+}