Search in sources :

Example 6 with StaticRoute

use of org.webpieces.router.impl.StaticRoute in project webpieces by deanhiller.

the class TestCompressionCache method testStartServerTwiceButUrlPathChanges.

@Test
public void testStartServerTwiceButUrlPathChanges() throws IOException {
    File f = new File("src/test/resources/cacheTest1");
    File stagingDir = new File("output/staging");
    FileUtils.copyDirectory(f, stagingDir);
    runBasicServerOnce(stagingDir);
    List<StaticRoute> routes2 = new ArrayList<>();
    routes2.add(new StaticRoute(new UrlPath("", "/public1.4/"), stagingDir.getAbsolutePath() + "/", false, cacheDir));
    //if server is just restarted(no file changes), we should skip reading files...
    cache.setupCache(routes2);
    Assert.assertEquals(2, proxy.getReadFiles().size());
    Assert.assertEquals(2, proxy.getCompressedFiles().size());
}
Also used : StaticRoute(org.webpieces.router.impl.StaticRoute) UrlPath(org.webpieces.router.impl.UrlPath) ArrayList(java.util.ArrayList) File(java.io.File) Test(org.junit.Test)

Example 7 with StaticRoute

use of org.webpieces.router.impl.StaticRoute in project webpieces by deanhiller.

the class TestCompressionCache method testCreateCacheAndUpdateTimestampButNotChangeFileContents.

@Test
public void testCreateCacheAndUpdateTimestampButNotChangeFileContents() 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);
    //do not preserve dates here...
    FileUtils.copyDirectory(f, stagingDir, false);
    //if server is just restarted(no file changes), we should skip reading files...
    cache.setupCache(routes);
    Assert.assertEquals(2, proxy.getReadFiles().size());
    Assert.assertEquals(0, proxy.getCompressedFiles().size());
}
Also used : StaticRoute(org.webpieces.router.impl.StaticRoute) File(java.io.File) Test(org.junit.Test)

Aggregations

StaticRoute (org.webpieces.router.impl.StaticRoute)7 File (java.io.File)4 Test (org.junit.Test)4 UrlPath (org.webpieces.router.impl.UrlPath)3 ArrayList (java.util.ArrayList)2 RouteMeta (org.webpieces.router.impl.RouteMeta)1