Search in sources :

Example 61 with Page

use of com.gargoylesoftware.htmlunit.Page in project spring-framework by spring-projects.

the class DelegatingWebConnectionTests method verifyExampleInClassLevelJavadoc.

@Test
@EnabledForTestGroups(LONG_RUNNING)
public void verifyExampleInClassLevelJavadoc() throws Exception {
    WebClient webClient = new WebClient();
    MockMvc mockMvc = MockMvcBuilders.standaloneSetup().build();
    MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, webClient);
    WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");
    WebConnection httpConnection = new HttpWebConnection(webClient);
    webClient.setWebConnection(new DelegatingWebConnection(mockConnection, new DelegateWebConnection(cdnMatcher, httpConnection)));
    Page page = webClient.getPage("https://code.jquery.com/jquery-1.11.0.min.js");
    assertThat(page.getWebResponse().getStatusCode()).isEqualTo(200);
    assertThat(page.getWebResponse().getContentAsString()).isNotEmpty();
}
Also used : HttpWebConnection(com.gargoylesoftware.htmlunit.HttpWebConnection) WebConnection(com.gargoylesoftware.htmlunit.WebConnection) DelegateWebConnection(org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection) HttpWebConnection(com.gargoylesoftware.htmlunit.HttpWebConnection) DelegateWebConnection(org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection) Page(com.gargoylesoftware.htmlunit.Page) WebClient(com.gargoylesoftware.htmlunit.WebClient) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.jupiter.api.Test) EnabledForTestGroups(org.springframework.core.testfixture.EnabledForTestGroups)

Example 62 with Page

use of com.gargoylesoftware.htmlunit.Page in project spring-framework by spring-projects.

the class MockMvcWebConnectionTests method contextPathNull.

@Test
public void contextPathNull() throws IOException {
    this.webClient.setWebConnection(new MockMvcWebConnection(this.mockMvc, this.webClient, null));
    Page page = this.webClient.getPage("http://localhost/context/a");
    assertThat(page.getWebResponse().getStatusCode()).isEqualTo(200);
}
Also used : Page(com.gargoylesoftware.htmlunit.Page) Test(org.junit.jupiter.api.Test)

Aggregations

Page (com.gargoylesoftware.htmlunit.Page)62 Test (org.junit.Test)39 WebClient (com.gargoylesoftware.htmlunit.WebClient)33 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)15 PublicAtsApi (com.axway.ats.common.PublicAtsApi)9 HtmlForm (com.gargoylesoftware.htmlunit.html.HtmlForm)5 File (java.io.File)5 IOException (java.io.IOException)5 URL (java.net.URL)5 JenkinsRule (org.jvnet.hudson.test.JenkinsRule)5 VerificationException (com.axway.ats.uiengine.exceptions.VerificationException)4 ConfirmHandler (com.gargoylesoftware.htmlunit.ConfirmHandler)4 Map (java.util.Map)4 JSONObject (net.sf.json.JSONObject)4 RsaJsonWebKey (org.jose4j.jwk.RsaJsonWebKey)4 JsonWebSignature (org.jose4j.jws.JsonWebSignature)4 JwtClaims (org.jose4j.jwt.JwtClaims)4 JwtConsumer (org.jose4j.jwt.consumer.JwtConsumer)4 JwtConsumerBuilder (org.jose4j.jwt.consumer.JwtConsumerBuilder)4 JsonWebStructure (org.jose4j.jwx.JsonWebStructure)4