Search in sources :

Example 6 with FStaticRouter

use of org.webpieces.router.impl.routers.FStaticRouter 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 = FileFactory.newBaseFile("output/staging");
    FileUtils.copyDirectory(f, stagingDir);
    runBasicServerOnce(stagingDir);
    List<FStaticRouter> routes2 = new ArrayList<>();
    VirtualFile dir = VirtualFileFactory.newFile(stagingDir);
    routes2.add(create(Port.BOTH, new UrlPath("", "/public1.4/"), dir, 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 : VirtualFile(org.webpieces.util.file.VirtualFile) FStaticRouter(org.webpieces.router.impl.routers.FStaticRouter) UrlPath(org.webpieces.router.impl.UrlPath) ArrayList(java.util.ArrayList) File(java.io.File) VirtualFile(org.webpieces.util.file.VirtualFile) Test(org.junit.Test)

Example 7 with FStaticRouter

use of org.webpieces.router.impl.routers.FStaticRouter 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 = FileFactory.newBaseFile("output/staging");
    FileUtils.copyDirectory(f, stagingDir);
    List<FStaticRouter> 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 : FStaticRouter(org.webpieces.router.impl.routers.FStaticRouter) File(java.io.File) VirtualFile(org.webpieces.util.file.VirtualFile) Test(org.junit.Test)

Aggregations

FStaticRouter (org.webpieces.router.impl.routers.FStaticRouter)7 VirtualFile (org.webpieces.util.file.VirtualFile)6 File (java.io.File)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)3 UrlPath (org.webpieces.router.impl.UrlPath)2 Pattern (java.util.regex.Pattern)1 MatchInfo (org.webpieces.router.impl.routers.MatchInfo)1