diff --git a/eclipse.classpath b/eclipse.classpath
index 6ad60df597b..d0cd7f5aab3 100644
--- a/eclipse.classpath
+++ b/eclipse.classpath
@@ -1,89 +1,119 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserCacheConfig.java b/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserCacheConfig.java
index 0f888a07747..9df55df0794 100644
--- a/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserCacheConfig.java
+++ b/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserCacheConfig.java
@@ -1,58 +1,57 @@
-package org.apache.jmeter.protocol.web.config;
-
-import org.apache.jmeter.config.ConfigTestElement;
-import org.apache.jmeter.engine.event.LoopIterationEvent;
-import org.apache.jmeter.engine.event.LoopIterationListener;
-import org.apache.jmeter.protocol.web.util.BrowserFactory;
-import org.apache.jmeter.testbeans.TestBean;
-import org.apache.jmeter.testelement.TestListener;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
-public class WebBrowserCacheConfig extends ConfigTestElement implements TestBean, TestListener {
- private static final Logger LOGGER = LoggingManager.getLoggerForClass();
-
- private static final long serialVersionUID = -6579029558490898888L;
-
- private static final String CACHE_SETTINGS = "WebBrowserCacheConfig.cacheSettings";
-
- public WebBrowserCacheConfig() {
- }
-
- public String getCacheSettings() {
- return getPropertyAsString(CACHE_SETTINGS);
- }
-
- public void setCacheSettings(String cacheSettings) {
- LOGGER.info("Setting to: "+cacheSettings);
- setProperty(CACHE_SETTINGS, cacheSettings);
- }
-
- @Override
- public void testStarted() {
- LOGGER.info("Cache settings: "+getCacheSettings());
- if(WebBrowserCacheConfigBeanInfo.CLEAR_ALL.equals(getCacheSettings())) {
- BrowserFactory.getInstance().clearBrowser();
- } else if(WebBrowserCacheConfigBeanInfo.CLEAR_COOKIES.equals(getCacheSettings())) {
- BrowserFactory.getInstance().clearBrowserCookies();
- }
- }
-
- @Override
- public void testStarted(String host) {
- testStarted();
- }
-
- @Override
- public void testEnded() {
- }
-
- @Override
- public void testEnded(String host) {
- }
-
- @Override
- public void testIterationStart(LoopIterationEvent event) {
- testStarted();
- }
-}
+package org.apache.jmeter.protocol.web.config;
+
+import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.event.LoopIterationEvent;
+import org.apache.jmeter.protocol.web.util.BrowserFactory;
+import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testelement.TestListener;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public class WebBrowserCacheConfig extends ConfigTestElement implements TestBean, TestListener {
+ private static final Logger LOGGER = LoggingManager.getLoggerForClass();
+
+ private static final long serialVersionUID = -6579029558490898888L;
+
+ private static final String CACHE_SETTINGS = "WebBrowserCacheConfig.cacheSettings";
+
+ public WebBrowserCacheConfig() {
+ }
+
+ public String getCacheSettings() {
+ return getPropertyAsString(CACHE_SETTINGS);
+ }
+
+ public void setCacheSettings(String cacheSettings) {
+ LOGGER.info("Setting to: "+cacheSettings);
+ setProperty(CACHE_SETTINGS, cacheSettings);
+ }
+
+ @Override
+ public void testStarted() {
+ LOGGER.info("Cache settings: "+getCacheSettings());
+ if(WebBrowserCacheConfigBeanInfo.CLEAR_ALL.equals(getCacheSettings())) {
+ BrowserFactory.getInstance().clearBrowser();
+ } else if(WebBrowserCacheConfigBeanInfo.CLEAR_COOKIES.equals(getCacheSettings())) {
+ BrowserFactory.getInstance().clearBrowserCookies();
+ }
+ }
+
+ @Override
+ public void testStarted(String host) {
+ testStarted();
+ }
+
+ @Override
+ public void testEnded() {
+ }
+
+ @Override
+ public void testEnded(String host) {
+ }
+
+ @Override
+ public void testIterationStart(LoopIterationEvent event) {
+ testStarted();
+ }
+}
diff --git a/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfig.java b/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfig.java
index f2d06f3bc75..b76d8960369 100644
--- a/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfig.java
+++ b/src/protocol/web/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfig.java
@@ -1,55 +1,54 @@
-package org.apache.jmeter.protocol.web.config;
-
-import org.apache.jmeter.config.ConfigTestElement;
-import org.apache.jmeter.engine.event.LoopIterationEvent;
-import org.apache.jmeter.engine.event.LoopIterationListener;
-import org.apache.jmeter.protocol.web.util.BrowserFactory;
-import org.apache.jmeter.protocol.web.util.BrowserType;
-import org.apache.jmeter.testbeans.TestBean;
-import org.apache.jmeter.testelement.TestListener;
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-
-public class WebBrowserTypeConfig extends ConfigTestElement implements TestBean, TestListener {
- private static final Logger LOGGER = LoggingManager.getLoggerForClass();
-
- private static final long serialVersionUID = -1257902955849089888L;
-
- private static final String TYPE = "WebBrowserTypeConfig.type";
-
- public WebBrowserTypeConfig() {
- }
-
- public String getType() {
- return getPropertyAsString(TYPE);
- }
-
- public void setType(String type) {
- LOGGER.info("setType: "+type);
- setProperty(TYPE, type);
- }
-
- @Override
- public void testStarted() {
- BrowserFactory.getInstance().setBrowserType(BrowserType.valueOf(getType()));
- }
-
- @Override
- public void testStarted(String host) {
- testStarted();
- }
-
- @Override
- public void testEnded() {
- }
-
- @Override
- public void testEnded(String host) {
- }
-
- @Override
- public void testIterationStart(LoopIterationEvent event) {
- LOGGER.info("Setting browser to: "+getType());
- BrowserFactory.getInstance().setBrowserType(BrowserType.valueOf(getType()));
- }
-}
+package org.apache.jmeter.protocol.web.config;
+
+import org.apache.jmeter.config.ConfigTestElement;
+import org.apache.jmeter.engine.event.LoopIterationEvent;
+import org.apache.jmeter.protocol.web.util.BrowserFactory;
+import org.apache.jmeter.protocol.web.util.BrowserType;
+import org.apache.jmeter.testbeans.TestBean;
+import org.apache.jmeter.testelement.TestListener;
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+
+public class WebBrowserTypeConfig extends ConfigTestElement implements TestBean, TestListener {
+ private static final Logger LOGGER = LoggingManager.getLoggerForClass();
+
+ private static final long serialVersionUID = -1257902955849089888L;
+
+ private static final String TYPE = "WebBrowserTypeConfig.type";
+
+ public WebBrowserTypeConfig() {
+ }
+
+ public String getType() {
+ return getPropertyAsString(TYPE);
+ }
+
+ public void setType(String type) {
+ LOGGER.info("setType: "+type);
+ setProperty(TYPE, type);
+ }
+
+ @Override
+ public void testStarted() {
+ BrowserFactory.getInstance().setBrowserType(BrowserType.valueOf(getType()));
+ }
+
+ @Override
+ public void testStarted(String host) {
+ testStarted();
+ }
+
+ @Override
+ public void testEnded() {
+ }
+
+ @Override
+ public void testEnded(String host) {
+ }
+
+ @Override
+ public void testIterationStart(LoopIterationEvent event) {
+ LOGGER.info("Setting browser to: "+getType());
+ BrowserFactory.getInstance().setBrowserType(BrowserType.valueOf(getType()));
+ }
+}
diff --git a/src/protocol/web/org/apache/jmeter/protocol/web/util/BrowserFactory.java b/src/protocol/web/org/apache/jmeter/protocol/web/util/BrowserFactory.java
index 0b6d8e4fc40..c6564a88110 100644
--- a/src/protocol/web/org/apache/jmeter/protocol/web/util/BrowserFactory.java
+++ b/src/protocol/web/org/apache/jmeter/protocol/web/util/BrowserFactory.java
@@ -1,140 +1,138 @@
-package org.apache.jmeter.protocol.web.util;
-
-import org.apache.jorphan.logging.LoggingManager;
-import org.apache.log.Logger;
-import org.openqa.selenium.Proxy;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.android.AndroidDriver;
-import org.openqa.selenium.chrome.ChromeDriver;
-import org.openqa.selenium.chrome.ChromeDriverService;
-import org.openqa.selenium.chrome.ChromeOptions;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.remote.CapabilityType;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import org.openqa.selenium.remote.RemoteWebDriver;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * This is responsible for accessing (and unsetting) a WebDriver browser instance per thread.
- */
-public class BrowserFactory {
- private static final Logger LOGGER = LoggingManager.getLoggerForClass();
-
- /**
- * Each thread will reference their WebDriver (browser) instance via this ThreadLocal instance. This is
- * initialised in the {@see #threadStarted()} and quit & unset in {@see #threadFinished()}.
- */
- private static final ThreadLocal BROWSERS = new ThreadLocal();
-
- private static final ThreadLocal SERVICES = new ThreadLocal();
- private static final ThreadLocal PROXIES = new ThreadLocal();
-
- private static final ThreadLocal BROWSER_TYPES = new ThreadLocal() {
- @Override
- public BrowserType initialValue() {
- return BrowserType.CHROME;
- }
- };
-
- private static final BrowserFactory INSTANCE = new BrowserFactory();
-
- public static BrowserFactory getInstance() {
- return INSTANCE;
- }
-
- private BrowserFactory() {}
-
- /**
- * Call this method to get a WebDriver (browser) for the current thread. The returned browser instance will be
- * stored and returned on subsequent calls until {@see #clearBrowser()} is called.
- *
- * @return a thread specific WebDriver instance.
- */
- public WebDriver getBrowser() {
- if(BROWSERS.get() == null) {
- BROWSERS.set(createBrowser());
- }
-
- return BROWSERS.get();
- }
-
- private WebDriver createBrowser() {
- BrowserType browserType = BROWSER_TYPES.get();
- if(BrowserType.CHROME == browserType) {
- initialiseService();
- DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
- desiredCapabilities.setCapability(CapabilityType.PROXY, getProxy());
- return new RemoteWebDriver(SERVICES.get().getUrl(), desiredCapabilities);
- }
- else if(BrowserType.ANDROID == browserType) {
- return new AndroidDriver();
- }
- else {
- DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
- desiredCapabilities.setCapability(CapabilityType.PROXY, getProxy());
- return new FirefoxDriver(desiredCapabilities);
- }
- }
-
- private static void initialiseService() {
- if(SERVICES.get() == null) {
- SERVICES.set(new ChromeDriverService.Builder().usingChromeDriverExecutable(new File(System.getProperty("webdriver.chrome.driver"))).usingAnyFreePort().build());
- try {
- SERVICES.get().start();
- } catch (IOException e) {
- throw new RuntimeException("Failed to start chrome service", e);
- }
- }
- }
-
- /**
- * Removes all cookies in the current browser used by the running thread.
- */
- public void clearBrowserCookies() {
- getBrowser().manage().deleteAllCookies();
- }
-
- /**
- * Removes any WebDriver instance associated with the calling thread and quits the running browser instance.
- */
- public void clearBrowser() {
- if(BROWSERS.get() != null) {
- BROWSERS.get().quit();
- BROWSERS.remove();
- }
-
- if(SERVICES.get() != null) {
- SERVICES.get().stop();
- SERVICES.set(null);
- }
- }
-
- /**
- * Use this to set the proxy to use when getting/creating new WebDriver instances {#getBrowser}. Unlike the browsers
- * this setting spans across threads, so there is no per thread configured values.
- *
- * @param proxy is the proxy to use when {#getBrowser} is invoked.
- */
- public void setProxy(Proxy proxy) {
- PROXIES.set(proxy);
- }
-
- /**
- * Access the proxy configured for all browsers accessed from this factory.
- *
- * @return the configured proxy.
- */
- public Proxy getProxy() {
- return PROXIES.get();
- }
-
- public void setBrowserType(BrowserType browserType) {
- BROWSER_TYPES.set(browserType);
- }
-
- public BrowserType getBrowserType() {
- return BROWSER_TYPES.get();
- }
-}
+package org.apache.jmeter.protocol.web.util;
+
+import org.apache.jorphan.logging.LoggingManager;
+import org.apache.log.Logger;
+import org.openqa.selenium.Proxy;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.android.AndroidDriver;
+import org.openqa.selenium.chrome.ChromeDriverService;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.remote.CapabilityType;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.openqa.selenium.remote.RemoteWebDriver;
+
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * This is responsible for accessing (and unsetting) a WebDriver browser instance per thread.
+ */
+public class BrowserFactory {
+ private static final Logger LOGGER = LoggingManager.getLoggerForClass();
+
+ /**
+ * Each thread will reference their WebDriver (browser) instance via this ThreadLocal instance. This is
+ * initialised in the {@see #threadStarted()} and quit & unset in {@see #threadFinished()}.
+ */
+ private static final ThreadLocal BROWSERS = new ThreadLocal();
+
+ private static final ThreadLocal SERVICES = new ThreadLocal();
+ private static final ThreadLocal PROXIES = new ThreadLocal();
+
+ private static final ThreadLocal BROWSER_TYPES = new ThreadLocal() {
+ @Override
+ public BrowserType initialValue() {
+ return BrowserType.CHROME;
+ }
+ };
+
+ private static final BrowserFactory INSTANCE = new BrowserFactory();
+
+ public static BrowserFactory getInstance() {
+ return INSTANCE;
+ }
+
+ private BrowserFactory() {}
+
+ /**
+ * Call this method to get a WebDriver (browser) for the current thread. The returned browser instance will be
+ * stored and returned on subsequent calls until {@see #clearBrowser()} is called.
+ *
+ * @return a thread specific WebDriver instance.
+ */
+ public WebDriver getBrowser() {
+ if(BROWSERS.get() == null) {
+ BROWSERS.set(createBrowser());
+ }
+
+ return BROWSERS.get();
+ }
+
+ private WebDriver createBrowser() {
+ BrowserType browserType = BROWSER_TYPES.get();
+ if(BrowserType.CHROME == browserType) {
+ initialiseService();
+ DesiredCapabilities desiredCapabilities = DesiredCapabilities.chrome();
+ desiredCapabilities.setCapability(CapabilityType.PROXY, getProxy());
+ return new RemoteWebDriver(SERVICES.get().getUrl(), desiredCapabilities);
+ }
+ else if(BrowserType.ANDROID == browserType) {
+ return new AndroidDriver();
+ }
+ else {
+ DesiredCapabilities desiredCapabilities = DesiredCapabilities.firefox();
+ desiredCapabilities.setCapability(CapabilityType.PROXY, getProxy());
+ return new FirefoxDriver(desiredCapabilities);
+ }
+ }
+
+ private static void initialiseService() {
+ if(SERVICES.get() == null) {
+ SERVICES.set(new ChromeDriverService.Builder().usingChromeDriverExecutable(new File(System.getProperty("webdriver.chrome.driver"))).usingAnyFreePort().build());
+ try {
+ SERVICES.get().start();
+ } catch (IOException e) {
+ throw new RuntimeException("Failed to start chrome service", e);
+ }
+ }
+ }
+
+ /**
+ * Removes all cookies in the current browser used by the running thread.
+ */
+ public void clearBrowserCookies() {
+ getBrowser().manage().deleteAllCookies();
+ }
+
+ /**
+ * Removes any WebDriver instance associated with the calling thread and quits the running browser instance.
+ */
+ public void clearBrowser() {
+ if(BROWSERS.get() != null) {
+ BROWSERS.get().quit();
+ BROWSERS.remove();
+ }
+
+ if(SERVICES.get() != null) {
+ SERVICES.get().stop();
+ SERVICES.set(null);
+ }
+ }
+
+ /**
+ * Use this to set the proxy to use when getting/creating new WebDriver instances {#getBrowser}. Unlike the browsers
+ * this setting spans across threads, so there is no per thread configured values.
+ *
+ * @param proxy is the proxy to use when {#getBrowser} is invoked.
+ */
+ public void setProxy(Proxy proxy) {
+ PROXIES.set(proxy);
+ }
+
+ /**
+ * Access the proxy configured for all browsers accessed from this factory.
+ *
+ * @return the configured proxy.
+ */
+ public Proxy getProxy() {
+ return PROXIES.get();
+ }
+
+ public void setBrowserType(BrowserType browserType) {
+ BROWSER_TYPES.set(browserType);
+ }
+
+ public BrowserType getBrowserType() {
+ return BROWSER_TYPES.get();
+ }
+}
diff --git a/test/src/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfigTest.java b/test/src/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfigTest.java
index 79bf3eb3b19..9e5f2c2844d 100644
--- a/test/src/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfigTest.java
+++ b/test/src/org/apache/jmeter/protocol/web/config/WebBrowserTypeConfigTest.java
@@ -1,63 +1,57 @@
-package org.apache.jmeter.protocol.web.config;
-
-import org.apache.jmeter.protocol.web.util.BrowserFactory;
-import org.apache.jmeter.protocol.web.util.BrowserType;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertThat;
-import static org.mockito.Mockito.*;
-
-public class WebBrowserTypeConfigTest {
- private WebBrowserTypeConfig typeConfig;
-
- @Before
- public void setUp() {
- typeConfig = new WebBrowserTypeConfig();
- }
-
- @Test
- public void shouldBeAbleToReadSamePropertiesFromConfigAfterDeserialisation() throws IOException, ClassNotFoundException {
- ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
- ObjectOutputStream outputStream = new ObjectOutputStream(byteArray);
-
- final String type = "cache setting value";
-
- typeConfig.setType(type);
-
- outputStream.writeObject(typeConfig);
- outputStream.flush();
-
- ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(byteArray.toByteArray()));
- WebBrowserTypeConfig deserialisedtypeConfig = (WebBrowserTypeConfig)inputStream.readObject();
-
- assertThat(deserialisedtypeConfig.getType(), is(type));
- }
-
- @Test
- public void shouldUseChromeWhenSpecified() throws Exception {
- typeConfig.setType(WebBrowserTypeConfigBeanInfo.CHROME);
- typeConfig.testIterationStart(null);
-
- assertThat(BrowserFactory.getInstance().getBrowserType(), is(BrowserType.CHROME));
- }
-
- @Test
- public void shouldUseFirefoxWhenSpecified() throws Exception {
- typeConfig.setType(WebBrowserTypeConfigBeanInfo.FIREFOX);
- typeConfig.testIterationStart(null);
-
- assertThat(BrowserFactory.getInstance().getBrowserType(), is(BrowserType.FIREFOX));
- }
-}
+package org.apache.jmeter.protocol.web.config;
+
+import org.apache.jmeter.protocol.web.util.BrowserFactory;
+import org.apache.jmeter.protocol.web.util.BrowserType;
+import org.junit.Before;
+import org.junit.Test;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+public class WebBrowserTypeConfigTest {
+ private WebBrowserTypeConfig typeConfig;
+
+ @Before
+ public void setUp() {
+ typeConfig = new WebBrowserTypeConfig();
+ }
+
+ @Test
+ public void shouldBeAbleToReadSamePropertiesFromConfigAfterDeserialisation() throws IOException, ClassNotFoundException {
+ ByteArrayOutputStream byteArray = new ByteArrayOutputStream();
+ ObjectOutputStream outputStream = new ObjectOutputStream(byteArray);
+
+ final String type = "cache setting value";
+
+ typeConfig.setType(type);
+
+ outputStream.writeObject(typeConfig);
+ outputStream.flush();
+
+ ObjectInputStream inputStream = new ObjectInputStream(new ByteArrayInputStream(byteArray.toByteArray()));
+ WebBrowserTypeConfig deserialisedtypeConfig = (WebBrowserTypeConfig)inputStream.readObject();
+
+ assertThat(deserialisedtypeConfig.getType(), is(type));
+ }
+
+ @Test
+ public void shouldUseChromeWhenSpecified() throws Exception {
+ typeConfig.setType(WebBrowserTypeConfigBeanInfo.CHROME);
+ typeConfig.testIterationStart(null);
+
+ assertThat(BrowserFactory.getInstance().getBrowserType(), is(BrowserType.CHROME));
+ }
+
+ @Test
+ public void shouldUseFirefoxWhenSpecified() throws Exception {
+ typeConfig.setType(WebBrowserTypeConfigBeanInfo.FIREFOX);
+ typeConfig.testIterationStart(null);
+
+ assertThat(BrowserFactory.getInstance().getBrowserType(), is(BrowserType.FIREFOX));
+ }
+}
diff --git a/test/src/org/apache/jmeter/protocol/web/util/BrowserFactoryTest.java b/test/src/org/apache/jmeter/protocol/web/util/BrowserFactoryTest.java
index b095a285763..d3085d9e223 100644
--- a/test/src/org/apache/jmeter/protocol/web/util/BrowserFactoryTest.java
+++ b/test/src/org/apache/jmeter/protocol/web/util/BrowserFactoryTest.java
@@ -1,251 +1,249 @@
-package org.apache.jmeter.protocol.web.util;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.openqa.selenium.Capabilities;
-import org.openqa.selenium.Proxy;
-import org.openqa.selenium.WebDriver;
-import org.openqa.selenium.android.AndroidDriver;
-import org.openqa.selenium.chrome.ChromeDriver;
-import org.openqa.selenium.chrome.ChromeDriverService;
-import org.openqa.selenium.chrome.ChromeOptions;
-import org.openqa.selenium.firefox.FirefoxDriver;
-import org.openqa.selenium.remote.CapabilityType;
-import org.openqa.selenium.remote.DesiredCapabilities;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-
-import java.util.List;
-import java.util.Vector;
-
-import static org.hamcrest.CoreMatchers.*;
-import static org.junit.Assert.assertThat;
-import static org.junit.matchers.JUnitMatchers.hasItem;
-import static org.mockito.Matchers.any;
-import static org.mockito.Matchers.eq;
-import static org.mockito.Matchers.isA;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-import static org.powermock.api.mockito.PowerMockito.*;
-
-@RunWith(PowerMockRunner.class)
-@PrepareForTest(BrowserFactory.class)
-public class BrowserFactoryTest {
- /**
- * Used to store the browsers created by {#BrowserCreator} threads.
- */
- private final List browsers = new Vector();
-
- /**
- * The run method will access a browser from the factory and add it to the {#browsers} list.
- */
- private class BrowserCreator implements Runnable {
-
- private BrowserType type;
- private Proxy proxy;
-
- public BrowserCreator(BrowserType type) {
- this(type, null);
- }
-
- public BrowserCreator(Proxy proxy) {
- this(BrowserType.FIREFOX, proxy);
- }
-
- public BrowserCreator(BrowserType type, Proxy proxy) {
- this.type = type;
- this.proxy = proxy;
- }
-
- @Override
- public void run() {
- BrowserFactoryTest.this.factory.setBrowserType(type);
- BrowserFactoryTest.this.factory.setProxy(proxy);
- browsers.add(BrowserFactoryTest.this.factory.getBrowser());
- }
- };
-
- private BrowserFactory factory;
-
- @Before
- public void initFactory() {
- factory = BrowserFactory.getInstance();
- factory.setBrowserType(BrowserType.FIREFOX);
- factory.setProxy(null);
- }
-
- @After
- public void clearBrowsers() {
- factory.clearBrowser();
- for(WebDriver browser: browsers) {
- browser.quit();
- }
- browsers.clear();
- }
-
- @Test
- public void shouldReturnTheSameBrowserWhenSubsequentGetBrowserIsInvoked() throws Exception {
- FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(Capabilities.class)).thenReturn(mockBrowser);
-
- WebDriver firstBrowser = factory.getBrowser();
- WebDriver secondBrowser = factory.getBrowser();
- assertThat(firstBrowser, is(sameInstance(secondBrowser)));
-
- verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
- }
-
- @Test
- public void shouldClearCookiesOnCurrentBrowserWhenClearCookiesIsInvoked() throws Exception {
- FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(Capabilities.class)).thenReturn(mockBrowser);
- WebDriver.Options mockOptions = mock(WebDriver.Options.class);
- when(mockBrowser.manage()).thenReturn(mockOptions);
-
- factory.clearBrowserCookies();
-
- verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
- verify(mockOptions).deleteAllCookies();
- }
-
- @Test
- public void shouldBrowserShouldContainProxySettingsWhenSpecified() throws Exception {
- FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(mockBrowser);
-
- factory.setProxy(new Proxy());
- WebDriver browser = factory.getBrowser();
- assertThat(browser, is(not(nullValue())));
-
- verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
- }
-
- @Test
- public void shouldReturnNewBrowserWhenClearBrowserIsInvoked() throws Exception {
- FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
- FirefoxDriver secondBrowser = mock(FirefoxDriver.class);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(firstBrowser, secondBrowser);
-
- WebDriver beforeReset = factory.getBrowser();
- factory.clearBrowser();
- WebDriver afterReset = factory.getBrowser();
-
- assertThat(afterReset, is(not(sameInstance(beforeReset))));
-
- verifyNew(FirefoxDriver.class, Mockito.times(2)).withArguments(isA(DesiredCapabilities.class));
- }
-
- @Test
- public void shouldReturnDifferentBrowserWhenCalledFromSeparateThreads() throws Exception {
- FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
- FirefoxDriver secondBrowser = mock(FirefoxDriver.class);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(firstBrowser, secondBrowser);
-
- Thread firstThread = new Thread(this.new BrowserCreator(BrowserType.FIREFOX));
- Thread secondThread = new Thread(this.new BrowserCreator(BrowserType.FIREFOX));
-
- firstThread.start();
- secondThread.start();
-
- firstThread.join();
- secondThread.join();
-
- assertThat(browsers.size(), is(2));
- assertThat(browsers.get(0), is(not(sameInstance(browsers.get(1)))));
-
- verifyNew(FirefoxDriver.class, Mockito.times(2)).withArguments(isA(DesiredCapabilities.class));
- }
-
- @Test
- public void shouldBeAbleToSetBrowserTypeFromSeparateThread() throws Exception {
- FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
- ChromeDriver secondBrowser = mock(ChromeDriver.class);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(firstBrowser);
- whenNew(ChromeDriver.class).withParameterTypes(ChromeOptions.class).withArguments(isA(ChromeOptions.class)).thenReturn(secondBrowser);
-
- Thread firstThread = new Thread(this.new BrowserCreator(BrowserType.FIREFOX));
- Thread secondThread = new Thread(this.new BrowserCreator(BrowserType.CHROME));
-
- firstThread.start();
- secondThread.start();
-
- firstThread.join();
- secondThread.join();
-
- assertThat(browsers.size(), is(2));
- assertThat(browsers.get(0), is(not(sameInstance(browsers.get(1)))));
-
- verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
- verifyNew(ChromeDriver.class, Mockito.times(1)).withArguments(isA(ChromeOptions.class));
- }
-
- @Test
- @PrepareForTest(value = {DesiredCapabilities.class, BrowserFactory.class})
- public void shouldBeAbleToSetProxyFromSeparateThread() throws Exception {
- FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
- FirefoxDriver secondBrowser = mock(FirefoxDriver.class);
- ArgumentCaptor proxyArgumentCaptor = ArgumentCaptor.forClass(Proxy.class);
- PowerMockito.mockStatic(DesiredCapabilities.class);
- DesiredCapabilities desiredCapabilities = mock(DesiredCapabilities.class);
- when(DesiredCapabilities.firefox()).thenReturn(desiredCapabilities);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(desiredCapabilities).thenReturn(firstBrowser);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(desiredCapabilities).thenReturn(secondBrowser);
-
- Proxy firstProxy = new Proxy();
- Proxy secondProxy = new Proxy();
- Thread firstThread = new Thread(this.new BrowserCreator(firstProxy));
- Thread secondThread = new Thread(this.new BrowserCreator(secondProxy));
-
- firstThread.start();
- secondThread.start();
-
- firstThread.join();
- secondThread.join();
-
- assertThat(browsers.size(), is(2));
-
- verifyNew(FirefoxDriver.class, Mockito.times(2)).withArguments(desiredCapabilities);
- verify(desiredCapabilities, Mockito.atLeastOnce()).setCapability(eq(CapabilityType.PROXY), proxyArgumentCaptor.capture());
-
- assertThat(proxyArgumentCaptor.getAllValues(), hasItem(firstProxy));
- assertThat(proxyArgumentCaptor.getAllValues(), hasItem(secondProxy));
- }
-
- @Test
- public void shouldReturnFirefoxBrowserWhenNoneSpecified() throws Exception {
- FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
- whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(mockBrowser);
-
- assertThat(factory.getBrowser(), is(sameInstance((WebDriver) mockBrowser)));
-
- verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
- }
-
- @Test
- public void shouldReturnChromeBrowserWhenSpecified() throws Exception {
- ChromeDriver mockBrowser = mock(ChromeDriver.class);
- whenNew(ChromeDriver.class).withParameterTypes(ChromeOptions.class).withArguments(isA(ChromeOptions.class)).thenReturn(mockBrowser);
-
- factory.setBrowserType(BrowserType.CHROME);
- assertThat(factory.getBrowser(), is(sameInstance((WebDriver)mockBrowser)));
-
- verifyNew(ChromeDriver.class, Mockito.times(1)).withArguments(isA(ChromeOptions.class));
- }
-
- @Test
- public void shouldReturnAndroidBrowserWhenSpecified() throws Exception {
- AndroidDriver mockBrowser = mock(AndroidDriver.class);
- whenNew(AndroidDriver.class).withNoArguments().thenReturn(mockBrowser);
-
- factory.setBrowserType(BrowserType.ANDROID);
- assertThat(factory.getBrowser(), is(sameInstance((WebDriver)mockBrowser)));
-
- verifyNew(AndroidDriver.class, Mockito.times(1)).withNoArguments();
- }
-}
+package org.apache.jmeter.protocol.web.util;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.Mockito;
+import org.openqa.selenium.Capabilities;
+import org.openqa.selenium.Proxy;
+import org.openqa.selenium.WebDriver;
+import org.openqa.selenium.android.AndroidDriver;
+import org.openqa.selenium.chrome.ChromeDriver;
+import org.openqa.selenium.chrome.ChromeOptions;
+import org.openqa.selenium.firefox.FirefoxDriver;
+import org.openqa.selenium.remote.CapabilityType;
+import org.openqa.selenium.remote.DesiredCapabilities;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import java.util.List;
+import java.util.Vector;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.junit.Assert.assertThat;
+import static org.junit.matchers.JUnitMatchers.hasItem;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Matchers.isA;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import static org.powermock.api.mockito.PowerMockito.*;
+
+@RunWith(PowerMockRunner.class)
+@PrepareForTest(BrowserFactory.class)
+public class BrowserFactoryTest {
+ /**
+ * Used to store the browsers created by {#BrowserCreator} threads.
+ */
+ private final List browsers = new Vector();
+
+ /**
+ * The run method will access a browser from the factory and add it to the {#browsers} list.
+ */
+ private class BrowserCreator implements Runnable {
+
+ private BrowserType type;
+ private Proxy proxy;
+
+ public BrowserCreator(BrowserType type) {
+ this(type, null);
+ }
+
+ public BrowserCreator(Proxy proxy) {
+ this(BrowserType.FIREFOX, proxy);
+ }
+
+ public BrowserCreator(BrowserType type, Proxy proxy) {
+ this.type = type;
+ this.proxy = proxy;
+ }
+
+ @Override
+ public void run() {
+ BrowserFactoryTest.this.factory.setBrowserType(type);
+ BrowserFactoryTest.this.factory.setProxy(proxy);
+ browsers.add(BrowserFactoryTest.this.factory.getBrowser());
+ }
+ }
+
+ private BrowserFactory factory;
+
+ @Before
+ public void initFactory() {
+ factory = BrowserFactory.getInstance();
+ factory.setBrowserType(BrowserType.FIREFOX);
+ factory.setProxy(null);
+ }
+
+ @After
+ public void clearBrowsers() {
+ factory.clearBrowser();
+ for(WebDriver browser: browsers) {
+ browser.quit();
+ }
+ browsers.clear();
+ }
+
+ @Test
+ public void shouldReturnTheSameBrowserWhenSubsequentGetBrowserIsInvoked() throws Exception {
+ FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(Capabilities.class)).thenReturn(mockBrowser);
+
+ WebDriver firstBrowser = factory.getBrowser();
+ WebDriver secondBrowser = factory.getBrowser();
+ assertThat(firstBrowser, is(sameInstance(secondBrowser)));
+
+ verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
+ }
+
+ @Test
+ public void shouldClearCookiesOnCurrentBrowserWhenClearCookiesIsInvoked() throws Exception {
+ FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(Capabilities.class)).thenReturn(mockBrowser);
+ WebDriver.Options mockOptions = mock(WebDriver.Options.class);
+ when(mockBrowser.manage()).thenReturn(mockOptions);
+
+ factory.clearBrowserCookies();
+
+ verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
+ verify(mockOptions).deleteAllCookies();
+ }
+
+ @Test
+ public void shouldBrowserShouldContainProxySettingsWhenSpecified() throws Exception {
+ FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(mockBrowser);
+
+ factory.setProxy(new Proxy());
+ WebDriver browser = factory.getBrowser();
+ assertThat(browser, is(not(nullValue())));
+
+ verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
+ }
+
+ @Test
+ public void shouldReturnNewBrowserWhenClearBrowserIsInvoked() throws Exception {
+ FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
+ FirefoxDriver secondBrowser = mock(FirefoxDriver.class);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(firstBrowser, secondBrowser);
+
+ WebDriver beforeReset = factory.getBrowser();
+ factory.clearBrowser();
+ WebDriver afterReset = factory.getBrowser();
+
+ assertThat(afterReset, is(not(sameInstance(beforeReset))));
+
+ verifyNew(FirefoxDriver.class, Mockito.times(2)).withArguments(isA(DesiredCapabilities.class));
+ }
+
+ @Test
+ public void shouldReturnDifferentBrowserWhenCalledFromSeparateThreads() throws Exception {
+ FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
+ FirefoxDriver secondBrowser = mock(FirefoxDriver.class);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(firstBrowser, secondBrowser);
+
+ Thread firstThread = new Thread(this.new BrowserCreator(BrowserType.FIREFOX));
+ Thread secondThread = new Thread(this.new BrowserCreator(BrowserType.FIREFOX));
+
+ firstThread.start();
+ secondThread.start();
+
+ firstThread.join();
+ secondThread.join();
+
+ assertThat(browsers.size(), is(2));
+ assertThat(browsers.get(0), is(not(sameInstance(browsers.get(1)))));
+
+ verifyNew(FirefoxDriver.class, Mockito.times(2)).withArguments(isA(DesiredCapabilities.class));
+ }
+
+ @Test
+ public void shouldBeAbleToSetBrowserTypeFromSeparateThread() throws Exception {
+ FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
+ ChromeDriver secondBrowser = mock(ChromeDriver.class);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(firstBrowser);
+ whenNew(ChromeDriver.class).withParameterTypes(ChromeOptions.class).withArguments(isA(ChromeOptions.class)).thenReturn(secondBrowser);
+
+ Thread firstThread = new Thread(this.new BrowserCreator(BrowserType.FIREFOX));
+ Thread secondThread = new Thread(this.new BrowserCreator(BrowserType.CHROME));
+
+ firstThread.start();
+ secondThread.start();
+
+ firstThread.join();
+ secondThread.join();
+
+ assertThat(browsers.size(), is(2));
+ assertThat(browsers.get(0), is(not(sameInstance(browsers.get(1)))));
+
+ verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
+ verifyNew(ChromeDriver.class, Mockito.times(1)).withArguments(isA(ChromeOptions.class));
+ }
+
+ @Test
+ @PrepareForTest(value = {DesiredCapabilities.class, BrowserFactory.class})
+ public void shouldBeAbleToSetProxyFromSeparateThread() throws Exception {
+ FirefoxDriver firstBrowser = mock(FirefoxDriver.class);
+ FirefoxDriver secondBrowser = mock(FirefoxDriver.class);
+ ArgumentCaptor proxyArgumentCaptor = ArgumentCaptor.forClass(Proxy.class);
+ PowerMockito.mockStatic(DesiredCapabilities.class);
+ DesiredCapabilities desiredCapabilities = mock(DesiredCapabilities.class);
+ when(DesiredCapabilities.firefox()).thenReturn(desiredCapabilities);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(desiredCapabilities).thenReturn(firstBrowser);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(desiredCapabilities).thenReturn(secondBrowser);
+
+ Proxy firstProxy = new Proxy();
+ Proxy secondProxy = new Proxy();
+ Thread firstThread = new Thread(this.new BrowserCreator(firstProxy));
+ Thread secondThread = new Thread(this.new BrowserCreator(secondProxy));
+
+ firstThread.start();
+ secondThread.start();
+
+ firstThread.join();
+ secondThread.join();
+
+ assertThat(browsers.size(), is(2));
+
+ verifyNew(FirefoxDriver.class, Mockito.times(2)).withArguments(desiredCapabilities);
+ verify(desiredCapabilities, Mockito.atLeastOnce()).setCapability(eq(CapabilityType.PROXY), proxyArgumentCaptor.capture());
+
+ assertThat(proxyArgumentCaptor.getAllValues(), hasItem(firstProxy));
+ assertThat(proxyArgumentCaptor.getAllValues(), hasItem(secondProxy));
+ }
+
+ @Test
+ public void shouldReturnFirefoxBrowserWhenNoneSpecified() throws Exception {
+ FirefoxDriver mockBrowser = mock(FirefoxDriver.class);
+ whenNew(FirefoxDriver.class).withParameterTypes(Capabilities.class).withArguments(isA(DesiredCapabilities.class)).thenReturn(mockBrowser);
+
+ assertThat(factory.getBrowser(), is(sameInstance((WebDriver) mockBrowser)));
+
+ verifyNew(FirefoxDriver.class, Mockito.times(1)).withArguments(isA(DesiredCapabilities.class));
+ }
+
+ @Test
+ public void shouldReturnChromeBrowserWhenSpecified() throws Exception {
+ ChromeDriver mockBrowser = mock(ChromeDriver.class);
+ whenNew(ChromeDriver.class).withParameterTypes(ChromeOptions.class).withArguments(isA(ChromeOptions.class)).thenReturn(mockBrowser);
+
+ factory.setBrowserType(BrowserType.CHROME);
+ assertThat(factory.getBrowser(), is(sameInstance((WebDriver)mockBrowser)));
+
+ verifyNew(ChromeDriver.class, Mockito.times(1)).withArguments(isA(ChromeOptions.class));
+ }
+
+ @Test
+ public void shouldReturnAndroidBrowserWhenSpecified() throws Exception {
+ AndroidDriver mockBrowser = mock(AndroidDriver.class);
+ whenNew(AndroidDriver.class).withNoArguments().thenReturn(mockBrowser);
+
+ factory.setBrowserType(BrowserType.ANDROID);
+ assertThat(factory.getBrowser(), is(sameInstance((WebDriver)mockBrowser)));
+
+ verifyNew(AndroidDriver.class, Mockito.times(1)).withNoArguments();
+ }
+}