Add test for FreenetRequest
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 6 Oct 2016 20:01:10 +0000 (22:01 +0200)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Thu, 6 Oct 2016 20:01:10 +0000 (22:01 +0200)
src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java [new file with mode: 0644]

diff --git a/src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java b/src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java
new file mode 100644 (file)
index 0000000..ac01e51
--- /dev/null
@@ -0,0 +1,54 @@
+package net.pterodactylus.sone.web.page;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.mockito.Mockito.mock;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import net.pterodactylus.util.web.Method;
+
+import freenet.clients.http.ToadletContext;
+import freenet.support.api.HTTPRequest;
+
+import org.junit.Test;
+
+/**
+ * Unit test for {@link FreenetRequest}.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class FreenetRequestTest {
+
+       private final URI uri = new URI(".");
+       private final Method method = Method.GET;
+       private final HTTPRequest httpRequest = mock(HTTPRequest.class);
+       private final ToadletContext toadletContext = mock(ToadletContext.class);
+       private final FreenetRequest request = new FreenetRequest(uri, method, httpRequest, toadletContext);
+
+       @SuppressWarnings("unused")
+       public FreenetRequestTest() throws URISyntaxException {
+       }
+
+       @Test
+       public void uriIsRetainedCorrectly() {
+               assertThat(request.getUri(), is(uri));
+       }
+
+       @Test
+       public void methodIsRetainedCorrectly() {
+               assertThat(request.getMethod(), is(method));
+       }
+
+       @Test
+       public void httpRequestIsRetainedCorrectly() {
+               assertThat(request.getHttpRequest(), is(httpRequest));
+       }
+
+       @Test
+       public void toadletContextIsRetainedCorrectly() {
+               assertThat(request.getToadletContext(), is(toadletContext));
+       }
+
+}