Skip to content

Commit 6c8f08c

Browse files
committed
Cleanup test implementation (#929)
1 parent 631b9b3 commit 6c8f08c

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package org.testcontainers.junit;
22

33
import org.junit.Test;
4-
import org.openqa.selenium.remote.DesiredCapabilities;
4+
import org.openqa.selenium.chrome.ChromeOptions;
55
import org.testcontainers.containers.BrowserWebDriverContainer;
66

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

1515
@Test
1616
public void honorPresetNoProxyEnvironment() {
17-
BrowserWebDriverContainer chromeWithNoProxySet = (BrowserWebDriverContainer) new BrowserWebDriverContainer()
18-
.withDesiredCapabilities(DesiredCapabilities.chrome())
19-
.withEnv(NO_PROXY_KEY, NO_PROXY_VALUE);
20-
21-
try {
17+
try (
18+
BrowserWebDriverContainer chromeWithNoProxySet = (BrowserWebDriverContainer) new BrowserWebDriverContainer()
19+
.withCapabilities(new ChromeOptions())
20+
.withEnv(NO_PROXY_KEY, NO_PROXY_VALUE)
21+
) {
2222
chromeWithNoProxySet.start();
2323

2424
Object noProxy = chromeWithNoProxySet.getEnvMap().get(NO_PROXY_KEY);
2525
assertEquals("no_proxy should be preserved by the container rule", NO_PROXY_VALUE, noProxy);
26-
} finally {
27-
chromeWithNoProxySet.stop();
2826
}
2927
}
3028

3129
@Test
3230
public void provideDefaultNoProxyEnvironmentIfNotSet() {
33-
BrowserWebDriverContainer chromeWithoutNoProxySet = new BrowserWebDriverContainer()
34-
.withDesiredCapabilities(DesiredCapabilities.chrome());
31+
try (
32+
BrowserWebDriverContainer chromeWithoutNoProxySet = new BrowserWebDriverContainer()
33+
.withCapabilities(new ChromeOptions())
3534

36-
try {
35+
) {
3736
chromeWithoutNoProxySet.start();
3837

3938
Object noProxy = chromeWithoutNoProxySet.getEnvMap().get(NO_PROXY_KEY);
4039
assertEquals("no_proxy should be set to default if not already present", "localhost", noProxy);
41-
} finally {
42-
chromeWithoutNoProxySet.stop();
4340
}
4441
}
4542
}

0 commit comments

Comments
 (0)