Refactor code to use Java 5 features

- Apply and use Generics
- Remove JdkVersion.isAtLeastJava15() conditionals
- Replace iterator loops with foreach syntax
- Switch on warning in eclipse

Issues: SWF-1532
This commit is contained in:
Phil Webb
2012-03-29 21:02:07 -07:00
parent 619249b52b
commit 4d008f3f09
457 changed files with 3220 additions and 3148 deletions

View File

@@ -30,7 +30,7 @@ import junit.framework.TestCase;
public class CompositeIteratorTests extends TestCase {
public void testNoIterators() {
CompositeIterator it = new CompositeIterator();
CompositeIterator<Object> it = new CompositeIterator<Object>();
assertFalse(it.hasNext());
try {
it.next();
@@ -41,7 +41,7 @@ public class CompositeIteratorTests extends TestCase {
}
public void testSingleIterator() {
CompositeIterator it = new CompositeIterator();
CompositeIterator<String> it = new CompositeIterator<String>();
it.add(Arrays.asList(new String[] { "0", "1" }).iterator());
for (int i = 0; i < 2; i++) {
assertTrue(it.hasNext());
@@ -57,7 +57,7 @@ public class CompositeIteratorTests extends TestCase {
}
public void testMultipleIterators() {
CompositeIterator it = new CompositeIterator();
CompositeIterator<String> it = new CompositeIterator<String>();
it.add(Arrays.asList(new String[] { "0", "1" }).iterator());
it.add(Arrays.asList(new String[] { "2" }).iterator());
it.add(Arrays.asList(new String[] { "3", "4" }).iterator());
@@ -75,8 +75,8 @@ public class CompositeIteratorTests extends TestCase {
}
public void testInUse() {
List list = Arrays.asList(new String[] { "0", "1" });
CompositeIterator it = new CompositeIterator();
List<String> list = Arrays.asList(new String[] { "0", "1" });
CompositeIterator<String> it = new CompositeIterator<String>();
it.add(list.iterator());
it.hasNext();
try {
@@ -85,7 +85,7 @@ public class CompositeIteratorTests extends TestCase {
} catch (IllegalStateException e) {
// expected
}
it = new CompositeIterator();
it = new CompositeIterator<String>();
it.add(list.iterator());
it.next();
try {
@@ -97,9 +97,9 @@ public class CompositeIteratorTests extends TestCase {
}
public void testDuplicateIterators() {
List list = Arrays.asList(new String[] { "0", "1" });
Iterator iterator = list.iterator();
CompositeIterator it = new CompositeIterator();
List<String> list = Arrays.asList(new String[] { "0", "1" });
Iterator<String> iterator = list.iterator();
CompositeIterator<String> it = new CompositeIterator<String>();
it.add(iterator);
it.add(list.iterator());
try {

View File

@@ -6,14 +6,14 @@ import java.util.Map;
import junit.framework.TestCase;
public class MapAccessorTests extends TestCase {
private MapAccessor accessor;
private MapAccessor<String, Object> accessor;
protected void setUp() throws Exception {
Map map = new HashMap();
Map<String, Object> map = new HashMap<String, Object>();
map.put("string", "hello");
map.put("integer", new Integer(9));
map.put("null", null);
this.accessor = new MapAccessor(map);
this.accessor = new MapAccessor<String, Object>(map);
}
public void testAccessNullAttribute() {

View File

@@ -27,7 +27,8 @@ import junit.framework.TestCase;
*/
public class SharedMapDecoratorTests extends TestCase {
private SharedMapDecorator map = new SharedMapDecorator(new HashMap());
private SharedMapDecorator<String, String> map = new SharedMapDecorator<String, String>(
new HashMap<String, String>());
public void testGetPutRemove() {
assertTrue(map.size() == 0);
@@ -47,7 +48,7 @@ public class SharedMapDecoratorTests extends TestCase {
}
public void testPutAll() {
Map all = new HashMap();
Map<String, String> all = new HashMap<String, String>();
all.put("foo", "bar");
all.put("bar", "baz");
map.putAll(all);
@@ -57,21 +58,21 @@ public class SharedMapDecoratorTests extends TestCase {
public void testEntrySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set entrySet = map.entrySet();
Set<Map.Entry<String, String>> entrySet = map.entrySet();
assertTrue(entrySet.size() == 2);
}
public void testKeySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set keySet = map.keySet();
Set<String> keySet = map.keySet();
assertTrue(keySet.size() == 2);
}
public void testValues() {
map.put("foo", "bar");
map.put("bar", "baz");
Collection values = map.values();
Collection<String> values = map.values();
assertTrue(values.size() == 2);
}
}

View File

@@ -28,15 +28,15 @@ import junit.framework.TestCase;
*/
public class StringKeyedMapAdapterTests extends TestCase {
private Map contents = new HashMap();
private Map<String, String> contents = new HashMap<String, String>();
private StringKeyedMapAdapter map = new StringKeyedMapAdapter() {
private StringKeyedMapAdapter<String> map = new StringKeyedMapAdapter<String>() {
protected Object getAttribute(String key) {
protected String getAttribute(String key) {
return contents.get(key);
}
protected Iterator getAttributeNames() {
protected Iterator<String> getAttributeNames() {
return contents.keySet().iterator();
}
@@ -44,7 +44,7 @@ public class StringKeyedMapAdapterTests extends TestCase {
contents.remove(key);
}
protected void setAttribute(String key, Object value) {
protected void setAttribute(String key, String value) {
contents.put(key, value);
}
};
@@ -67,7 +67,7 @@ public class StringKeyedMapAdapterTests extends TestCase {
}
public void testPutAll() {
Map all = new HashMap();
Map<String, String> all = new HashMap<String, String>();
all.put("foo", "bar");
all.put("bar", "baz");
map.putAll(all);
@@ -77,21 +77,21 @@ public class StringKeyedMapAdapterTests extends TestCase {
public void testEntrySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set entrySet = map.entrySet();
Set<Map.Entry<String, String>> entrySet = map.entrySet();
assertTrue(entrySet.size() == 2);
}
public void testKeySet() {
map.put("foo", "bar");
map.put("bar", "baz");
Set keySet = map.keySet();
Set<String> keySet = map.keySet();
assertTrue(keySet.size() == 2);
}
public void testValues() {
map.put("foo", "bar");
map.put("bar", "baz");
Collection values = map.values();
Collection<String> values = map.values();
assertTrue(values.size() == 2);
}
}

View File

@@ -45,11 +45,12 @@ import org.springframework.binding.format.DefaultNumberFormatFactory;
*
* @author Keith Donald
*/
@SuppressWarnings("deprecation")
public class DefaultConversionServiceTests extends TestCase {
public void testConvertCompatibleTypes() {
DefaultConversionService service = new DefaultConversionService();
List lst = new ArrayList();
List<Object> lst = new ArrayList<Object>();
assertSame(lst, service.getConversionExecutor(ArrayList.class, List.class).execute(lst));
}
@@ -205,15 +206,17 @@ public class DefaultConversionServiceTests extends TestCase {
}
}
@SuppressWarnings("unchecked")
public void testRegisterCustomConverterArrayToList() {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", String[].class, List.class);
List list = (List) executor.execute(new String[] { "princy1", "princy2" });
assertEquals("princy1", ((Principal) list.get(0)).getName());
assertEquals("princy2", ((Principal) list.get(1)).getName());
List<Principal> list = (List<Principal>) executor.execute(new String[] { "princy1", "princy2" });
assertEquals("princy1", (list.get(0)).getName());
assertEquals("princy2", (list.get(1)).getName());
}
@SuppressWarnings("unchecked")
public void testRegisterCustomConverterArrayToListReverse() {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
@@ -228,7 +231,7 @@ public class DefaultConversionServiceTests extends TestCase {
return "princy2";
}
};
List p = (List) executor.execute(new Principal[] { princy1, princy2 });
List<String> p = (List<String>) executor.execute(new Principal[] { princy1, princy2 });
assertEquals("princy1", p.get(0));
assertEquals("princy2", p.get(1));
}
@@ -248,7 +251,7 @@ public class DefaultConversionServiceTests extends TestCase {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", List.class, Principal[].class);
List princyList = new ArrayList();
List<String> princyList = new ArrayList<String>();
princyList.add("princy1");
princyList.add("princy2");
Principal[] p = (Principal[]) executor.execute(princyList);
@@ -270,7 +273,7 @@ public class DefaultConversionServiceTests extends TestCase {
return "princy2";
}
};
List princyList = new ArrayList();
List<Principal> princyList = new ArrayList<Principal>();
princyList.add(princy1);
princyList.add(princy2);
String[] p = (String[]) executor.execute(princyList);
@@ -321,21 +324,23 @@ public class DefaultConversionServiceTests extends TestCase {
}
}
@SuppressWarnings("unchecked")
public void testRegisterCustomConverterObjectToList() {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", String.class, List.class);
List list = (List) executor.execute("princy1");
assertEquals("princy1", ((Principal) list.get(0)).getName());
List<Principal> list = (List<Principal>) executor.execute("princy1");
assertEquals("princy1", list.get(0).getName());
}
@SuppressWarnings("unchecked")
public void testRegisterCustomConverterCsvStringToList() {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new PrincipalCsvStringToListConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", String.class, List.class);
List list = (List) executor.execute("princy1,princy2");
assertEquals("princy1", ((Principal) list.get(0)).getName());
assertEquals("princy2", ((Principal) list.get(1)).getName());
List<Principal> list = (List<Principal>) executor.execute("princy1,princy2");
assertEquals("princy1", list.get(0).getName());
assertEquals("princy2", list.get(1).getName());
}
public void testRegisterCustomConverterObjectToListBogus() {
@@ -350,6 +355,7 @@ public class DefaultConversionServiceTests extends TestCase {
}
}
@SuppressWarnings("unchecked")
public void testRegisterCustomConverterObjectToListReverse() {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
@@ -359,22 +365,24 @@ public class DefaultConversionServiceTests extends TestCase {
return "princy1";
}
};
List list = (List) executor.execute(princy1);
List<String> list = (List<String>) executor.execute(princy1);
assertEquals("princy1", list.get(0));
}
@SuppressWarnings("unchecked")
public void testRegisterCustomConverterListToList() {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", List.class, List.class);
List princyList = new ArrayList();
List<String> princyList = new ArrayList<String>();
princyList.add("princy1");
princyList.add("princy2");
List list = (List) executor.execute(princyList);
assertEquals("princy1", ((Principal) list.get(0)).getName());
assertEquals("princy2", ((Principal) list.get(1)).getName());
List<Principal> list = (List<Principal>) executor.execute(princyList);
assertEquals("princy1", list.get(0).getName());
assertEquals("princy2", list.get(1).getName());
}
@SuppressWarnings("unchecked")
public void testRegisterCustomConverterListToListReverse() {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
@@ -389,10 +397,10 @@ public class DefaultConversionServiceTests extends TestCase {
return "princy2";
}
};
List princyList = new ArrayList();
List<Principal> princyList = new ArrayList<Principal>();
princyList.add(princy1);
princyList.add(princy2);
List list = (List) executor.execute(princyList);
List<String> list = (List<String>) executor.execute(princyList);
assertEquals("princy1", list.get(0));
assertEquals("princy2", list.get(1));
}
@@ -401,8 +409,8 @@ public class DefaultConversionServiceTests extends TestCase {
DefaultConversionService service = new DefaultConversionService();
service.addConverter("princy", new CustomTwoWayConverter());
ConversionExecutor executor = service.getConversionExecutor("princy", List.class, List.class);
List princyList = new ArrayList();
princyList.add(new Integer(1));
List<Integer> princyList = new ArrayList<Integer>();
princyList.add(1);
try {
executor.execute(princyList);
fail("Should have failed");
@@ -436,10 +444,11 @@ public class DefaultConversionServiceTests extends TestCase {
assertEquals(3, result[2]);
}
@SuppressWarnings("unchecked")
public void testArrayToListConversion() {
DefaultConversionService service = new DefaultConversionService();
ConversionExecutor executor = service.getConversionExecutor(String[].class, List.class);
List result = (List) executor.execute(new String[] { "1", "2", "3" });
List<String> result = (List<String>) executor.execute(new String[] { "1", "2", "3" });
assertEquals("1", result.get(0));
assertEquals("2", result.get(1));
assertEquals("3", result.get(2));
@@ -448,7 +457,7 @@ public class DefaultConversionServiceTests extends TestCase {
public void testListToArrayConversion() {
DefaultConversionService service = new DefaultConversionService();
ConversionExecutor executor = service.getConversionExecutor(Collection.class, String[].class);
List list = new ArrayList();
List<String> list = new ArrayList<String>();
list.add("1");
list.add("2");
list.add("3");
@@ -458,14 +467,15 @@ public class DefaultConversionServiceTests extends TestCase {
assertEquals("3", result[2]);
}
@SuppressWarnings("unchecked")
public void testSetToListConversion() {
DefaultConversionService service = new DefaultConversionService();
ConversionExecutor executor = service.getConversionExecutor(Set.class, List.class);
Set set = new LinkedHashSet();
Set<String> set = new LinkedHashSet<String>();
set.add("1");
set.add("2");
set.add("3");
List result = (List) executor.execute(set);
List<String> result = (List<String>) executor.execute(set);
assertEquals("1", result.get(0));
assertEquals("2", result.get(1));
assertEquals("3", result.get(2));
@@ -474,7 +484,7 @@ public class DefaultConversionServiceTests extends TestCase {
public void testListToArrayConversionWithComponentConversion() {
try {
DefaultConversionService service = new DefaultConversionService();
ConversionExecutor executor = service.getConversionExecutor(Collection.class, Integer[].class);
service.getConversionExecutor(Collection.class, Integer[].class);
// This test case is no longer supported:
// https://jira.springframework.org/browse/SPR-7496
@@ -493,10 +503,11 @@ public class DefaultConversionServiceTests extends TestCase {
}
}
@SuppressWarnings("unchecked")
public void testArrayToLinkedListConversion() {
DefaultConversionService service = new DefaultConversionService();
ConversionExecutor executor = service.getConversionExecutor(String[].class, LinkedList.class);
LinkedList result = (LinkedList) executor.execute(new String[] { "1", "2", "3" });
LinkedList<String> result = (LinkedList<String>) executor.execute(new String[] { "1", "2", "3" });
assertEquals("1", result.get(0));
assertEquals("2", result.get(1));
assertEquals("3", result.get(2));
@@ -521,10 +532,11 @@ public class DefaultConversionServiceTests extends TestCase {
assertEquals("3", result[2]);
}
@SuppressWarnings("unchecked")
public void testStringToListConversion() {
DefaultConversionService service = new DefaultConversionService();
ConversionExecutor executor = service.getConversionExecutor(String.class, List.class);
List result = (List) executor.execute("1,2,3");
List<String> result = (List<String>) executor.execute("1,2,3");
assertEquals(3, result.size());
assertEquals("1", result.get(0));
assertEquals("2", result.get(1));
@@ -541,7 +553,7 @@ public class DefaultConversionServiceTests extends TestCase {
private static class CustomConverter implements Converter {
public Object convertSourceToTargetClass(final Object source, Class targetClass) throws Exception {
public Object convertSourceToTargetClass(final Object source, Class<?> targetClass) throws Exception {
return new Principal() {
public String getName() {
return (String) source;
@@ -549,33 +561,33 @@ public class DefaultConversionServiceTests extends TestCase {
};
}
public Class getSourceClass() {
public Class<?> getSourceClass() {
return String.class;
}
public Class getTargetClass() {
public Class<?> getTargetClass() {
return Principal.class;
}
}
private static class CustomTwoWayConverter extends CustomConverter implements TwoWayConverter {
public Object convertTargetToSourceClass(Object target, Class sourceClass) throws Exception {
public Object convertTargetToSourceClass(Object target, Class<?> sourceClass) throws Exception {
return ((Principal) target).getName();
}
}
private static class Trimmer implements Converter {
public Object convertSourceToTargetClass(Object source, Class targetClass) throws Exception {
public Object convertSourceToTargetClass(Object source, Class<?> targetClass) throws Exception {
return ((String) source).trim();
}
public Class getSourceClass() {
public Class<?> getSourceClass() {
return String.class;
}
public Class getTargetClass() {
public Class<?> getTargetClass() {
return String.class;
}
@@ -587,8 +599,8 @@ public class DefaultConversionServiceTests extends TestCase {
super(List.class);
}
protected Object toObject(String string, Class targetClass) throws Exception {
List principals = new ArrayList();
protected Object toObject(String string, Class<?> targetClass) throws Exception {
List<Principal> principals = new ArrayList<Principal>();
StringTokenizer tokenizer = new StringTokenizer(string, ",");
while (tokenizer.hasMoreTokens()) {
final String name = tokenizer.nextToken();

View File

@@ -1,5 +1,6 @@
package org.springframework.binding.expression.el;
import java.beans.FeatureDescriptor;
import java.util.Iterator;
import javax.el.ELContext;
@@ -84,8 +85,8 @@ public class ELExpressionParserTests extends TestCase {
public void testParseBeanEvalExpressionInvalidELVariable() {
try {
String expressionString = "bogus";
Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
.evaluate(TestBean.class));
Expression exp = parser.parseExpression(expressionString,
new FluentParserContext().evaluate(TestBean.class));
exp.getValue(new TestBean());
fail("Should have failed");
} catch (EvaluationException e) {
@@ -108,8 +109,8 @@ public class ELExpressionParserTests extends TestCase {
public void testParseTemplateExpressionWithVariables() {
String expressionString = "#{value}#{max}";
Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(
new ExpressionVariable("max", "maximum")));
Expression exp = parser.parseExpression(expressionString,
new FluentParserContext().template().variable(new ExpressionVariable("max", "maximum")));
TestBean target = new TestBean();
assertEquals("foo2", exp.getValue(target));
}
@@ -123,9 +124,11 @@ public class ELExpressionParserTests extends TestCase {
public void testTemplateNestedVariables() {
String expressionString = "#{value}#{max}";
Expression exp = parser.parseExpression(expressionString, new FluentParserContext().template().variable(
new ExpressionVariable("max", "#{maximum}#{var}", new FluentParserContext().template().variable(
new ExpressionVariable("var", "'bar'")))));
Expression exp = parser.parseExpression(
expressionString,
new FluentParserContext().template().variable(
new ExpressionVariable("max", "#{maximum}#{var}", new FluentParserContext().template()
.variable(new ExpressionVariable("var", "'bar'")))));
TestBean target = new TestBean();
assertEquals("foo2bar", exp.getValue(target));
}
@@ -159,8 +162,8 @@ public class ELExpressionParserTests extends TestCase {
public void testGetValueCoersionError() {
String expressionString = "maximum";
Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
.expectResult(TestBean.class));
Expression exp = parser.parseExpression(expressionString,
new FluentParserContext().expectResult(TestBean.class));
TestBean context = new TestBean();
try {
exp.getValue(context);
@@ -201,15 +204,15 @@ public class ELExpressionParserTests extends TestCase {
return new ELContext() {
public ELResolver getELResolver() {
return new ELResolver() {
public Class getCommonPropertyType(ELContext arg0, Object arg1) {
public Class<?> getCommonPropertyType(ELContext arg0, Object arg1) {
return Object.class;
}
public Iterator getFeatureDescriptors(ELContext arg0, Object arg1) {
public Iterator<FeatureDescriptor> getFeatureDescriptors(ELContext arg0, Object arg1) {
return null;
}
public Class getType(ELContext arg0, Object arg1, Object arg2) {
public Class<?> getType(ELContext arg0, Object arg1, Object arg2) {
return String.class;
}

View File

@@ -18,13 +18,13 @@ public class MapAdaptableELResolverTests extends TestCase {
}
public void testGetType() {
Class type = context.getELResolver().getType(context, new TestMapAdaptable(), "bar");
Class<?> type = context.getELResolver().getType(context, new TestMapAdaptable(), "bar");
assertTrue(context.isPropertyResolved());
assertEquals(String.class, type);
}
public void testGetType_UnknownProperty() {
Class type = context.getELResolver().getType(context, new TestMapAdaptable(), "foo");
Class<?> type = context.getELResolver().getType(context, new TestMapAdaptable(), "foo");
assertTrue(context.isPropertyResolved());
assertEquals(null, type);
}
@@ -42,27 +42,27 @@ public class MapAdaptableELResolverTests extends TestCase {
}
public void testSetValue() {
MapAdaptable testMap = new TestMapAdaptable();
MapAdaptable<String, String> testMap = new TestMapAdaptable();
context.getELResolver().setValue(context, testMap, "foo", "foo");
assertTrue(context.isPropertyResolved());
assertEquals("foo", testMap.asMap().get("foo"));
}
public void testSetValue_OverWrite() {
MapAdaptable testMap = new TestMapAdaptable();
MapAdaptable<String, String> testMap = new TestMapAdaptable();
context.getELResolver().setValue(context, testMap, "bar", "foo");
assertTrue(context.isPropertyResolved());
assertEquals("foo", testMap.asMap().get("bar"));
}
private class TestMapAdaptable implements MapAdaptable {
private Map map = new HashMap();
private class TestMapAdaptable implements MapAdaptable<String, String> {
private Map<String, String> map = new HashMap<String, String>();
public TestMapAdaptable() {
map.put("bar", "bar");
}
public Map asMap() {
public Map<String, String> asMap() {
return map;
}
}

View File

@@ -23,7 +23,7 @@ public class TestBean {
private String value = "foo";
private int maximum = 2;
private TestBean bean;
private List list = new ArrayList();
private List<String> list = new ArrayList<String>();
public TestBean() {
initList();
@@ -65,7 +65,7 @@ public class TestBean {
this.maximum = maximum;
}
public List getList() {
public List<String> getList() {
return list;
}
}

View File

@@ -127,9 +127,7 @@ public class OgnlExpressionParserTests extends TestCase {
// maps
parser.parseExpression("#{ 'foo' : 'foo value', 'bar' : 'bar value' }", null);
parser
.parseExpression("${#{ 'foo' : 'foo value', 'bar' : 'bar value' }}", new FluentParserContext()
.template());
parser.parseExpression("${#{ 'foo' : 'foo value', 'bar' : 'bar value' }}", new FluentParserContext().template());
parser.parseExpression("#@java.util.LinkedHashMap@{ 'foo' : 'foo value', 'bar' : 'bar value' }", null);
parser.parseExpression("${#@java.util.LinkedHashMap@{ 'foo' : 'foo value', 'bar' : 'bar value' }}",
new FluentParserContext().template());
@@ -141,8 +139,8 @@ public class OgnlExpressionParserTests extends TestCase {
}
public void testVariables() {
Expression exp = parser.parseExpression("#var", new FluentParserContext().variable(new ExpressionVariable(
"var", "flag")));
Expression exp = parser.parseExpression("#var",
new FluentParserContext().variable(new ExpressionVariable("var", "flag")));
assertEquals(false, ((Boolean) exp.getValue(bean)).booleanValue());
}
@@ -186,8 +184,8 @@ public class OgnlExpressionParserTests extends TestCase {
public void testGetValueCoersionError() {
String expressionString = "number";
Expression exp = parser.parseExpression(expressionString, new FluentParserContext()
.expectResult(TestBean.class));
Expression exp = parser.parseExpression(expressionString,
new FluentParserContext().expectResult(TestBean.class));
TestBean context = new TestBean();
try {
exp.getValue(context);

View File

@@ -27,7 +27,7 @@ public class TestBean {
private Date date;
private List list = new ArrayList();
private List<Object> list = new ArrayList<Object>();
public boolean isFlag() {
return flag;
@@ -45,11 +45,11 @@ public class TestBean {
this.number = number;
}
public List getList() {
public List<Object> getList() {
return list;
}
public void setList(List list) {
public void setList(List<Object> list) {
this.list = list;
}

View File

@@ -147,7 +147,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
String expressionString = "maximum";
Expression exp = parser.parseExpression(expressionString, null);
TestBean context = new TestBean();
Class clazz = exp.getValueType(context);
Class<?> clazz = exp.getValueType(context);
assertTrue(int.class.equals(clazz) || Integer.class.equals(clazz));
}
@@ -207,7 +207,7 @@ public class ELExpressionParserCompatibilityTests extends TestCase {
TypeDescriptor.valueOf(String.class));
}
public Class[] getSpecificTargetClasses() {
public Class<?>[] getSpecificTargetClasses() {
return null;
}

View File

@@ -49,7 +49,7 @@ public class DefaultMapperTests extends TestCase {
DefaultMapping mapping1 = new DefaultMapping(parser.parseExpression("beep", null), parser.parseExpression(
"beep", null));
mapper.addMapping(mapping1);
Map bean1 = new HashMap();
Map<String, String> bean1 = new HashMap<String, String>();
bean1.put("beep", "en");
TestBean2 bean2 = new TestBean2();
MappingResults results = mapper.map(bean1, bean2);
@@ -61,11 +61,11 @@ public class DefaultMapperTests extends TestCase {
DefaultMapping mapping1 = new DefaultMapping(parser.parseExpression("boop", null), parser.parseExpression(
"boop", null));
mapper.addMapping(mapping1);
Map bean1 = new HashMap();
Map<String, String> bean1 = new HashMap<String, String>();
bean1.put("boop", "bogus");
TestBean2 bean2 = new TestBean2();
MappingResults results = mapper.map(bean1, bean2);
assertEquals("typeMismatch", ((MappingResult) results.getErrorResults().get(0)).getCode());
assertEquals("typeMismatch", results.getErrorResults().get(0).getCode());
}
public static class TestBean {

View File

@@ -45,8 +45,8 @@ public class DefaultMessageContextTests extends TestCase {
}
public void testResolveMessageWithArgs() {
context.addMessage(new MessageBuilder().error().source(this).code("argmessage").arg("Keith").defaultText(
"Hello world fallback!").build());
context.addMessage(new MessageBuilder().error().source(this).code("argmessage").arg("Keith")
.defaultText("Hello world fallback!").build());
Message[] messages = context.getAllMessages();
assertEquals(1, messages.length);
assertEquals("Hello world Keith!", messages[0].getText());

View File

@@ -80,7 +80,7 @@ public class MessageContextErrorsTests extends TestCase {
}
public void testAddAllErrors() {
MapBindingResult result = new MapBindingResult(new HashMap(), "object");
MapBindingResult result = new MapBindingResult(new HashMap<Object, Object>(), "object");
result.reject("bar", new Object[] { "boop" }, null);
result.rejectValue("field", "bar", new Object[] { "boop" }, null);
errors.addAllErrors(result);

View File

@@ -67,7 +67,7 @@ public class MethodInvokerTests extends TestCase {
assertEquals(Boolean.TRUE, methodInvoker.invoke(method, new TestObject(), null));
}
private static class TestObject {
static class TestObject {
public void test() {
throw new IllegalArgumentException("just testing");
@@ -82,7 +82,7 @@ public class MethodInvokerTests extends TestCase {
}
}
private static class Bean {
static class Bean {
String value;
}
}

View File

@@ -59,7 +59,7 @@ public class MethodKeyTests extends TestCase {
new MethodKey(File.class, "listFiles", new Class[] { null });
}
private static final Method safeGetMethod(Class type, String name, Class[] argTypes) {
private static final Method safeGetMethod(Class<?> type, String name, Class<?>[] argTypes) {
try {
return type.getMethod(name, argTypes);
} catch (NoSuchMethodException e) {