Search in sources :

Example 1 with ProxyHostPort

use of com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort in project jmeter-plugins by undera.

the class WebDriverConfig method createProxy.

/**
 * Call this method to create a {@link Proxy} instance for use when creating a {@link org.openqa.selenium.WebDriver}
 * instance.  The values/settings of the proxy depends entirely on the values set on this config instance.
 *
 * @return a {@link Proxy}
 */
public Proxy createProxy() {
    switch(getProxyType()) {
        case PROXY_PAC:
            return proxyFactory.getConfigUrlProxy(getProxyPacUrl());
        case DIRECT:
            return proxyFactory.getDirectProxy();
        case AUTO_DETECT:
            return proxyFactory.getAutodetectProxy();
        case MANUAL:
            if (isUseHttpSettingsForAllProtocols()) {
                ProxyHostPort proxy = new ProxyHostPort(getHttpHost(), getHttpPort());
                return proxyFactory.getManualProxy(proxy, proxy, proxy, proxy, getNoProxyHost());
            }
            ProxyHostPort http = new ProxyHostPort(getHttpHost(), getHttpPort());
            ProxyHostPort https = new ProxyHostPort(getHttpsHost(), getHttpsPort());
            ProxyHostPort ftp = new ProxyHostPort(getFtpHost(), getFtpPort());
            ProxyHostPort socks = new ProxyHostPort(getSocksHost(), getSocksPort());
            return proxyFactory.getManualProxy(http, https, ftp, socks, getNoProxyHost());
        default:
            return proxyFactory.getSystemProxy();
    }
}
Also used : ProxyHostPort(com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort)

Example 2 with ProxyHostPort

use of com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort in project jmeter-plugins by undera.

the class WebDriverConfigTest method shouldDelegateToProxyFactoryWhenCreatingManualProxyWithHttpAsDefault.

@Test
public void shouldDelegateToProxyFactoryWhenCreatingManualProxyWithHttpAsDefault() {
    final ProxyHostPort http = new ProxyHostPort("http", 1);
    final String noProxy = "host1, host2";
    config.setHttpHost(http.getHost());
    config.setHttpPort(http.getPort());
    config.setUseHttpSettingsForAllProtocols(true);
    config.setNoProxyHost(noProxy);
    when(proxyFactory.getManualProxy(http, http, http, http, noProxy)).thenReturn(new Proxy());
    config.setProxyType(ProxyType.MANUAL);
    Proxy proxy = config.createProxy();
    assertThat(proxy, is(notNullValue()));
    verify(proxyFactory, times(1)).getManualProxy(http, http, http, http, noProxy);
}
Also used : Proxy(org.openqa.selenium.Proxy) ProxyHostPort(com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort) Test(org.junit.Test)

Example 3 with ProxyHostPort

use of com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort in project jmeter-plugins by undera.

the class WebDriverConfigTest method shouldDelegateToProxyFactoryWhenCreatingManualProxyWithAllValuesSpecified.

@Test
public void shouldDelegateToProxyFactoryWhenCreatingManualProxyWithAllValuesSpecified() {
    final ProxyHostPort http = new ProxyHostPort("http", 1);
    final ProxyHostPort https = new ProxyHostPort("https", 2);
    final ProxyHostPort ftp = new ProxyHostPort("ftp", 3);
    final ProxyHostPort socks = new ProxyHostPort("socks", 4);
    final String noProxy = "host1, host2";
    config.setHttpHost(http.getHost());
    config.setHttpPort(http.getPort());
    config.setUseHttpSettingsForAllProtocols(false);
    config.setHttpsHost(https.getHost());
    config.setHttpsPort(https.getPort());
    config.setFtpHost(ftp.getHost());
    config.setFtpPort(ftp.getPort());
    config.setSocksHost(socks.getHost());
    config.setSocksPort(socks.getPort());
    config.setNoProxyHost(noProxy);
    when(proxyFactory.getManualProxy(http, https, ftp, socks, noProxy)).thenReturn(new Proxy());
    config.setProxyType(ProxyType.MANUAL);
    Proxy proxy = config.createProxy();
    assertThat(proxy, is(notNullValue()));
    verify(proxyFactory, times(1)).getManualProxy(http, https, ftp, socks, noProxy);
}
Also used : Proxy(org.openqa.selenium.Proxy) ProxyHostPort(com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort) Test(org.junit.Test)

Aggregations

ProxyHostPort (com.googlecode.jmeter.plugins.webdriver.proxy.ProxyHostPort)3 Test (org.junit.Test)2 Proxy (org.openqa.selenium.Proxy)2