use of io.undertow.server.handlers.resource.CachingResourceManager in project undertow by undertow-io.
the class DefaultServletCachingListenerTestCase method setup.
@BeforeClass
public static void setup() throws ServletException, IOException {
tmpDir = Files.createTempDirectory(DIR_NAME);
// assume tmp is in the default file system and watch-service is not the slow polling impl
Assume.assumeTrue("WatchService is going to work OK", FileSystems.getDefault().equals(tmpDir.getFileSystem()) && !FileSystems.getDefault().newWatchService().getClass().getName().equals("sun.nio.fs.PollingWatchService"));
final PathHandler root = new PathHandler();
final ServletContainer container = ServletContainer.Factory.newInstance();
DeploymentInfo builder = new DeploymentInfo().setClassIntrospecter(TestClassIntrospector.INSTANCE).setClassLoader(ServletPathMappingTestCase.class.getClassLoader()).setContextPath("/servletContext").addWelcomePage("index.html").setDeploymentName("servletContext.war").setResourceManager(new CachingResourceManager(100, MAX_FILE_SIZE, dataCache, new PathResourceManager(tmpDir, 10485760, false, false, true), -1));
builder.addServlet(new ServletInfo("DefaultTestServlet", PathTestServlet.class).addMapping("/path/default")).addFilter(Servlets.filter("message", MessageFilter.class).addInitParam(MessageFilter.MESSAGE, "FILTER_TEXT ")).addFilterUrlMapping("message", "*.txt", DispatcherType.REQUEST);
DeploymentManager manager = container.addDeployment(builder);
manager.deploy();
root.addPrefixPath(builder.getContextPath(), manager.start());
DefaultServer.setRootHandler(root);
}
use of io.undertow.server.handlers.resource.CachingResourceManager in project undertow by undertow-io.
the class RangeRequestTestCase method setup.
@BeforeClass
public static void setup() throws URISyntaxException {
Path rootPath = Paths.get(RangeRequestTestCase.class.getResource("range.txt").toURI()).getParent();
PathHandler path = Handlers.path();
path.addPrefixPath("/path", new ByteRangeHandler(new HttpHandler() {
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
exchange.getResponseHeaders().put(Headers.LAST_MODIFIED, DateUtils.toDateString(new Date(10000)));
exchange.getResponseHeaders().put(Headers.ETAG, "\"someetag\"");
exchange.getResponseSender().send("0123456789");
}
}, true));
path.addPrefixPath("/resource", new ResourceHandler(new PathResourceManager(rootPath, 10485760)).setDirectoryListingEnabled(true));
path.addPrefixPath("/cachedresource", new ResourceHandler(new CachingResourceManager(1000, 1000000, new DirectBufferCache(1000, 10, 10000), new PathResourceManager(rootPath, 10485760), -1)).setDirectoryListingEnabled(true));
DefaultServer.setRootHandler(path);
}
Aggregations