summaryrefslogtreecommitdiff
path: root/spring-core/src/test/java/org/springframework
diff options
context:
space:
mode:
authorEmmanuel Bourg <ebourg@apache.org>2016-12-23 09:09:27 +0100
committerEmmanuel Bourg <ebourg@apache.org>2016-12-23 09:09:27 +0100
commit7b2b01514e9875ddcb0f6cc15c6557a0417b22fc (patch)
tree9327f61a75d4bb1bcac2e8827d315d9a37c201a7 /spring-core/src/test/java/org/springframework
parent0591d269b8b2b33af090ace1ecbd408490618428 (diff)
New upstream version 4.3.5
Diffstat (limited to 'spring-core/src/test/java/org/springframework')
-rw-r--r--spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java2
-rw-r--r--spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java31
-rw-r--r--spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java24
-rw-r--r--spring-core/src/test/java/org/springframework/util/MimeTypeTests.java10
-rw-r--r--spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java12
-rw-r--r--spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java5
-rw-r--r--spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java5
7 files changed, 59 insertions, 30 deletions
diff --git a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java
index 5cbc10d9..f33f71d6 100644
--- a/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java
+++ b/spring-core/src/test/java/org/springframework/core/annotation/ComposedRepeatableAnnotationsTests.java
@@ -186,7 +186,7 @@ public class ComposedRepeatableAnnotationsTests {
private void expectNonRepeatableAnnotation() {
exception.expect(IllegalArgumentException.class);
- exception.expectMessage(startsWith("annotationType must be a repeatable annotation"));
+ exception.expectMessage(startsWith("Annotation type must be a repeatable annotation"));
exception.expectMessage(containsString("failed to resolve container type for"));
exception.expectMessage(containsString(NonRepeatable.class.getName()));
}
diff --git a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java
index 39184c2c..9fd16139 100644
--- a/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java
+++ b/spring-core/src/test/java/org/springframework/core/convert/TypeDescriptorTests.java
@@ -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.
@@ -533,7 +533,7 @@ public class TypeDescriptorTests {
public void elementTypePreserveContext() throws Exception {
TypeDescriptor desc = new TypeDescriptor(getClass().getField("listPreserveContext"));
assertEquals(Integer.class, desc.getElementTypeDescriptor().getElementTypeDescriptor().getType());
- List<Integer> value = new ArrayList<Integer>(3);
+ List<Integer> value = new ArrayList<>(3);
desc = desc.elementTypeDescriptor(value);
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
@@ -551,7 +551,7 @@ public class TypeDescriptorTests {
public void mapKeyTypePreserveContext() throws Exception {
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
assertEquals(Integer.class, desc.getMapKeyTypeDescriptor().getElementTypeDescriptor().getType());
- List<Integer> value = new ArrayList<Integer>(3);
+ List<Integer> value = new ArrayList<>(3);
desc = desc.getMapKeyTypeDescriptor(value);
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
@@ -569,7 +569,7 @@ public class TypeDescriptorTests {
public void mapValueTypePreserveContext() throws Exception {
TypeDescriptor desc = new TypeDescriptor(getClass().getField("mapPreserveContext"));
assertEquals(Integer.class, desc.getMapValueTypeDescriptor().getElementTypeDescriptor().getType());
- List<Integer> value = new ArrayList<Integer>(3);
+ List<Integer> value = new ArrayList<>(3);
desc = desc.getMapValueTypeDescriptor(value);
assertEquals(Integer.class, desc.getElementTypeDescriptor().getType());
assertNotNull(desc.getAnnotation(FieldAnnotation.class));
@@ -598,15 +598,16 @@ public class TypeDescriptorTests {
TypeDescriptor t12 = new TypeDescriptor(getClass().getField("mapField"));
assertEquals(t11, t12);
- TypeDescriptor t13 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0));
- TypeDescriptor t14 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0));
+ MethodParameter testAnnotatedMethod = new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0);
+ TypeDescriptor t13 = new TypeDescriptor(testAnnotatedMethod);
+ TypeDescriptor t14 = new TypeDescriptor(testAnnotatedMethod);
assertEquals(t13, t14);
- TypeDescriptor t15 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0));
+ TypeDescriptor t15 = new TypeDescriptor(testAnnotatedMethod);
TypeDescriptor t16 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethodDifferentAnnotationValue", String.class), 0));
assertNotEquals(t15, t16);
- TypeDescriptor t17 = new TypeDescriptor(new MethodParameter(getClass().getMethod("testAnnotatedMethod", String.class), 0));
+ TypeDescriptor t17 = new TypeDescriptor(testAnnotatedMethod);
TypeDescriptor t18 = new TypeDescriptor(new MethodParameter(getClass().getMethod("test5", String.class), 0));
assertNotEquals(t17, t18);
}
@@ -841,19 +842,19 @@ public class TypeDescriptorTests {
public List<String> listOfString;
- public List<List<String>> listOfListOfString = new ArrayList<List<String>>();
+ public List<List<String>> listOfListOfString = new ArrayList<>();
- public List<List> listOfListOfUnknown = new ArrayList<List>();
+ public List<List> listOfListOfUnknown = new ArrayList<>();
public int[] intArray;
public List<String>[] arrayOfListOfString;
- public List<Integer> listField = new ArrayList<Integer>();
+ public List<Integer> listField = new ArrayList<>();
- public Map<String, Integer> mapField = new HashMap<String, Integer>();
+ public Map<String, Integer> mapField = new HashMap<>();
- public Map<String, List<Integer>> nestedMapField = new HashMap<String, List<Integer>>();
+ public Map<String, List<Integer>> nestedMapField = new HashMap<>();
public Map<List<Integer>, List<Long>> fieldMap;
@@ -879,9 +880,9 @@ public class TypeDescriptorTests {
public Map<CharSequence, Number> isAssignableMapKeyValueTypes;
- public MultiValueMap<String, Integer> multiValueMap = new LinkedMultiValueMap<String, Integer>();
+ public MultiValueMap<String, Integer> multiValueMap = new LinkedMultiValueMap<>();
- public PassDownGeneric<Integer> passDownGeneric = new PassDownGeneric<Integer>();
+ public PassDownGeneric<Integer> passDownGeneric = new PassDownGeneric<>();
// Classes designed for test introspection
diff --git a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
index 446f0f91..19880892 100644
--- a/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
+++ b/spring-core/src/test/java/org/springframework/core/convert/converter/DefaultConversionServiceTests.java
@@ -628,12 +628,34 @@ public class DefaultConversionServiceTests {
}
@Test
+ public void convertListOfNonStringifiable() {
+ List<Object> list = Arrays.asList(new TestEntity(1L), new TestEntity(2L));
+ assertTrue(conversionService.canConvert(list.getClass(), String.class));
+ try {
+ conversionService.convert(list, String.class);
+ }
+ catch (ConversionFailedException ex) {
+ assertTrue(ex.getMessage().contains(list.getClass().getName()));
+ assertTrue(ex.getCause() instanceof ConverterNotFoundException);
+ assertTrue(ex.getCause().getMessage().contains(TestEntity.class.getName()));
+ }
+ }
+
+ @Test
+ public void convertListOfStringToString() {
+ List<String> list = Arrays.asList("Foo", "Bar");
+ assertTrue(conversionService.canConvert(list.getClass(), String.class));
+ String result = conversionService.convert(list, String.class);
+ assertEquals("Foo,Bar", result);
+ }
+
+ @Test
public void convertListOfListToString() {
List<String> list1 = Arrays.asList("Foo", "Bar");
List<String> list2 = Arrays.asList("Baz", "Boop");
List<List<String>> list = Arrays.asList(list1, list2);
+ assertTrue(conversionService.canConvert(list.getClass(), String.class));
String result = conversionService.convert(list, String.class);
- assertNotNull(result);
assertEquals("Foo,Bar,Baz,Boop", result);
}
diff --git a/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java b/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java
index 99c5a826..43420d36 100644
--- a/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java
+++ b/spring-core/src/test/java/org/springframework/util/MimeTypeTests.java
@@ -88,6 +88,16 @@ public class MimeTypeTests {
}
@Test
+ public void parseQuotedSeparator() {
+ String s = "application/xop+xml;charset=utf-8;type=\"application/soap+xml;action=\\\"http://x.y.z\\\"\"";
+ MimeType mimeType = MimeType.valueOf(s);
+ assertEquals("Invalid type", "application", mimeType.getType());
+ assertEquals("Invalid subtype", "xop+xml", mimeType.getSubtype());
+ assertEquals("Invalid charset", Charset.forName("UTF-8"), mimeType.getCharset());
+ assertEquals("\"application/soap+xml;action=\\\"http://x.y.z\\\"\"", mimeType.getParameter("type"));
+ }
+
+ @Test
public void withConversionService() {
ConversionService conversionService = new DefaultConversionService();
assertTrue(conversionService.canConvert(String.class, MimeType.class));
diff --git a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
index e23c92cc..adabedc3 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/AbstractStaxHandlerTestCase.java
@@ -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.
@@ -19,7 +19,6 @@ package org.springframework.util.xml;
import java.io.StringReader;
import java.io.StringWriter;
import java.net.Socket;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.stream.XMLStreamException;
@@ -30,7 +29,6 @@ import javax.xml.transform.stream.StreamResult;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
-
import org.w3c.dom.Document;
import org.xml.sax.InputSource;
import org.xml.sax.XMLReader;
@@ -58,11 +56,13 @@ public abstract class AbstractStaxHandlerTestCase {
private XMLReader xmlReader;
+
@Before
public void createXMLReader() throws Exception {
xmlReader = XMLReaderFactory.createXMLReader();
}
+
@Test
public void noNamespacePrefixes() throws Exception {
Assume.assumeTrue(wwwSpringframeworkOrgIsAccessible());
@@ -109,8 +109,7 @@ public abstract class AbstractStaxHandlerTestCase {
@Test
public void noNamespacePrefixesDom() throws Exception {
- DocumentBuilderFactory documentBuilderFactory =
- DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
@@ -131,8 +130,7 @@ public abstract class AbstractStaxHandlerTestCase {
@Test
public void namespacePrefixesDom() throws Exception {
- DocumentBuilderFactory documentBuilderFactory =
- DocumentBuilderFactory.newInstance();
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
documentBuilderFactory.setNamespaceAware(true);
DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java
index d2c44d66..2ad1ae9a 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxEventHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 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.
@@ -27,8 +27,7 @@ import javax.xml.transform.Result;
public class StaxEventHandlerTests extends AbstractStaxHandlerTestCase {
@Override
- protected AbstractStaxHandler createStaxHandler(Result result)
- throws XMLStreamException {
+ protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(result);
return new StaxEventHandler(eventWriter);
diff --git a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java
index a039826b..116aec62 100644
--- a/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java
+++ b/spring-core/src/test/java/org/springframework/util/xml/StaxStreamHandlerTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2014 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.
@@ -27,8 +27,7 @@ import javax.xml.transform.Result;
public class StaxStreamHandlerTests extends AbstractStaxHandlerTestCase {
@Override
- protected AbstractStaxHandler createStaxHandler(Result result)
- throws XMLStreamException {
+ protected AbstractStaxHandler createStaxHandler(Result result) throws XMLStreamException {
XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();
XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(result);
return new StaxStreamHandler(streamWriter);