Skip to content

Commit

Permalink
Cleanup test implementation (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
roamingthings committed Feb 2, 2019
1 parent 631b9b3 commit 6c8f08c
Showing 1 changed file with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.testcontainers.junit;

import org.junit.Test;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testcontainers.containers.BrowserWebDriverContainer;

import static org.rnorth.visibleassertions.VisibleAssertions.assertEquals;
Expand All @@ -14,32 +14,29 @@ public class BrowserWebDriverContainerTest {

@Test
public void honorPresetNoProxyEnvironment() {
BrowserWebDriverContainer chromeWithNoProxySet = (BrowserWebDriverContainer) new BrowserWebDriverContainer()
.withDesiredCapabilities(DesiredCapabilities.chrome())
.withEnv(NO_PROXY_KEY, NO_PROXY_VALUE);

try {
try (
BrowserWebDriverContainer chromeWithNoProxySet = (BrowserWebDriverContainer) new BrowserWebDriverContainer()
.withCapabilities(new ChromeOptions())
.withEnv(NO_PROXY_KEY, NO_PROXY_VALUE)
) {
chromeWithNoProxySet.start();

Object noProxy = chromeWithNoProxySet.getEnvMap().get(NO_PROXY_KEY);
assertEquals("no_proxy should be preserved by the container rule", NO_PROXY_VALUE, noProxy);
} finally {
chromeWithNoProxySet.stop();
}
}

@Test
public void provideDefaultNoProxyEnvironmentIfNotSet() {
BrowserWebDriverContainer chromeWithoutNoProxySet = new BrowserWebDriverContainer()
.withDesiredCapabilities(DesiredCapabilities.chrome());
try (
BrowserWebDriverContainer chromeWithoutNoProxySet = new BrowserWebDriverContainer()
.withCapabilities(new ChromeOptions())

try {
) {
chromeWithoutNoProxySet.start();

Object noProxy = chromeWithoutNoProxySet.getEnvMap().get(NO_PROXY_KEY);
assertEquals("no_proxy should be set to default if not already present", "localhost", noProxy);
} finally {
chromeWithoutNoProxySet.stop();
}
}
}

0 comments on commit 6c8f08c

Please sign in to comment.