Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.nordstrom.ui-tools</groupId>
<artifactId>htmlunit-remote</artifactId>
<version>4.29.1-SNAPSHOT</version>
<version>4.30.1-SNAPSHOT</version>

<name>htmlunit-remote</name>
<description>This is the remote wrapper for HtmlUnitDriver</description>
Expand Down Expand Up @@ -34,6 +34,7 @@
<maven.compiler.target>11</maven.compiler.target>
<selenium.version>4.30.0</selenium.version>
<htmlunit.version>4.30.0</htmlunit.version>
<junit.version>4.13.2</junit.version>
<checkstyle.version>10.15.0</checkstyle.version>
<spotbugs.version>4.8.4</spotbugs.version>
<dependencycheck.version>9.1.0</dependencycheck.version>
Expand Down Expand Up @@ -91,7 +92,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public class HtmlUnitDriverServer extends NettyServer {
* @param options {@link BaseServerOptions} object
*/
public HtmlUnitDriverServer(BaseServerOptions options) {
super(options, createHandlers().httpHandler);
super(options, HANDLERS.httpHandler);
}

private static final Type MAP_OF_LONGS = new TypeToken<Map<String, Long>>() {}.getType();
Expand All @@ -92,10 +92,20 @@ public HtmlUnitDriverServer(BaseServerOptions options) {
private static final Type MAP_OF_ACTIONS = new TypeToken<Map<String, ActionsCoercer>>() {}.getType();
private static final Type MAP_OF_COOKIES = new TypeToken<Map<String, CookieCoercer>>() {}.getType();

private static final Handlers HANDLERS = createHandlers();
private static final Logger LOG = Logger.getLogger(HtmlUnitDriverServer.class.getName());

private static Map<String, HtmlUnitDriver> driverMap = new ConcurrentHashMap<>();

static {
Runtime.getRuntime().addShutdownHook(new Thread() {
@Override
public void run() {
HANDLERS.close();
LOG.info("HtmlUnitDriverServer handlers have closed");
}
});
}

/**
* Define the handlers for the routes supported by this server.
*
Expand Down Expand Up @@ -386,7 +396,6 @@ public HttpResponse execute(final HttpRequest req) throws UncheckedIOException {
public HttpResponse execute(final HttpRequest req) throws UncheckedIOException {
return releaseActions(sessionIdFrom(params));
}

}),
post("/session/{sessionId}/alert/dismiss").to(params -> new HttpHandler() {
@Override
Expand Down Expand Up @@ -422,7 +431,7 @@ public HttpResponse execute(final HttpRequest req) throws UncheckedIOException {
) {
@Override
public void close() {
// TODO: Add implementation
// nothing to do here
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,23 @@ public abstract class WebDriverTestCase extends WebTestCase {
private static final Executor EXECUTOR_POOL = Executors.newFixedThreadPool(4);

private static class ServerHolder {
private static final Server<?> INSTANCE;
private static final Handlers HANDLERS = createHandlers();
private static final Server<?> INSTANCE = new NettyServer(defaultOptions(), HANDLERS.httpHandler);

static {
INSTANCE = new NettyServer(defaultOptions(), createHandlers().httpHandler);
INSTANCE.start();

Runtime.getRuntime().addShutdownHook(
new Thread() {
@Override
public void run() {
INSTANCE.stop();
HANDLERS.close();
LOG.info("Example site web server has stopped");
}
});

LOG.info("Example site web server has started");
}

private static Handlers createHandlers() {
Expand Down