Package com.browserup.bup.client
Class ClientUtil
- java.lang.Object
-
- com.browserup.bup.client.ClientUtil
-
public class ClientUtil extends java.lang.ObjectA utility class with convenience methods for clients using BrowserUp Proxy in embedded mode.
-
-
Constructor Summary
Constructors Constructor Description ClientUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static AdvancedHostResolvercreateDnsJavaResolver()Deprecated.The dnsjava resolver has been deprecated in favor of the standard JVM resolver and will be removed in BUP >2.1.static AdvancedHostResolvercreateDnsJavaWithNativeFallbackResolver()Deprecated.The dnsjava resolver has been deprecated in favor of the standard JVM resolver and will be removed in BUP >2.1.static AdvancedHostResolvercreateNativeCacheManipulatingResolver()Creates aNativeCacheManipulatingResolverinstance that can be used when callingBrowserUpProxy.setHostNameResolver(com.browserup.bup.proxy.dns.AdvancedHostResolver).static AdvancedHostResolvercreateNativeResolver()Creates aNativeResolverinstance that does not support cache manipulation that can be used when callingBrowserUpProxy.setHostNameResolver(com.browserup.bup.proxy.dns.AdvancedHostResolver).static org.openqa.selenium.ProxycreateSeleniumProxy(BrowserUpProxy browserUpProxy)Creates a Selenium Proxy object from the BrowserUpProxy instance.static org.openqa.selenium.ProxycreateSeleniumProxy(BrowserUpProxy browserUpProxy, java.net.InetAddress connectableAddress)Creates a Selenium Proxy object from the BrowserUpProxy instance, using the specified connectableAddress as the Selenium Proxy object's proxy address.static org.openqa.selenium.ProxycreateSeleniumProxy(java.net.InetSocketAddress connectableAddressAndPort)Creates a Selenium Proxy object using the specified connectableAddressAndPort as the HTTP proxy server.static java.net.InetAddressgetConnectableAddress()Attempts to retrieve a "connectable" address for this device that other devices on the network can use to connect to a local proxy.
-
-
-
Method Detail
-
createNativeCacheManipulatingResolver
public static AdvancedHostResolver createNativeCacheManipulatingResolver()
Creates aNativeCacheManipulatingResolverinstance that can be used when callingBrowserUpProxy.setHostNameResolver(com.browserup.bup.proxy.dns.AdvancedHostResolver).- Returns:
- a new NativeCacheManipulatingResolver
-
createNativeResolver
public static AdvancedHostResolver createNativeResolver()
Creates aNativeResolverinstance that does not support cache manipulation that can be used when callingBrowserUpProxy.setHostNameResolver(com.browserup.bup.proxy.dns.AdvancedHostResolver).- Returns:
- a new NativeResolver
-
createDnsJavaResolver
@Deprecated public static AdvancedHostResolver createDnsJavaResolver()
Deprecated.The dnsjava resolver has been deprecated in favor of the standard JVM resolver and will be removed in BUP >2.1.Creates aDnsJavaResolverinstance that can be used when callingBrowserUpProxy.setHostNameResolver(com.browserup.bup.proxy.dns.AdvancedHostResolver).- Returns:
- a new DnsJavaResolver
-
createDnsJavaWithNativeFallbackResolver
@Deprecated public static AdvancedHostResolver createDnsJavaWithNativeFallbackResolver()
Deprecated.The dnsjava resolver has been deprecated in favor of the standard JVM resolver and will be removed in BUP >2.1.Creates aChainedHostResolverinstance that first attempts to resolve a hostname using aDnsJavaResolver, then usesNativeCacheManipulatingResolver. Can be used when callingBrowserUpProxy.setHostNameResolver(com.browserup.bup.proxy.dns.AdvancedHostResolver).- Returns:
- a new ChainedHostResolver that resolves addresses first using a DnsJavaResolver, then using a NativeCacheManipulatingResolver
-
createSeleniumProxy
public static org.openqa.selenium.Proxy createSeleniumProxy(BrowserUpProxy browserUpProxy)
Creates a Selenium Proxy object from the BrowserUpProxy instance. The BrowserUpProxy must be started. Retrieves the address of the Proxy usinggetConnectableAddress().- Parameters:
browserUpProxy- started BrowserUpProxy instance to read connection information from- Returns:
- a Selenium Proxy instance, configured to use the BrowserUpProxy instance as its proxy server
- Throws:
java.lang.IllegalStateException- if the proxy has not been started.
-
createSeleniumProxy
public static org.openqa.selenium.Proxy createSeleniumProxy(BrowserUpProxy browserUpProxy, java.net.InetAddress connectableAddress)
Creates a Selenium Proxy object from the BrowserUpProxy instance, using the specified connectableAddress as the Selenium Proxy object's proxy address. Determines the port usingBrowserUpProxy.getPort(). The BrowserUpProxy must be started.- Parameters:
browserUpProxy- started BrowserUpProxy instance to read the port fromconnectableAddress- the network address the Selenium Proxy will use to reach this BrowserUpProxy instance- Returns:
- a Selenium Proxy instance, configured to use the BrowserUpProxy instance as its proxy server
- Throws:
java.lang.IllegalStateException- if the proxy has not been started.
-
createSeleniumProxy
public static org.openqa.selenium.Proxy createSeleniumProxy(java.net.InetSocketAddress connectableAddressAndPort)
Creates a Selenium Proxy object using the specified connectableAddressAndPort as the HTTP proxy server.- Parameters:
connectableAddressAndPort- the network address (or hostname) and port the Selenium Proxy will use to reach its proxy server (the InetSocketAddress may be unresolved).- Returns:
- a Selenium Proxy instance, configured to use the specified address and port as its proxy server
-
getConnectableAddress
public static java.net.InetAddress getConnectableAddress()
Attempts to retrieve a "connectable" address for this device that other devices on the network can use to connect to a local proxy. This is a "reasonable guess" that is suitable in many (but not all) common scenarios. TODO: define the algorithm used to discover a "connectable" local host- Returns:
- a "reasonable guess" at an address that can be used by other machines on the network to reach this host
-
-