本文整理了Java中com.gargoylesoftware.htmlunit.WebClient.getWebConnection()
方法的一些代码示例,展示了WebClient.getWebConnection()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebClient.getWebConnection()
方法的具体详情如下:
包路径:com.gargoylesoftware.htmlunit.WebClient
类名称:WebClient
方法名:getWebConnection
[英]Returns the object that will resolve all URL requests.
[中]返回将解析所有URL请求的对象。
代码示例来源:origin: spring-projects/spring-framework
/**
* Access the current {@link WebConnection} for the {@link WebClient}.
* @return the current {@code WebConnection}
*/
public WebConnection getWebConnection() {
return getWebClient().getWebConnection();
}
代码示例来源:origin: spring-projects/spring-framework
/**
* Create a new {@link WebConnection} that will use a {@link MockMvc}
* instance if one of the specified {@link WebRequestMatcher} instances
* matches.
* @param webClient the WebClient to use if none of the specified
* {@code WebRequestMatcher} instances matches (never {@code null})
* @return a new {@code WebConnection} that will use a {@code MockMvc}
* instance if one of the specified {@code WebRequestMatcher} matches
* @since 4.3
* @see #alwaysUseMockMvc()
* @see #useMockMvc(WebRequestMatcher...)
* @see #useMockMvcForHosts(String...)
*/
protected final WebConnection createConnection(WebClient webClient) {
Assert.notNull(webClient, "WebClient must not be null");
return createConnection(webClient, webClient.getWebConnection());
}
代码示例来源:origin: spring-projects/spring-framework
@Before
public void setup() {
when(this.client.getWebConnection()).thenReturn(mock(WebConnection.class));
this.builder = new MockMvcWebConnectionBuilderSupport(this.wac) {};
}
代码示例来源:origin: spring-projects/spring-framework
private WebResponse createResponse(WebClient client, WebRequest request) throws IOException {
return client.getWebConnection().getResponse(request);
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Access the current {@link WebConnection} for the {@link WebClient}.
* @return the current {@code WebConnection}
*/
public WebConnection getWebConnection() {
return this.webClient.getWebConnection();
}
代码示例来源:origin: net.sourceforge.jwebunit/jwebunit-htmlunit-plugin
@Override
public void setTimeout(int milliseconds) {
if (wc != null && wc.getWebConnection() != null) {
throw new IllegalArgumentException("Cannot set the timeout when the WebConnection has already been created.");
}
timeout = milliseconds;
}
代码示例来源:origin: net.sourceforge.htmlunit/htmlunit
/**
* Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
* connection of the WebClient.
* @param webClient the WebClient which WebConnection should be wrapped
* @throws IllegalArgumentException if the WebClient is {@code null}
*/
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
if (webClient == null) {
throw new IllegalArgumentException("WebClient can't be null");
}
wrappedWebConnection_ = webClient.getWebConnection();
webClient.setWebConnection(this);
}
代码示例来源:origin: net.disy.htmlunit/htmlunit
/**
* Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
* connection of the WebClient.
* @param webClient the WebClient which WebConnection should be wrapped
* @throws IllegalArgumentException if the WebClient is <code>null</code>
*/
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
if (webClient == null) {
throw new IllegalArgumentException("WebClient can't be null");
}
wrappedWebConnection_ = webClient.getWebConnection();
webClient.setWebConnection(this);
}
代码示例来源:origin: org.jenkins-ci/htmlunit
/**
* Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
* connection of the WebClient.
* @param webClient the WebClient which WebConnection should be wrapped
* @throws IllegalArgumentException if the WebClient is <code>null</code>
*/
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
if (webClient == null) {
throw new IllegalArgumentException("WebClient can't be null");
}
wrappedWebConnection_ = webClient.getWebConnection();
webClient.setWebConnection(this);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test
/**
* Access the current {@link WebConnection} for the {@link WebClient}.
* @return the current {@code WebConnection}
*/
public WebConnection getWebConnection() {
return getWebClient().getWebConnection();
}
代码示例来源:origin: org.jvnet.hudson/htmlunit
/**
* Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
* connection of the WebClient.
* @param webClient the WebClient which WebConnection should be wrapped
* @throws IllegalArgumentException if the WebClient is <code>null</code>
*/
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
if (webClient == null) {
throw new IllegalArgumentException("WebClient can't be null");
}
wrappedWebConnection_ = webClient.getWebConnection();
webClient.setWebConnection(this);
}
代码示例来源:origin: HtmlUnit/htmlunit
/**
* Constructs a WebConnection object wrapping the connection of the WebClient and places itself as
* connection of the WebClient.
* @param webClient the WebClient which WebConnection should be wrapped
* @throws IllegalArgumentException if the WebClient is {@code null}
*/
public WebConnectionWrapper(final WebClient webClient) throws IllegalArgumentException {
if (webClient == null) {
throw new IllegalArgumentException("WebClient can't be null");
}
wrappedWebConnection_ = webClient.getWebConnection();
webClient.setWebConnection(this);
}
代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-test
/**
* Create a new {@link WebConnection} that will use a {@link MockMvc}
* instance if one of the specified {@link WebRequestMatcher} instances
* matches.
* @param webClient the WebClient to use if none of the specified
* {@code WebRequestMatcher} instances matches (never {@code null})
* @return a new {@code WebConnection} that will use a {@code MockMvc}
* instance if one of the specified {@code WebRequestMatcher} matches
* @since 4.3
* @see #alwaysUseMockMvc()
* @see #useMockMvc(WebRequestMatcher...)
* @see #useMockMvcForHosts(String...)
*/
protected final WebConnection createConnection(WebClient webClient) {
Assert.notNull(webClient, "WebClient must not be null");
return createConnection(webClient, webClient.getWebConnection());
}
代码示例来源:origin: apache/servicemix-bundles
/**
* Create a new {@link WebConnection} that will use a {@link MockMvc}
* instance if one of the specified {@link WebRequestMatcher} instances
* matches.
* @param webClient the WebClient to use if none of the specified
* {@code WebRequestMatcher} instances matches (never {@code null})
* @return a new {@code WebConnection} that will use a {@code MockMvc}
* instance if one of the specified {@code WebRequestMatcher} matches
* @see #alwaysUseMockMvc()
* @see #useMockMvc(WebRequestMatcher...)
* @see #useMockMvcForHosts(String...)
* @since 4.3
*/
protected final WebConnection createConnection(WebClient webClient) {
Assert.notNull(webClient, "WebClient must not be null");
return createConnection(webClient, webClient.getWebConnection());
}
代码示例来源:origin: org.jboss.jsfunit/jboss-jsfunit-core
private void setFaceletsErrorDetector()
{
JSFUnitWebConnection webConnection = (JSFUnitWebConnection)webClient.getWebConnection();
webConnection.addListener(new FaceletsErrorPageDetector());
}
代码示例来源:origin: org.jboss.jsfunit/jboss-jsfunit-core
private void doSeamSetup()
{
if (!SeamUtil.isSeamPresent()) return;
SeamUtil.suppressSeamComponentWarning();
JSFUnitWebConnection webConnection = (JSFUnitWebConnection)this.webClient.getWebConnection();
webConnection.addListener(new SeamRequestListener());
}
代码示例来源:origin: org.jboss.jsfunit/jboss-jsfunit-core
if (proxyHost == null) wc = new WebClient(wcSpec.getBrowserVersion());
wc.setAjaxController(new NicelyResynchronizingAjaxController());
wc.setWebConnection(new JSFUnitWebConnection(wc.getWebConnection()));
wcSpec.setWebClient(wc);
代码示例来源:origin: org.jboss.jsfunit/jboss-jsfunit-core
/**
* Creates a new session for testing the JSF application.
* This constructor will also clear the HttpSession.
*
* Note that the initialPage param should be something that maps into the FacesServlet.
* In the case where the FacesServlet is extension mapped in web.xml, this param will be something
* like "/index.jsf" or "/index.faces". If the FacesServlet is path-mapped then the
* initialPage param will be something like "/faces/index.jsp".
*
* @param webClient An HtmlUnit WebClient containing custom attributes. Note that this WebClient
* instance should be created with the JSFUnit WebConversationFactory instead of
* the WebClient constructor.
* @param initialPage The page used to start a client session with JSF. Example: "/index.jsf"
*
* @throws IOException If there is an error calling the JSF app
*/
public JSFSession(WebClientSpec wcSpec) throws IOException
{
this.webClient = wcSpec.getWebClient();
wcSpec.doInitialRequest();
this.jsfServerSession = new JSFServerSession();
this.jsfClientSession = new JSFClientSession(webClient, jsfServerSession);
JSFUnitWebConnection webConnection = (JSFUnitWebConnection)this.webClient.getWebConnection();
webConnection.addListener(this.jsfServerSession);
if (HtmlUnitSnooper.enabled()) webConnection.addListener(new HtmlUnitSnooper());
}
代码示例来源:origin: jenkinsci/subversion-plugin
private FreeStyleBuild sendCommitTriggerMultipleSvnLocations(FreeStyleProject p, boolean includeRevision) throws Exception {
String repoUUID = "71c3de6d-444a-0410-be80-ed276b4c234a";
WebClient wc = r.createWebClient();
WebRequest wr = new WebRequest(new URL(r.getURL() + "subversion/" + repoUUID + "/notifyCommit"), HttpMethod.POST);
wr.setRequestBody("A trunk/hudson/test-projects/trivial-ant/build.xml\n" +
"M trunk/hudson/test-projects/trivial-maven/src/main/");
wr.setAdditionalHeader("Content-Type", "text/plain;charset=UTF-8");
if (includeRevision) {
wr.setAdditionalHeader("X-Hudson-Subversion-Revision", "18075");
}
WebConnection conn = wc.getWebConnection();
WebResponse resp = conn.getResponse(wr);
assertTrue(r.isGoodHttpStatus(resp.getStatusCode()));
Thread.sleep(1000);
r.waitUntilNoActivity();
FreeStyleBuild b = p.getLastBuild();
assertNotNull(b);
r.assertBuildStatus(Result.SUCCESS,b);
return b;
}
代码示例来源:origin: jenkinsci/subversion-plugin
private FreeStyleBuild sendCommitTrigger(FreeStyleProject p, boolean includeRevision) throws Exception {
String repoUUID = "71c3de6d-444a-0410-be80-ed276b4c234a";
WebClient wc = r.createWebClient();
WebRequest wr = new WebRequest(new URL(r.getURL() + "subversion/" + repoUUID + "/notifyCommit"), HttpMethod.POST);
wr.setRequestBody("A trunk/hudson/test-projects/trivial-ant/build.xml");
wr.setAdditionalHeader("Content-Type", "text/plain;charset=UTF-8");
if (includeRevision) {
wr.setAdditionalHeader("X-Hudson-Subversion-Revision", "13000");
}
WebConnection conn = wc.getWebConnection();
WebResponse resp = conn.getResponse(wr);
assertTrue(r.isGoodHttpStatus(resp.getStatusCode()));
Thread.sleep(1000);
r.waitUntilNoActivity();
FreeStyleBuild b = p.getLastBuild();
assertNotNull(b);
r.assertBuildStatus(Result.SUCCESS,b);
return b;
}
内容来源于网络,如有侵权,请联系作者删除!