Upgrade to HtmlUnit 2.25 and Jackson 2.9 PR1

Includes Log4J 2.8.1 and Selenium 3.2 as well.

Issue: SPR-15319
This commit is contained in:
Juergen Hoeller
2017-03-06 17:54:28 +01:00
parent 47c4cf7abf
commit e61e8d5062
5 changed files with 50 additions and 55 deletions

View File

@@ -56,6 +56,13 @@ import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
public class DelegatingWebConnectionTests {
private DelegatingWebConnection webConnection;
private WebRequest request;
private WebResponse expectedResponse;
@Mock
private WebRequestMatcher matcher1;
@@ -72,15 +79,8 @@ public class DelegatingWebConnectionTests {
private WebConnection connection2;
private DelegatingWebConnection webConnection;
private WebRequest request;
private WebResponse expectedResponse;
@Before
public void setUp() throws Exception {
public void setup() throws Exception {
request = new WebRequest(new URL("http://localhost/"));
WebResponseData data = new WebResponseData("".getBytes("UTF-8"), 200, "", Collections.<NameValuePair> emptyList());
expectedResponse = new WebResponse(data, request, 100L);
@@ -88,6 +88,7 @@ public class DelegatingWebConnectionTests {
new DelegateWebConnection(matcher1, connection1), new DelegateWebConnection(matcher2, connection2));
}
@Test
public void getResponseDefault() throws Exception {
when(defaultConnection.getResponse(request)).thenReturn(expectedResponse);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -18,6 +18,7 @@ package org.springframework.test.web.servlet.htmlunit;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -28,9 +29,12 @@ import javax.servlet.http.Cookie;
import javax.servlet.http.HttpSession;
import com.gargoylesoftware.htmlunit.FormEncodingType;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.util.NameValuePair;
import org.apache.commons.io.IOUtils;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.junit.Before;
import org.junit.Test;
@@ -41,15 +45,10 @@ import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import com.gargoylesoftware.htmlunit.HttpMethod;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.WebRequest;
import com.gargoylesoftware.htmlunit.util.NameValuePair;
import static java.util.Arrays.asList;
import static java.util.Arrays.*;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.assertThat;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
/**
* Unit tests for {@link HtmlUnitRequestBuilder}.
@@ -72,12 +71,13 @@ public class HtmlUnitRequestBuilderTests {
@Before
public void setUp() throws Exception {
public void setup() throws Exception {
webRequest = new WebRequest(new URL("http://example.com:80/test/this/here"));
webRequest.setHttpMethod(HttpMethod.GET);
requestBuilder = new HtmlUnitRequestBuilder(sessions, webClient, webRequest);
}
// --- constructor
@Test(expected = IllegalArgumentException.class)
@@ -95,6 +95,7 @@ public class HtmlUnitRequestBuilderTests {
new HtmlUnitRequestBuilder(sessions, webClient, null);
}
// --- buildRequest
@Test
@@ -114,12 +115,11 @@ public class HtmlUnitRequestBuilderTests {
@Test
public void buildRequestCharacterEncoding() {
String charset = "UTF-8";
webRequest.setCharset(charset);
webRequest.setCharset(StandardCharsets.UTF_8);
MockHttpServletRequest actualRequest = requestBuilder.buildRequest(servletContext);
assertThat(actualRequest.getCharacterEncoding(), equalTo(charset));
assertThat(actualRequest.getCharacterEncoding(), equalTo("UTF-8"));
}
@Test
@@ -151,7 +151,7 @@ public class HtmlUnitRequestBuilderTests {
assertThat(actualRequest.getHeader("Content-Type"), equalTo(contentType));
}
@Test // SPR-14916
@Test // SPR-14916
public void buildRequestContentTypeWithFormSubmission() {
webRequest.setEncodingType(FormEncodingType.URL_ENCODED);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 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.
@@ -17,6 +17,7 @@
package org.springframework.test.web.servlet.htmlunit;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.List;
import javax.servlet.http.Cookie;
@@ -47,7 +48,7 @@ public class MockWebResponseBuilderTests {
@Before
public void setUp() throws Exception {
public void setup() throws Exception {
this.webRequest = new WebRequest(new URL("http://example.com:80/test/this/here"));
this.responseBuilder = new MockWebResponseBuilder(System.currentTimeMillis(), this.webRequest, this.response);
}
@@ -81,7 +82,7 @@ public class MockWebResponseBuilderTests {
this.response.addHeader("Content-Type", "text/html; charset=UTF-8");
WebResponse webResponse = this.responseBuilder.build();
assertThat(webResponse.getContentCharset(), equalTo("UTF-8"));
assertThat(webResponse.getContentCharset(), equalTo(StandardCharsets.UTF_8));
}
@Test