Polishing

This commit is contained in:
Juergen Hoeller
2016-08-17 20:43:41 +02:00
parent 52f21bdf54
commit b9a2d0af98
13 changed files with 217 additions and 156 deletions

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.
@@ -63,7 +63,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
@Before
public void setUp() {
converter = new Jaxb2CollectionHttpMessageConverter<>();
converter = new Jaxb2CollectionHttpMessageConverter<Collection<Object>>();
rootElementListType = new ParameterizedTypeReference<List<RootElement>>() {}.getType();
rootElementSetType = new ParameterizedTypeReference<Set<RootElement>>() {}.getType();
typeListType = new ParameterizedTypeReference<List<TestType>>() {}.getType();
@@ -157,7 +157,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
assertEquals("", result.iterator().next().external);
}
catch (HttpMessageNotReadableException ex) {
// Some parsers raise exception by default
// Some parsers raise an exception
}
}
@@ -212,7 +212,6 @@ public class Jaxb2CollectionHttpMessageConverterTests {
}
@SuppressWarnings("unused")
@XmlRootElement
public static class RootElement {
@@ -247,6 +246,7 @@ public class Jaxb2CollectionHttpMessageConverterTests {
}
}
@XmlType
public static class TestType {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2012 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.
@@ -13,9 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.web.accept;
import static org.junit.Assert.assertEquals;
package org.springframework.web.accept;
import java.util.Arrays;
import java.util.Collections;
@@ -24,6 +23,7 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.springframework.http.MediaType;
import org.springframework.mock.web.test.MockHttpServletRequest;
import org.springframework.mock.web.test.MockServletContext;
@@ -31,8 +31,11 @@ import org.springframework.util.StringUtils;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.context.request.ServletWebRequest;
import static org.junit.Assert.*;
/**
* Test fixture for {@link ContentNegotiationManagerFactoryBean} tests.
*
* @author Rossen Stoyanchev
*/
public class ContentNegotiationManagerFactoryBeanTests {
@@ -43,6 +46,7 @@ public class ContentNegotiationManagerFactoryBeanTests {
private MockHttpServletRequest servletRequest;
@Before
public void setup() {
TestServletContext servletContext = new TestServletContext();
@@ -55,6 +59,7 @@ public class ContentNegotiationManagerFactoryBeanTests {
this.factoryBean.setServletContext(this.servletRequest.getServletContext());
}
@Test
public void defaultSettings() throws Exception {
this.factoryBean.afterPropertiesSet();
@@ -149,17 +154,14 @@ public class ContentNegotiationManagerFactoryBeanTests {
assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(this.webRequest));
// SPR-10513
this.servletRequest.addHeader("Accept", MediaType.ALL_VALUE);
assertEquals(Arrays.asList(MediaType.APPLICATION_JSON), manager.resolveMediaTypes(this.webRequest));
}
private static class TestServletContext extends MockServletContext {
private final Map<String, String> mimeTypes = new HashMap<>();
private final Map<String, String> mimeTypes = new HashMap<String, String>();
public Map<String, String> getMimeTypes() {
return this.mimeTypes;