private WebServer configureServer(int port) { WebServer server = WebServers.createWebServer(newFixedThreadPool(5), port); // Note: Does first matching prefix matching, so /common/foo must be set up before /common // Delegating to a PathMatchHandler can be used to limit this forwardPathToHandlerUnderCommon("/page", new LastPathSegmentHandler(), server); forwardPathToHandlerUnderCommon("/redirect", new RedirectHandler("resultPage.html"), server); forwardPathToHandlerUnderCommon("/sleep", new SleepHandler(), server); forwardPathToHandlerUnderCommon( "/encoding", new StringHttpHandler("text/html", SHALOM_TEXT, Charsets.UTF_16), server); forwardPathToHandlerUnderCommon( "/upload", new PathMatchHandler("^$", new UploadFileHandler()), server); forwardPathToHandlerUnderCommon("/basicAuth", new BasicAuthHandler("test:test"), server); forwardPathToHandlerUnderCommon("/quitquitquit", new QuitQuitQuitHandler(), server); server.add(new PathAugmentingStaticFileHandler(InProject.locate("common/src/web"), "/common")); server.add( new PathAugmentingStaticFileHandler(InProject.locate("javascript"), JS_SRC_CONTEXT_PATH)); server.add( new PathAugmentingStaticFileHandler( InProject.locate("/third_party/closure/goog"), CLOSURE_CONTEXT_PATH)); server.add( new PathAugmentingStaticFileHandler( InProject.locate("/third_party/js"), THIRD_PARTY_JS_CONTEXT_PATH)); return server; }
private InputStream getKeystoreFile() { try { return new FileInputStream(InProject.locate("java/client/test/keystore")); } catch (Throwable t) { throw Throwables.propagate(t); } }
@Test public void shouldInstallExtensionFromZip() throws IOException { FirefoxProfile profile = new FirefoxProfile(); profile.addExtension(InProject.locate(FIREBUG_PATH)); File profileDir = profile.layoutOnDisk(); File extensionDir = new File(profileDir, "extensions/[email protected]"); assertTrue(extensionDir.exists()); }
@Test public void testCanUnzipASingleEntry() throws IOException { File source = InProject.locate("java/client/test/org/openqa/selenium/internal/single-file.zip"); zip.unzip(source, outputDir); assertTrue(new File(outputDir, "example.txt").exists()); }
@Test public void testCanUnzipAComplexZip() throws IOException { File source = InProject.locate("java/client/test/org/openqa/selenium/internal/subfolders.zip"); zip.unzip(source, outputDir); assertTrue(new File(outputDir, "example.txt").exists()); assertTrue(new File(outputDir, "subdir/foodyfun.txt").exists()); }
@Test public void shouldInstallExtensionFromDirectory() throws IOException { FirefoxProfile profile = new FirefoxProfile(); File extension = InProject.locate(FIREBUG_PATH); File unzippedExtension = FileHandler.unzip(new FileInputStream(extension)); profile.addExtension(unzippedExtension); File profileDir = profile.layoutOnDisk(); File extensionDir = new File(profileDir, "extensions/[email protected]"); assertTrue(extensionDir.exists()); }