/** * Access the current {@link WebConnection} for the {@link WebClient}. * @return the current {@code WebConnection} */ public WebConnection getWebConnection() { return getWebClient().getWebConnection(); }
/** * 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()); }
@Before public void setup() { when(this.client.getWebConnection()).thenReturn(mock(WebConnection.class)); this.builder = new MockMvcWebConnectionBuilderSupport(this.wac) {}; }
private WebResponse createResponse(WebClient client, WebRequest request) throws IOException { return client.getWebConnection().getResponse(request); }
/** * Access the current {@link WebConnection} for the {@link WebClient}. * @return the current {@code WebConnection} */ public WebConnection getWebConnection() { return this.webClient.getWebConnection(); }
@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; }
/** * 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); }
/** * 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); }
/** * 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); }
/** * Access the current {@link WebConnection} for the {@link WebClient}. * @return the current {@code WebConnection} */ public WebConnection getWebConnection() { return getWebClient().getWebConnection(); }
/** * 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); }
/** * 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); }
/** * 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()); }
/** * 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()); }
private void setFaceletsErrorDetector() { JSFUnitWebConnection webConnection = (JSFUnitWebConnection)webClient.getWebConnection(); webConnection.addListener(new FaceletsErrorPageDetector()); }
private void doSeamSetup() { if (!SeamUtil.isSeamPresent()) return; SeamUtil.suppressSeamComponentWarning(); JSFUnitWebConnection webConnection = (JSFUnitWebConnection)this.webClient.getWebConnection(); webConnection.addListener(new SeamRequestListener()); }
if (proxyHost == null) wc = new WebClient(wcSpec.getBrowserVersion()); wc.setAjaxController(new NicelyResynchronizingAjaxController()); wc.setWebConnection(new JSFUnitWebConnection(wc.getWebConnection())); wcSpec.setWebClient(wc);
/** * 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()); }
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; }
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; }