Thread.State, Thread.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
static String |
PROJECT_NAME |
static String |
PROJECT_VERSION |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
CAPServer(ICapsConfiguration configuration)
CAPS main thread constructor Initialize the server with a configuration object and use the start() method to
start listening.
|
| Modifier and Type | Method and Description |
|---|---|
static CAPServer |
bringItUpRunning(ICapsConfiguration conf)
Factory to instantiate the proxy, start it and wait until it is listening prior to returning with the CAPS
instance.
|
Integer |
getProxyListenerPort()
Get the current proxy port, will be null if proxy startup is not yet finished or not initiated.
|
String |
getProxyString()
The proxy string has the form {hostname}:{port} and can be used to create a selenium proxy object.
|
void |
run()
The main loop thread which starts the server and listens for new socket connections until it gets shutdown.
|
void |
shutdown()
Initiate shutdown of the proxy server.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yieldpublic static String PROJECT_NAME
public static String PROJECT_VERSION
public CAPServer(ICapsConfiguration configuration)
capsConf = new CapsConfiguration()
.setTargetKeyStorePath("certs/test.p12")
.setTargetKeyStorePassword("testPassword");
CAPServer cs = new CAPServer(capsConf);
cs.start();
... do whatever tests you want to do ...
// Getting a proxy object to use in selenium
String proxyString = "localhost:" + cs.getProxyListenerPort();
org.openqa.selenium.Proxy proxy = new Proxy().setSslProxy(proxyString).setHttpProxy(proxyString)
DesiredCapabilities caps = DesiredCapabilities.htmlUnit();
caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
caps.setCapability(CapabilityType.PROXY, proxy);
HtmlUnitDriver d = new HtmlUnitDriver(caps);
...
cs.shutdown();
configuration - public static CAPServer bringItUpRunning(ICapsConfiguration conf) throws InterruptedException, CertificateException, UnrecoverableKeyException, NoSuchAlgorithmException, IOException, KeyManagementException, KeyStoreException, ConfigurationException
conf - InterruptedExceptionCertificateExceptionUnrecoverableKeyExceptionNoSuchAlgorithmExceptionIOExceptionKeyManagementExceptionKeyStoreExceptionConfigurationExceptionpublic void run()
public void shutdown()
public Integer getProxyListenerPort()
public String getProxyString()
String proxyString = cs.getProxyString();
org.openqa.selenium.Proxy proxy = new Proxy().setSslProxy(proxyString).setHttpProxy(proxyString);
DesiredCapabilities caps = DesiredCapabilities.htmlUnit();
caps.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
caps.setCapability(CapabilityType.PROXY, proxy);
Copyright © 2015. All rights reserved.