use of org.webpieces.router.api.RouterService in project webpieces by deanhiller.
the class ErrorCommonTest method createServer.
/**
* Need to live test with browser to see if PRG is better or just returning 404 is better!!!
* Current behavior is to return a 404
*/
//TODO: Test this with browser and then fix for best user experience
// @Test
// public void testNotFoundPostRouteResultsInRedirectToNotFoundCatchAllController() {
// log.info("starting");
// String moduleFileContents = CommonRoutesModules.class.getName();
// RoutingService server = createServer(isProdTest, moduleFileContents);
//
// server.start();
//
// RouterRequest req = RequestCreation.createHttpRequest(HttpMethod.POST, "/notexistpostroute");
// MockResponseStream mockResponseStream = new MockResponseStream();
//
// server.incomingCompleteRequest(req, mockResponseStream);
//
// verifyNotFoundRendered(mockResponseStream);
// }
public static RouterService createServer(boolean isProdTest, String moduleFileContents) {
VirtualFile f = new VirtualFileInputStream(moduleFileContents.getBytes(), "testAppModules");
if (isProdTest)
return RouterSvcFactory.create(f);
//otherwise create the development server
String filePath = System.getProperty("user.dir");
File myCodePath = new File(filePath + "/src/test/java");
CompileConfig compileConfig = new CompileConfig(new VirtualFileImpl(myCodePath));
log.info("bytecode dir=" + compileConfig.getByteCodeCacheDir());
RouterService server = DevRouterFactory.create(f, compileConfig);
return server;
}
use of org.webpieces.router.api.RouterService 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);
}
use of org.webpieces.router.api.RouterService in project webpieces by deanhiller.
the class DevRouterFactory method create.
public static RouterService create(RouterConfig config, CompileConfig compileConfig) {
Module devModules = Modules.override(RouterSvcFactory.getModules(config)).with(new DevRouterModule(compileConfig));
Injector injector = Guice.createInjector(devModules);
RouterService svc = injector.getInstance(RouterService.class);
return svc;
}
use of org.webpieces.router.api.RouterService in project webpieces by deanhiller.
the class TestSimpleRoutes method bothServers.
@SuppressWarnings("rawtypes")
@Parameterized.Parameters
public static Collection bothServers() {
String moduleFileContents = AppModules.class.getName();
VirtualFile f = new VirtualFileInputStream(moduleFileContents.getBytes(), "testAppModules");
TestModule module = new TestModule();
RouterConfig config = new RouterConfig().setMetaFile(f).setWebappOverrides(module).setSecretKey(SecretKeyInfo.generateForTest());
RouterService prodSvc = RouterSvcFactory.create(config);
//for dev must be null
config.setWebappOverrides(null);
String filePath = System.getProperty("user.dir");
File myCodePath = new File(filePath + "/src/test/java");
CompileConfig compileConfig = new CompileConfig(new VirtualFileImpl(myCodePath));
RouterService devSvc = DevRouterFactory.create(config, compileConfig);
return Arrays.asList(new Object[][] { { prodSvc, module }, { devSvc, module } });
}
Aggregations