Skip to content

Commit

Permalink
JAMES-1958 Change port for WebAdmin on every test
Browse files Browse the repository at this point in the history
  • Loading branch information
chibenwa committed Mar 16, 2017
1 parent 19e2a15 commit a495cd3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
Expand Up @@ -19,25 +19,15 @@


package org.apache.james.webadmin.integration; package org.apache.james.webadmin.integration;


import org.apache.james.webadmin.RandomPort;
import org.apache.james.webadmin.WebAdminConfiguration; import org.apache.james.webadmin.WebAdminConfiguration;


import com.google.inject.AbstractModule; import com.google.inject.AbstractModule;
import com.google.inject.Provides;


public class WebAdminConfigurationModule extends AbstractModule { public class WebAdminConfigurationModule extends AbstractModule {


@Override @Override
protected void configure() { protected void configure() {

bind(WebAdminConfiguration.class).toProvider(WebAdminConfiguration::testingConfiguration);
}

@Provides
public WebAdminConfiguration provideWebAdminConfiguration() throws Exception {
return WebAdminConfiguration.builder()
.enabled()
.port(new RandomPort())
.build();
} }


} }
Expand Up @@ -31,10 +31,13 @@ public class WebAdminConfiguration {
public static final boolean DEFAULT_CORS_DISABLED = false; public static final boolean DEFAULT_CORS_DISABLED = false;
public static final String CORS_ALL_ORIGINS = "*"; public static final String CORS_ALL_ORIGINS = "*";


public static final WebAdminConfiguration TESTING_CONFIGURATION = WebAdminConfiguration.builder() public static WebAdminConfiguration testingConfiguration() {
.enabled() return WebAdminConfiguration.builder()
.port(new RandomPort()) .enabled()
.build(); .port(new RandomPort())
.build();
}

public static final WebAdminConfiguration DISABLED_CONFIGURATION = WebAdminConfiguration.builder() public static final WebAdminConfiguration DISABLED_CONFIGURATION = WebAdminConfiguration.builder()
.disabled() .disabled()
.build(); .build();
Expand Down
Expand Up @@ -67,7 +67,7 @@ private WebAdminServer(WebAdminConfiguration configuration, Set<Routes> routesLi


@VisibleForTesting @VisibleForTesting
public WebAdminServer(MetricFactory metricFactory, Routes... routes) throws IOException { public WebAdminServer(MetricFactory metricFactory, Routes... routes) throws IOException {
this(WebAdminConfiguration.TESTING_CONFIGURATION, this(WebAdminConfiguration.testingConfiguration(),
ImmutableSet.copyOf(routes), ImmutableSet.copyOf(routes),
new NoAuthenticationFilter(), new NoAuthenticationFilter(),
metricFactory); metricFactory);
Expand Down

0 comments on commit a495cd3

Please sign in to comment.