Consistent use of Charset.forName over JDK 7 StandardCharsets in 4.x line
This commit is contained in:
@@ -20,7 +20,6 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -539,7 +538,7 @@ public class SendToMethodReturnValueHandlerTests {
|
|||||||
Message<?> message = this.messageCaptor.getValue();
|
Message<?> message = this.messageCaptor.getValue();
|
||||||
assertNotNull(message);
|
assertNotNull(message);
|
||||||
|
|
||||||
String bytes = new String((byte[]) message.getPayload(), StandardCharsets.UTF_8);
|
String bytes = new String((byte[]) message.getPayload(), Charset.forName("UTF-8"));
|
||||||
assertEquals("{\"withView1\":\"with\"}", bytes);
|
assertEquals("{\"withView1\":\"with\"}", bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -18,7 +18,6 @@ package org.springframework.messaging.simp.annotation.support;
|
|||||||
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.security.Principal;
|
import java.security.Principal;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import com.fasterxml.jackson.annotation.JsonView;
|
||||||
@@ -179,7 +178,7 @@ public class SubscriptionMethodReturnValueHandlerTests {
|
|||||||
Message<?> message = this.messageCaptor.getValue();
|
Message<?> message = this.messageCaptor.getValue();
|
||||||
assertNotNull(message);
|
assertNotNull(message);
|
||||||
|
|
||||||
assertEquals("{\"withView1\":\"with\"}", new String((byte[]) message.getPayload(), StandardCharsets.UTF_8));
|
assertEquals("{\"withView1\":\"with\"}", new String((byte[]) message.getPayload(), Charset.forName("UTF-8")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
package org.springframework.test.web.servlet.samples.standalone;
|
package org.springframework.test.web.servlet.samples.standalone;
|
||||||
|
|
||||||
import java.io.StringWriter;
|
import java.io.StringWriter;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.Charset;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -78,7 +78,7 @@ public class AsyncTests {
|
|||||||
public void streaming() throws Exception {
|
public void streaming() throws Exception {
|
||||||
this.mockMvc.perform(get("/1").param("streaming", "true"))
|
this.mockMvc.perform(get("/1").param("streaming", "true"))
|
||||||
.andExpect(request().asyncStarted())
|
.andExpect(request().asyncStarted())
|
||||||
.andDo(r -> r.getAsyncResult()) // fetch async result similar to "asyncDispatch" builder
|
.andDo(MvcResult::getAsyncResult) // fetch async result similar to "asyncDispatch" builder
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string("name=Joe"));
|
.andExpect(content().string("name=Joe"));
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ public class AsyncTests {
|
|||||||
public void streamingSlow() throws Exception {
|
public void streamingSlow() throws Exception {
|
||||||
this.mockMvc.perform(get("/1").param("streamingSlow", "true"))
|
this.mockMvc.perform(get("/1").param("streamingSlow", "true"))
|
||||||
.andExpect(request().asyncStarted())
|
.andExpect(request().asyncStarted())
|
||||||
.andDo(r -> r.getAsyncResult())
|
.andDo(MvcResult::getAsyncResult)
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().string("name=Joe&someBoolean=true"));
|
.andExpect(content().string("name=Joe&someBoolean=true"));
|
||||||
}
|
}
|
||||||
@@ -96,7 +96,7 @@ public class AsyncTests {
|
|||||||
public void streamingJson() throws Exception {
|
public void streamingJson() throws Exception {
|
||||||
this.mockMvc.perform(get("/1").param("streamingJson", "true"))
|
this.mockMvc.perform(get("/1").param("streamingJson", "true"))
|
||||||
.andExpect(request().asyncStarted())
|
.andExpect(request().asyncStarted())
|
||||||
.andDo(r -> r.getAsyncResult())
|
.andDo(MvcResult::getAsyncResult)
|
||||||
.andExpect(status().isOk())
|
.andExpect(status().isOk())
|
||||||
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
.andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8_VALUE))
|
||||||
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.5}"));
|
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.5}"));
|
||||||
@@ -129,10 +129,7 @@ public class AsyncTests {
|
|||||||
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
|
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test // SPR-13079
|
||||||
* SPR-13079
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void deferredResultWithDelayedError() throws Exception {
|
public void deferredResultWithDelayedError() throws Exception {
|
||||||
MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResultWithDelayedError", "true"))
|
MvcResult mvcResult = this.mockMvc.perform(get("/1").param("deferredResultWithDelayedError", "true"))
|
||||||
.andExpect(request().asyncStarted())
|
.andExpect(request().asyncStarted())
|
||||||
@@ -157,10 +154,7 @@ public class AsyncTests {
|
|||||||
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
|
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test // SPR-12597
|
||||||
* SPR-12597
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void completableFutureWithImmediateValue() throws Exception {
|
public void completableFutureWithImmediateValue() throws Exception {
|
||||||
MvcResult mvcResult = this.mockMvc.perform(get("/1").param("completableFutureWithImmediateValue", "true"))
|
MvcResult mvcResult = this.mockMvc.perform(get("/1").param("completableFutureWithImmediateValue", "true"))
|
||||||
.andExpect(request().asyncStarted())
|
.andExpect(request().asyncStarted())
|
||||||
@@ -172,10 +166,7 @@ public class AsyncTests {
|
|||||||
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
|
.andExpect(content().string("{\"name\":\"Joe\",\"someDouble\":0.0,\"someBoolean\":false}"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
@Test // SPR-12735
|
||||||
* SPR-12735
|
|
||||||
*/
|
|
||||||
@Test
|
|
||||||
public void printAsyncResult() throws Exception {
|
public void printAsyncResult() throws Exception {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
|
|
||||||
@@ -203,12 +194,9 @@ public class AsyncTests {
|
|||||||
@RequestMapping(path = "/{id}", produces = "application/json")
|
@RequestMapping(path = "/{id}", produces = "application/json")
|
||||||
private static class AsyncController {
|
private static class AsyncController {
|
||||||
|
|
||||||
private final Collection<DeferredResult<Person>> deferredResults =
|
private final Collection<DeferredResult<Person>> deferredResults = new CopyOnWriteArrayList<>();
|
||||||
new CopyOnWriteArrayList<DeferredResult<Person>>();
|
|
||||||
|
|
||||||
private final Collection<ListenableFutureTask<Person>> futureTasks =
|
|
||||||
new CopyOnWriteArrayList<ListenableFutureTask<Person>>();
|
|
||||||
|
|
||||||
|
private final Collection<ListenableFutureTask<Person>> futureTasks = new CopyOnWriteArrayList<>();
|
||||||
|
|
||||||
@RequestMapping(params = "callable")
|
@RequestMapping(params = "callable")
|
||||||
public Callable<Person> getCallable() {
|
public Callable<Person> getCallable() {
|
||||||
@@ -217,7 +205,7 @@ public class AsyncTests {
|
|||||||
|
|
||||||
@RequestMapping(params = "streaming")
|
@RequestMapping(params = "streaming")
|
||||||
public StreamingResponseBody getStreaming() {
|
public StreamingResponseBody getStreaming() {
|
||||||
return os -> os.write("name=Joe".getBytes());
|
return os -> os.write("name=Joe".getBytes(Charset.forName("UTF-8")));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(params = "streamingSlow")
|
@RequestMapping(params = "streamingSlow")
|
||||||
@@ -226,7 +214,7 @@ public class AsyncTests {
|
|||||||
os.write("name=Joe".getBytes());
|
os.write("name=Joe".getBytes());
|
||||||
try {
|
try {
|
||||||
Thread.sleep(200);
|
Thread.sleep(200);
|
||||||
os.write("&someBoolean=true".getBytes());
|
os.write("&someBoolean=true".getBytes(Charset.forName("UTF-8")));
|
||||||
}
|
}
|
||||||
catch (InterruptedException e) {
|
catch (InterruptedException e) {
|
||||||
/* no-op */
|
/* no-op */
|
||||||
@@ -237,26 +225,26 @@ public class AsyncTests {
|
|||||||
@RequestMapping(params = "streamingJson")
|
@RequestMapping(params = "streamingJson")
|
||||||
public ResponseEntity<StreamingResponseBody> getStreamingJson() {
|
public ResponseEntity<StreamingResponseBody> getStreamingJson() {
|
||||||
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON_UTF8)
|
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON_UTF8)
|
||||||
.body(os -> os.write("{\"name\":\"Joe\",\"someDouble\":0.5}".getBytes(StandardCharsets.UTF_8)));
|
.body(os -> os.write("{\"name\":\"Joe\",\"someDouble\":0.5}".getBytes(Charset.forName("UTF-8"))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(params = "deferredResult")
|
@RequestMapping(params = "deferredResult")
|
||||||
public DeferredResult<Person> getDeferredResult() {
|
public DeferredResult<Person> getDeferredResult() {
|
||||||
DeferredResult<Person> deferredResult = new DeferredResult<Person>();
|
DeferredResult<Person> deferredResult = new DeferredResult<>();
|
||||||
this.deferredResults.add(deferredResult);
|
this.deferredResults.add(deferredResult);
|
||||||
return deferredResult;
|
return deferredResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(params = "deferredResultWithImmediateValue")
|
@RequestMapping(params = "deferredResultWithImmediateValue")
|
||||||
public DeferredResult<Person> getDeferredResultWithImmediateValue() {
|
public DeferredResult<Person> getDeferredResultWithImmediateValue() {
|
||||||
DeferredResult<Person> deferredResult = new DeferredResult<Person>();
|
DeferredResult<Person> deferredResult = new DeferredResult<>();
|
||||||
deferredResult.setResult(new Person("Joe"));
|
deferredResult.setResult(new Person("Joe"));
|
||||||
return deferredResult;
|
return deferredResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(params = "deferredResultWithDelayedError")
|
@RequestMapping(params = "deferredResultWithDelayedError")
|
||||||
public DeferredResult<Person> getDeferredResultWithDelayedError() {
|
public DeferredResult<Person> getDeferredResultWithDelayedError() {
|
||||||
final DeferredResult<Person> deferredResult = new DeferredResult<Person>();
|
final DeferredResult<Person> deferredResult = new DeferredResult<>();
|
||||||
new Thread() {
|
new Thread() {
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@@ -273,14 +261,14 @@ public class AsyncTests {
|
|||||||
|
|
||||||
@RequestMapping(params = "listenableFuture")
|
@RequestMapping(params = "listenableFuture")
|
||||||
public ListenableFuture<Person> getListenableFuture() {
|
public ListenableFuture<Person> getListenableFuture() {
|
||||||
ListenableFutureTask<Person> futureTask = new ListenableFutureTask<Person>(() -> new Person("Joe"));
|
ListenableFutureTask<Person> futureTask = new ListenableFutureTask<>(() -> new Person("Joe"));
|
||||||
this.futureTasks.add(futureTask);
|
this.futureTasks.add(futureTask);
|
||||||
return futureTask;
|
return futureTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(params = "completableFutureWithImmediateValue")
|
@RequestMapping(params = "completableFutureWithImmediateValue")
|
||||||
public CompletableFuture<Person> getCompletableFutureWithImmediateValue() {
|
public CompletableFuture<Person> getCompletableFutureWithImmediateValue() {
|
||||||
CompletableFuture<Person> future = new CompletableFuture<Person>();
|
CompletableFuture<Person> future = new CompletableFuture<>();
|
||||||
future.complete(new Person("Joe"));
|
future.complete(new Person("Joe"));
|
||||||
return future;
|
return future;
|
||||||
}
|
}
|
||||||
@@ -291,7 +279,7 @@ public class AsyncTests {
|
|||||||
return e.getMessage();
|
return e.getMessage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMessage(String name) {
|
void onMessage(String name) {
|
||||||
for (DeferredResult<Person> deferredResult : this.deferredResults) {
|
for (DeferredResult<Person> deferredResult : this.deferredResults) {
|
||||||
deferredResult.setResult(new Person(name));
|
deferredResult.setResult(new Person(name));
|
||||||
this.deferredResults.remove(deferredResult);
|
this.deferredResults.remove(deferredResult);
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -21,7 +21,6 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -145,8 +144,8 @@ import org.springframework.web.servlet.view.velocity.VelocityConfigurer;
|
|||||||
import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
|
import org.springframework.web.servlet.view.velocity.VelocityViewResolver;
|
||||||
import org.springframework.web.util.UrlPathHelper;
|
import org.springframework.web.util.UrlPathHelper;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.*;
|
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
import static org.hamcrest.Matchers.*;
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -823,7 +822,7 @@ public class MvcNamespaceTests {
|
|||||||
assertNotNull(scriptTemplateConfigurer);
|
assertNotNull(scriptTemplateConfigurer);
|
||||||
assertEquals("render", scriptTemplateConfigurer.getRenderFunction());
|
assertEquals("render", scriptTemplateConfigurer.getRenderFunction());
|
||||||
assertEquals(MediaType.TEXT_PLAIN_VALUE, scriptTemplateConfigurer.getContentType());
|
assertEquals(MediaType.TEXT_PLAIN_VALUE, scriptTemplateConfigurer.getContentType());
|
||||||
assertEquals(StandardCharsets.ISO_8859_1, scriptTemplateConfigurer.getCharset());
|
assertEquals("ISO-8859-1", scriptTemplateConfigurer.getCharset().name());
|
||||||
assertEquals("classpath:", scriptTemplateConfigurer.getResourceLoaderPath());
|
assertEquals("classpath:", scriptTemplateConfigurer.getResourceLoaderPath());
|
||||||
assertFalse(scriptTemplateConfigurer.isSharedEngine());
|
assertFalse(scriptTemplateConfigurer.isSharedEngine());
|
||||||
String[] scripts = { "org/springframework/web/servlet/view/script/nashorn/render.js" };
|
String[] scripts = { "org/springframework/web/servlet/view/script/nashorn/render.js" };
|
||||||
@@ -956,18 +955,21 @@ public class MvcNamespaceTests {
|
|||||||
public @interface IsoDate {
|
public @interface IsoDate {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@NumberFormat(style = NumberFormat.Style.PERCENT)
|
@NumberFormat(style = NumberFormat.Style.PERCENT)
|
||||||
@Target({ElementType.PARAMETER})
|
@Target({ElementType.PARAMETER})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface PercentNumber {
|
public @interface PercentNumber {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Validated(MyGroup.class)
|
@Validated(MyGroup.class)
|
||||||
@Target({ElementType.PARAMETER})
|
@Target({ElementType.PARAMETER})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface MyValid {
|
public @interface MyValid {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public static class TestController {
|
public static class TestController {
|
||||||
|
|
||||||
@@ -978,13 +980,16 @@ public class MvcNamespaceTests {
|
|||||||
private boolean recordedValidationError;
|
private boolean recordedValidationError;
|
||||||
|
|
||||||
@RequestMapping
|
@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.date = date;
|
||||||
this.percent = percent;
|
this.percent = percent;
|
||||||
this.recordedValidationError = (result.getErrorCount() == 1);
|
this.recordedValidationError = (result.getErrorCount() == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestValidator implements Validator {
|
public static class TestValidator implements Validator {
|
||||||
|
|
||||||
boolean validatorInvoked;
|
boolean validatorInvoked;
|
||||||
@@ -1000,10 +1005,12 @@ public class MvcNamespaceTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface MyGroup {
|
public @interface MyGroup {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class TestBean {
|
private static class TestBean {
|
||||||
|
|
||||||
@NotNull(groups = MyGroup.class)
|
@NotNull(groups = MyGroup.class)
|
||||||
@@ -1020,6 +1027,7 @@ public class MvcNamespaceTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static class TestMockServletContext extends MockServletContext {
|
private static class TestMockServletContext extends MockServletContext {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1033,12 +1041,15 @@ public class MvcNamespaceTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestCallableProcessingInterceptor extends CallableProcessingInterceptorAdapter {
|
public static class TestCallableProcessingInterceptor extends CallableProcessingInterceptorAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestDeferredResultProcessingInterceptor extends DeferredResultProcessingInterceptorAdapter {
|
public static class TestDeferredResultProcessingInterceptor extends DeferredResultProcessingInterceptorAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestPathMatcher implements PathMatcher {
|
public static class TestPathMatcher implements PathMatcher {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1077,9 +1088,11 @@ public class MvcNamespaceTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestPathHelper extends UrlPathHelper {
|
public static class TestPathHelper extends UrlPathHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class TestCacheManager implements CacheManager {
|
public static class TestCacheManager implements CacheManager {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
package org.springframework.web.servlet.view.script;
|
package org.springframework.web.servlet.view.script;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.Charset;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -86,7 +86,7 @@ public class ScriptTemplateViewTests {
|
|||||||
this.configurer.setRenderObject("Template");
|
this.configurer.setRenderObject("Template");
|
||||||
this.configurer.setRenderFunction("render");
|
this.configurer.setRenderFunction("render");
|
||||||
this.configurer.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
this.configurer.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
||||||
this.configurer.setCharset(StandardCharsets.ISO_8859_1);
|
this.configurer.setCharset(Charset.forName("ISO-8859-1"));
|
||||||
this.configurer.setSharedEngine(true);
|
this.configurer.setSharedEngine(true);
|
||||||
|
|
||||||
DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
|
DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
|
||||||
@@ -95,7 +95,7 @@ public class ScriptTemplateViewTests {
|
|||||||
assertEquals("Template", accessor.getPropertyValue("renderObject"));
|
assertEquals("Template", accessor.getPropertyValue("renderObject"));
|
||||||
assertEquals("render", accessor.getPropertyValue("renderFunction"));
|
assertEquals("render", accessor.getPropertyValue("renderFunction"));
|
||||||
assertEquals(MediaType.TEXT_PLAIN_VALUE, accessor.getPropertyValue("contentType"));
|
assertEquals(MediaType.TEXT_PLAIN_VALUE, accessor.getPropertyValue("contentType"));
|
||||||
assertEquals(StandardCharsets.ISO_8859_1, accessor.getPropertyValue("charset"));
|
assertEquals(Charset.forName("ISO-8859-1"), accessor.getPropertyValue("charset"));
|
||||||
assertEquals(true, accessor.getPropertyValue("sharedEngine"));
|
assertEquals(true, accessor.getPropertyValue("sharedEngine"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +112,7 @@ public class ScriptTemplateViewTests {
|
|||||||
assertEquals("Template", accessor.getPropertyValue("renderObject"));
|
assertEquals("Template", accessor.getPropertyValue("renderObject"));
|
||||||
assertEquals("render", accessor.getPropertyValue("renderFunction"));
|
assertEquals("render", accessor.getPropertyValue("renderFunction"));
|
||||||
assertEquals(MediaType.TEXT_HTML_VALUE, accessor.getPropertyValue("contentType"));
|
assertEquals(MediaType.TEXT_HTML_VALUE, accessor.getPropertyValue("contentType"));
|
||||||
assertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("charset"));
|
assertEquals(Charset.forName("UTF-8"), accessor.getPropertyValue("charset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -128,7 +128,7 @@ public class ScriptTemplateViewTests {
|
|||||||
DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
|
DirectFieldAccessor accessor = new DirectFieldAccessor(this.view);
|
||||||
assertNull(accessor.getPropertyValue("renderObject"));
|
assertNull(accessor.getPropertyValue("renderObject"));
|
||||||
assertEquals("render", accessor.getPropertyValue("renderFunction"));
|
assertEquals("render", accessor.getPropertyValue("renderFunction"));
|
||||||
assertEquals(StandardCharsets.UTF_8, accessor.getPropertyValue("charset"));
|
assertEquals(Charset.forName("UTF-8"), accessor.getPropertyValue("charset"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -252,19 +252,19 @@ public class ScriptTemplateViewTests {
|
|||||||
|
|
||||||
this.view.render(model, request, response);
|
this.view.render(model, request, response);
|
||||||
assertEquals(MediaType.TEXT_HTML_VALUE + ";charset=" +
|
assertEquals(MediaType.TEXT_HTML_VALUE + ";charset=" +
|
||||||
StandardCharsets.UTF_8, response.getHeader(HttpHeaders.CONTENT_TYPE));
|
Charset.forName("UTF-8"), response.getHeader(HttpHeaders.CONTENT_TYPE));
|
||||||
|
|
||||||
response = new MockHttpServletResponse();
|
response = new MockHttpServletResponse();
|
||||||
this.view.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
this.view.setContentType(MediaType.TEXT_PLAIN_VALUE);
|
||||||
this.view.render(model, request, response);
|
this.view.render(model, request, response);
|
||||||
assertEquals(MediaType.TEXT_PLAIN_VALUE + ";charset=" +
|
assertEquals(MediaType.TEXT_PLAIN_VALUE + ";charset=" +
|
||||||
StandardCharsets.UTF_8, response.getHeader(HttpHeaders.CONTENT_TYPE));
|
Charset.forName("UTF-8"), response.getHeader(HttpHeaders.CONTENT_TYPE));
|
||||||
|
|
||||||
response = new MockHttpServletResponse();
|
response = new MockHttpServletResponse();
|
||||||
this.view.setCharset(StandardCharsets.ISO_8859_1);
|
this.view.setCharset(Charset.forName("ISO-8859-1"));
|
||||||
this.view.render(model, request, response);
|
this.view.render(model, request, response);
|
||||||
assertEquals(MediaType.TEXT_PLAIN_VALUE + ";charset=" +
|
assertEquals(MediaType.TEXT_PLAIN_VALUE + ";charset=" +
|
||||||
StandardCharsets.ISO_8859_1, response.getHeader(HttpHeaders.CONTENT_TYPE));
|
Charset.forName("ISO-8859-1"), response.getHeader(HttpHeaders.CONTENT_TYPE));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user