Guice modules passed to TestDrivers will always override config module
@@ -12,7 +12,6 @@ import com.yahoo.jdisc.http.ServletPathsConfig;
import com.yahoo.jdisc.http.guiceModules.ConnectorFactoryRegistryModule;
import com.yahoo.jdisc.http.guiceModules.ServletModule;
-import java.io.IOException;
import java.nio.file.Path;
/**
@@ -24,14 +23,14 @@ public class TestDrivers {
public static TestDriver newConfiguredInstance(RequestHandler requestHandler,
ServerConfig.Builder serverConfig,
ConnectorConfig.Builder connectorConfig,
- Module... guiceModules) throws IOException {
+ Module... guiceModules) {
return TestDriver.newInstance(
JettyHttpServer.class,
requestHandler,
newConfigModule(serverConfig, connectorConfig, guiceModules));
}
- public static TestDriver newInstance(RequestHandler requestHandler, Module... guiceModules) throws IOException {
+ public static TestDriver newInstance(RequestHandler requestHandler, Module... guiceModules) {
return TestDriver.newInstance(
JettyHttpServer.class,
requestHandler,
@@ -48,11 +47,10 @@ public class TestDrivers {
Path certificateFile,
Path privateKeyFile,
TlsClientAuth tlsClientAuth,
- Module... guiceModules) throws IOException {
+ Module... guiceModules) {
return TestDriver.newInstance(
JettyHttpServer.class,
requestHandler,
- Modules.override(
newConfigModule(
new ServerConfig.Builder().connectionLog(new ServerConfig.ConnectionLog.Builder().enabled(true)),
new ConnectorConfig.Builder()
@@ -67,14 +65,15 @@ public class TestDrivers {
: ConnectorConfig.Ssl.ClientAuth.Enum.WANT_AUTH)
.privateKeyFile(privateKeyFile.toString())
.certificateFile(certificateFile.toString())
- .caCertificateFile(certificateFile.toString()))))
- .with(guiceModules));
+ .caCertificateFile(certificateFile.toString())),
+ guiceModules));
}
private static Module newConfigModule(ServerConfig.Builder serverConfig,
ConnectorConfig.Builder connectorConfigBuilder,
Module... guiceModules) {
- return Modules.combine(
+ return Modules.override(
+ Modules.combine(
new AbstractModule() {
@Override
protected void configure() {
@@ -86,8 +85,8 @@ public class TestDrivers {
}
},
new ConnectorFactoryRegistryModule(connectorConfigBuilder),
- new ServletModule(),
- Modules.combine(guiceModules));
+ new ServletModule()))
+ .with(guiceModules);
}
}
