Fix [deprecation] compiler warnings
Fix deprecation compiler warnings by refactoring code or applying
@SuppressWarnings("deprecation") annotations. JUnit tests of
internally deprecated classes are now themselves marked as
@Deprecated.
Numerous EasyMock deprecation warnings will remain until the
migration to mockito can be completed.
This commit is contained in:
@@ -33,21 +33,25 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
public class CollectionFactoryTests extends TestCase {
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testLinkedSet() {
|
||||
Set set = CollectionFactory.createLinkedSetIfPossible(16);
|
||||
assertTrue(set instanceof LinkedHashSet);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testLinkedMap() {
|
||||
Map map = CollectionFactory.createLinkedMapIfPossible(16);
|
||||
assertTrue(map instanceof LinkedHashMap);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testIdentityMap() {
|
||||
Map map = CollectionFactory.createIdentityMapIfPossible(16);
|
||||
assertTrue(map instanceof IdentityHashMap);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testConcurrentMap() {
|
||||
Map map = CollectionFactory.createConcurrentMapIfPossible(16);
|
||||
assertTrue(map.getClass().getName().endsWith("ConcurrentHashMap"));
|
||||
@@ -58,6 +62,7 @@ public class CollectionFactoryTests extends TestCase {
|
||||
assertTrue(map.getClass().getName().endsWith("MultiValueMap"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testConcurrentMapWithExplicitInterface() {
|
||||
ConcurrentMap map = CollectionFactory.createConcurrentMap(16);
|
||||
assertTrue(map.getClass().getSuperclass().getName().endsWith("ConcurrentHashMap"));
|
||||
|
||||
@@ -25,8 +25,6 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.springframework.beans.GenericBean;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
@@ -96,11 +94,11 @@ public class GenericCollectionTypeResolverTests extends AbstractGenericsTests {
|
||||
|
||||
public void testProgrammaticListIntrospection() throws Exception {
|
||||
Method setter = GenericBean.class.getMethod("setResourceList", List.class);
|
||||
Assert.assertEquals(Resource.class,
|
||||
assertEquals(Resource.class,
|
||||
GenericCollectionTypeResolver.getCollectionParameterType(new MethodParameter(setter, 0)));
|
||||
|
||||
Method getter = GenericBean.class.getMethod("getResourceList");
|
||||
Assert.assertEquals(Resource.class,
|
||||
assertEquals(Resource.class,
|
||||
GenericCollectionTypeResolver.getCollectionReturnType(getter));
|
||||
}
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import junit.framework.Assert;
|
||||
|
||||
/**
|
||||
* @author Rod Johnson
|
||||
@@ -52,7 +51,7 @@ public class NestedExceptionTests extends TestCase {
|
||||
Exception rootCause = new Exception(rootCauseMesg);
|
||||
// Making a class abstract doesn't _really_ prevent instantiation :-)
|
||||
NestedRuntimeException nex = new NestedRuntimeException(myMessage, rootCause) {};
|
||||
Assert.assertEquals(nex.getCause(), rootCause);
|
||||
assertEquals(nex.getCause(), rootCause);
|
||||
assertTrue(nex.getMessage().indexOf(myMessage) != -1);
|
||||
assertTrue(nex.getMessage().indexOf(rootCauseMesg) != -1);
|
||||
|
||||
@@ -90,7 +89,7 @@ public class NestedExceptionTests extends TestCase {
|
||||
Exception rootCause = new Exception(rootCauseMesg);
|
||||
// Making a class abstract doesn't _really_ prevent instantiation :-)
|
||||
NestedCheckedException nex = new NestedCheckedException(myMessage, rootCause) {};
|
||||
Assert.assertEquals(nex.getCause(), rootCause);
|
||||
assertEquals(nex.getCause(), rootCause);
|
||||
assertTrue(nex.getMessage().indexOf(myMessage) != -1);
|
||||
assertTrue(nex.getMessage().indexOf(rootCauseMesg) != -1);
|
||||
|
||||
|
||||
@@ -401,7 +401,7 @@ public class DefaultConversionTests {
|
||||
public void convertArrayToObjectAssignableTargetType() {
|
||||
Long[] array = new Long[] { 3L };
|
||||
Long[] result = (Long[]) conversionService.convert(array, Object.class);
|
||||
assertEquals(array, result);
|
||||
assertArrayEquals(array, result);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -29,6 +29,7 @@ import junit.framework.TestCase;
|
||||
* @author Juergen Hoeller
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@Deprecated
|
||||
public class LabeledEnumTests extends TestCase {
|
||||
|
||||
private byte[] serializeObject(final Object obj) throws IOException {
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.beans.PropertyEditor;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.core.env.StandardEnvironment;
|
||||
import org.springframework.core.io.Resource;
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,9 @@ public class ResourceArrayPropertyEditorTests {
|
||||
|
||||
@Test(expected=IllegalArgumentException.class)
|
||||
public void testStrictSystemPropertyReplacement() {
|
||||
PropertyEditor editor = new ResourceArrayPropertyEditor(new PathMatchingResourcePatternResolver(), false);
|
||||
PropertyEditor editor = new ResourceArrayPropertyEditor(
|
||||
new PathMatchingResourcePatternResolver(), new StandardEnvironment(),
|
||||
false);
|
||||
System.setProperty("test.prop", "foo");
|
||||
try {
|
||||
editor.setAsText("${test.prop}-${bar}");
|
||||
|
||||
@@ -17,13 +17,14 @@
|
||||
package org.springframework.core.style;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.springframework.core.CollectionFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,7 @@ public class ToStringCreatorTests extends TestCase {
|
||||
}
|
||||
|
||||
private Map getMap() {
|
||||
Map map = CollectionFactory.createLinkedMapIfPossible(3);
|
||||
Map map = new LinkedHashMap(3);
|
||||
map.put("Keri", "Softball");
|
||||
map.put("Scot", "Fishing");
|
||||
map.put("Keith", "Flag Football");
|
||||
@@ -96,7 +97,7 @@ public class ToStringCreatorTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testSet() {
|
||||
Set set = CollectionFactory.createLinkedSetIfPossible(3);
|
||||
Set set = new LinkedHashSet<>(3);
|
||||
set.add(s1);
|
||||
set.add(s2);
|
||||
set.add(s3);
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.util;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import junit.framework.*;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.springframework.beans.TestBean;
|
||||
|
||||
@@ -72,14 +71,14 @@ public class AutoPopulatingListTests extends TestCase {
|
||||
for(int x = 0; x < list.size(); x++) {
|
||||
Object element = list.get(x);
|
||||
if(element instanceof TestBean) {
|
||||
junit.framework.Assert.assertEquals(x, ((TestBean) element).getAge());
|
||||
assertEquals(x, ((TestBean) element).getAge());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void testSerialization() throws Exception {
|
||||
AutoPopulatingList<?> list = new AutoPopulatingList<Object>(TestBean.class);
|
||||
Assert.assertEquals(list, SerializationTestUtils.serializeAndDeserialize(list));
|
||||
assertEquals(list, SerializationTestUtils.serializeAndDeserialize(list));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import junit.framework.TestCase;
|
||||
* @author Keith Donald
|
||||
* @author Juergen Hoeller
|
||||
*/
|
||||
@Deprecated
|
||||
public class CachingMapDecoratorTests extends TestCase {
|
||||
|
||||
public void testValidCache() {
|
||||
|
||||
@@ -41,6 +41,8 @@ import org.springframework.beans.TestBean;
|
||||
*/
|
||||
public class ClassUtilsTests extends TestCase {
|
||||
|
||||
private ClassLoader classLoader = getClass().getClassLoader();
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
InnerClass.noArgCalled = false;
|
||||
@@ -49,56 +51,56 @@ public class ClassUtilsTests extends TestCase {
|
||||
}
|
||||
|
||||
public void testIsPresent() throws Exception {
|
||||
assertTrue(ClassUtils.isPresent("java.lang.String"));
|
||||
assertFalse(ClassUtils.isPresent("java.lang.MySpecialString"));
|
||||
assertTrue(ClassUtils.isPresent("java.lang.String", classLoader));
|
||||
assertFalse(ClassUtils.isPresent("java.lang.MySpecialString", classLoader));
|
||||
}
|
||||
|
||||
public void testForName() throws ClassNotFoundException {
|
||||
assertEquals(String.class, ClassUtils.forName("java.lang.String"));
|
||||
assertEquals(String[].class, ClassUtils.forName("java.lang.String[]"));
|
||||
assertEquals(String[].class, ClassUtils.forName(String[].class.getName()));
|
||||
assertEquals(String[][].class, ClassUtils.forName(String[][].class.getName()));
|
||||
assertEquals(String[][][].class, ClassUtils.forName(String[][][].class.getName()));
|
||||
assertEquals(TestBean.class, ClassUtils.forName("org.springframework.beans.TestBean"));
|
||||
assertEquals(TestBean[].class, ClassUtils.forName("org.springframework.beans.TestBean[]"));
|
||||
assertEquals(TestBean[].class, ClassUtils.forName(TestBean[].class.getName()));
|
||||
assertEquals(TestBean[][].class, ClassUtils.forName("org.springframework.beans.TestBean[][]"));
|
||||
assertEquals(TestBean[][].class, ClassUtils.forName(TestBean[][].class.getName()));
|
||||
assertEquals(short[][][].class, ClassUtils.forName("[[[S"));
|
||||
assertEquals(String.class, ClassUtils.forName("java.lang.String", classLoader));
|
||||
assertEquals(String[].class, ClassUtils.forName("java.lang.String[]", classLoader));
|
||||
assertEquals(String[].class, ClassUtils.forName(String[].class.getName(), classLoader));
|
||||
assertEquals(String[][].class, ClassUtils.forName(String[][].class.getName(), classLoader));
|
||||
assertEquals(String[][][].class, ClassUtils.forName(String[][][].class.getName(), classLoader));
|
||||
assertEquals(TestBean.class, ClassUtils.forName("org.springframework.beans.TestBean", classLoader));
|
||||
assertEquals(TestBean[].class, ClassUtils.forName("org.springframework.beans.TestBean[]", classLoader));
|
||||
assertEquals(TestBean[].class, ClassUtils.forName(TestBean[].class.getName(), classLoader));
|
||||
assertEquals(TestBean[][].class, ClassUtils.forName("org.springframework.beans.TestBean[][]", classLoader));
|
||||
assertEquals(TestBean[][].class, ClassUtils.forName(TestBean[][].class.getName(), classLoader));
|
||||
assertEquals(short[][][].class, ClassUtils.forName("[[[S", classLoader));
|
||||
}
|
||||
|
||||
public void testForNameWithPrimitiveClasses() throws ClassNotFoundException {
|
||||
assertEquals(boolean.class, ClassUtils.forName("boolean"));
|
||||
assertEquals(byte.class, ClassUtils.forName("byte"));
|
||||
assertEquals(char.class, ClassUtils.forName("char"));
|
||||
assertEquals(short.class, ClassUtils.forName("short"));
|
||||
assertEquals(int.class, ClassUtils.forName("int"));
|
||||
assertEquals(long.class, ClassUtils.forName("long"));
|
||||
assertEquals(float.class, ClassUtils.forName("float"));
|
||||
assertEquals(double.class, ClassUtils.forName("double"));
|
||||
assertEquals(void.class, ClassUtils.forName("void"));
|
||||
assertEquals(boolean.class, ClassUtils.forName("boolean", classLoader));
|
||||
assertEquals(byte.class, ClassUtils.forName("byte", classLoader));
|
||||
assertEquals(char.class, ClassUtils.forName("char", classLoader));
|
||||
assertEquals(short.class, ClassUtils.forName("short", classLoader));
|
||||
assertEquals(int.class, ClassUtils.forName("int", classLoader));
|
||||
assertEquals(long.class, ClassUtils.forName("long", classLoader));
|
||||
assertEquals(float.class, ClassUtils.forName("float", classLoader));
|
||||
assertEquals(double.class, ClassUtils.forName("double", classLoader));
|
||||
assertEquals(void.class, ClassUtils.forName("void", classLoader));
|
||||
}
|
||||
|
||||
public void testForNameWithPrimitiveArrays() throws ClassNotFoundException {
|
||||
assertEquals(boolean[].class, ClassUtils.forName("boolean[]"));
|
||||
assertEquals(byte[].class, ClassUtils.forName("byte[]"));
|
||||
assertEquals(char[].class, ClassUtils.forName("char[]"));
|
||||
assertEquals(short[].class, ClassUtils.forName("short[]"));
|
||||
assertEquals(int[].class, ClassUtils.forName("int[]"));
|
||||
assertEquals(long[].class, ClassUtils.forName("long[]"));
|
||||
assertEquals(float[].class, ClassUtils.forName("float[]"));
|
||||
assertEquals(double[].class, ClassUtils.forName("double[]"));
|
||||
assertEquals(boolean[].class, ClassUtils.forName("boolean[]", classLoader));
|
||||
assertEquals(byte[].class, ClassUtils.forName("byte[]", classLoader));
|
||||
assertEquals(char[].class, ClassUtils.forName("char[]", classLoader));
|
||||
assertEquals(short[].class, ClassUtils.forName("short[]", classLoader));
|
||||
assertEquals(int[].class, ClassUtils.forName("int[]", classLoader));
|
||||
assertEquals(long[].class, ClassUtils.forName("long[]", classLoader));
|
||||
assertEquals(float[].class, ClassUtils.forName("float[]", classLoader));
|
||||
assertEquals(double[].class, ClassUtils.forName("double[]", classLoader));
|
||||
}
|
||||
|
||||
public void testForNameWithPrimitiveArraysInternalName() throws ClassNotFoundException {
|
||||
assertEquals(boolean[].class, ClassUtils.forName(boolean[].class.getName()));
|
||||
assertEquals(byte[].class, ClassUtils.forName(byte[].class.getName()));
|
||||
assertEquals(char[].class, ClassUtils.forName(char[].class.getName()));
|
||||
assertEquals(short[].class, ClassUtils.forName(short[].class.getName()));
|
||||
assertEquals(int[].class, ClassUtils.forName(int[].class.getName()));
|
||||
assertEquals(long[].class, ClassUtils.forName(long[].class.getName()));
|
||||
assertEquals(float[].class, ClassUtils.forName(float[].class.getName()));
|
||||
assertEquals(double[].class, ClassUtils.forName(double[].class.getName()));
|
||||
assertEquals(boolean[].class, ClassUtils.forName(boolean[].class.getName(), classLoader));
|
||||
assertEquals(byte[].class, ClassUtils.forName(byte[].class.getName(), classLoader));
|
||||
assertEquals(char[].class, ClassUtils.forName(char[].class.getName(), classLoader));
|
||||
assertEquals(short[].class, ClassUtils.forName(short[].class.getName(), classLoader));
|
||||
assertEquals(int[].class, ClassUtils.forName(int[].class.getName(), classLoader));
|
||||
assertEquals(long[].class, ClassUtils.forName(long[].class.getName(), classLoader));
|
||||
assertEquals(float[].class, ClassUtils.forName(float[].class.getName(), classLoader));
|
||||
assertEquals(double[].class, ClassUtils.forName(double[].class.getName(), classLoader));
|
||||
}
|
||||
|
||||
public void testGetShortName() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2010 the original author or authors.
|
||||
* Copyright 2002-2012 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.
|
||||
@@ -16,8 +16,13 @@
|
||||
|
||||
package org.springframework.util.xml;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
import java.io.StringReader;
|
||||
import java.io.StringWriter;
|
||||
|
||||
import javax.xml.parsers.DocumentBuilder;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
@@ -28,7 +33,6 @@ import javax.xml.transform.TransformerFactory;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
import javax.xml.transform.stream.StreamResult;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.w3c.dom.Document;
|
||||
@@ -101,4 +105,4 @@ public class StaxSourceTests {
|
||||
transformer.transform(source, new DOMResult(result));
|
||||
assertXMLEqual("Invalid result", expected, result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user