From 6c8f08c99c018b654beaa44e8b463262ca41582f Mon Sep 17 00:00:00 2001 From: Alexander Sparkowsky Date: Sat, 2 Feb 2019 20:27:34 +0100 Subject: [PATCH] Cleanup test implementation (#929) --- .../junit/BrowserWebDriverContainerTest.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java b/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java index 5f6d22e79f9..036262a6bd1 100644 --- a/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java +++ b/modules/selenium/src/test/java/org/testcontainers/junit/BrowserWebDriverContainerTest.java @@ -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; @@ -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(); } } }