Polishing

This commit is contained in:
Juergen Hoeller 2016-08-26 13:27:33 +02:00
parent a8f7f75f64
commit 14046575b0
6 changed files with 23 additions and 18 deletions

View File

@ -16,7 +16,6 @@
package org.springframework.util;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Locale;
import java.util.Properties;

View File

@ -19,7 +19,6 @@ package org.springframework.messaging.simp.annotation.support;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.Principal;
import java.util.LinkedHashMap;

View File

@ -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.
@ -17,7 +17,6 @@
package org.springframework.messaging.simp.annotation.support;
import java.lang.reflect.Method;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.Principal;

View File

@ -17,6 +17,7 @@
package org.springframework.test.web.servlet.samples.standalone;
import java.io.StringWriter;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import java.util.concurrent.Callable;
import java.util.concurrent.CompletableFuture;
@ -39,7 +40,6 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.async.DeferredResult;
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.junit.Assert.*;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*;
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.*;
@ -154,10 +154,7 @@ public class AsyncTests {
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
/**
* SPR-12597
*/
@Test
@Test // SPR-12597
public void completableFutureWithImmediateValue() throws Exception {
MvcResult mvcResult = this.mockMvc.perform(get("/1").param("completableFutureWithImmediateValue", "true"))
.andExpect(request().asyncStarted())
@ -169,10 +166,7 @@ public class AsyncTests {
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
}
/**
* SPR-12735
*/
@Test
@Test // SPR-12735
public void printAsyncResult() throws Exception {
StringWriter writer = new StringWriter();
@ -204,7 +198,6 @@ public class AsyncTests {
private final Collection<ListenableFutureTask<Person>> futureTasks = new CopyOnWriteArrayList<>();
@RequestMapping(params = "callable")
public Callable<Person> getCallable() {
return () -> new Person("Joe");
@ -212,7 +205,7 @@ public class AsyncTests {
@RequestMapping(params = "streaming")
public StreamingResponseBody getStreaming() {
return os -> os.write("name=Joe".getBytes(UTF_8));
return os -> os.write("name=Joe".getBytes(StandardCharsets.UTF_8));
}
@RequestMapping(params = "streamingSlow")
@ -221,7 +214,7 @@ public class AsyncTests {
os.write("name=Joe".getBytes());
try {
Thread.sleep(200);
os.write("&someBoolean=true".getBytes(UTF_8));
os.write("&someBoolean=true".getBytes(StandardCharsets.UTF_8));
}
catch (InterruptedException e) {
/* no-op */
@ -232,7 +225,7 @@ public class AsyncTests {
@RequestMapping(params = "streamingJson")
public ResponseEntity<StreamingResponseBody> getStreamingJson() {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON_UTF8)
.body(os -> os.write("{\"name\":\"Joe\",\"someDouble\":0.5}".getBytes(UTF_8)));
.body(os -> os.write("{\"name\":\"Joe\",\"someDouble\":0.5}".getBytes(StandardCharsets.UTF_8)));
}
@RequestMapping(params = "deferredResult")

View File

@ -933,18 +933,21 @@ public class MvcNamespaceTests {
public @interface IsoDate {
}
@NumberFormat(style = NumberFormat.Style.PERCENT)
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface PercentNumber {
}
@Validated(MyGroup.class)
@Target({ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface MyValid {
}
@Controller
public static class TestController {
@ -955,13 +958,16 @@ public class MvcNamespaceTests {
private boolean recordedValidationError;
@RequestMapping
public void testBind(@RequestParam @IsoDate Date date, @RequestParam(required = false) @PercentNumber Double percent, @MyValid TestBean bean, BindingResult result) {
public void testBind(@RequestParam @IsoDate Date date,
@RequestParam(required = false) @PercentNumber Double percent,
@MyValid TestBean bean, BindingResult result) {
this.date = date;
this.percent = percent;
this.recordedValidationError = (result.getErrorCount() == 1);
}
}
public static class TestValidator implements Validator {
boolean validatorInvoked;
@ -977,10 +983,12 @@ public class MvcNamespaceTests {
}
}
@Retention(RetentionPolicy.RUNTIME)
public @interface MyGroup {
}
private static class TestBean {
@NotNull(groups = MyGroup.class)
@ -997,6 +1005,7 @@ public class MvcNamespaceTests {
}
}
private static class TestMockServletContext extends MockServletContext {
@Override
@ -1015,12 +1024,15 @@ public class MvcNamespaceTests {
}
}
public static class TestCallableProcessingInterceptor extends CallableProcessingInterceptorAdapter {
}
public static class TestDeferredResultProcessingInterceptor extends DeferredResultProcessingInterceptorAdapter {
}
public static class TestPathMatcher implements PathMatcher {
@Override
@ -1059,9 +1071,11 @@ public class MvcNamespaceTests {
}
}
public static class TestPathHelper extends UrlPathHelper {
}
public static class TestCacheManager implements CacheManager {
@Override

View File

@ -62,6 +62,7 @@ public class GroovyMarkupViewTests {
this.servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.webAppContext);
}
@Test
public void missingGroovyMarkupConfig() throws Exception {
GroovyMarkupView view = new GroovyMarkupView();