+++ /dev/null
-package net.pterodactylus.sone.freenet;
-
-import static freenet.support.Base64.encode;
-import static net.pterodactylus.sone.freenet.Key.from;
-import static net.pterodactylus.sone.freenet.Key.routingKey;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.is;
-
-import java.net.MalformedURLException;
-
-import freenet.keys.FreenetURI;
-
-import org.junit.Test;
-
-/**
- * Unit test for {@link Key}.
- */
-public class KeyTest {
-
- private final FreenetURI uri;
- private final Key key;
-
- public KeyTest() throws MalformedURLException {
- uri = new FreenetURI(
- "SSK@NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs,Miglsgix0VR56ZiPl4NgjnUd~UdrnHqIvXJ3KKHmxmI,AQACAAE/some-site-12/foo/bar.html");
- key = from(uri);
- }
-
- @Test
- public void keyCanBeCreatedFromFreenetUri() throws MalformedURLException {
- assertThat(key.getRoutingKey(),
- is("NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs"));
- assertThat(key.getCryptoKey(),
- is("Miglsgix0VR56ZiPl4NgjnUd~UdrnHqIvXJ3KKHmxmI"));
- assertThat(key.getExtra(), is("AQACAAE"));
- }
-
- @Test
- public void keyCanBeConvertedToUsk() throws MalformedURLException {
- FreenetURI uskUri = key.toUsk("other-site", 15, "some", "path.html");
- assertThat(uskUri.toString(),
- is("USK@NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs,Miglsgix0VR56ZiPl4NgjnUd~UdrnHqIvXJ3KKHmxmI,AQACAAE/other-site/15/some/path.html"));
- }
-
- @Test
- public void keyCanBeConvertedToSskWithoutEdition()
- throws MalformedURLException {
- FreenetURI uskUri = key.toSsk("other-site", "some", "path.html");
- assertThat(uskUri.toString(),
- is("SSK@NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs,Miglsgix0VR56ZiPl4NgjnUd~UdrnHqIvXJ3KKHmxmI,AQACAAE/other-site/some/path.html"));
- }
-
- @Test
- public void keyCanBeConvertedToSskWithEdition()
- throws MalformedURLException {
- FreenetURI uskUri = key.toSsk("other-site", 15, "some", "path.html");
- assertThat(uskUri.toString(),
- is("SSK@NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs,Miglsgix0VR56ZiPl4NgjnUd~UdrnHqIvXJ3KKHmxmI,AQACAAE/other-site-15/some/path.html"));
- }
-
- @Test
- public void routingKeyIsExtractCorrectly() {
- assertThat(routingKey(uri),
- is("NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs"));
- }
-
-}
--- /dev/null
+package net.pterodactylus.sone.freenet
+
+import freenet.keys.*
+import net.pterodactylus.sone.freenet.Key.*
+import org.hamcrest.MatcherAssert.*
+import org.hamcrest.Matchers.*
+import org.junit.*
+
+/**
+ * Unit test for [Key].
+ */
+class KeyTest {
+
+ private val uri = FreenetURI("SSK@$routingKey,$cryptoKey,$extra/some-site-12/foo/bar.html")
+ private val key: Key = from(uri)
+
+ @Test
+ fun keyCanBeCreatedFromFreenetUri() {
+ assertThat(key.routingKey, equalTo(routingKey))
+ assertThat(key.cryptoKey, equalTo(cryptoKey))
+ assertThat(key.extra, equalTo(extra))
+ }
+
+ @Test
+ fun keyCanBeConvertedToUsk() {
+ val uskUri = key.toUsk("other-site", 15, "some", "path.html")
+ assertThat(uskUri.toString(), equalTo("USK@$routingKey,$cryptoKey,$extra/other-site/15/some/path.html"))
+ }
+
+ @Test
+ fun keyCanBeConvertedToSskWithoutEdition() {
+ val uskUri = key.toSsk("other-site", "some", "path.html")
+ assertThat(uskUri.toString(), equalTo("SSK@$routingKey,$cryptoKey,$extra/other-site/some/path.html"))
+ }
+
+ @Test
+ fun keyCanBeConvertedToSskWithEdition() {
+ val uskUri = key.toSsk("other-site", 15, "some", "path.html")
+ assertThat(uskUri.toString(), equalTo("SSK@$routingKey,$cryptoKey,$extra/other-site-15/some/path.html"))
+ }
+
+ @Test
+ fun routingKeyIsExtractCorrectly() {
+ assertThat(routingKey(uri), equalTo(routingKey))
+ }
+
+}
+
+private const val routingKey = "NfUYvxDwU9vqb2mh-qdT~DYJ6U0XNbxMGGoLe0aCHJs"
+private const val cryptoKey = "Miglsgix0VR56ZiPl4NgjnUd~UdrnHqIvXJ3KKHmxmI"
+private const val extra = "AQACAAE"