Browse Source

Polishing

pull/1331/merge
Juergen Hoeller 9 years ago
parent
commit
1ddf8ec625
  1. 7
      spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java
  2. 9
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java
  3. 7
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java
  4. 8
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java
  5. 10
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java
  6. 13
      spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java
  7. 16
      spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolverTests.java

7
spring-web/src/main/java/org/springframework/web/filter/ShallowEtagHeaderFilter.java

@ -19,7 +19,6 @@ package org.springframework.web.filter; @@ -19,7 +19,6 @@ package org.springframework.web.filter;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
@ -72,8 +71,8 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { @@ -72,8 +71,8 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
* Set whether the ETag value written to the response should be weak, as per RFC 7232.
* <p>Should be configured using an {@code <init-param>} for parameter name
* "writeWeakETag" in the filter definition in {@code web.xml}.
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">RFC 7232 section 2.3</a>
* @since 4.3
* @see <a href="https://tools.ietf.org/html/rfc7232#section-2.3">RFC 7232 section 2.3</a>
*/
public void setWriteWeakETag(boolean writeWeakETag) {
this.writeWeakETag = writeWeakETag;
@ -89,8 +88,8 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter { @@ -89,8 +88,8 @@ public class ShallowEtagHeaderFilter extends OncePerRequestFilter {
/**
* The default value is "false" so that the filter may delay the generation of
* an ETag until the last asynchronously dispatched thread.
* The default value is {@code false} so that the filter may delay the generation
* of an ETag until the last asynchronously dispatched thread.
*/
@Override
protected boolean shouldNotFilterAsyncDispatch() {

9
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/JacksonHintsIntegrationTests.java

@ -1,5 +1,5 @@ @@ -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.
@ -20,7 +20,6 @@ import java.util.Arrays; @@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonView;
import static org.junit.Assert.assertEquals;
import org.junit.Test;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@ -36,6 +35,8 @@ import org.springframework.web.bind.annotation.RequestBody; @@ -36,6 +35,8 @@ import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
import static org.junit.Assert.*;
/**
* @author Sebastien Deleuze
*/
@ -49,6 +50,7 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat @@ -49,6 +50,7 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat
return wac;
}
@Test
public void jsonViewResponse() throws Exception {
String expected = "{\"withView1\":\"with\"}";
@ -98,6 +100,7 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat @@ -98,6 +100,7 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat
static class WebConfig {
}
@RestController
@SuppressWarnings("unused")
private static class JsonViewRestController {
@ -188,4 +191,4 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat @@ -188,4 +191,4 @@ public class JacksonHintsIntegrationTests extends AbstractRequestMappingIntegrat
}
}
}
}

7
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingDataBindingIntegrationTests.java

@ -1,5 +1,5 @@ @@ -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.
@ -42,8 +42,7 @@ import org.springframework.web.bind.annotation.RequestParam; @@ -42,8 +42,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* Data binding and type conversion related integration tests for
@ -89,6 +88,7 @@ public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMa @@ -89,6 +88,7 @@ public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMa
static class WebConfig {
}
@RestController
@SuppressWarnings({"unused", "OptionalUsedAsFieldOrParameterType"})
private static class TestController {
@ -120,6 +120,7 @@ public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMa @@ -120,6 +120,7 @@ public class RequestMappingDataBindingIntegrationTests extends AbstractRequestMa
}
}
private static class Foo {
private final Long id;

8
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingExceptionHandlingIntegrationTests.java

@ -1,5 +1,5 @@ @@ -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.
@ -31,8 +31,7 @@ import org.springframework.web.bind.annotation.GetMapping; @@ -31,8 +31,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* {@code @RequestMapping} integration tests with exception handling scenarios.
@ -41,7 +40,6 @@ import static org.junit.Assert.assertEquals; @@ -41,7 +40,6 @@ import static org.junit.Assert.assertEquals;
*/
public class RequestMappingExceptionHandlingIntegrationTests extends AbstractRequestMappingIntegrationTests {
@Override
protected ApplicationContext initApplicationContext() {
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
@ -69,7 +67,6 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq @@ -69,7 +67,6 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
@ComponentScan(resourcePattern = "**/RequestMappingExceptionHandlingIntegrationTests$*.class")
@SuppressWarnings({"unused", "WeakerAccess"})
static class WebConfig {
}
@ -96,7 +93,6 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq @@ -96,7 +93,6 @@ public class RequestMappingExceptionHandlingIntegrationTests extends AbstractReq
public ResponseEntity<Publisher<String>> handleStateException(IllegalStateException ex) {
return ResponseEntity.ok(Mono.just("Recovered from error: " + ex.getMessage()));
}
}
}

10
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingIntegrationTests.java

@ -1,5 +1,5 @@ @@ -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.
@ -31,9 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam; @@ -31,9 +31,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.reactive.config.EnableWebFlux;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.*;
/**
* Integration tests with {@code @RequestMapping} handler methods.
@ -54,6 +52,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr @@ -54,6 +52,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr
return wac;
}
@Test
public void handleWithParam() throws Exception {
String expected = "Hello George!";
@ -86,6 +85,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr @@ -86,6 +85,7 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr
static class WebConfig {
}
@RestController
@SuppressWarnings("unused")
private static class TestRestController {
@ -104,9 +104,9 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr @@ -104,9 +104,9 @@ public class RequestMappingIntegrationTests extends AbstractRequestMappingIntegr
public Publisher<Foo> objectStreamResponseBody() {
return Flux.just(new Foo("bar"));
}
}
private static class Foo {
private String name;

13
spring-webflux/src/test/java/org/springframework/web/reactive/result/method/annotation/RequestMappingViewResolutionIntegrationTests.java

@ -1,5 +1,5 @@ @@ -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.
@ -39,10 +39,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurationSupport; @@ -39,10 +39,7 @@ import org.springframework.web.reactive.config.WebFluxConfigurationSupport;
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.server.ServerWebExchange;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.springframework.http.RequestEntity.get;
import static org.junit.Assert.*;
/**
* {@code @RequestMapping} integration tests with view resolution scenarios.
@ -51,7 +48,6 @@ import static org.springframework.http.RequestEntity.get; @@ -51,7 +48,6 @@ import static org.springframework.http.RequestEntity.get;
*/
public class RequestMappingViewResolutionIntegrationTests extends AbstractRequestMappingIntegrationTests {
@Override
protected ApplicationContext initApplicationContext() {
AnnotationConfigApplicationContext wac = new AnnotationConfigApplicationContext();
@ -70,7 +66,7 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques @@ -70,7 +66,7 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
@Test
public void etagCheckWithNotModifiedResponse() throws Exception {
URI uri = new URI("http://localhost:" + this.port + "/html");
RequestEntity<Void> request = get(uri).ifNoneMatch("\"deadb33f8badf00d\"").build();
RequestEntity<Void> request = RequestEntity.get(uri).ifNoneMatch("\"deadb33f8badf00d\"").build();
ResponseEntity<String> response = getRestTemplate().exchange(request, String.class);
assertEquals(HttpStatus.NOT_MODIFIED, response.getStatusCode());
@ -95,9 +91,9 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques @@ -95,9 +91,9 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
configurer.setTemplateLoaderPath("classpath*:org/springframework/web/reactive/view/freemarker/");
return configurer;
}
}
@Controller
@SuppressWarnings("unused")
private static class TestController {
@ -112,7 +108,6 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques @@ -112,7 +108,6 @@ public class RequestMappingViewResolutionIntegrationTests extends AbstractReques
model.addAttribute("hello", "Hello: " + name.orElse("<no name>") + "!");
return "test";
}
}
}

16
spring-webmvc/src/test/java/org/springframework/web/servlet/mvc/method/annotation/ServletRequestMethodArgumentResolverTests.java

@ -50,25 +50,27 @@ import static org.junit.Assert.*; @@ -50,25 +50,27 @@ import static org.junit.Assert.*;
*/
public class ServletRequestMethodArgumentResolverTests {
private final ServletRequestMethodArgumentResolver resolver = new ServletRequestMethodArgumentResolver();
private Method method;
private ServletRequestMethodArgumentResolver resolver;
private ModelAndViewContainer mavContainer;
private MockHttpServletRequest servletRequest;
private ServletWebRequest webRequest;
private MockHttpServletRequest servletRequest;
private Method method;
@Before
public void setup() throws Exception {
method = getClass().getMethod("supportedParams", ServletRequest.class, MultipartRequest.class,
HttpSession.class, Principal.class, Locale.class, InputStream.class, Reader.class,
WebRequest.class, TimeZone.class, ZoneId.class, HttpMethod.class);
resolver = new ServletRequestMethodArgumentResolver();
mavContainer = new ModelAndViewContainer();
servletRequest = new MockHttpServletRequest("GET", "");
webRequest = new ServletWebRequest(servletRequest, new MockHttpServletResponse());
method = getClass().getMethod("supportedParams", ServletRequest.class, MultipartRequest.class,
HttpSession.class, Principal.class, Locale.class, InputStream.class, Reader.class,
WebRequest.class, TimeZone.class, ZoneId.class, HttpMethod.class);
}

Loading…
Cancel
Save