package net.pterodactylus.sone.web;
+import static net.pterodactylus.sone.web.WebTestUtils.redirectsTo;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyInt;
import static org.mockito.Matchers.eq;
import net.pterodactylus.sone.data.Album;
import net.pterodactylus.sone.data.Sone;
import net.pterodactylus.sone.web.page.FreenetRequest;
-import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException;
import net.pterodactylus.util.template.Template;
import net.pterodactylus.util.template.TemplateContext;
import net.pterodactylus.util.web.Method;
import freenet.clients.http.ToadletContext;
import freenet.support.api.HTTPRequest;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.hamcrest.TypeSafeDiagnosingMatcher;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
uploadImagePage.processTemplate(request, templateContext);
}
- private Matcher<RedirectException> redirectsTo(final String page) {
- return new TypeSafeDiagnosingMatcher<RedirectException>() {
- @Override
- protected boolean matchesSafely(RedirectException exception, Description mismatchDescription) {
- if (!exception.getTarget().equals(page)) {
- mismatchDescription.appendText("target is ").appendValue(exception.getTarget());
- return false;
- }
- return true;
- }
-
- @Override
- public void describeTo(Description description) {
- description.appendText("target is ").appendValue(page);
- }
- };
- }
-
}
--- /dev/null
+package net.pterodactylus.sone.web;
+
+import javax.annotation.Nonnull;
+
+import net.pterodactylus.sone.web.page.FreenetTemplatePage.RedirectException;
+
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
+import org.hamcrest.TypeSafeDiagnosingMatcher;
+
+/**
+ * Utilities for testing the <code>web</code> package.
+ *
+ * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
+ */
+public class WebTestUtils {
+
+ @Nonnull
+ public static Matcher<RedirectException> redirectsTo(@Nonnull final String page) {
+ return new TypeSafeDiagnosingMatcher<RedirectException>() {
+ @Override
+ protected boolean matchesSafely(RedirectException exception, Description mismatchDescription) {
+ if (!exception.getTarget().equals(page)) {
+ mismatchDescription.appendText("target is ").appendValue(exception.getTarget());
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("target is ").appendValue(page);
+ }
+ };
+ }
+
+}