本文整理汇总了Java中net.lightbody.bmp.proxy.ProxyServer类的典型用法代码示例。如果您正苦于以下问题:Java ProxyServer类的具体用法?Java ProxyServer怎么用?Java ProxyServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProxyServer类属于net.lightbody.bmp.proxy包,在下文中一共展示了ProxyServer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getProxy
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
private Proxy getProxy() {
ProxyServer server = getServer();
server.setCaptureContent(true);
server.setCaptureHeaders(true);
SeleniumHolder.setProxyServer(server);
Proxy proxy = new Proxy();
try {
proxy = server.seleniumProxy();
String localIp = InetAddress.getLocalHost().getHostAddress();
String proxyStr = String.format("%s:%d", localIp, server.getPort());
proxy.setHttpProxy(proxyStr);
proxy.setSslProxy("trustAllSSLCertificates");
proxy.setFtpProxy(proxyStr);
SeleniumHolder.setProxy(proxy);
} catch (UnknownHostException e) {
LOGGER.error("UnknownHostException occurs", e);
}
return proxy;
}
开发者ID:WileyLabs,项目名称:teasy,代码行数:24,代码来源:SeleniumTestExecutionListener.java
示例2: setScavengePeriod
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
/**
* @param seconds
*/
public void setScavengePeriod(int seconds)
{
if (seconds==0)
seconds=60;
int old_period=_scavengePeriodMs;
int period = seconds*1000;
if (period > ProxyServer.PROXY_TIMEOUT)
period = ProxyServer.PROXY_TIMEOUT;
if (period < 1000)
period = 1000;
if (period != old_period)
{
synchronized(this)
{
_scavengePeriodMs = period;
if (_scavenger != null)
_scavenger.interrupt();
}
}
}
开发者ID:epam,项目名称:Wilma,代码行数:26,代码来源:AbstractSessionManager.java
示例3: start
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Override
public void start() {
try {
getProperties();
server.setPort(proxyPort);
server.start(requestTimeout);
ProxyServer.setResponseVolatile(responseVolatile);
ProxyServer.setShouldKeepSslConnectionAlive(shouldKeepSslConnectionAlive);
server.setCaptureContent(true);
server.setCaptureBinaryContent(true);
server.addRequestInterceptor(requestInterceptor);
server.addResponseInterceptor(responseInterceptor);
} catch (Exception e) {
throw new ProxyCannotBeStartedException("Starting the proxy server failed.", e);
}
}
开发者ID:epam,项目名称:Wilma,代码行数:17,代码来源:BrowserMobProxy.java
示例4: testStartShouldStartTheProxySuccessfully
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void testStartShouldStartTheProxySuccessfully() throws Exception {
// GIVEN
int requestTimeout = 30000;
int proxyPort = 9092;
propertiesDTO = new ProxyPropertyDTO(proxyPort, requestTimeout, true, false);
given(configurationAccess.getProperties()).willReturn(propertiesDTO);
// WHEN
underTest.start();
// THEN
Mockito.verify(server).setPort(proxyPort);
Mockito.verify(server).start(requestTimeout);
Mockito.verify(server).addRequestInterceptor(loggingRequestInterceptor);
Mockito.verify(server).addResponseInterceptor(loggingResponseInterceptor);
Assert.assertTrue(ProxyServer.getResponseVolatile(), "Response volatility status was not set properly.");
}
开发者ID:epam,项目名称:Wilma,代码行数:17,代码来源:BrowserMobProxyTest.java
示例5: strippingReferer
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void strippingReferer() throws Exception {
ProxyServer bmp = new ProxyServer(8071);
bmp.start();
HttpRequestInterceptor stripper = new RefererStripper();
bmp.addRequestInterceptor(stripper);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());
WebDriver driver = new FirefoxDriver(caps);
driver.get("http://localhost/test_referer.html");
driver.findElement(By.tagName("a")).click();
assertThat(
driver.findElement(By.tagName("body")).getText(),
containsString("No referer"));
Thread.sleep(10000);
driver.quit();
bmp.stop();
}
开发者ID:barancev,项目名称:selen-confetqa-2013,代码行数:27,代码来源:Sample6_StrippingReferer.java
示例6: startWithProxy
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void startWithProxy() throws Exception {
ProxyServer bmp = new ProxyServer(8071);
bmp.start();
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());
WebDriver driver = new FirefoxDriver(caps);
driver.get("http://localhost/");
assertThat(
driver.findElement(By.tagName("body")).getText(),
containsString("WampServer"));
driver.quit();
bmp.stop();
}
开发者ID:barancev,项目名称:selen-confetqa-2013,代码行数:20,代码来源:Sample1_StartWithProxy.java
示例7: downloadingFiles
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void downloadingFiles() throws Exception {
ProxyServer bmp = new ProxyServer(8071);
bmp.start();
HttpResponseInterceptor downloader = new FileDownloader()
.addContentType("application/pdf");
bmp.addResponseInterceptor(downloader);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());
WebDriver driver = new FirefoxDriver(caps);
driver.get("http://localhost/test_download.html");
driver.findElement(By.tagName("a")).click();
String fileName = driver.findElement(By.tagName("body")).getText();
assertTrue(new File(fileName).exists());
Thread.sleep(30000);
driver.quit();
bmp.stop();
}
开发者ID:barancev,项目名称:selen-confetqa-2013,代码行数:27,代码来源:Sample8_DownloadingFiles.java
示例8: injectingJavaScript
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void injectingJavaScript() throws Exception {
ProxyServer bmp = new ProxyServer(8071);
bmp.start();
HttpResponseInterceptor injector = new JQueryInjector();
bmp.addResponseInterceptor(injector);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());
FirefoxDriver driver = new FirefoxDriver(caps);
driver.get("http://localhost/test_referer.html");
String linkText = (String) driver.executeScript("return $(\"a\").text()");
assertThat(
linkText,
is("click me!"));
driver.quit();
bmp.stop();
}
开发者ID:barancev,项目名称:selen-confetqa-2013,代码行数:25,代码来源:Sample7_InjectingJavaScript.java
示例9: autoBasicAuthorization
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void autoBasicAuthorization() throws Exception {
ProxyServer bmp = new ProxyServer(8071);
bmp.start();
bmp.autoBasicAuthorization("", "admin", "password");
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());
WebDriver driver = new FirefoxDriver(caps);
driver.get("http://localhost/restricted");
assertThat(
driver.findElement(By.tagName("body")).getText(),
containsString("Access granted"));
driver.quit();
bmp.stop();
}
开发者ID:barancev,项目名称:selen-confetqa-2013,代码行数:22,代码来源:Sample2_Authentication.java
示例10: changingUserAgent
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void changingUserAgent() throws Exception {
ProxyServer bmp = new ProxyServer(8071);
bmp.start();
RequestInterceptor userAgentChanger = new UserAgentChanger(
"Mozilla/5.0 (Linux; U; Android 2.2; en-us; Nexus One Build/FRF91)"
+ "AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1");
bmp.addRequestInterceptor(userAgentChanger);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());
WebDriver driver = new FirefoxDriver(caps);
driver.get("http://software-testing.ru/forum");
Thread.sleep(10000);
driver.quit();
bmp.stop();
}
开发者ID:barancev,项目名称:selen-confetqa-2013,代码行数:23,代码来源:Sample4_ChangingUserAgent.java
示例11: changingLanguage
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void changingLanguage() throws Exception {
ProxyServer bmp = new ProxyServer(8071);
bmp.start();
RequestInterceptor languageChanger = new LanguageChanger("en,ru");
bmp.addRequestInterceptor(languageChanger);
DesiredCapabilities caps = new DesiredCapabilities();
caps.setCapability(CapabilityType.PROXY, bmp.seleniumProxy());
WebDriver driver = new FirefoxDriver(caps);
driver.get("http://ci.seleniumhq.org:8080/");
Thread.sleep(10000);
driver.quit();
bmp.stop();
}
开发者ID:barancev,项目名称:selen-confetqa-2013,代码行数:21,代码来源:Sample5_ChangingLanguage.java
示例12: doGet
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Override
protected void doGet(final HttpServletRequest req, final HttpServletResponse resp) throws ServletException, IOException {
resp.setContentType("application/json");
PrintWriter out = resp.getWriter();
boolean responseVolatility = ProxyServer.getResponseVolatile();
out.write("{\"responseVolatility\":" + responseVolatility + "}");
out.flush();
out.close();
}
开发者ID:epam,项目名称:Wilma,代码行数:10,代码来源:ResponseMessageVolatilityStatusServlet.java
示例13: doGetShouldWriteJsonMessage
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void doGetShouldWriteJsonMessage() throws ServletException, IOException {
//GIVEN request and response
given(resp.getWriter()).willReturn(printWriter);
ProxyServer.setResponseVolatile(true);
//WHEN
underTest.doGet(req, resp);
//THEN
verify(resp).setContentType("application/json");
verify(printWriter).write("{\"responseVolatility\":true}");
}
开发者ID:epam,项目名称:Wilma,代码行数:12,代码来源:ResponseMessageVolatilityStatusServletTest.java
示例14: doPostShouldCallDoGet
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public void doPostShouldCallDoGet() throws ServletException, IOException {
//GIVEN request and response
given(resp.getWriter()).willReturn(printWriter);
ProxyServer.setResponseVolatile(true);
//WHEN
underTest.doPost(req, resp);
//THEN
verify(resp).setContentType("application/json");
verify(printWriter).write("{\"responseVolatility\":true}");
}
开发者ID:epam,项目名称:Wilma,代码行数:12,代码来源:ResponseMessageVolatilityStatusServletTest.java
示例15: testDoGetShouldTurnResponseVolatilityOff
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public final void testDoGetShouldTurnResponseVolatilityOff() throws ServletException, IOException {
// GIVEN in setup
ProxyServer.setResponseVolatile(true);
// WHEN
underTest.doGet(request, response);
// THEN
Assert.assertTrue(!ProxyServer.getResponseVolatile());
}
开发者ID:epam,项目名称:Wilma,代码行数:10,代码来源:ResponseMessageVolatilityOffServletTest.java
示例16: testDoGetShouldTurnResponseVolatilityOn
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@Test
public final void testDoGetShouldTurnResponseVolatilityOn() throws ServletException, IOException {
// GIVEN in setup
ProxyServer.setResponseVolatile(false);
// WHEN
underTest.doGet(request, response);
// THEN
Assert.assertTrue(ProxyServer.getResponseVolatile());
}
开发者ID:epam,项目名称:Wilma,代码行数:10,代码来源:ResponseMessageVolatilityOnServletTest.java
示例17: withWebDriver
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
public BrowserThread withWebDriver(final String browser) throws Exception {
for (int i = 0; i < 50; i++) {
final int port = portCounter.getAndIncrement();
try {
proxyServer = new ProxyServer(port);
proxyServer.start();
break;
} catch (final Exception e) {
proxyServer = null;
logger.info("Unable to open port " + port, e);
}
}
if (proxyServer == null) {
throw new RuntimeException("Unable to start proxy server!");
}
final CrawlerInterceptor crawlerInterceptor = new CrawlerInterceptor();
proxyServer.addRequestInterceptor(crawlerInterceptor);
proxyServer.addResponseInterceptor(crawlerInterceptor);
proxyServer.setCaptureContent(true);
final DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(PROXY, proxyServer.seleniumProxy());
this.webDriver = getBrowser(browser, capabilities);
this.crawlerInterceptor = crawlerInterceptor;
crawlerInterceptor.setBrowserId(browserCounter.incrementAndGet());
return this;
}
开发者ID:web-traffic-simulator,项目名称:web-traffic-simulator,代码行数:28,代码来源:BrowserThread.java
示例18: proxyServer
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
/**
* Starts the proxy server
* @param port
* @return
* @throws Exception
*/
public ProxyServer proxyServer(int port) throws Exception{
ProxyServer server = new ProxyServer(port);
server.start();
server.setCaptureHeaders(true);
server.setCaptureContent(true);
this.server=server;
return server;
}
开发者ID:GiannisPapadakis,项目名称:seletest,代码行数:15,代码来源:PerformanceUtils.java
示例19: stopServer
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
/**
* Stops proxy server
* @param server
* @return
* @throws Exception
*/
public PerformanceUtils stopServer(ProxyServer server){
try {
server.stop();
} catch (Exception e) {
log.error("Exception while trying to stop proxy server {}",e.getMessage());
}
return this;
}
开发者ID:GiannisPapadakis,项目名称:seletest,代码行数:15,代码来源:PerformanceUtils.java
示例20: startProxy
import net.lightbody.bmp.proxy.ProxyServer; //导入依赖的package包/类
@BeforeTest
public void startProxy() throws Exception {
server = new ProxyServer(port);
server.start();
server.setCaptureHeaders(true);
server.setCaptureContent(true);
server.setLocalHost(InetAddress.getByName(proxyIp));
server.newHar("test_proxy");
}
开发者ID:atinfo,项目名称:at.info-knowledge-base,代码行数:10,代码来源:BaseTest.java
注:本文中的net.lightbody.bmp.proxy.ProxyServer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论