Search in sources :

Example 6 with WebConnection

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

the class MockMvcConnectionBuilderSupportTests method mockMvc.

@Test
public void mockMvc() throws Exception {
    MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(wac).build();
    WebConnection conn = new MockMvcWebConnectionBuilderSupport(mockMvc) {
    }.createConnection(this.client);
    assertMockMvcUsed(conn, "http://localhost/");
    assertMockMvcNotUsed(conn, "http://example.com/");
}
Also used : WebConnection(com.gargoylesoftware.htmlunit.WebConnection) MockMvc(org.springframework.test.web.servlet.MockMvc) Test(org.junit.Test)

Example 7 with WebConnection

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

the class MockMvcConnectionBuilderSupportTests method defaultContextPathEmpty.

@Test
public void defaultContextPathEmpty() throws Exception {
    WebConnection conn = this.builder.createConnection(this.client);
    assertThat(getResponse(conn, "http://localhost/abc").getContentAsString(), equalTo(""));
}
Also used : WebConnection(com.gargoylesoftware.htmlunit.WebConnection) Test(org.junit.Test)

Example 8 with WebConnection

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

the class MockMvcConnectionBuilderSupportTests method defaultContextPathCustom.

@Test
public void defaultContextPathCustom() throws Exception {
    WebConnection conn = this.builder.contextPath("/abc").createConnection(this.client);
    assertThat(getResponse(conn, "http://localhost/abc/def").getContentAsString(), equalTo("/abc"));
}
Also used : WebConnection(com.gargoylesoftware.htmlunit.WebConnection) Test(org.junit.Test)

Example 9 with WebConnection

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

the class MockMvcConnectionBuilderSupportTests method mockMvcExampleDotCom.

@Test
public void mockMvcExampleDotCom() throws Exception {
    WebConnection conn = this.builder.useMockMvcForHosts("example.com").createConnection(this.client);
    assertMockMvcUsed(conn, "http://localhost/");
    assertMockMvcUsed(conn, "http://example.com/");
    assertMockMvcNotUsed(conn, "http://other.com/");
}
Also used : WebConnection(com.gargoylesoftware.htmlunit.WebConnection) Test(org.junit.Test)

Example 10 with WebConnection

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

the class MockMvcConnectionBuilderSupportTests method mockMvcAlwaysUseMockMvc.

@Test
public void mockMvcAlwaysUseMockMvc() throws Exception {
    WebConnection conn = this.builder.alwaysUseMockMvc().createConnection(this.client);
    assertMockMvcUsed(conn, "http://other.com/");
}
Also used : WebConnection(com.gargoylesoftware.htmlunit.WebConnection) Test(org.junit.Test)

Aggregations

WebConnection (com.gargoylesoftware.htmlunit.WebConnection)11 Test (org.junit.Test)9 WebClient (com.gargoylesoftware.htmlunit.WebClient)3 URL (java.net.URL)3 MockEnvironment (org.springframework.mock.env.MockEnvironment)2 MockMvc (org.springframework.test.web.servlet.MockMvc)2 DelegateWebConnection (org.springframework.test.web.servlet.htmlunit.DelegatingWebConnection.DelegateWebConnection)2 HttpWebConnection (com.gargoylesoftware.htmlunit.HttpWebConnection)1 Page (com.gargoylesoftware.htmlunit.Page)1 StringWebResponse (com.gargoylesoftware.htmlunit.StringWebResponse)1 WebResponse (com.gargoylesoftware.htmlunit.WebResponse)1 ArrayList (java.util.ArrayList)1