Search in sources :

Example 11 with WebserverForTest

use of org.webpieces.webserver.WebserverForTest in project webpieces by deanhiller.

the class TestFieldTag method setUp.

@Before
public void setUp() {
    VirtualFileClasspath metaFile = new VirtualFileClasspath("tagsMeta.txt", WebserverForTest.class.getClassLoader());
    WebserverForTest webserver = new WebserverForTest(platformOverrides, null, false, metaFile);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : WebserverForTest(org.webpieces.webserver.WebserverForTest) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) Before(org.junit.Before)

Example 12 with WebserverForTest

use of org.webpieces.webserver.WebserverForTest in project webpieces by deanhiller.

the class TestFormTag method setUp.

@Before
public void setUp() {
    VirtualFileClasspath metaFile = new VirtualFileClasspath("tagsMeta.txt", WebserverForTest.class.getClassLoader());
    WebserverForTest webserver = new WebserverForTest(platformOverrides, null, false, metaFile);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : WebserverForTest(org.webpieces.webserver.WebserverForTest) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) Before(org.junit.Before)

Example 13 with WebserverForTest

use of org.webpieces.webserver.WebserverForTest in project webpieces by deanhiller.

the class TestDevRefreshPageWithNoRestarting method setUp.

@Before
public void setUp() throws ClassNotFoundException, IOException {
    Asserts.assertWasCompiledWithParamNames("test");
    userDir = System.getProperty("user.dir");
    log.info("running from dir=" + userDir);
    existingCodeLoc = new File(userDir + "/src/test/java/org/webpieces/webserver/dev/app");
    //developers tend to exit their test leaving the code in a bad state so if they run it again, restore the original
    //version for them(if we change the original version, we have to copy it to this directory as well though :(
    File original = new File(userDir + "/src/test/devServerTest/devServerOriginal");
    FileUtils.copyDirectory(original, existingCodeLoc, null);
    //cache existing code for use by teardown...
    stashedExistingCodeDir = new File(System.getProperty("java.io.tmpdir") + "/webpiecesTestDevServer/app");
    FileUtils.copyDirectory(existingCodeLoc, stashedExistingCodeDir);
    //list all source paths here as you add them(or just create for loop)
    //These are the list of directories that we detect java file changes under
    List<VirtualFile> srcPaths = new ArrayList<>();
    srcPaths.add(new VirtualFileImpl(userDir + "/src/test/java"));
    VirtualFile metaFile = new VirtualFileImpl(userDir + "/src/test/resources/devMeta.txt");
    log.info("LOADING from meta file=" + metaFile.getCanonicalPath());
    //html and json template file encoding...
    TemplateCompileConfig templateConfig = new TemplateCompileConfig(srcPaths);
    //java source files encoding...
    CompileConfig devConfig = new CompileConfig(srcPaths);
    Module platformOverrides = Modules.combine(new DevRouterModule(devConfig), new PlatformOverridesForTest(mgr, time, mockTimer, templateConfig));
    WebserverForTest webserver = new WebserverForTest(platformOverrides, null, false, metaFile);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : VirtualFile(org.webpieces.util.file.VirtualFile) PlatformOverridesForTest(org.webpieces.webserver.test.PlatformOverridesForTest) DevRouterModule(org.webpieces.devrouter.api.DevRouterModule) WebserverForTest(org.webpieces.webserver.WebserverForTest) ArrayList(java.util.ArrayList) TemplateCompileConfig(org.webpieces.templatingdev.api.TemplateCompileConfig) CompileConfig(org.webpieces.compiler.api.CompileConfig) TemplateCompileConfig(org.webpieces.templatingdev.api.TemplateCompileConfig) VirtualFileImpl(org.webpieces.util.file.VirtualFileImpl) Module(com.google.inject.Module) DevRouterModule(org.webpieces.devrouter.api.DevRouterModule) File(java.io.File) VirtualFile(org.webpieces.util.file.VirtualFile) Before(org.junit.Before)

Example 14 with WebserverForTest

use of org.webpieces.webserver.WebserverForTest in project webpieces by deanhiller.

the class TestI18n method setUp.

@Before
public void setUp() {
    VirtualFileClasspath metaFile = new VirtualFileClasspath("i18nMeta.txt", WebserverForTest.class.getClassLoader());
    WebserverForTest webserver = new WebserverForTest(platformOverrides, null, false, metaFile);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : WebserverForTest(org.webpieces.webserver.WebserverForTest) VirtualFileClasspath(org.webpieces.util.file.VirtualFileClasspath) Before(org.junit.Before)

Example 15 with WebserverForTest

use of org.webpieces.webserver.WebserverForTest in project webpieces by deanhiller.

the class TestDevSynchronousErrors method setUp.

@Before
public void setUp() throws InterruptedException, ClassNotFoundException {
    Asserts.assertWasCompiledWithParamNames("test");
    String filePath1 = System.getProperty("user.dir");
    log.info("running from dir=" + filePath1);
    List<VirtualFile> srcPaths = new ArrayList<>();
    srcPaths.add(new VirtualFileImpl(filePath1 + "/src/test/java"));
    TemplateCompileConfig templateConfig = new TemplateCompileConfig(false);
    Module platformOverrides = Modules.combine(new PlatformOverridesForTest(mgr, time, mockTimer, templateConfig), new ForTestingStaticDevelopmentModeModule());
    //you may want to create this server ONCE in a static method BUT if you do, also remember to clear out all your
    //mocks after every test AND you can no longer run single threaded(tradeoffs, tradeoffs)
    //This is however pretty fast to do in many systems...
    WebserverForTest webserver = new WebserverForTest(platformOverrides, new AppOverridesModule(), false, null);
    webserver.start();
    http11Socket = http11Simulator.openHttp();
}
Also used : VirtualFile(org.webpieces.util.file.VirtualFile) PlatformOverridesForTest(org.webpieces.webserver.test.PlatformOverridesForTest) WebserverForTest(org.webpieces.webserver.WebserverForTest) ArrayList(java.util.ArrayList) TemplateCompileConfig(org.webpieces.templatingdev.api.TemplateCompileConfig) VirtualFileImpl(org.webpieces.util.file.VirtualFileImpl) Module(com.google.inject.Module) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)34 WebserverForTest (org.webpieces.webserver.WebserverForTest)34 VirtualFileClasspath (org.webpieces.util.file.VirtualFileClasspath)29 JdbcApi (org.webpieces.ddl.api.JdbcApi)4 TestConfig (org.webpieces.webserver.TestConfig)4 SeleniumOverridesForTest (org.webpieces.webserver.test.SeleniumOverridesForTest)4 Module (com.google.inject.Module)3 ArrayList (java.util.ArrayList)2 TemplateCompileConfig (org.webpieces.templatingdev.api.TemplateCompileConfig)2 VirtualFile (org.webpieces.util.file.VirtualFile)2 VirtualFileImpl (org.webpieces.util.file.VirtualFileImpl)2 PlatformOverridesForTest (org.webpieces.webserver.test.PlatformOverridesForTest)2 File (java.io.File)1 Ignore (org.junit.Ignore)1 CompileConfig (org.webpieces.compiler.api.CompileConfig)1 DevRouterModule (org.webpieces.devrouter.api.DevRouterModule)1 TagOverridesModule (org.webpieces.webserver.api.TagOverridesModule)1