use of org.webpieces.router.api.mocks.VirtualFileInputStream in project webpieces by deanhiller.
the class ErrorCommonTest method createServer.
public static RouterService createServer(boolean isProdTest, String moduleFileContents) {
VirtualFile f = new VirtualFileInputStream(moduleFileContents.getBytes(), "testAppModules");
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
TemplateApi nullApi = new NullTemplateApi();
if (isProdTest)
return RouterServiceFactory.create("ErrorCommonTest", metrics, f, nullApi);
// otherwise create the development server
String filePath = System.getProperty("user.dir");
File myCodePath = new File(filePath + "/src/test/java");
VirtualFile cacheLocation = new VirtualFileImpl(FileFactory.newCacheLocation("webpieces/" + ErrorCommonTest.class.getSimpleName() + "/bytecode"));
CompileConfig compileConfig = new CompileConfig(new VirtualFileImpl(myCodePath), cacheLocation);
log.info("bytecode dir=" + compileConfig.getByteCodeCacheDir());
RouterService server = DevRouterFactory.create("ErrorCommonTest", metrics, f, compileConfig, nullApi);
return server;
}
use of org.webpieces.router.api.mocks.VirtualFileInputStream in project webpieces by deanhiller.
the class TestProdRouter method bothServers.
@SuppressWarnings("rawtypes")
@Parameterized.Parameters
public static Collection bothServers() {
String moduleFileContents = AppModules.class.getName();
VirtualFile f = new VirtualFileInputStream(moduleFileContents.getBytes(), "testAppModules");
File baseWorkingDir = FileFactory.getBaseWorkingDir();
TestModule module = new TestModule();
Arguments args = new CommandLineParser().parse();
RouterConfig config = new RouterConfig(baseWorkingDir, "TestProdRouter").setMetaFile(f).setWebappOverrides(module).setSecretKey(SecretKeyInfo.generateForTest());
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
TemplateApi nullApi = new NullTemplateApi();
RouterService prodSvc = RouterServiceFactory.create(metrics, config, nullApi);
prodSvc.configure(args);
args.checkConsumedCorrectly();
return Arrays.asList(new Object[][] { { prodSvc, module } });
}
use of org.webpieces.router.api.mocks.VirtualFileInputStream 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();
File baseWorkingDir = FileFactory.getBaseWorkingDir();
Arguments args = new CommandLineParser().parse();
RouterConfig config = new RouterConfig(baseWorkingDir, "TestSimpleRoutes").setMetaFile(f).setWebappOverrides(module).setSecretKey(SecretKeyInfo.generateForTest());
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
TemplateApi nullApi = new NullTemplateApi();
RouterService prodSvc = RouterServiceFactory.create(metrics, config, nullApi);
prodSvc.configure(args);
args.checkConsumedCorrectly();
// for dev must be null
config.setWebappOverrides(null);
String filePath = System.getProperty("user.dir");
File myCodePath = new File(filePath + "/src/test/java");
VirtualFile cacheLocation = new VirtualFileImpl(FileFactory.newCacheLocation("webpieces/" + TestSimpleRoutes.class.getSimpleName() + "/bytecode"));
CompileConfig compileConfig = new CompileConfig(new VirtualFileImpl(myCodePath), cacheLocation);
Arguments args2 = new CommandLineParser().parse();
SimpleMeterRegistry metrics2 = new SimpleMeterRegistry();
RouterService devSvc = DevRouterFactory.create(metrics2, config, compileConfig, nullApi);
devSvc.configure(args2);
args2.checkConsumedCorrectly();
return Arrays.asList(new Object[][] { { prodSvc, module }, { devSvc, module } });
}
Aggregations