use of org.webpieces.webserver.test.OverridesForEmbeddedSvrWithParsing in project webpieces by deanhiller.
the class TestDevRefreshPageWithNoRestarting method setUp.
@Before
public void setUp() throws ClassNotFoundException, IOException, InterruptedException, ExecutionException, TimeoutException {
Asserts.assertWasCompiledWithParamNames("test");
userDir = System.getProperty("user.dir");
log.info("running from dir=" + userDir);
existingCodeLoc = FileFactory.newBaseFile("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 = FileFactory.newBaseFile("src/test/devServerTest/devServerOriginal");
FileUtils.copyDirectory(original, existingCodeLoc, null);
// cache existing code for use by teardown...
stashedExistingCodeDir = FileFactory.newCacheLocation("webpieces/" + getClass().getSimpleName() + "/javaFiles");
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(VirtualFileFactory.newBaseFile("src/test/java"));
VirtualFile metaFile = VirtualFileFactory.newBaseFile("src/test/resources/devMeta.txt");
log.info("LOADING from meta file=" + metaFile.getCanonicalPath());
// html and json template file encoding...
TemplateCompileConfig templateConfig = new TemplateCompileConfig(srcPaths);
VirtualFile cacheLocation = new VirtualFileImpl(FileFactory.newCacheLocation("webpieces/" + getClass().getSimpleName() + "/bytecode"));
// java source files encoding...
CompileConfig devConfig = new CompileConfig(srcPaths, cacheLocation);
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
Module platformOverrides = Modules.combine(new DevRouterModule(devConfig), new OverridesForEmbeddedSvrWithParsing(mgr, time, mockTimer, templateConfig, metrics));
PrivateWebserverForTest webserver = new PrivateWebserverForTest(platformOverrides, null, false, metaFile);
webserver.start();
http11Socket = connectHttp(false, webserver.getUnderlyingHttpChannel().getLocalAddress());
}
use of org.webpieces.webserver.test.OverridesForEmbeddedSvrWithParsing in project webpieces by deanhiller.
the class TestDevSynchronousErrors method setUp.
@Before
public void setUp() throws InterruptedException, ClassNotFoundException, ExecutionException, TimeoutException {
Asserts.assertWasCompiledWithParamNames("test");
String filePath1 = System.getProperty("user.dir");
log.info("running from dir=" + filePath1);
List<VirtualFile> srcPaths = new ArrayList<>();
srcPaths.add(VirtualFileFactory.newBaseFile("src/test/java"));
TemplateCompileConfig templateConfig = new TemplateCompileConfig(false);
SimpleMeterRegistry metrics = new SimpleMeterRegistry();
Module platformOverrides = Modules.combine(new OverridesForEmbeddedSvrWithParsing(mgr, time, mockTimer, templateConfig, metrics), 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...
PrivateWebserverForTest webserver = new PrivateWebserverForTest(platformOverrides, new AppOverridesModule(), false, null);
webserver.start();
http11Socket = connectHttp(false, webserver.getUnderlyingHttpChannel().getLocalAddress());
}
Aggregations