use of org.webpieces.util.file.VirtualFileImpl in project webpieces by deanhiller.
the class AbstractCompileTest method createCompileConfig.
protected CompileConfig createCompileConfig() {
List<VirtualFile> arrayList = new ArrayList<>();
arrayList.add(new VirtualFileImpl(myCodePath));
CompileConfig config = new CompileConfig(arrayList, new VirtualFileImpl(byteCodeCacheDir));
return config;
}
use of org.webpieces.util.file.VirtualFileImpl 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();
}
use of org.webpieces.util.file.VirtualFileImpl 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();
}
use of org.webpieces.util.file.VirtualFileImpl 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.util.file.VirtualFileImpl 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