use of org.webpieces.router.impl.StaticRoute in project webpieces by deanhiller.
the class R1RouterBuilder method addStaticRoute.
private void addStaticRoute(String urlPath, String fileSystemPath, boolean isOnClassPath) {
if (isOnClassPath)
throw new UnsupportedOperationException("oops, isOnClassPath not supported yet");
StaticRoute route = new StaticRoute(new UrlPath(routerInfo, urlPath), fileSystemPath, isOnClassPath, holder.getCachedCompressedDirectory());
staticRoutes.add(route);
log.info("scope:'" + routerInfo + "' adding static route=" + route.getFullPath() + " fileSystemPath=" + route.getFileSystemPath());
RouteMeta meta = new RouteMeta(route, holder.getInjector(), currentPackage.get(), holder.getUrlEncoding());
allRouting.addStaticRoute(meta);
}
use of org.webpieces.router.impl.StaticRoute in project webpieces by deanhiller.
the class TestCompressionCache method testModifyFileContentsButNotUrlPathFailure.
@Test
public void testModifyFileContentsButNotUrlPathFailure() throws IOException {
File f = new File("src/test/resources/cacheTest1");
File stagingDir = new File("output/staging");
FileUtils.copyDirectory(f, stagingDir);
List<StaticRoute> routes = runBasicServerOnce(stagingDir);
File f2 = new File("src/test/resources/cacheTest2");
FileUtils.deleteDirectory(stagingDir);
//do not preserve dates here...
FileUtils.copyDirectory(f2, stagingDir, false);
try {
cache.setupCache(routes);
Assert.fail("should have failed since file contents changed and url path didn't which would have broken web app customers");
} catch (IllegalStateException e) {
}
}
use of org.webpieces.router.impl.StaticRoute in project webpieces by deanhiller.
the class TestCompressionCache method testStartServerTwiceNoChanges.
@Test
public void testStartServerTwiceNoChanges() throws IOException {
File f = new File("src/test/resources/cacheTest1");
File stagingDir = new File("output/staging");
FileUtils.copyDirectory(f, stagingDir);
List<StaticRoute> routes = runBasicServerOnce(stagingDir);
//if server is just restarted(no file changes), we should skip reading files...
cache.setupCache(routes);
Assert.assertEquals(0, proxy.getReadFiles().size());
Assert.assertEquals(0, proxy.getCompressedFiles().size());
}
use of org.webpieces.router.impl.StaticRoute in project webpieces by deanhiller.
the class TestCompressionCache method runBasicServerOnce.
private List<StaticRoute> runBasicServerOnce(File stagingDir) {
List<StaticRoute> routes = new ArrayList<>();
routes.add(new StaticRoute(new UrlPath("", "/public/"), stagingDir.getAbsolutePath() + "/", false, cacheDir));
cache.setupCache(routes);
Assert.assertEquals(2, proxy.getReadFiles().size());
Assert.assertEquals(2, proxy.getCompressedFiles().size());
proxy.clear();
return routes;
}
use of org.webpieces.router.impl.StaticRoute in project webpieces by deanhiller.
the class ProdCompressionCacheSetup method setupCache.
public void setupCache(List<StaticRoute> staticRoutes) {
if (config.getCachedCompressedDirectory() == null) {
log.info("NOT setting up compressed cached directory so performance will not be as good");
return;
}
log.info("setting up compressed cache directories");
for (StaticRoute route : staticRoutes) {
createCache(route);
}
log.info("all cached directories setup");
}