diff --git a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java index 184d0b7ec7d..f57d4b69036 100644 --- a/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java +++ b/spring-test/src/main/java/org/springframework/test/web/servlet/htmlunit/MockMvcWebConnection.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2016 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of @@ -41,8 +41,7 @@ import org.springframework.util.Assert; *
* WebClient webClient = new WebClient();
* MockMvc mockMvc = ...
- * MockMvcWebConnection webConnection = new MockMvcWebConnection(mockMvc);
- * mockConnection.setWebClient(webClient);
+ * MockMvcWebConnection webConnection = new MockMvcWebConnection(mockMvc, webClient);
* webClient.setWebConnection(webConnection);
*
* // Use webClient as normal ...
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java
index 867d47be671..1b4f3e1abdd 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/DelegatingWebConnectionTests.java
@@ -131,8 +131,7 @@ public class DelegatingWebConnectionTests {
WebClient webClient = new WebClient();
MockMvc mockMvc = MockMvcBuilders.standaloneSetup(TestController.class).build();
- MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc);
- mockConnection.setWebClient(webClient);
+ MockMvcWebConnection mockConnection = new MockMvcWebConnection(mockMvc, webClient);
WebRequestMatcher cdnMatcher = new UrlRegexRequestMatcher(".*?//code.jquery.com/.*");
WebConnection httpConnection = new HttpWebConnection(webClient);
diff --git a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java
index 28a16b59192..303f5af9447 100644
--- a/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java
+++ b/spring-test/src/test/java/org/springframework/test/web/servlet/htmlunit/MockMvcConnectionBuilderSupportTests.java
@@ -24,6 +24,7 @@ import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebConnection;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.WebResponse;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -57,19 +58,19 @@ import static org.mockito.Mockito.when;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration
@WebAppConfiguration
+@SuppressWarnings("rawtypes")
public class MockMvcConnectionBuilderSupportTests {
- @Autowired
- private WebApplicationContext wac;
-
- private WebClient client;
+ private final WebClient client = mock(WebClient.class);
private MockMvcWebConnectionBuilderSupport builder;
+ @Autowired
+ private WebApplicationContext wac;
+
@Before
public void setup() {
- this.client = mock(WebClient.class);
when(this.client.getWebConnection()).thenReturn(mock(WebConnection.class));
this.builder = new MockMvcWebConnectionBuilderSupport(this.wac) {};
}
@@ -145,7 +146,6 @@ public class MockMvcConnectionBuilderSupportTests {
@Configuration
@EnableWebMvc
- @SuppressWarnings("unused")
static class Config {
@RestController