Search in sources :

Example 11 with CommandLineParser

use of org.webpieces.util.cmdline2.CommandLineParser 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 } });
}
Also used : VirtualFile(org.webpieces.util.file.VirtualFile) VirtualFileInputStream(org.webpieces.router.api.mocks.VirtualFileInputStream) RouterService(org.webpieces.router.api.RouterService) TemplateApi(org.webpieces.router.api.TemplateApi) SimpleMeterRegistry(io.micrometer.core.instrument.simple.SimpleMeterRegistry) Arguments(org.webpieces.util.cmdline2.Arguments) CompileConfig(org.webpieces.compiler.api.CompileConfig) RouterConfig(org.webpieces.router.api.RouterConfig) CommandLineParser(org.webpieces.util.cmdline2.CommandLineParser) VirtualFileImpl(org.webpieces.util.file.VirtualFileImpl) File(java.io.File) VirtualFile(org.webpieces.util.file.VirtualFile)

Aggregations

Arguments (org.webpieces.util.cmdline2.Arguments)11 CommandLineParser (org.webpieces.util.cmdline2.CommandLineParser)11 Test (org.junit.Test)6 File (java.io.File)5 CommandLineException (org.webpieces.util.cmdline2.CommandLineException)5 VirtualFile (org.webpieces.util.file.VirtualFile)5 List (java.util.List)4 RouterConfig (org.webpieces.router.api.RouterConfig)4 RouterService (org.webpieces.router.api.RouterService)3 SimpleMeterRegistry (io.micrometer.core.instrument.simple.SimpleMeterRegistry)2 TemplateApi (org.webpieces.router.api.TemplateApi)2 VirtualFileInputStream (org.webpieces.router.api.mocks.VirtualFileInputStream)2 CompileConfig (org.webpieces.compiler.api.CompileConfig)1 TemplateConfig (org.webpieces.templating.api.TemplateConfig)1 VirtualFileImpl (org.webpieces.util.file.VirtualFileImpl)1 WebServerConfig (org.webpieces.webserver.api.WebServerConfig)1