Polishing
Closes gh-26682
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -55,7 +55,7 @@ class MockFilterChainTests {
|
||||
@Test
|
||||
void constructorNullServlet() {
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
new MockFilterChain((Servlet) null));
|
||||
new MockFilterChain(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.mock.web;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -112,7 +113,7 @@ class MockHttpServletRequestTests {
|
||||
@Test
|
||||
void setContentAndGetContentAsStringWithExplicitCharacterEncoding() throws IOException {
|
||||
String palindrome = "ablE was I ere I saw Elba";
|
||||
byte[] bytes = palindrome.getBytes("UTF-16");
|
||||
byte[] bytes = palindrome.getBytes(StandardCharsets.UTF_16);
|
||||
request.setCharacterEncoding("UTF-16");
|
||||
request.setContent(bytes);
|
||||
assertThat(request.getContentLength()).isEqualTo(bytes.length);
|
||||
@@ -394,7 +395,7 @@ class MockHttpServletRequestTests {
|
||||
void getServerNameWithInvalidIpv6AddressViaHostHeader() {
|
||||
request.addHeader(HOST, "[::ffff:abcd:abcd"); // missing closing bracket
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> request.getServerName())
|
||||
.isThrownBy(request::getServerName)
|
||||
.withMessageStartingWith("Invalid Host header: ");
|
||||
}
|
||||
|
||||
@@ -426,7 +427,7 @@ class MockHttpServletRequestTests {
|
||||
void getServerPortWithInvalidIpv6AddressViaHostHeader() {
|
||||
request.addHeader(HOST, "[::ffff:abcd:abcd:8080"); // missing closing bracket
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> request.getServerPort())
|
||||
.isThrownBy(request::getServerPort)
|
||||
.withMessageStartingWith("Invalid Host header: ");
|
||||
}
|
||||
|
||||
@@ -434,7 +435,7 @@ class MockHttpServletRequestTests {
|
||||
void getServerPortWithIpv6AddressAndInvalidPortViaHostHeader() {
|
||||
request.addHeader(HOST, "[::ffff:abcd:abcd]:bogus"); // "bogus" is not a port number
|
||||
assertThatExceptionOfType(NumberFormatException.class)
|
||||
.isThrownBy(() -> request.getServerPort())
|
||||
.isThrownBy(request::getServerPort)
|
||||
.withMessageContaining("bogus");
|
||||
}
|
||||
|
||||
@@ -521,7 +522,7 @@ class MockHttpServletRequestTests {
|
||||
void getRequestURLWithInvalidIpv6AddressViaHostHeader() {
|
||||
request.addHeader(HOST, "[::ffff:abcd:abcd"); // missing closing bracket
|
||||
assertThatIllegalStateException()
|
||||
.isThrownBy(() -> request.getRequestURL())
|
||||
.isThrownBy(request::getRequestURL)
|
||||
.withMessageStartingWith("Invalid Host header: ");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2021 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.
|
||||
@@ -49,10 +49,10 @@ import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException
|
||||
* @author Rob Winch
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
public class StandaloneMockMvcBuilderTests {
|
||||
class StandaloneMockMvcBuilderTests {
|
||||
|
||||
@Test // SPR-10825
|
||||
public void placeHoldersInRequestMapping() throws Exception {
|
||||
void placeHoldersInRequestMapping() throws Exception {
|
||||
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PlaceholderController());
|
||||
builder.addPlaceholderValue("sys.login.ajax", "/foo");
|
||||
builder.build();
|
||||
@@ -68,7 +68,7 @@ public class StandaloneMockMvcBuilderTests {
|
||||
|
||||
@Test // SPR-13637
|
||||
@SuppressWarnings("deprecation")
|
||||
public void suffixPatternMatch() throws Exception {
|
||||
void suffixPatternMatch() throws Exception {
|
||||
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PersonController());
|
||||
builder.setUseSuffixPatternMatch(false);
|
||||
builder.build();
|
||||
@@ -86,7 +86,7 @@ public class StandaloneMockMvcBuilderTests {
|
||||
}
|
||||
|
||||
@Test // SPR-12553
|
||||
public void applicationContextAttribute() {
|
||||
void applicationContextAttribute() {
|
||||
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PlaceholderController());
|
||||
builder.addPlaceholderValue("sys.login.ajax", "/foo");
|
||||
WebApplicationContext wac = builder.initWebAppContext();
|
||||
@@ -94,28 +94,28 @@ public class StandaloneMockMvcBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addFiltersFiltersNull() {
|
||||
void addFiltersFiltersNull() {
|
||||
StandaloneMockMvcBuilder builder = MockMvcBuilders.standaloneSetup(new PersonController());
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
builder.addFilters((Filter[]) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addFiltersFiltersContainsNull() {
|
||||
void addFiltersFiltersContainsNull() {
|
||||
StandaloneMockMvcBuilder builder = MockMvcBuilders.standaloneSetup(new PersonController());
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
builder.addFilters(new ContinueFilter(), (Filter) null));
|
||||
builder.addFilters(new ContinueFilter(), null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addFilterPatternsNull() {
|
||||
void addFilterPatternsNull() {
|
||||
StandaloneMockMvcBuilder builder = MockMvcBuilders.standaloneSetup(new PersonController());
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
builder.addFilter(new ContinueFilter(), (String[]) null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addFilterPatternContainsNull() {
|
||||
void addFilterPatternContainsNull() {
|
||||
StandaloneMockMvcBuilder builder = MockMvcBuilders.standaloneSetup(new PersonController());
|
||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||
builder.addFilter(new ContinueFilter(), (String) null));
|
||||
@@ -123,7 +123,7 @@ public class StandaloneMockMvcBuilderTests {
|
||||
|
||||
@Test // SPR-13375
|
||||
@SuppressWarnings("rawtypes")
|
||||
public void springHandlerInstantiator() {
|
||||
void springHandlerInstantiator() {
|
||||
TestStandaloneMockMvcBuilder builder = new TestStandaloneMockMvcBuilder(new PersonController());
|
||||
builder.build();
|
||||
SpringHandlerInstantiator instantiator = new SpringHandlerInstantiator(builder.wac.getAutowireCapableBeanFactory());
|
||||
@@ -171,7 +171,7 @@ public class StandaloneMockMvcBuilderTests {
|
||||
}
|
||||
|
||||
|
||||
private class ContinueFilter extends OncePerRequestFilter {
|
||||
private static class ContinueFilter extends OncePerRequestFilter {
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
|
||||
|
||||
Reference in New Issue
Block a user