提交 8d2e125e 编写于 作者: C Chris Beams

Fix [rawtypes] compiler warnings

 - Suppress rawtypes warnings for src/main
 - Enable rawtypes warnings for src/test

This commit attempts to to resolve all rawtypes problems across tests as
aggressively as possible, i.e. without regard for binary compatibility,
whereas main sources must be treated much more cautiously with an eye
toward compatibility.
上级 4d97ff24
......@@ -106,6 +106,7 @@ public final class MethodLocatingFactoryBeanTests {
}
@Test
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testSunnyDayPath() throws Exception {
expect((Class) beanFactory.getType(BEAN_NAME)).andReturn(String.class);
replay(beanFactory);
......@@ -121,6 +122,7 @@ public final class MethodLocatingFactoryBeanTests {
}
@Test(expected=IllegalArgumentException.class)
@SuppressWarnings({ "unchecked", "rawtypes" })
public void testWhereMethodCannotBeResolved() {
expect((Class) beanFactory.getType(BEAN_NAME)).andReturn(String.class);
replay(beanFactory);
......
......@@ -120,7 +120,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testNoInterceptorsAndNoTarget() {
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
// Add no interceptors
try {
AopProxy aop = createAopProxy(pc);
......@@ -418,7 +418,7 @@ public abstract class AbstractAopProxyTests {
return s;
}
};
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
if (context) {
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
}
......@@ -445,7 +445,7 @@ public abstract class AbstractAopProxyTests {
TestBean raw = new OwnSpouse();
ProxyCreatorSupport pc = new ProxyCreatorSupport();
pc.setInterfaces(new Class[] {ITestBean.class});
pc.setInterfaces(new Class<?>[] {ITestBean.class});
pc.setTarget(raw);
ITestBean tb = (ITestBean) createProxy(pc);
......@@ -461,7 +461,7 @@ public abstract class AbstractAopProxyTests {
throw expectedException;
}
};
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
pc.addAdvice(mi);
......@@ -495,7 +495,7 @@ public abstract class AbstractAopProxyTests {
throw unexpectedException;
}
};
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
pc.addAdvice(mi);
......@@ -527,7 +527,7 @@ public abstract class AbstractAopProxyTests {
throw unexpectedException;
}
};
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
pc.addAdvice(mi);
......@@ -555,7 +555,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testTargetCanGetInvocationEvenIfNoAdviceChain() throws Throwable {
NeedsToSeeProxy target = new NeedsToSeeProxy();
AdvisedSupport pc = new AdvisedSupport(new Class[] {INeedsToSeeProxy.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {INeedsToSeeProxy.class});
pc.setTarget(target);
pc.setExposeProxy(true);
......@@ -570,7 +570,7 @@ public abstract class AbstractAopProxyTests {
public void testTargetCanGetInvocation() throws Throwable {
final InvocationCheckExposedInvocationTestBean expectedTarget = new InvocationCheckExposedInvocationTestBean();
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class, IOther.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class, IOther.class});
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
TrapTargetInterceptor tii = new TrapTargetInterceptor() {
public Object invoke(MethodInvocation invocation) throws Throwable {
......@@ -615,7 +615,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testMixinWithIntroductionAdvisor() throws Throwable {
TestBean tb = new TestBean();
ProxyFactory pc = new ProxyFactory(new Class[] {ITestBean.class});
ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
pc.addAdvisor(new LockMixinAdvisor());
pc.setTarget(tb);
......@@ -625,7 +625,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testMixinWithIntroductionInfo() throws Throwable {
TestBean tb = new TestBean();
ProxyFactory pc = new ProxyFactory(new Class[] {ITestBean.class});
ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
// We don't use an IntroductionAdvisor, we can just add an advice that implements IntroductionInfo
pc.addAdvice(new LockMixin());
pc.setTarget(tb);
......@@ -664,7 +664,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testReplaceArgument() throws Throwable {
TestBean tb = new TestBean();
ProxyFactory pc = new ProxyFactory(new Class[] {ITestBean.class});
ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
pc.setTarget(tb);
pc.addAdvisor(new StringSetterNullReplacementAdvice());
......@@ -952,7 +952,7 @@ public abstract class AbstractAopProxyTests {
public void testProxyConfigString() {
TestBean target = new TestBean();
ProxyFactory pc = new ProxyFactory(target);
pc.setInterfaces(new Class[] {ITestBean.class});
pc.setInterfaces(new Class<?>[] {ITestBean.class});
pc.addAdvice(new NopInterceptor());
MethodBeforeAdvice mba = new CountingBeforeAdvice();
Advisor advisor = new DefaultPointcutAdvisor(new NameMatchMethodPointcut(), mba);
......@@ -968,7 +968,7 @@ public abstract class AbstractAopProxyTests {
public void testCanPreventCastToAdvisedUsingOpaque() {
TestBean target = new TestBean();
ProxyFactory pc = new ProxyFactory(target);
pc.setInterfaces(new Class[] {ITestBean.class});
pc.setInterfaces(new Class<?>[] {ITestBean.class});
pc.addAdvice(new NopInterceptor());
CountingBeforeAdvice mba = new CountingBeforeAdvice();
Advisor advisor = new DefaultPointcutAdvisor(new NameMatchMethodPointcut().addMethodName("setAge"), mba);
......@@ -1069,7 +1069,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testDynamicMethodPointcutThatAlwaysAppliesStatically() throws Throwable {
TestBean tb = new TestBean();
ProxyFactory pc = new ProxyFactory(new Class[] {ITestBean.class});
ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
TestDynamicPointcutAdvice dp = new TestDynamicPointcutAdvice(new NopInterceptor(), "getAge");
pc.addAdvisor(dp);
pc.setTarget(tb);
......@@ -1085,7 +1085,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testDynamicMethodPointcutThatAppliesStaticallyOnlyToSetters() throws Throwable {
TestBean tb = new TestBean();
ProxyFactory pc = new ProxyFactory(new Class[] {ITestBean.class});
ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
// Could apply dynamically to getAge/setAge but not to getName
TestDynamicPointcutForSettersOnly dp = new TestDynamicPointcutForSettersOnly(new NopInterceptor(), "Age");
pc.addAdvisor(dp);
......@@ -1107,7 +1107,7 @@ public abstract class AbstractAopProxyTests {
@Test
public void testStaticMethodPointcut() throws Throwable {
TestBean tb = new TestBean();
ProxyFactory pc = new ProxyFactory(new Class[] {ITestBean.class});
ProxyFactory pc = new ProxyFactory(new Class<?>[] {ITestBean.class});
NopInterceptor di = new NopInterceptor();
TestStaticPointcutAdvice sp = new TestStaticPointcutAdvice(di, "getAge");
pc.addAdvisor(sp);
......@@ -1353,7 +1353,7 @@ public abstract class AbstractAopProxyTests {
return invocation.proceed();
}
};
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
MapAwareMethodInterceptor mami1 = new MapAwareMethodInterceptor(new HashMap<String, String>(), new HashMap<String, String>());
Map<String, String> firstValuesToAdd = new HashMap<String, String>();
firstValuesToAdd.put("test", "");
......
......@@ -87,7 +87,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
@Test
public void testNoTarget() {
AdvisedSupport pc = new AdvisedSupport(new Class[]{ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[]{ITestBean.class});
pc.addAdvice(new NopInterceptor());
try {
AopProxy aop = createAopProxy(pc);
......@@ -104,7 +104,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
ProtectedMethodTestBean bean = new ProtectedMethodTestBean();
mockTargetSource.setTarget(bean);
AdvisedSupport as = new AdvisedSupport(new Class[]{});
AdvisedSupport as = new AdvisedSupport(new Class<?>[]{});
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
AopProxy aop = new CglibAopProxy(as);
......@@ -158,7 +158,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
CglibTestBean bean = new CglibTestBean();
bean.setName("Rob Harrop");
AdvisedSupport as = new AdvisedSupport(new Class[]{});
AdvisedSupport as = new AdvisedSupport(new Class<?>[]{});
as.setTarget(bean);
as.addAdvice(new NopInterceptor());
AopProxy aop = new CglibAopProxy(as);
......@@ -174,7 +174,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
CglibTestBean target = new CglibTestBean();
target.setName("Rob Harrop");
AdvisedSupport pc = new AdvisedSupport(new Class[]{});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[]{});
pc.setFrozen(true);
pc.setTarget(target);
......@@ -202,7 +202,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
}
private ITestBean getAdvisedProxy(TestBean target) {
ProxyFactory pf = new ProxyFactory(new Class[]{ITestBean.class});
ProxyFactory pf = new ProxyFactory(new Class<?>[]{ITestBean.class});
pf.setProxyTargetClass(true);
MethodInterceptor advice = new NopInterceptor();
......@@ -241,7 +241,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
}
private ITestBean getIntroductionAdvisorProxy(TestBean target) {
ProxyFactory pf = new ProxyFactory(new Class[]{ITestBean.class});
ProxyFactory pf = new ProxyFactory(new Class<?>[]{ITestBean.class});
pf.setProxyTargetClass(true);
pf.addAdvisor(new LockMixinAdvisor());
......@@ -258,11 +258,11 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
target.reset();
mockTargetSource.setTarget(target);
AdvisedSupport pc = new AdvisedSupport(new Class[]{});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[]{});
pc.setTargetSource(mockTargetSource);
CglibAopProxy aop = new CglibAopProxy(pc);
aop.setConstructorArguments(new Object[] {"Rob Harrop", new Integer(22)},
new Class[] {String.class, int.class});
new Class<?>[] {String.class, int.class});
NoArgCtorTestBean proxy = (NoArgCtorTestBean) aop.getProxy();
proxy = (NoArgCtorTestBean) aop.getProxy();
......@@ -275,7 +275,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
ITestBean target = new TestBean();
mockTargetSource.setTarget(target);
AdvisedSupport as = new AdvisedSupport(new Class[]{});
AdvisedSupport as = new AdvisedSupport(new Class<?>[]{});
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
CglibAopProxy cglib = new CglibAopProxy(as);
......@@ -283,7 +283,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
ITestBean proxy1 = (ITestBean) cglib.getProxy();
mockTargetSource.setTarget(proxy1);
as = new AdvisedSupport(new Class[]{});
as = new AdvisedSupport(new Class<?>[]{});
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
cglib = new CglibAopProxy(as);
......@@ -296,7 +296,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
ITestBean target = new TestBean();
mockTargetSource.setTarget(target);
AdvisedSupport as = new AdvisedSupport(new Class[]{});
AdvisedSupport as = new AdvisedSupport(new Class<?>[]{});
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
as.addInterface(Serializable.class);
......@@ -305,7 +305,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
ITestBean proxy1 = (ITestBean) cglib.getProxy();
mockTargetSource.setTarget(proxy1);
as = new AdvisedSupport(new Class[]{});
as = new AdvisedSupport(new Class<?>[]{});
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
cglib = new CglibAopProxy(as);
......@@ -319,7 +319,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
ExceptionThrower bean = new ExceptionThrower();
mockTargetSource.setTarget(bean);
AdvisedSupport as = new AdvisedSupport(new Class[]{});
AdvisedSupport as = new AdvisedSupport(new Class<?>[]{});
as.setTargetSource(mockTargetSource);
as.addAdvice(new NopInterceptor());
AopProxy aop = new CglibAopProxy(as);
......
......@@ -66,7 +66,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
public void testProxyIsJustInterface() throws Throwable {
TestBean raw = new TestBean();
raw.setAge(32);
AdvisedSupport pc = new AdvisedSupport(new Class[] {ITestBean.class});
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class});
pc.setTarget(raw);
JdkDynamicAopProxy aop = new JdkDynamicAopProxy(pc);
......@@ -80,7 +80,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
int age = 25;
MethodInterceptor mi = createMock(MethodInterceptor.class);
AdvisedSupport pc = new AdvisedSupport(new Class[] { ITestBean.class });
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] { ITestBean.class });
pc.addAdvice(mi);
AopProxy aop = createAopProxy(pc);
......@@ -101,7 +101,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
}
};
AdvisedSupport pc = new AdvisedSupport(new Class[] { ITestBean.class, IOther.class });
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] { ITestBean.class, IOther.class });
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
TrapTargetInterceptor tii = new TrapTargetInterceptor() {
public Object invoke(MethodInvocation invocation) throws Throwable {
......@@ -130,7 +130,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
public void testProxyNotWrappedIfIncompatible() {
FooBar bean = new FooBar();
ProxyCreatorSupport as = new ProxyCreatorSupport();
as.setInterfaces(new Class[] {Foo.class});
as.setInterfaces(new Class<?>[] {Foo.class});
as.setTarget(bean);
Foo proxy = (Foo) createProxy(as);
......@@ -140,7 +140,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
}
public void testEqualsAndHashCodeDefined() throws Exception {
AdvisedSupport as = new AdvisedSupport(new Class[]{Named.class});
AdvisedSupport as = new AdvisedSupport(new Class<?>[]{Named.class});
as.setTarget(new Person());
JdkDynamicAopProxy aopProxy = new JdkDynamicAopProxy(as);
Named proxy = (Named) aopProxy.getProxy();
......
......@@ -539,7 +539,7 @@ public final class ProxyFactoryBeanTests {
// 2 globals + 2 explicit
assertEquals("Have 2 globals and 2 explicit advisors", 3, pfb.getAdvisors().length);
ApplicationListener l = (ApplicationListener) factory.getBean("validGlobals");
ApplicationListener<?> l = (ApplicationListener<?>) factory.getBean("validGlobals");
agi = (AddedGlobalInterface) l;
assertTrue(agi.globalsAdded() == -1);
......@@ -760,7 +760,7 @@ public final class ProxyFactoryBeanTests {
}
public Class<?>[] getInterfaces() {
return new Class[] { AddedGlobalInterface.class };
return new Class<?>[] { AddedGlobalInterface.class };
}
public boolean isPerInstance() {
......
......@@ -126,7 +126,7 @@ public class ScopedProxyTests {
assertTrue(scope.getMap().containsKey("scopedTarget.scopedList"));
assertEquals(ArrayList.class, scope.getMap().get("scopedTarget.scopedList").getClass());
ArrayList deserialized = (ArrayList) SerializationTestUtils.serializeAndDeserialize(tb.getFriends());
ArrayList<?> deserialized = (ArrayList<?>) SerializationTestUtils.serializeAndDeserialize(tb.getFriends());
assertNotNull(deserialized);
assertTrue(AopUtils.isCglibProxy(deserialized));
assertTrue(deserialized.contains("myFriend"));
......
......@@ -34,17 +34,17 @@ public class IndexedTestBean {
private TestBean[] array;
private Collection collection;
private Collection<?> collection;
private List list;
private List<TestBean> list;
private Set set;
private Set<TestBean> set;
private SortedSet sortedSet;
private SortedSet<?> sortedSet;
private Map map;
private Map<String, Object> map;
private SortedMap sortedMap;
private SortedMap<?, ?> sortedMap;
public IndexedTestBean() {
......@@ -69,17 +69,17 @@ public class IndexedTestBean {
TestBean tbX = new TestBean("nameX", 0);
TestBean tbY = new TestBean("nameY", 0);
this.array = new TestBean[] {tb0, tb1};
this.list = new ArrayList();
this.list = new ArrayList<>();
this.list.add(tb2);
this.list.add(tb3);
this.set = new TreeSet();
this.set = new TreeSet<>();
this.set.add(tb6);
this.set.add(tb7);
this.map = new HashMap();
this.map = new HashMap<>();
this.map.put("key1", tb4);
this.map.put("key2", tb5);
this.map.put("key.3", tb5);
List list = new ArrayList();
List<Object> list = new ArrayList<>();
list.add(tbX);
list.add(tbY);
this.map.put("key4", list);
......@@ -94,51 +94,52 @@ public class IndexedTestBean {
this.array = array;
}
public Collection getCollection() {
public Collection<?> getCollection() {
return collection;
}
public void setCollection(Collection collection) {
public void setCollection(Collection<?> collection) {
this.collection = collection;
}
public List getList() {
public List<TestBean> getList() {
return list;
}
public void setList(List list) {
public void setList(List<TestBean> list) {
this.list = list;
}
public Set getSet() {
public Set<TestBean> getSet() {
return set;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
public void setSet(Set set) {
this.set = set;
}
public SortedSet getSortedSet() {
public SortedSet<?> getSortedSet() {
return sortedSet;
}
public void setSortedSet(SortedSet sortedSet) {
public void setSortedSet(SortedSet<?> sortedSet) {
this.sortedSet = sortedSet;
}
public Map getMap() {
public Map<String, Object> getMap() {
return map;
}
public void setMap(Map map) {
public void setMap(Map<String, Object> map) {
this.map = map;
}
public SortedMap getSortedMap() {
public SortedMap<?, ?> getSortedMap() {
return sortedMap;
}
public void setSortedMap(SortedMap sortedMap) {
public void setSortedMap(SortedMap<?, ?> sortedMap) {
this.sortedMap = sortedMap;
}
......
......@@ -40,7 +40,7 @@ import org.springframework.util.ObjectUtils;
* @author Juergen Hoeller
* @since 15 April 2001
*/
public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable {
public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOther, Comparable<Object> {
private String beanName;
......@@ -70,13 +70,13 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
private Float myFloat = new Float(0.0);
private Collection friends = new LinkedList();
private Collection<? super Object> friends = new LinkedList<>();
private Set someSet = new HashSet();
private Set<?> someSet = new HashSet<>();
private Map someMap = new HashMap();
private Map<?, ?> someMap = new HashMap<>();
private List someList = new ArrayList();
private List<?> someList = new ArrayList<>();
private Properties someProperties = new Properties();
......@@ -94,9 +94,9 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
private Boolean someBoolean;
private List otherColours;
private List<?> otherColours;
private List pets;
private List<?> pets;
public TestBean() {
......@@ -120,15 +120,15 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.someProperties = someProperties;
}
public TestBean(List someList) {
public TestBean(List<?> someList) {
this.someList = someList;
}
public TestBean(Set someSet) {
public TestBean(Set<?> someSet) {
this.someSet = someSet;
}
public TestBean(Map someMap) {
public TestBean(Map<?, ?> someMap) {
this.someMap = someMap;
}
......@@ -262,35 +262,35 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.myFloat = myFloat;
}
public Collection getFriends() {
public Collection<? super Object> getFriends() {
return friends;
}
public void setFriends(Collection friends) {
public void setFriends(Collection<? super Object> friends) {
this.friends = friends;
}
public Set getSomeSet() {
public Set<?> getSomeSet() {
return someSet;
}
public void setSomeSet(Set someSet) {
public void setSomeSet(Set<?> someSet) {
this.someSet = someSet;
}
public Map getSomeMap() {
public Map<?, ?> getSomeMap() {
return someMap;
}
public void setSomeMap(Map someMap) {
public void setSomeMap(Map<?, ?> someMap) {
this.someMap = someMap;
}
public List getSomeList() {
public List<?> getSomeList() {
return someList;
}
public void setSomeList(List someList) {
public void setSomeList(List<?> someList) {
this.someList = someList;
}
......@@ -350,19 +350,19 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.nestedIndexedBean = nestedIndexedBean;
}
public List getOtherColours() {
public List<?> getOtherColours() {
return otherColours;
}
public void setOtherColours(List otherColours) {
public void setOtherColours(List<?> otherColours) {
this.otherColours = otherColours;
}
public List getPets() {
public List<?> getPets() {
return pets;
}
public void setPets(List pets) {
public void setPets(List<?> pets) {
this.pets = pets;
}
......
......@@ -32,7 +32,7 @@ import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
* @since 10.03.2003
*/
public class DummyFactory
implements FactoryBean, BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean {
implements FactoryBean<Object>, BeanNameAware, BeanFactoryAware, InitializingBean, DisposableBean {
public static final String SINGLETON_NAME = "Factory singleton";
......@@ -158,7 +158,7 @@ public class DummyFactory
}
}
public Class getObjectType() {
public Class<TestBean> getObjectType() {
return TestBean.class;
}
......
......@@ -28,34 +28,34 @@ import java.util.Set;
*/
public class HasMap {
private Map map;
private Map<?, ?> map;
private Set set;
private Set<?> set;
private Properties props;
private Object[] objectArray;
private Class[] classArray;
private Class<?>[] classArray;
private Integer[] intArray;
private HasMap() {
}
public Map getMap() {
public Map<?, ?> getMap() {
return map;
}
public void setMap(Map map) {
public void setMap(Map<?, ?> map) {
this.map = map;
}
public Set getSet() {
public Set<?> getSet() {
return set;
}
public void setSet(Set set) {
public void setSet(Set<?> set) {
this.set = set;
}
......@@ -75,11 +75,11 @@ public class HasMap {
this.objectArray = objectArray;
}
public Class[] getClassArray() {
public Class<?>[] getClassArray() {
return classArray;
}
public void setClassArray(Class[] classArray) {
public void setClassArray(Class<?>[] classArray) {
this.classArray = classArray;
}
......
......@@ -27,7 +27,7 @@ public class TestBean {
private String name;
private List list;
private List<?> list;
private Object objRef;
......@@ -48,14 +48,14 @@ public class TestBean {
/**
* @return Returns the list.
*/
public List getList() {
public List<?> getList() {
return list;
}
/**
* @param list The list to set.
*/
public void setList(List list) {
public void setList(List<?> list) {
this.list = list;
}
......
......@@ -31,20 +31,20 @@ import org.springframework.beans.factory.ObjectFactory;
@SuppressWarnings("serial")
public class SimpleMapScope implements Scope, Serializable {
private final Map map = new HashMap();
private final Map<String, Object> map = new HashMap<String, Object>();
private final List callbacks = new LinkedList();
private final List<Runnable> callbacks = new LinkedList<Runnable>();
public SimpleMapScope() {
}
public final Map getMap() {
public final Map<String, Object> getMap() {
return this.map;
}
public Object get(String name, ObjectFactory objectFactory) {
public Object get(String name, ObjectFactory<?> objectFactory) {
synchronized (this.map) {
Object scopedObject = this.map.get(name);
if (scopedObject == null) {
......
......@@ -31,20 +31,20 @@ import org.springframework.core.CollectionFactory;
*/
public class CollectingReaderEventListener implements ReaderEventListener {
private final List defaults = new LinkedList();
private final List<DefaultsDefinition> defaults = new LinkedList<DefaultsDefinition>();
private final Map componentDefinitions = CollectionFactory.createLinkedMapIfPossible(8);
private final Map<String, ComponentDefinition> componentDefinitions = CollectionFactory.createLinkedMapIfPossible(8);
private final Map aliasMap = CollectionFactory.createLinkedMapIfPossible(8);
private final Map<String, List<AliasDefinition>> aliasMap = CollectionFactory.createLinkedMapIfPossible(8);
private final List imports = new LinkedList();
private final List<ImportDefinition> imports = new LinkedList<ImportDefinition>();
public void defaultsRegistered(DefaultsDefinition defaultsDefinition) {
this.defaults.add(defaultsDefinition);
}
public List getDefaults() {
public List<DefaultsDefinition> getDefaults() {
return Collections.unmodifiableList(this.defaults);
}
......@@ -53,25 +53,25 @@ public class CollectingReaderEventListener implements ReaderEventListener {
}
public ComponentDefinition getComponentDefinition(String name) {
return (ComponentDefinition) this.componentDefinitions.get(name);
return this.componentDefinitions.get(name);
}
public ComponentDefinition[] getComponentDefinitions() {
Collection collection = this.componentDefinitions.values();
return (ComponentDefinition[]) collection.toArray(new ComponentDefinition[collection.size()]);
Collection<ComponentDefinition> collection = this.componentDefinitions.values();
return collection.toArray(new ComponentDefinition[collection.size()]);
}
public void aliasRegistered(AliasDefinition aliasDefinition) {
List aliases = (List) this.aliasMap.get(aliasDefinition.getBeanName());
List<AliasDefinition> aliases = this.aliasMap.get(aliasDefinition.getBeanName());
if(aliases == null) {
aliases = new ArrayList();
aliases = new ArrayList<AliasDefinition>();
this.aliasMap.put(aliasDefinition.getBeanName(), aliases);
}
aliases.add(aliasDefinition);
}
public List getAliases(String beanName) {
List aliases = (List) this.aliasMap.get(beanName);
public List<?> getAliases(String beanName) {
List<?> aliases = this.aliasMap.get(beanName);
return aliases == null ? null : Collections.unmodifiableList(aliases);
}
......@@ -79,7 +79,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
this.imports.add(importDefinition);
}
public List getImports() {
public List<ImportDefinition> getImports() {
return Collections.unmodifiableList(this.imports);
}
......
......@@ -24,7 +24,7 @@ import java.util.Map;
* @author Thomas Risberg
* @author Juergen Hoeller
*/
public class BeanThatListens implements ApplicationListener {
public class BeanThatListens implements ApplicationListener<ApplicationEvent> {
private BeanThatBroadcasts beanThatBroadcasts;
......@@ -36,7 +36,7 @@ public class BeanThatListens implements ApplicationListener {
public BeanThatListens(BeanThatBroadcasts beanThatBroadcasts) {
this.beanThatBroadcasts = beanThatBroadcasts;
Map beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class);
Map<?, BeanThatListens> beans = beanThatBroadcasts.applicationContext.getBeansOfType(BeanThatListens.class);
if (!beans.isEmpty()) {
throw new IllegalStateException("Shouldn't have found any BeanThatListens instances");
}
......
......@@ -22,7 +22,7 @@ package org.springframework.context;
* @author Rod Johnson
* @since January 21, 2001
*/
public class TestListener implements ApplicationListener {
public class TestListener implements ApplicationListener<ApplicationEvent> {
private int eventCount;
......
......@@ -206,7 +206,7 @@ public class CommonAnnotationBeanPostProcessorTests {
bf.registerBeanDefinition("testBean4", new RootBeanDefinition(TestBean.class, false));
bf.registerResolvableDependency(BeanFactory.class, bf);
bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory() {
bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() {
public Object getObject() throws BeansException {
return new NestedTestBean();
}
......
......@@ -42,7 +42,7 @@ public class SimpleConfigTests {
String value = fooService.foo(1);
assertEquals("bar", value);
Future future = fooService.asyncFoo(1);
Future<?> future = fooService.asyncFoo(1);
assertTrue(future instanceof FutureTask);
assertEquals("bar", future.get());
......
......@@ -230,7 +230,7 @@ public class ConfigurationClassProcessingTests {
public @Bean Object stringBean() {
return "foo";
}
public @Bean FactoryBean factoryBean() {
public @Bean FactoryBean<?> factoryBean() {
ListFactoryBean fb = new ListFactoryBean();
fb.setSourceList(Arrays.asList("element1", "element2"));
return fb;
......
......@@ -47,7 +47,8 @@ public class ApplicationContextEventTests {
@Test
public void simpleApplicationEventMulticaster() {
ApplicationListener listener = EasyMock.createMock(ApplicationListener.class);
@SuppressWarnings("unchecked")
ApplicationListener<ApplicationEvent> listener = mock(ApplicationListener.class);
ApplicationEvent evt = new ContextClosedEvent(new StaticApplicationContext());
listener.onApplicationEvent(evt);
......@@ -73,11 +74,12 @@ public class ApplicationContextEventTests {
}
@Test
@SuppressWarnings("unchecked")
public void proxiedListeners() {
MyOrderedListener1 listener1 = new MyOrderedListener1();
MyOrderedListener2 listener2 = new MyOrderedListener2(listener1);
ApplicationListener proxy1 = (ApplicationListener) new ProxyFactory(listener1).getProxy();
ApplicationListener proxy2 = (ApplicationListener) new ProxyFactory(listener2).getProxy();
ApplicationListener<ApplicationEvent> proxy1 = (ApplicationListener<ApplicationEvent>) new ProxyFactory(listener1).getProxy();
ApplicationListener<ApplicationEvent> proxy2 = (ApplicationListener<ApplicationEvent>) new ProxyFactory(listener2).getProxy();
SimpleApplicationEventMulticaster smc = new SimpleApplicationEventMulticaster();
smc.addApplicationListener(proxy1);
......@@ -208,7 +210,7 @@ public class ApplicationContextEventTests {
}
public static class MyOrderedListener1 implements ApplicationListener, Ordered {
public static class MyOrderedListener1 implements ApplicationListener<ApplicationEvent>, Ordered {
public final Set<ApplicationEvent> seenEvents = new HashSet<ApplicationEvent>();
......@@ -248,7 +250,7 @@ public class ApplicationContextEventTests {
}
public static class MyNonSingletonListener implements ApplicationListener {
public static class MyNonSingletonListener implements ApplicationListener<ApplicationEvent> {
public static final Set<ApplicationEvent> seenEvents = new HashSet<ApplicationEvent>();
......
......@@ -138,13 +138,13 @@ public class EventPublicationInterceptorTests {
}
public static class FactoryBeanTestListener extends TestListener implements FactoryBean {
public static class FactoryBeanTestListener extends TestListener implements FactoryBean<Object> {
public Object getObject() throws Exception {
return "test";
}
public Class getObjectType() {
public Class<String> getObjectType() {
return String.class;
}
......
......@@ -63,7 +63,7 @@ public class LifecycleEventTests extends TestCase {
}
private static class LifecycleListener implements ApplicationListener {
private static class LifecycleListener implements ApplicationListener<ApplicationEvent> {
private ApplicationContext context;
......
......@@ -57,7 +57,7 @@ public class ApplicationContextExpressionTests {
AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
ac.getBeanFactory().registerScope("myScope", new Scope() {
public Object get(String name, ObjectFactory objectFactory) {
public Object get(String name, ObjectFactory<?> objectFactory) {
return objectFactory.getObject();
}
public Object remove(String name) {
......
......@@ -61,6 +61,7 @@ public class ConversionServiceFactoryBeanTests {
converters.add(new ConverterFactory<String, Bar>() {
public <T extends Bar> Converter<String, T> getConverter(Class<T> targetType) {
return new Converter<String, T> () {
@SuppressWarnings("unchecked")
public T convert(String source) {
return (T) new Bar();
}
......@@ -103,7 +104,7 @@ public class ConversionServiceFactoryBeanTests {
doTestConversionServiceInApplicationContext("conversionServiceWithResourceOverriding.xml", FileSystemResource.class);
}
private void doTestConversionServiceInApplicationContext(String fileName, Class resourceClass) {
private void doTestConversionServiceInApplicationContext(String fileName, Class<?> resourceClass) {
ApplicationContext ctx = new ClassPathXmlApplicationContext(fileName, getClass());
ResourceTestBean tb = ctx.getBean("resourceTestBean", ResourceTestBean.class);
assertTrue(resourceClass.isInstance(tb.getResource()));
......@@ -128,7 +129,7 @@ public class ConversionServiceFactoryBeanTests {
public static class ComplexConstructorArgument {
public ComplexConstructorArgument(Map<String, Class> map) {
public ComplexConstructorArgument(Map<String, Class<?>> map) {
assertTrue(!map.isEmpty());
assertTrue(map.keySet().iterator().next() instanceof String);
assertTrue(map.values().iterator().next() instanceof Class);
......
......@@ -692,7 +692,7 @@ public class DefaultLifecycleProcessorTests {
}
public static class DummySmartLifecycleFactoryBean implements FactoryBean, SmartLifecycle {
public static class DummySmartLifecycleFactoryBean implements FactoryBean<Object>, SmartLifecycle {
public boolean running = false;
......@@ -702,7 +702,7 @@ public class DefaultLifecycleProcessorTests {
return this.bean;
}
public Class getObjectType() {
public Class<?> getObjectType() {
return DummySmartLifecycleBean.class;
}
......
......@@ -8,13 +8,13 @@ import org.springframework.context.ApplicationListener;
* @author Juergen Hoeller
* @since 06.10.2004
*/
public class FactoryBeanAndApplicationListener implements FactoryBean, ApplicationListener {
public class FactoryBeanAndApplicationListener implements FactoryBean<String>, ApplicationListener<ApplicationEvent> {
public Object getObject() throws Exception {
public String getObject() throws Exception {
return "";
}
public Class getObjectType() {
public Class<String> getObjectType() {
return String.class;
}
......
......@@ -115,8 +115,8 @@ public class ResourceBundleMessageSourceTests extends TestCase {
if (alwaysUseMessageFormat) {
pvs.add("alwaysUseMessageFormat", Boolean.TRUE);
}
Class clazz = reloadable ?
(Class) ReloadableResourceBundleMessageSource.class : ResourceBundleMessageSource.class;
Class<?> clazz = reloadable ?
(Class<?>) ReloadableResourceBundleMessageSource.class : ResourceBundleMessageSource.class;
ac.registerSingleton("messageSource", clazz, pvs);
ac.refresh();
......
......@@ -30,7 +30,7 @@ public class Spr7283Tests {
@Test
public void testListWithInconsistentElementType() {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("spr7283.xml", getClass());
List list = ctx.getBean("list", List.class);
List<?> list = ctx.getBean("list", List.class);
assertEquals(2, list.size());
assertTrue(list.get(0) instanceof A);
assertTrue(list.get(1) instanceof B);
......
......@@ -45,7 +45,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
/** Run for each test */
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map m = new HashMap();
Map<String, String> m = new HashMap<String, String>();
m.put("name", "Roderick");
parent.registerPrototype("rod", TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
......
......@@ -41,7 +41,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes
/** Run for each test */
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map m = new HashMap();
Map<String, String> m = new HashMap<String, String>();
m.put("name", "Roderick");
parent.registerPrototype("rod", TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
......
......@@ -198,7 +198,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map m = new HashMap();
Map<String, String> m = new HashMap<String, String>();
m.put("name", "Roderick");
parent.registerPrototype("rod", org.springframework.beans.TestBean.class, new MutablePropertyValues(m));
m.put("name", "Albert");
......@@ -221,7 +221,7 @@ public class StaticMessageSourceTests extends AbstractApplicationContextTests {
sac.addListener(listener);
StaticMessageSource messageSource = sac.getStaticMessageSource();
Map usMessages = new HashMap(3);
Map<String, String> usMessages = new HashMap<String, String>(3);
usMessages.put("message.format.example1", MSG_TXT1_US);
usMessages.put("message.format.example2", MSG_TXT2_US);
usMessages.put("message.format.example3", MSG_TXT3_US);
......
......@@ -90,7 +90,7 @@ public class LocalSlsbInvokerInterceptorTests {
LocalSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
ProxyFactory pf = new ProxyFactory(new Class[] { BusinessMethods.class } );
ProxyFactory pf = new ProxyFactory(new Class<?>[] { BusinessMethods.class } );
pf.addAdvice(si);
BusinessMethods target = (BusinessMethods) pf.getProxy();
......@@ -113,7 +113,7 @@ public class LocalSlsbInvokerInterceptorTests {
LocalSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
ProxyFactory pf = new ProxyFactory(new Class[] { BusinessMethods.class } );
ProxyFactory pf = new ProxyFactory(new Class<?>[] { BusinessMethods.class } );
pf.addAdvice(si);
BusinessMethods target = (BusinessMethods) pf.getProxy();
......@@ -133,7 +133,7 @@ public class LocalSlsbInvokerInterceptorTests {
LocalSlsbInvokerInterceptor si = configuredInterceptor(mockContext, jndiName);
ProxyFactory pf = new ProxyFactory(new Class[] { LocalInterfaceWithBusinessMethods.class } );
ProxyFactory pf = new ProxyFactory(new Class<?>[] { LocalInterfaceWithBusinessMethods.class } );
pf.addAdvice(si);
LocalInterfaceWithBusinessMethods target = (LocalInterfaceWithBusinessMethods) pf.getProxy();
......
......@@ -79,7 +79,7 @@ public class SimpleRemoteSlsbInvokerInterceptorTests {
protected Object configuredProxy(SimpleRemoteSlsbInvokerInterceptor si, Class<?> ifc) throws NamingException {
si.afterPropertiesSet();
ProxyFactory pf = new ProxyFactory(new Class[] {ifc});
ProxyFactory pf = new ProxyFactory(new Class<?>[] {ifc});
pf.addAdvice(si);
return pf.getProxy();
}
......
......@@ -238,7 +238,7 @@ public final class MBeanExporterTests extends AbstractMBeanServerTests {
ProxyFactory factory = new ProxyFactory();
factory.setTarget(bean);
factory.addAdvice(new NopInterceptor());
factory.setInterfaces(new Class[] { IJmxTestBean.class });
factory.setInterfaces(new Class<?>[] { IJmxTestBean.class });
IJmxTestBean proxy = (IJmxTestBean) factory.getProxy();
String name = "bean:mmm=whatever";
......
......@@ -158,7 +158,7 @@ public abstract class AbstractMetadataAssemblerTests extends AbstractJmxAssemble
String objectName = "spring:bean=test,proxy=true";
Map beans = new HashMap();
Map<String, Object> beans = new HashMap<String, Object>();
beans.put(objectName, proxy);
exporter.setBeans(beans);
exporter.afterPropertiesSet();
......
......@@ -40,7 +40,7 @@ public class InterfaceBasedMBeanInfoAssemblerCustomTests extends AbstractJmxAsse
protected MBeanInfoAssembler getAssembler() {
InterfaceBasedMBeanInfoAssembler assembler = new InterfaceBasedMBeanInfoAssembler();
assembler.setManagedInterfaces(new Class[] {ICustomJmxBean.class});
assembler.setManagedInterfaces(new Class<?>[] {ICustomJmxBean.class});
return assembler;
}
......
......@@ -60,7 +60,7 @@ public class InterfaceBasedMBeanInfoAssemblerMappedTests extends AbstractJmxAsse
public void ignoreTestWithFallThrough() throws Exception {
InterfaceBasedMBeanInfoAssembler assembler =
getWithMapping("foobar", "org.springframework.jmx.export.assembler.ICustomJmxBean");
assembler.setManagedInterfaces(new Class[] {IAdditionalTestMethods.class});
assembler.setManagedInterfaces(new Class<?>[] {IAdditionalTestMethods.class});
ModelMBeanInfo inf = assembler.getMBeanInfo(getBean(), getObjectName());
MBeanAttributeInfo attr = inf.getAttribute("NickName");
......
......@@ -88,7 +88,7 @@ public class RmiSupportTests extends TestCase {
doTestRmiProxyFactoryBeanWithException(UnmarshalException.class);
}
private void doTestRmiProxyFactoryBeanWithException(Class exceptionClass) throws Exception {
private void doTestRmiProxyFactoryBeanWithException(Class<?> exceptionClass) throws Exception {
CountingRmiProxyFactoryBean factory = new CountingRmiProxyFactoryBean();
factory.setServiceInterface(IRemoteBean.class);
factory.setServiceUrl("rmi://localhost:1090/test");
......@@ -130,7 +130,7 @@ public class RmiSupportTests extends TestCase {
doTestRmiProxyFactoryBeanWithExceptionAndRefresh(StubNotFoundException.class);
}
private void doTestRmiProxyFactoryBeanWithExceptionAndRefresh(Class exceptionClass) throws Exception {
private void doTestRmiProxyFactoryBeanWithExceptionAndRefresh(Class<?> exceptionClass) throws Exception {
CountingRmiProxyFactoryBean factory = new CountingRmiProxyFactoryBean();
factory.setServiceInterface(IRemoteBean.class);
factory.setServiceUrl("rmi://localhost:1090/test");
......@@ -217,7 +217,7 @@ public class RmiSupportTests extends TestCase {
}
private void doTestRmiProxyFactoryBeanWithBusinessInterfaceAndException(
Class rmiExceptionClass, Class springExceptionClass) throws Exception {
Class<?> rmiExceptionClass, Class<?> springExceptionClass) throws Exception {
CountingRmiProxyFactoryBean factory = new CountingRmiProxyFactoryBean();
factory.setServiceInterface(IBusinessBean.class);
......@@ -272,7 +272,7 @@ public class RmiSupportTests extends TestCase {
}
private void doTestRmiProxyFactoryBeanWithBusinessInterfaceAndExceptionAndRefresh(
Class rmiExceptionClass, Class springExceptionClass) throws Exception {
Class<?> rmiExceptionClass, Class<?> springExceptionClass) throws Exception {
CountingRmiProxyFactoryBean factory = new CountingRmiProxyFactoryBean();
factory.setServiceInterface(IBusinessBean.class);
......@@ -319,7 +319,7 @@ public class RmiSupportTests extends TestCase {
// let's see if the remote invocation object works
final RemoteBean rb = new RemoteBean();
final Method setNameMethod = rb.getClass().getDeclaredMethod("setName", new Class[] {String.class});
final Method setNameMethod = rb.getClass().getDeclaredMethod("setName", new Class<?>[] {String.class});
MethodInvocation mi = new MethodInvocation() {
public Method getMethod() {
......@@ -351,10 +351,10 @@ public class RmiSupportTests extends TestCase {
assertEquals("bla", inv.getArguments()[0]);
inv.setMethodName("setName");
assertEquals("setName", inv.getMethodName());
inv.setParameterTypes(new Class[] {String.class});
inv.setParameterTypes(new Class<?>[] {String.class});
assertEquals(String.class, inv.getParameterTypes()[0]);
inv = new RemoteInvocation("setName", new Class[] {String.class}, new Object[] {"bla"});
inv = new RemoteInvocation("setName", new Class<?>[] {String.class}, new Object[] {"bla"});
assertEquals("bla", inv.getArguments()[0]);
assertEquals("setName", inv.getMethodName());
assertEquals(String.class, inv.getParameterTypes()[0]);
......@@ -436,8 +436,8 @@ public class RmiSupportTests extends TestCase {
if (nam != null && nam.endsWith("Exception")) {
RemoteException rex = null;
try {
Class exClass = Class.forName(nam);
Constructor ctor = exClass.getConstructor(new Class[] {String.class});
Class<?> exClass = Class.forName(nam);
Constructor<?> ctor = exClass.getConstructor(new Class<?>[] {String.class});
rex = (RemoteException) ctor.newInstance(new Object[] {"myMessage"});
}
catch (Exception ex) {
......
......@@ -48,7 +48,7 @@ public class TimerSupportTests extends TestCase {
tasks[1] = new ScheduledTimerTask(timerTask1, 10, 20, true);
tasks[2] = new ScheduledTimerTask(timerTask2, 20);
final List success = new ArrayList(3);
final List<Boolean> success = new ArrayList<Boolean>(3);
final Timer timer = new Timer(true) {
public void schedule(TimerTask task, long delay, long period) {
if (task == timerTask0 && delay == 0 && period == 10) {
......
......@@ -199,9 +199,9 @@ public class BshScriptFactoryTests extends TestCase {
mock.replay();
BshScriptFactory factory = new BshScriptFactory(
ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX + badScript,
new Class[] {Messenger.class});
new Class<?>[] {Messenger.class});
try {
Messenger messenger = (Messenger) factory.getScriptedObject(script, new Class[]{Messenger.class});
Messenger messenger = (Messenger) factory.getScriptedObject(script, new Class<?>[]{Messenger.class});
messenger.getMessage();
fail("Must have thrown a BshScriptUtils.BshExecutionException.");
}
......@@ -212,7 +212,7 @@ public class BshScriptFactoryTests extends TestCase {
public void testCtorWithNullScriptSourceLocator() throws Exception {
try {
new BshScriptFactory(null, new Class[] {Messenger.class});
new BshScriptFactory(null, new Class<?>[] {Messenger.class});
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
......@@ -221,7 +221,7 @@ public class BshScriptFactoryTests extends TestCase {
public void testCtorWithEmptyScriptSourceLocator() throws Exception {
try {
new BshScriptFactory("", new Class[] {Messenger.class});
new BshScriptFactory("", new Class<?>[] {Messenger.class});
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
......@@ -230,7 +230,7 @@ public class BshScriptFactoryTests extends TestCase {
public void testCtorWithWhitespacedScriptSourceLocator() throws Exception {
try {
new BshScriptFactory("\n ", new Class[] {Messenger.class});
new BshScriptFactory("\n ", new Class<?>[] {Messenger.class});
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
......@@ -241,7 +241,7 @@ public class BshScriptFactoryTests extends TestCase {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext("bsh-with-xsd.xml", getClass());
TestBean testBean = (TestBean) ctx.getBean("testBean");
Collection beanNames = Arrays.asList(ctx.getBeanNamesForType(Messenger.class));
Collection<String> beanNames = Arrays.asList(ctx.getBeanNamesForType(Messenger.class));
assertTrue(beanNames.contains("messenger"));
assertTrue(beanNames.contains("messengerImpl"));
assertTrue(beanNames.contains("messengerInstance"));
......@@ -262,7 +262,7 @@ public class BshScriptFactoryTests extends TestCase {
TestBeanAwareMessenger messengerByName = (TestBeanAwareMessenger) ctx.getBean("messengerByName");
assertEquals(testBean, messengerByName.getTestBean());
Collection beans = ctx.getBeansOfType(Messenger.class).values();
Collection<Messenger> beans = ctx.getBeansOfType(Messenger.class).values();
assertTrue(beans.contains(messenger));
assertTrue(beans.contains(messengerImpl));
assertTrue(beans.contains(messengerInstance));
......
......@@ -34,12 +34,12 @@ public class GroovyClassLoadingTests extends TestCase {
StaticApplicationContext context = new StaticApplicationContext();
GroovyClassLoader gcl = new GroovyClassLoader();
Class class1 = gcl.parseClass("class TestBean { def myMethod() { \"foo\" } }");
Class class2 = gcl.parseClass("class TestBean { def myMethod() { \"bar\" } }");
Class<?> class1 = gcl.parseClass("class TestBean { def myMethod() { \"foo\" } }");
Class<?> class2 = gcl.parseClass("class TestBean { def myMethod() { \"bar\" } }");
context.registerBeanDefinition("testBean", new RootBeanDefinition(class1));
Object testBean1 = context.getBean("testBean");
Method method1 = class1.getDeclaredMethod("myMethod", new Class[0]);
Method method1 = class1.getDeclaredMethod("myMethod", new Class<?>[0]);
Object result1 = ReflectionUtils.invokeMethod(method1, testBean1);
assertEquals("foo", (String) result1);
......@@ -48,7 +48,7 @@ public class GroovyClassLoadingTests extends TestCase {
context.registerBeanDefinition("testBean", new RootBeanDefinition(class2));
Object testBean2 = context.getBean("testBean");
Method method2 = class2.getDeclaredMethod("myMethod", new Class[0]);
Method method2 = class2.getDeclaredMethod("myMethod", new Class<?>[0]);
Object result2 = ReflectionUtils.invokeMethod(method2, testBean2);
assertEquals("bar", (String) result2);
}
......
......@@ -201,7 +201,7 @@ public class GroovyScriptFactoryTests {
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
+ badScript);
try {
factory.getScriptedObject(script, new Class[] {});
factory.getScriptedObject(script, new Class<?>[] {});
fail("Must have thrown a ScriptCompilationException (no public no-arg ctor in scripted class).");
} catch (ScriptCompilationException expected) {
assertTrue(expected.contains(InstantiationException.class));
......@@ -219,7 +219,7 @@ public class GroovyScriptFactoryTests {
GroovyScriptFactory factory = new GroovyScriptFactory(ScriptFactoryPostProcessor.INLINE_SCRIPT_PREFIX
+ badScript);
try {
factory.getScriptedObject(script, new Class[] {});
factory.getScriptedObject(script, new Class<?>[] {});
fail("Must have thrown a ScriptCompilationException (no oublic no-arg ctor in scripted class).");
} catch (ScriptCompilationException expected) {
assertTrue(expected.contains(IllegalAccessException.class));
......@@ -402,7 +402,7 @@ public class GroovyScriptFactoryTests {
@Test
public void testAnonymousScriptDetected() throws Exception {
ApplicationContext ctx = new ClassPathXmlApplicationContext("groovy-with-xsd.xml", getClass());
Map beans = ctx.getBeansOfType(Messenger.class);
Map<?, Messenger> beans = ctx.getBeansOfType(Messenger.class);
assertEquals(4, beans.size());
}
......
......@@ -94,7 +94,7 @@ public class JRubyScriptFactoryTests extends TestCase {
public void testCtorWithNullScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory(null, new Class[]{Messenger.class});
new JRubyScriptFactory(null, new Class<?>[]{Messenger.class});
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
......@@ -103,7 +103,7 @@ public class JRubyScriptFactoryTests extends TestCase {
public void testCtorWithEmptyScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory("", new Class[]{Messenger.class});
new JRubyScriptFactory("", new Class<?>[]{Messenger.class});
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
......@@ -112,7 +112,7 @@ public class JRubyScriptFactoryTests extends TestCase {
public void testCtorWithWhitespacedScriptSourceLocator() throws Exception {
try {
new JRubyScriptFactory("\n ", new Class[]{Messenger.class});
new JRubyScriptFactory("\n ", new Class<?>[]{Messenger.class});
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
......@@ -130,7 +130,7 @@ public class JRubyScriptFactoryTests extends TestCase {
public void testCtorWithEmptyScriptInterfacesArray() throws Exception {
try {
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR, new Class[]{});
new JRubyScriptFactory(RUBY_SCRIPT_SOURCE_LOCATOR, new Class<?>[]{});
fail("Must have thrown exception by this point.");
}
catch (IllegalArgumentException expected) {
......@@ -250,14 +250,14 @@ public class JRubyScriptFactoryTests extends TestCase {
assertEquals("2", lol[1][0]);
assertEquals("3", lol[2][0]);
Map singleValueMap = adder.toMap("key", "value");
Map<?, ?> singleValueMap = adder.toMap("key", "value");
assertNotNull(singleValueMap);
assertEquals(1, singleValueMap.size());
assertEquals("key", singleValueMap.keySet().iterator().next());
assertEquals("value", singleValueMap.values().iterator().next());
String[] expectedStrings = new String[]{"1", "2", "3"};
Map map = adder.toMap("key", expectedStrings);
Map<?, ?> map = adder.toMap("key", expectedStrings);
assertNotNull(map);
assertEquals(1, map.size());
assertEquals("key", map.keySet().iterator().next());
......
......@@ -47,6 +47,6 @@ public interface WrapperAdder {
String[][] createListOfLists(String one, String second, String third);
Map toMap(String key, Object value);
Map<?, ?> toMap(String key, Object value);
}
......@@ -276,7 +276,7 @@ public final class ModelMapTests {
ModelMap map = new ModelMap();
Object proxy = Proxy.newProxyInstance(
getClass().getClassLoader(),
new Class[] {Map.class},
new Class<?>[] {Map.class},
new InvocationHandler() {
public Object invoke(Object proxy, Method method, Object[] args) {
return "proxy";
......
......@@ -50,7 +50,7 @@ public class DataBinderFieldAccessTests extends TestCase {
assertTrue("changed name correctly", rod.getName().equals("Rod"));
assertTrue("changed age correctly", rod.getAge() == 32);
Map m = binder.getBindingResult().getModel();
Map<?, ?> m = binder.getBindingResult().getModel();
assertTrue("There is one element in map", m.size() == 2);
FieldAccessBean tb = (FieldAccessBean) m.get("person");
assertTrue("Same object", tb.equals(rod));
......@@ -92,7 +92,7 @@ public class DataBinderFieldAccessTests extends TestCase {
assertTrue("changed name correctly", rod.getName().equals("Rod"));
//assertTrue("changed age correctly", rod.getAge() == 32);
Map map = binder.getBindingResult().getModel();
Map<?, ?> map = binder.getBindingResult().getModel();
//assertTrue("There are 3 element in map", m.size() == 1);
FieldAccessBean tb = (FieldAccessBean) map.get("person");
assertTrue("Same object", tb.equals(rod));
......@@ -136,7 +136,7 @@ public class DataBinderFieldAccessTests extends TestCase {
assertTrue("changed name correctly", rod.getName().equals("Rod"));
//assertTrue("changed age correctly", rod.getAge() == 32);
Map model = binder.getBindingResult().getModel();
Map<?, ?> model = binder.getBindingResult().getModel();
//assertTrue("There are 3 element in map", m.size() == 1);
FieldAccessBean tb = (FieldAccessBean) model.get("person");
assertTrue("Same object", tb.equals(rod));
......
......@@ -80,7 +80,7 @@ public class DataBinderTests extends TestCase {
assertTrue("changed name correctly", rod.getName().equals("Rod"));
assertTrue("changed age correctly", rod.getAge() == 32);
Map map = binder.getBindingResult().getModel();
Map<?, ?> map = binder.getBindingResult().getModel();
assertTrue("There is one element in map", map.size() == 2);
TestBean tb = (TestBean) map.get("person");
assertTrue("Same object", tb.equals(rod));
......@@ -190,7 +190,7 @@ public class DataBinderTests extends TestCase {
assertTrue("changed name correctly", rod.getName().equals("Rod"));
//assertTrue("changed age correctly", rod.getAge() == 32);
Map map = binder.getBindingResult().getModel();
Map<?, ?> map = binder.getBindingResult().getModel();
//assertTrue("There are 3 element in map", m.size() == 1);
TestBean tb = (TestBean) map.get("person");
assertTrue("Same object", tb.equals(rod));
......@@ -284,7 +284,7 @@ public class DataBinderTests extends TestCase {
assertTrue("changed name correctly", rod.getName().equals("Rod"));
//assertTrue("changed age correctly", rod.getAge() == 32);
Map model = binder.getBindingResult().getModel();
Map<?, ?> model = binder.getBindingResult().getModel();
//assertTrue("There are 3 element in map", m.size() == 1);
TestBean tb = (TestBean) model.get("person");
assertTrue("Same object", tb.equals(rod));
......@@ -1177,8 +1177,8 @@ public class DataBinderTests extends TestCase {
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
binder.bind(pvs);
assertEquals("listtest1", ((TestBean) tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
assertEquals("listtest2", ((TestBean) tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
assertEquals("listtest1", tb.getArray()[0].getNestedIndexedBean().getList().get(0).getName());
assertEquals("listtest2", tb.getArray()[1].getNestedIndexedBean().getList().get(1).getName());
assertEquals("test1", binder.getBindingResult().getFieldValue("array[0].nestedIndexedBean.list[0].name"));
assertEquals("test2", binder.getBindingResult().getFieldValue("array[1].nestedIndexedBean.list[1].name"));
}
......@@ -1200,8 +1200,8 @@ public class DataBinderTests extends TestCase {
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
binder.bind(pvs);
assertEquals("listtest1", ((TestBean) tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
assertEquals("test2", ((TestBean) tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
assertEquals("listtest1", tb.getArray()[0].getNestedIndexedBean().getList().get(0).getName());
assertEquals("test2", tb.getArray()[1].getNestedIndexedBean().getList().get(1).getName());
assertEquals("test1", binder.getBindingResult().getFieldValue("array[0].nestedIndexedBean.list[0].name"));
assertEquals("test2", binder.getBindingResult().getFieldValue("array[1].nestedIndexedBean.list[1].name"));
}
......@@ -1223,8 +1223,8 @@ public class DataBinderTests extends TestCase {
pvs.add("array[0].nestedIndexedBean.list[0].name", "test1");
pvs.add("array[1].nestedIndexedBean.list[1].name", "test2");
binder.bind(pvs);
assertEquals("listtest1", ((TestBean) tb.getArray()[0].getNestedIndexedBean().getList().get(0)).getName());
assertEquals("test2", ((TestBean) tb.getArray()[1].getNestedIndexedBean().getList().get(1)).getName());
assertEquals("listtest1", tb.getArray()[0].getNestedIndexedBean().getList().get(0).getName());
assertEquals("test2", tb.getArray()[1].getNestedIndexedBean().getList().get(1).getName());
assertEquals("test1", binder.getBindingResult().getFieldValue("array[0].nestedIndexedBean.list[0].name"));
assertEquals("test2", binder.getBindingResult().getFieldValue("array[1].nestedIndexedBean.list[1].name"));
}
......@@ -1647,7 +1647,7 @@ public class DataBinderTests extends TestCase {
private static class TestBeanValidator implements Validator {
public boolean supports(Class clazz) {
public boolean supports(Class<?> clazz) {
return TestBean.class.isAssignableFrom(clazz);
}
......@@ -1674,7 +1674,7 @@ public class DataBinderTests extends TestCase {
private static class SpouseValidator implements Validator {
public boolean supports(Class clazz) {
public boolean supports(Class<?> clazz) {
return TestBean.class.isAssignableFrom(clazz);
}
......
......@@ -161,7 +161,7 @@ public class ValidationUtilsTests {
private static class EmptyValidator implements Validator {
public boolean supports(Class clazz) {
public boolean supports(Class<?> clazz) {
return TestBean.class.isAssignableFrom(clazz);
}
......@@ -173,7 +173,7 @@ public class ValidationUtilsTests {
private static class EmptyOrWhitespaceValidator implements Validator {
public boolean supports(Class clazz) {
public boolean supports(Class<?> clazz) {
return TestBean.class.isAssignableFrom(clazz);
}
......
......@@ -95,7 +95,7 @@ public class ValidatorFactoryTests {
Set<ConstraintViolation<ValidPerson>> result = validator.validate(person);
assertEquals(1, result.size());
Iterator<ConstraintViolation<ValidPerson>> iterator = result.iterator();
ConstraintViolation cv = iterator.next();
ConstraintViolation<?> cv = iterator.next();
assertEquals("", cv.getPropertyPath().toString());
assertTrue(cv.getConstraintDescriptor().getAnnotation() instanceof NameAddressValid);
}
......
......@@ -41,15 +41,15 @@ public class ConventionsTests extends TestCase {
}
public void testCollections() {
List list = new ArrayList();
List<TestBean> list = new ArrayList<TestBean>();
list.add(new TestBean());
assertEquals("Incorrect plural List form", "testBeanList", Conventions.getVariableName(list));
Set set = new HashSet();
Set<TestBean> set = new HashSet<TestBean>();
set.add(new TestBean());
assertEquals("Incorrect plural Set form", "testBeanList", Conventions.getVariableName(set));
List emptyList = new ArrayList();
List<?> emptyList = new ArrayList<Object>();
try {
Conventions.getVariableName(emptyList);
fail("Should not be able to generate name for empty collection");
......@@ -67,7 +67,7 @@ public class ConventionsTests extends TestCase {
public void testGetQualifiedAttributeName() throws Exception {
String baseName = "foo";
Class cls = String.class;
Class<String> cls = String.class;
String desiredResult = "java.lang.String.foo";
assertEquals(desiredResult, Conventions.getQualifiedAttributeName(cls, baseName));
}
......
......@@ -50,14 +50,14 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
}
public void testConsParameterNameDiscoveryNoArgs() throws NoSuchMethodException {
Constructor noArgsCons = TestBean.class.getConstructor(new Class[0]);
Constructor<TestBean> noArgsCons = TestBean.class.getConstructor(new Class[0]);
String[] names = discoverer.getParameterNames(noArgsCons);
assertNotNull("should find cons info", names);
assertEquals("no argument names", 0, names.length);
}
public void testConsParameterNameDiscoveryArgs() throws NoSuchMethodException {
Constructor twoArgCons = TestBean.class.getConstructor(new Class[] { String.class, int.class });
Constructor<TestBean> twoArgCons = TestBean.class.getConstructor(new Class[] { String.class, int.class });
String[] names = discoverer.getParameterNames(twoArgCons);
assertNotNull("should find cons info", names);
assertEquals("one argument", 2, names.length);
......@@ -73,7 +73,7 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
}
public void testOverloadedStaticMethod() throws Exception {
Class clazz = this.getClass();
Class<? extends LocalVariableTableParameterNameDiscovererTests> clazz = this.getClass();
Method m1 = clazz.getMethod("staticMethod", new Class[] { Long.TYPE, Long.TYPE });
String[] names = discoverer.getParameterNames(m1);
......@@ -92,7 +92,7 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
}
public void testOverloadedStaticMethodInInnerClass() throws Exception {
Class clazz = InnerClass.class;
Class<InnerClass> clazz = InnerClass.class;
Method m1 = clazz.getMethod("staticMethod", new Class[] { Long.TYPE });
String[] names = discoverer.getParameterNames(m1);
......@@ -109,7 +109,7 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
}
public void testOverloadedMethod() throws Exception {
Class clazz = this.getClass();
Class<? extends LocalVariableTableParameterNameDiscovererTests> clazz = this.getClass();
Method m1 = clazz.getMethod("instanceMethod", new Class[] { Double.TYPE, Double.TYPE });
String[] names = discoverer.getParameterNames(m1);
......@@ -128,7 +128,7 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
}
public void testOverloadedMethodInInnerClass() throws Exception {
Class clazz = InnerClass.class;
Class<InnerClass> clazz = InnerClass.class;
Method m1 = clazz.getMethod("instanceMethod", new Class[] { String.class });
String[] names = discoverer.getParameterNames(m1);
......@@ -145,9 +145,9 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
}
public void testGenerifiedClass() throws Exception {
Class clazz = GenerifiedClass.class;
Class<?> clazz = (Class<?>)GenerifiedClass.class;
Constructor ctor = clazz.getDeclaredConstructor(Object.class);
Constructor<?> ctor = clazz.getDeclaredConstructor(Object.class);
String[] names = discoverer.getParameterNames(ctor);
assertEquals(1, names.length);
assertEquals("key", names[0]);
......@@ -199,7 +199,7 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
@Ignore
public void ignore_testClassesWithoutDebugSymbols() throws Exception {
// JDK classes don't have debug information (usually)
Class clazz = Component.class;
Class<Component> clazz = Component.class;
String methodName = "list";
Method m = clazz.getMethod(methodName);
......@@ -275,9 +275,6 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
public static class GenerifiedClass<K, V> {
private static long date;
private K key;
private V value;
static {
// some custom static bloc or <clinit>
date = new Date().getTime();
......@@ -292,8 +289,6 @@ public class LocalVariableTableParameterNameDiscovererTests extends TestCase {
}
public GenerifiedClass(K key, V value) {
this.key = key;
this.value = value;
}
public static <P> long generifiedStaticMethod(P param) {
......
......@@ -38,7 +38,7 @@ public class AssertTests {
@Test(expected = IllegalArgumentException.class)
public void instanceOf() {
final Set set = new HashSet();
final Set<?> set = new HashSet<Object>();
Assert.isInstanceOf(HashSet.class, set);
Assert.isInstanceOf(HashMap.class, set);
}
......@@ -105,12 +105,12 @@ public class AssertTests {
@Test(expected = IllegalArgumentException.class)
public void assertNotEmptyWithNullCollectionThrowsException() throws Exception {
Assert.notEmpty((Collection) null);
Assert.notEmpty((Collection<?>) null);
}
@Test(expected = IllegalArgumentException.class)
public void assertNotEmptyWithEmptyCollectionThrowsException() throws Exception {
Assert.notEmpty(new ArrayList());
Assert.notEmpty(new ArrayList<Object>());
}
@Test
......@@ -122,12 +122,12 @@ public class AssertTests {
@Test(expected = IllegalArgumentException.class)
public void assertNotEmptyWithNullMapThrowsException() throws Exception {
Assert.notEmpty((Map) null);
Assert.notEmpty((Map<?, ?>) null);
}
@Test(expected = IllegalArgumentException.class)
public void assertNotEmptyWithEmptyMapThrowsException() throws Exception {
Assert.notEmpty(new HashMap());
Assert.notEmpty(new HashMap<Object, Object>());
}
@Test
......
......@@ -30,22 +30,22 @@ import org.springframework.beans.TestBean;
public class AutoPopulatingListTests extends TestCase {
public void testWithClass() throws Exception {
doTestWithClass(new AutoPopulatingList(TestBean.class));
doTestWithClass(new AutoPopulatingList<Object>(TestBean.class));
}
public void testWithClassAndUserSuppliedBackingList() throws Exception {
doTestWithClass(new AutoPopulatingList(new LinkedList(), TestBean.class));
doTestWithClass(new AutoPopulatingList<Object>(new LinkedList<Object>(), TestBean.class));
}
public void testWithElementFactory() throws Exception {
doTestWithElementFactory(new AutoPopulatingList(new MockElementFactory()));
doTestWithElementFactory(new AutoPopulatingList<Object>(new MockElementFactory()));
}
public void testWithElementFactoryAndUserSuppliedBackingList() throws Exception {
doTestWithElementFactory(new AutoPopulatingList(new LinkedList(), new MockElementFactory()));
doTestWithElementFactory(new AutoPopulatingList<Object>(new LinkedList<Object>(), new MockElementFactory()));
}
private void doTestWithClass(AutoPopulatingList list) {
private void doTestWithClass(AutoPopulatingList<Object> list) {
Object lastElement = null;
for (int x = 0; x < 10; x++) {
Object element = list.get(x);
......@@ -66,7 +66,7 @@ public class AutoPopulatingListTests extends TestCase {
assertTrue(list.get(20) instanceof TestBean);
}
private void doTestWithElementFactory(AutoPopulatingList list) {
private void doTestWithElementFactory(AutoPopulatingList<Object> list) {
doTestWithClass(list);
for(int x = 0; x < list.size(); x++) {
......@@ -78,7 +78,7 @@ public class AutoPopulatingListTests extends TestCase {
}
public void testSerialization() throws Exception {
AutoPopulatingList list = new AutoPopulatingList(TestBean.class);
AutoPopulatingList<?> list = new AutoPopulatingList<Object>(TestBean.class);
Assert.assertEquals(list, SerializationTestUtils.serializeAndDeserialize(list));
}
......
......@@ -40,16 +40,16 @@ public class CollectionUtilsTests {
@Test
public void testIsEmpty() {
assertTrue(CollectionUtils.isEmpty((Set) null));
assertTrue(CollectionUtils.isEmpty((Map) null));
assertTrue(CollectionUtils.isEmpty(new HashMap()));
assertTrue(CollectionUtils.isEmpty(new HashSet()));
assertTrue(CollectionUtils.isEmpty((Set<Object>) null));
assertTrue(CollectionUtils.isEmpty((Map<String, String>) null));
assertTrue(CollectionUtils.isEmpty(new HashMap<String, String>()));
assertTrue(CollectionUtils.isEmpty(new HashSet<Object>()));
List list = new LinkedList();
List<Object> list = new LinkedList<Object>();
list.add(new Object());
assertFalse(CollectionUtils.isEmpty(list));
Map map = new HashMap();
Map<String, String> map = new HashMap<String, String>();
map.put("foo", "bar");
assertFalse(CollectionUtils.isEmpty(map));
}
......@@ -57,7 +57,7 @@ public class CollectionUtilsTests {
@Test
public void testMergeArrayIntoCollection() {
Object[] arr = new Object[] {"value1", "value2"};
List list = new LinkedList();
List<Comparable<?>> list = new LinkedList<Comparable<?>>();
list.add("value3");
CollectionUtils.mergeArrayIntoCollection(arr, list);
......@@ -69,7 +69,7 @@ public class CollectionUtilsTests {
@Test
public void testMergePrimitiveArrayIntoCollection() {
int[] arr = new int[] {1, 2};
List list = new LinkedList();
List<Comparable<?>> list = new LinkedList<Comparable<?>>();
list.add(new Integer(3));
CollectionUtils.mergeArrayIntoCollection(arr, list);
......@@ -86,7 +86,7 @@ public class CollectionUtilsTests {
props.setProperty("prop2", "value2");
props.put("prop3", new Integer(3));
Map map = new HashMap();
Map<String, String> map = new HashMap<String, String>();
map.put("prop4", "value4");
CollectionUtils.mergePropertiesIntoMap(props, map);
......@@ -98,28 +98,28 @@ public class CollectionUtilsTests {
@Test
public void testContains() {
assertFalse(CollectionUtils.contains((Iterator) null, "myElement"));
assertFalse(CollectionUtils.contains((Enumeration) null, "myElement"));
assertFalse(CollectionUtils.contains(new LinkedList().iterator(), "myElement"));
assertFalse(CollectionUtils.contains(new Hashtable().keys(), "myElement"));
assertFalse(CollectionUtils.contains((Iterator<String>) null, "myElement"));
assertFalse(CollectionUtils.contains((Enumeration<String>) null, "myElement"));
assertFalse(CollectionUtils.contains(new LinkedList<String>().iterator(), "myElement"));
assertFalse(CollectionUtils.contains(new Hashtable<String, Object>().keys(), "myElement"));
List list = new LinkedList();
List<String> list = new LinkedList<String>();
list.add("myElement");
assertTrue(CollectionUtils.contains(list.iterator(), "myElement"));
Hashtable ht = new Hashtable();
Hashtable<String, String> ht = new Hashtable<String, String>();
ht.put("myElement", "myValue");
assertTrue(CollectionUtils.contains(ht.keys(), "myElement"));
}
@Test
public void testContainsAny() throws Exception {
List source = new ArrayList();
List<String> source = new ArrayList<String>();
source.add("abc");
source.add("def");
source.add("ghi");
List candidates = new ArrayList();
List<String> candidates = new ArrayList<String>();
candidates.add("xyz");
candidates.add("def");
candidates.add("abc");
......@@ -139,7 +139,7 @@ public class CollectionUtilsTests {
@Test
public void testContainsInstanceWithInstancesThatAreEqualButDistinct() throws Exception {
List list = new ArrayList();
List<Instance> list = new ArrayList<Instance>();
list.add(new Instance("fiona"));
assertFalse("Must return false if instance is not in the supplied Collection argument",
CollectionUtils.containsInstance(list, new Instance("fiona")));
......@@ -147,7 +147,7 @@ public class CollectionUtilsTests {
@Test
public void testContainsInstanceWithSameInstance() throws Exception {
List list = new ArrayList();
List<Instance> list = new ArrayList<Instance>();
list.add(new Instance("apple"));
Instance instance = new Instance("fiona");
list.add(instance);
......@@ -157,7 +157,7 @@ public class CollectionUtilsTests {
@Test
public void testContainsInstanceWithNullInstance() throws Exception {
List list = new ArrayList();
List<Instance> list = new ArrayList<Instance>();
list.add(new Instance("apple"));
list.add(new Instance("fiona"));
assertFalse("Must return false if null instance is supplied",
......@@ -166,12 +166,12 @@ public class CollectionUtilsTests {
@Test
public void testFindFirstMatch() throws Exception {
List source = new ArrayList();
List<String> source = new ArrayList<String>();
source.add("abc");
source.add("def");
source.add("ghi");
List candidates = new ArrayList();
List<String> candidates = new ArrayList<String>();
candidates.add("xyz");
candidates.add("def");
candidates.add("abc");
......@@ -181,35 +181,35 @@ public class CollectionUtilsTests {
@Test
public void testHasUniqueObject() {
List list = new LinkedList();
List<String> list = new LinkedList<String>();
list.add("myElement");
list.add("myOtherElement");
assertFalse(CollectionUtils.hasUniqueObject(list));
list = new LinkedList();
list = new LinkedList<String>();
list.add("myElement");
assertTrue(CollectionUtils.hasUniqueObject(list));
list = new LinkedList();
list = new LinkedList<String>();
list.add("myElement");
list.add(null);
assertFalse(CollectionUtils.hasUniqueObject(list));
list = new LinkedList();
list = new LinkedList<String>();
list.add(null);
list.add("myElement");
assertFalse(CollectionUtils.hasUniqueObject(list));
list = new LinkedList();
list = new LinkedList<String>();
list.add(null);
list.add(null);
assertTrue(CollectionUtils.hasUniqueObject(list));
list = new LinkedList();
list = new LinkedList<String>();
list.add(null);
assertTrue(CollectionUtils.hasUniqueObject(list));
list = new LinkedList();
list = new LinkedList<String>();
assertFalse(CollectionUtils.hasUniqueObject(list));
}
......
......@@ -43,14 +43,14 @@ public class MethodInvokerTests extends TestCase {
mi = new MethodInvoker();
mi.setTargetClass(TestClass1.class);
mi.setTargetMethod("supertypes");
mi.setArguments(new Object[] {new ArrayList(), new ArrayList(), "hello"});
mi.setArguments(new Object[] {new ArrayList<>(), new ArrayList<>(), "hello"});
mi.prepare();
assertEquals("hello", mi.invoke());
mi = new MethodInvoker();
mi.setTargetClass(TestClass1.class);
mi.setTargetMethod("supertypes2");
mi.setArguments(new Object[] {new ArrayList(), new ArrayList(), "hello", "bogus"});
mi.setArguments(new Object[] {new ArrayList<>(), new ArrayList<>(), "hello", "bogus"});
mi.prepare();
assertEquals("hello", mi.invoke());
......@@ -58,7 +58,7 @@ public class MethodInvokerTests extends TestCase {
mi = new MethodInvoker();
mi.setTargetClass(TestClass1.class);
mi.setTargetMethod("supertypes2");
mi.setArguments(new Object[] {new ArrayList(), new ArrayList(), "hello", Boolean.TRUE});
mi.setArguments(new Object[] {new ArrayList<>(), new ArrayList<>(), "hello", Boolean.TRUE});
try {
mi.prepare();
fail("Shouldn't have matched without argument conversion");
......@@ -169,23 +169,23 @@ public class MethodInvokerTests extends TestCase {
public static void intArguments(int[] arg) {
}
public static String supertypes(Collection c, Integer i) {
public static String supertypes(Collection<?> c, Integer i) {
return i.toString();
}
public static String supertypes(Collection c, List l, String s) {
public static String supertypes(Collection<?> c, List<?> l, String s) {
return s;
}
public static String supertypes2(Collection c, List l, Integer i) {
public static String supertypes2(Collection<?> c, List<?> l, Integer i) {
return i.toString();
}
public static String supertypes2(Collection c, List l, String s, Integer i) {
public static String supertypes2(Collection<?> c, List<?> l, String s, Integer i) {
return s;
}
public static String supertypes2(Collection c, List l, String s, String s2) {
public static String supertypes2(Collection<?> c, List<?> l, String s, String s2) {
return s;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册