Skip to content

Commit

Permalink
Fix [deprecation] compiler warnings
Browse files Browse the repository at this point in the history
Fix deprecation compiler warnings by refactoring code or applying
@SuppressWarnings("deprecation") annotations. JUnit tests of
internally deprecated classes are now themselves marked as
@deprecated.

Numerous EasyMock deprecation warnings will remain until the
migration to mockito can be completed.
  • Loading branch information
philwebb committed Jan 1, 2013
1 parent 9364043 commit 6626a38
Show file tree
Hide file tree
Showing 153 changed files with 1,665 additions and 1,188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,15 @@

package org.springframework.aop.config;

import static org.junit.Assert.*;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static test.util.TestResourceUtils.qualifiedResource;

import org.junit.Test;
import org.springframework.beans.factory.BeanDefinitionStoreException;
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
* @author Mark Fisher
Expand All @@ -33,7 +35,9 @@ public final class AopNamespaceHandlerPointcutErrorTests {
@Test
public void testDuplicatePointcutConfig() {
try {
new XmlBeanFactory(qualifiedResource(getClass(), "pointcutDuplication.xml"));
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(getClass(), "pointcutDuplication.xml"));
fail("parsing should have caused a BeanDefinitionStoreException");
}
catch (BeanDefinitionStoreException ex) {
Expand All @@ -44,7 +48,9 @@ public void testDuplicatePointcutConfig() {
@Test
public void testMissingPointcutConfig() {
try {
new XmlBeanFactory(qualifiedResource(getClass(), "pointcutMissing.xml"));
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(
qualifiedResource(getClass(), "pointcutMissing.xml"));
fail("parsing should have caused a BeanDefinitionStoreException");
}
catch (BeanDefinitionStoreException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

/**
Expand All @@ -37,25 +38,27 @@ public final class PrototypeTargetTests {
@Test
public void testPrototypeProxyWithPrototypeTarget() {
TestBeanImpl.constructionCount = 0;
XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
for (int i = 0; i < 10; i++) {
TestBean tb = (TestBean) xbf.getBean("testBeanPrototype");
TestBean tb = (TestBean) bf.getBean("testBeanPrototype");
tb.doSomething();
}
TestInterceptor interceptor = (TestInterceptor) xbf.getBean("testInterceptor");
TestInterceptor interceptor = (TestInterceptor) bf.getBean("testInterceptor");
assertEquals(10, TestBeanImpl.constructionCount);
assertEquals(10, interceptor.invocationCount);
}

@Test
public void testSingletonProxyWithPrototypeTarget() {
TestBeanImpl.constructionCount = 0;
XmlBeanFactory xbf = new XmlBeanFactory(CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
for (int i = 0; i < 10; i++) {
TestBean tb = (TestBean) xbf.getBean("testBeanSingleton");
TestBean tb = (TestBean) bf.getBean("testBeanSingleton");
tb.doSomething();
}
TestInterceptor interceptor = (TestInterceptor) xbf.getBean("testInterceptor");
TestInterceptor interceptor = (TestInterceptor) bf.getBean("testInterceptor");
assertEquals(1, TestBeanImpl.constructionCount);
assertEquals(10, interceptor.invocationCount);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@

package org.springframework.aop.interceptor;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static test.util.TestResourceUtils.qualifiedResource;

import org.aopalliance.intercept.MethodInvocation;
import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

import test.beans.ITestBean;
Expand All @@ -40,7 +42,8 @@ public final class ExposeInvocationInterceptorTests {

@Test
public void testXmlConfig() {
XmlBeanFactory bf = new XmlBeanFactory(CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
ITestBean tb = (ITestBean) bf.getBean("proxy");
String name= "tony";
tb.setName(name);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import static test.util.TestResourceUtils.qualifiedResource;

import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

/**
Expand All @@ -36,15 +37,17 @@ public final class ScopedProxyAutowireTests {

@Test
public void testScopedProxyInheritsAutowireCandidateFalse() {
XmlBeanFactory bf = new XmlBeanFactory(SCOPED_AUTOWIRE_FALSE_CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_FALSE_CONTEXT);
TestBean autowired = (TestBean) bf.getBean("autowired");
TestBean unscoped = (TestBean) bf.getBean("unscoped");
assertSame(unscoped, autowired.getChild());
}

@Test
public void testScopedProxyReplacesAutowireCandidateTrue() {
XmlBeanFactory bf = new XmlBeanFactory(SCOPED_AUTOWIRE_TRUE_CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SCOPED_AUTOWIRE_TRUE_CONTEXT);
TestBean autowired = (TestBean) bf.getBean("autowired");
TestBean scoped = (TestBean) bf.getBean("scoped");
assertSame(scoped, autowired.getChild());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@

import org.junit.Test;
import org.springframework.aop.framework.Advised;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

import test.aop.NopInterceptor;
Expand All @@ -43,7 +43,8 @@ public final class RegexpMethodPointcutAdvisorIntegrationTests {

@Test
public void testSinglePattern() throws Throwable {
BeanFactory bf = new XmlBeanFactory(CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
ITestBean advised = (ITestBean) bf.getBean("settersAdvised");
// Interceptor behind regexp advisor
NopInterceptor nop = (NopInterceptor) bf.getBean("nopInterceptor");
Expand All @@ -61,7 +62,8 @@ public void testSinglePattern() throws Throwable {

@Test
public void testMultiplePatterns() throws Throwable {
BeanFactory bf = new XmlBeanFactory(CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
// This is a CGLIB proxy, so we can proxy it to the target class
TestBean advised = (TestBean) bf.getBean("settersAndAbsquatulateAdvised");
// Interceptor behind regexp advisor
Expand All @@ -84,7 +86,8 @@ public void testMultiplePatterns() throws Throwable {

@Test
public void testSerialization() throws Throwable {
BeanFactory bf = new XmlBeanFactory(CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CONTEXT);
// This is a CGLIB proxy, so we can proxy it to the target class
Person p = (Person) bf.getBean("serializableSettersAdvised");
// Interceptor behind regexp advisor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@

package org.springframework.aop.target;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static test.util.TestResourceUtils.qualifiedResource;

import org.junit.After;
Expand All @@ -25,7 +27,8 @@
import org.springframework.aop.framework.Advised;
import org.springframework.aop.framework.ProxyFactory;
import org.springframework.aop.support.DefaultPointcutAdvisor;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

import test.aop.SerializableNopInterceptor;
Expand All @@ -46,11 +49,12 @@ public final class HotSwappableTargetSourceTests {
/** Initial count value set in bean factory XML */
private static final int INITIAL_COUNT = 10;

private XmlBeanFactory beanFactory;
private DefaultListableBeanFactory beanFactory;

@Before
public void setUp() throws Exception {
this.beanFactory = new XmlBeanFactory(CONTEXT);
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@

package org.springframework.aop.target;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static test.util.TestResourceUtils.qualifiedResource;

import java.util.Set;

import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

import test.beans.ITestBean;
Expand All @@ -43,7 +46,8 @@ public final class LazyInitTargetSourceTests {

@Test
public void testLazyInitSingletonTargetSource() {
XmlBeanFactory bf = new XmlBeanFactory(SINGLETON_CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(SINGLETON_CONTEXT);
bf.preInstantiateSingletons();

ITestBean tb = (ITestBean) bf.getBean("proxy");
Expand All @@ -54,7 +58,8 @@ public void testLazyInitSingletonTargetSource() {

@Test
public void testCustomLazyInitSingletonTargetSource() {
XmlBeanFactory bf = new XmlBeanFactory(CUSTOM_TARGET_CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(CUSTOM_TARGET_CONTEXT);
bf.preInstantiateSingletons();

ITestBean tb = (ITestBean) bf.getBean("proxy");
Expand All @@ -65,7 +70,8 @@ public void testCustomLazyInitSingletonTargetSource() {

@Test
public void testLazyInitFactoryBeanTargetSource() {
XmlBeanFactory bf = new XmlBeanFactory(FACTORY_BEAN_CONTEXT);
DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(bf).loadBeanDefinitions(FACTORY_BEAN_CONTEXT);
bf.preInstantiateSingletons();

Set<?> set1 = (Set<?>) bf.getBean("proxy1");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ public final class PrototypeBasedTargetSourceTests {
public void testSerializability() throws Exception {
MutablePropertyValues tsPvs = new MutablePropertyValues();
tsPvs.add("targetBeanName", "person");
RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class, tsPvs);
RootBeanDefinition tsBd = new RootBeanDefinition(TestTargetSource.class);
tsBd.setPropertyValues(tsPvs);

MutablePropertyValues pvs = new MutablePropertyValues();
RootBeanDefinition bd = new RootBeanDefinition(SerializablePerson.class, pvs);
RootBeanDefinition bd = new RootBeanDefinition(SerializablePerson.class);
bd.setPropertyValues(pvs);
bd.setScope(RootBeanDefinition.SCOPE_PROTOTYPE);

DefaultListableBeanFactory bf = new DefaultListableBeanFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

import test.beans.SideEffectBean;
Expand All @@ -43,7 +45,8 @@ public final class PrototypeTargetSourceTests {

@Before
public void setUp() throws Exception {
this.beanFactory = new XmlBeanFactory(CONTEXT);
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader((BeanDefinitionRegistry) this.beanFactory).loadBeanDefinitions(CONTEXT);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@

package org.springframework.aop.target;

import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import static test.util.TestResourceUtils.qualifiedResource;

import org.junit.Before;
import org.junit.Test;
import org.springframework.beans.factory.xml.XmlBeanFactory;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
import org.springframework.core.io.Resource;

import test.beans.ITestBean;
Expand All @@ -39,11 +42,12 @@ public class ThreadLocalTargetSourceTests {
/** Initial count value set in bean factory XML */
private static final int INITIAL_COUNT = 10;

private XmlBeanFactory beanFactory;
private DefaultListableBeanFactory beanFactory;

@Before
public void setUp() throws Exception {
this.beanFactory = new XmlBeanFactory(CONTEXT);
this.beanFactory = new DefaultListableBeanFactory();
new XmlBeanDefinitionReader(this.beanFactory).loadBeanDefinitions(CONTEXT);
}

/**
Expand Down
Loading

0 comments on commit 6626a38

Please sign in to comment.