Skip to content

Commit a3e7848

Browse files
committed
Clean up warnings and tests in spring-core
1 parent 9ab4062 commit a3e7848

16 files changed

+92
-96
lines changed

spring-core/src/main/java/org/springframework/core/env/AbstractEnvironment.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -364,7 +364,7 @@ public MutablePropertySources getPropertySources() {
364364
}
365365

366366
@Override
367-
@SuppressWarnings("unchecked")
367+
@SuppressWarnings({ "unchecked", "rawtypes" })
368368
public Map<String, Object> getSystemEnvironment() {
369369
if (suppressGetenvAccess()) {
370370
return Collections.emptyMap();
@@ -408,7 +408,7 @@ protected boolean suppressGetenvAccess() {
408408
}
409409

410410
@Override
411-
@SuppressWarnings("unchecked")
411+
@SuppressWarnings({ "unchecked", "rawtypes" })
412412
public Map<String, Object> getSystemProperties() {
413413
try {
414414
return (Map) System.getProperties();

spring-core/src/main/java/org/springframework/util/concurrent/ListenableFutureCallbackRegistry.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ public void addSuccessCallback(SuccessCallback<? super T> callback) {
9191
* @param callback the failure callback to add
9292
* @since 4.1
9393
*/
94-
@SuppressWarnings("unchecked")
9594
public void addFailureCallback(FailureCallback callback) {
9695
Assert.notNull(callback, "'callback' must not be null");
9796
synchronized (this.mutex) {

spring-core/src/test/java/org/springframework/core/BridgeMethodResolverTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -42,6 +42,7 @@
4242
* @author Juergen Hoeller
4343
* @author Chris Beams
4444
*/
45+
@SuppressWarnings("rawtypes")
4546
public class BridgeMethodResolverTests {
4647

4748
private static TypeVariable<?> findTypeVariable(Class<?> clazz, String name) {

spring-core/src/test/java/org/springframework/core/ExceptionDepthComparatorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -26,6 +26,7 @@
2626
* @author Juergen Hoeller
2727
* @author Chris Shepperd
2828
*/
29+
@SuppressWarnings("unchecked")
2930
public class ExceptionDepthComparatorTests {
3031

3132
@Test

spring-core/src/test/java/org/springframework/core/GenericTypeResolverTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
* @author Juergen Hoeller
3737
* @author Sam Brannen
3838
*/
39+
@SuppressWarnings({ "unchecked", "rawtypes" })
3940
public class GenericTypeResolverTests {
4041

4142
@Test
@@ -160,15 +161,15 @@ public void getGenericsOnArrayFromParamCannotBeResolved() throws Exception {
160161
MethodParameter methodParameter = MethodParameter.forMethodOrConstructor(
161162
WithArrayBase.class.getDeclaredMethod("array", Object[].class), 0);
162163
Class<?> resolved = GenericTypeResolver.resolveParameterType(methodParameter, WithArray.class);
163-
assertThat(resolved, equalTo((Class) Object[].class));
164+
assertThat(resolved, equalTo((Class<?>) Object[].class));
164165
}
165166

166167
@Test
167168
public void getGenericsOnArrayFromReturnCannotBeResolved() throws Exception {
168169
// SPR-11044
169170
Class<?> resolved = GenericTypeResolver.resolveReturnType(
170171
WithArrayBase.class.getDeclaredMethod("array", Object[].class), WithArray.class);
171-
assertThat(resolved, equalTo((Class) Object[].class));
172+
assertThat(resolved, equalTo((Class<?>) Object[].class));
172173
}
173174

174175
@Test
@@ -214,7 +215,6 @@ public Object object() {
214215
return null;
215216
}
216217

217-
@SuppressWarnings("rawtypes")
218218
public MyInterfaceType raw() {
219219
return null;
220220
}

spring-core/src/test/java/org/springframework/core/convert/support/CollectionToCollectionConverterTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -343,7 +343,7 @@ public static enum MyEnum {A, B, C}
343343

344344
public List<String> strings;
345345

346-
public List list = Collections.emptyList();
346+
public List<?> list = Collections.emptyList();
347347

348348
public Collection<?> wildcardCollection = Collections.emptyList();
349349

spring-core/src/test/java/org/springframework/core/convert/support/MapToMapConverterTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -278,6 +278,7 @@ public static enum MyEnum {A, B, C}
278278

279279
public MultiValueMap<String, String> multiValueMapTarget;
280280

281+
@SuppressWarnings("rawtypes")
281282
public Map notGenericMapSource;
282283

283284
public EnumMap<MyEnum, Integer> enumMap;

spring-core/src/test/java/org/springframework/core/style/ToStringCreatorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -30,6 +30,7 @@
3030
/**
3131
* @author Keith Donald
3232
*/
33+
@SuppressWarnings({ "rawtypes", "unchecked" })
3334
public class ToStringCreatorTests extends TestCase {
3435

3536
private SomeObject s1, s2, s3;
Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2007 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -17,29 +17,27 @@
1717

1818
import java.lang.reflect.Method;
1919

20-
import junit.framework.TestCase;
21-
2220
import org.springframework.util.ClassUtils;
2321
import org.springframework.util.ReflectionUtils;
2422

23+
import static org.junit.Assert.*;
24+
2525
/**
26-
*
2726
* @author Ramnivas Laddad
28-
*
27+
* @author Sam Brannen
2928
*/
30-
public class ClassloadingAssertions {
31-
public static boolean isClassLoaded(String className) {
29+
abstract class ClassloadingAssertions {
30+
31+
private static boolean isClassLoaded(String className) {
3232
ClassLoader cl = ClassUtils.getDefaultClassLoader();
33-
Method findLoadeClassMethod = ReflectionUtils.findMethod(cl.getClass(), "findLoadedClass", new Class[]{String.class});
34-
findLoadeClassMethod.setAccessible(true);
35-
Class loadedClass = (Class)ReflectionUtils.invokeMethod(findLoadeClassMethod, cl, new Object[]{className});
33+
Method findLoadeClassMethod = ReflectionUtils.findMethod(cl.getClass(), "findLoadedClass", new Class[] { String.class });
34+
ReflectionUtils.makeAccessible(findLoadeClassMethod);
35+
Class<?> loadedClass = (Class<?>) ReflectionUtils.invokeMethod(findLoadeClassMethod, cl, new Object[] { className });
3636
return loadedClass != null;
3737
}
3838

39-
public static void assertClassLoaded(String className) {
40-
}
41-
4239
public static void assertClassNotLoaded(String className) {
43-
TestCase.assertFalse("Class shouldn't have been loaded", isClassLoaded(className));
40+
assertFalse("Class [" + className + "] should not have been loaded", isClassLoaded(className));
4441
}
42+
4543
}

spring-core/src/test/java/org/springframework/util/AutoPopulatingListTests.java

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2015 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,29 +18,35 @@
1818

1919
import java.util.LinkedList;
2020

21-
import junit.framework.TestCase;
21+
import org.junit.Test;
2222

2323
import org.springframework.tests.sample.objects.TestObject;
2424

25+
import static org.junit.Assert.*;
26+
2527
/**
2628
* @author Rob Harrop
2729
* @author Juergen Hoeller
2830
*/
29-
public class AutoPopulatingListTests extends TestCase {
31+
public class AutoPopulatingListTests {
3032

31-
public void testWithClass() throws Exception {
33+
@Test
34+
public void withClass() throws Exception {
3235
doTestWithClass(new AutoPopulatingList<Object>(TestObject.class));
3336
}
3437

35-
public void testWithClassAndUserSuppliedBackingList() throws Exception {
38+
@Test
39+
public void withClassAndUserSuppliedBackingList() throws Exception {
3640
doTestWithClass(new AutoPopulatingList<Object>(new LinkedList<Object>(), TestObject.class));
3741
}
3842

39-
public void testWithElementFactory() throws Exception {
43+
@Test
44+
public void withElementFactory() throws Exception {
4045
doTestWithElementFactory(new AutoPopulatingList<Object>(new MockElementFactory()));
4146
}
4247

43-
public void testWithElementFactoryAndUserSuppliedBackingList() throws Exception {
48+
@Test
49+
public void withElementFactoryAndUserSuppliedBackingList() throws Exception {
4450
doTestWithElementFactory(new AutoPopulatingList<Object>(new LinkedList<Object>(), new MockElementFactory()));
4551
}
4652

@@ -76,13 +82,14 @@ private void doTestWithElementFactory(AutoPopulatingList<Object> list) {
7682
}
7783
}
7884

79-
public void testSerialization() throws Exception {
85+
@Test
86+
public void serialization() throws Exception {
8087
AutoPopulatingList<?> list = new AutoPopulatingList<Object>(TestObject.class);
8188
assertEquals(list, SerializationTestUtils.serializeAndDeserialize(list));
8289
}
8390

8491

85-
private static class MockElementFactory implements AutoPopulatingList.ElementFactory {
92+
private static class MockElementFactory implements AutoPopulatingList.ElementFactory<Object> {
8693

8794
@Override
8895
public Object createElement(int index) {

0 commit comments

Comments
 (0)