use of org.webpieces.router.api.mocks.MockResponseStream in project webpieces by deanhiller.
the class ErrorCommonTest method testGetNotMatchPostRoute.
@Test
public void testGetNotMatchPostRoute() {
log.info("starting");
String moduleFileContents = CommonRoutesModules.class.getName();
RouterService server = createServer(isProdTest, moduleFileContents);
server.start();
RouterRequest req = RequestCreation.createHttpRequest(HttpMethod.GET, "/postroute");
MockResponseStream mockResponseStream = new MockResponseStream();
Current.setContext(new RequestContext(new ValidationImpl(null), new FlashImpl(null), new SessionImpl(null), req));
server.incomingCompleteRequest(req, mockResponseStream);
verifyNotFoundRendered(mockResponseStream);
}
use of org.webpieces.router.api.mocks.MockResponseStream in project webpieces by deanhiller.
the class ErrorCommonTest method testRedirectRouteNotEnoughArguments.
@Test
public void testRedirectRouteNotEnoughArguments() {
//say method is something(int arg, String this)
//we verify redirects MUST match type and number of method arguments every time
//then when we form url, we put the stuff in the path OR put it as query params so it works on the way back in again too
String moduleFileContents = CommonRoutesModules.class.getName();
RouterService server = createServer(isProdTest, moduleFileContents);
server.start();
RouterRequest req = RequestCreation.createHttpRequest(HttpMethod.GET, "/user/5553");
MockResponseStream mockResponseStream = new MockResponseStream();
Current.setContext(new RequestContext(new ValidationImpl(null), new FlashImpl(null), new SessionImpl(null), req));
server.incomingCompleteRequest(req, mockResponseStream);
Throwable e = mockResponseStream.getOnlyException();
while (e.getCause() != null) {
e = e.getCause();
}
Assert.assertEquals(IllegalStateException.class, e.getClass());
}
use of org.webpieces.router.api.mocks.MockResponseStream in project webpieces by deanhiller.
the class ErrorCommonTest method testArgsTypeMismatch.
@Test
public void testArgsTypeMismatch() {
log.info("starting");
String moduleFileContents = CommonRoutesModules.class.getName();
RouterService server = createServer(isProdTest, moduleFileContents);
server.start();
RouterRequest req = RequestCreation.createHttpRequest(HttpMethod.GET, "/something");
MockResponseStream mockResponseStream = new MockResponseStream();
Current.setContext(new RequestContext(new ValidationImpl(null), new FlashImpl(null), new SessionImpl(null), req));
server.incomingCompleteRequest(req, mockResponseStream);
verifyNotFoundRendered(mockResponseStream);
}
Aggregations