From a9ca22b07e7a123f57ea1ce0d2f99c3a3af810fa Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 6 Oct 2016 22:01:10 +0200 Subject: [PATCH] Add test for FreenetRequest --- .../sone/web/page/FreenetRequestTest.java | 54 ++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java 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 index 0000000..ac01e51 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/page/FreenetRequestTest.java @@ -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 David ‘Bombe’ Roden + */ +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)); + } + +} -- 2.7.4