From a499658371a06dd52191bd6c0fed6542cfd1e9b0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 11 Oct 2016 21:11:14 +0200 Subject: [PATCH] Add test for about page --- .../net/pterodactylus/sone/web/AboutPageTest.java | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/test/java/net/pterodactylus/sone/web/AboutPageTest.java diff --git a/src/test/java/net/pterodactylus/sone/web/AboutPageTest.java b/src/test/java/net/pterodactylus/sone/web/AboutPageTest.java new file mode 100644 index 0000000..df41e61 --- /dev/null +++ b/src/test/java/net/pterodactylus/sone/web/AboutPageTest.java @@ -0,0 +1,43 @@ +package net.pterodactylus.sone.web; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.is; + +import org.junit.Test; + +/** + * Unit test for {@link AboutPage}. + * + * @author David ‘Bombe’ Roden + */ +public class AboutPageTest extends WebPageTest { + + private final String version = "0.1.2"; + private final int year = 1234; + private final String homepage = "home://page"; + private final AboutPage page = new AboutPage(template, webInterface, version, year, homepage); + + @Test + public void pageReturnsCorrectPath() { + assertThat(page.getPath(), is("about.html")); + } + + @Test + public void pageSetsCorrectVersionInTemplateContext() throws Exception { + page.processTemplate(freenetRequest, templateContext); + assertThat(templateContext.get("version"), is((Object) version)); + } + + @Test + public void pageSetsCorrectHomepageInTemplateContext() throws Exception { + page.processTemplate(freenetRequest, templateContext); + assertThat(templateContext.get("homepage"), is((Object) homepage)); + } + + @Test + public void pageSetsCorrectYearInTemplateContext() throws Exception { + page.processTemplate(freenetRequest, templateContext); + assertThat(templateContext.get("year"), is((Object) year)); + } + +} -- 2.7.4