Add @Override annotations to test sources

Issue: SPR-10129
This commit is contained in:
Chris Beams
2012-12-28 13:59:24 +01:00
parent 6f0c7eb8c1
commit 4c8cd7b0bd
797 changed files with 4745 additions and 0 deletions

View File

@@ -45,14 +45,17 @@ public class AutowiredQualifierFooService implements FooService {
this.initCalled = true;
}
@Override
public String foo(int id) {
return this.fooDao.findFoo(id);
}
@Override
public Future<String> asyncFoo(int id) {
return new AsyncResult<String>(this.fooDao.findFoo(id));
}
@Override
public boolean isInitCalled() {
return this.initCalled;
}

View File

@@ -74,16 +74,19 @@ public class FooServiceImpl implements FooService {
this.initCalled = true;
}
@Override
public String foo(int id) {
return this.fooDao.findFoo(id);
}
@Override
public Future<String> asyncFoo(int id) {
System.out.println(Thread.currentThread().getName());
Assert.state(ServiceInvocationCounter.getThreadLocalCount() != null, "Thread-local counter not exposed");
return new AsyncResult<String>(this.fooDao.findFoo(id));
}
@Override
public boolean isInitCalled() {
return this.initCalled;
}

View File

@@ -28,14 +28,17 @@ import org.springframework.scheduling.annotation.AsyncResult;
@Scope("myScope")
public class ScopedProxyTestBean implements FooService {
@Override
public String foo(int id) {
return "bar";
}
@Override
public Future<String> asyncFoo(int id) {
return new AsyncResult<String>("bar");
}
@Override
public boolean isInitCalled() {
return false;
}

View File

@@ -26,6 +26,7 @@ import org.springframework.stereotype.Repository;
@Qualifier("testing")
public class StubFooDao implements FooDao {
@Override
public String findFoo(int id) {
return "bar";
}

View File

@@ -110,26 +110,32 @@ public final class AspectAndAdvicePrecedenceTests {
}
}
@Override
public void beforeAdviceOne(String beanName) {
checkAdvice("beforeAdviceOne(" + beanName + ")");
}
@Override
public void beforeAdviceTwo(String beanName) {
checkAdvice("beforeAdviceTwo(" + beanName + ")");
}
@Override
public void aroundAdviceOne(String beanName) {
checkAdvice("aroundAdviceOne(" + beanName + ")");
}
@Override
public void aroundAdviceTwo(String beanName) {
checkAdvice("aroundAdviceTwo(" + beanName + ")");
}
@Override
public void afterAdviceOne(String beanName) {
checkAdvice("afterAdviceOne(" + beanName + ")");
}
@Override
public void afterAdviceTwo(String beanName) {
checkAdvice("afterAdviceTwo(" + beanName + ")");
}
@@ -147,6 +153,7 @@ class PrecedenceTestAspect implements BeanNameAware, Ordered {
private Collaborator collaborator;
@Override
public void setBeanName(String name) {
this.name = name;
}
@@ -155,6 +162,7 @@ class PrecedenceTestAspect implements BeanNameAware, Ordered {
this.order = order;
}
@Override
public int getOrder() {
return order;
}
@@ -223,6 +231,7 @@ class SimpleSpringBeforeAdvice implements MethodBeforeAdvice, BeanNameAware {
/* (non-Javadoc)
* @see org.springframework.aop.MethodBeforeAdvice#before(java.lang.reflect.Method, java.lang.Object[], java.lang.Object)
*/
@Override
public void before(Method method, Object[] args, Object target)
throws Throwable {
this.collaborator.beforeAdviceOne(this.name);
@@ -235,6 +244,7 @@ class SimpleSpringBeforeAdvice implements MethodBeforeAdvice, BeanNameAware {
/* (non-Javadoc)
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
@Override
public void setBeanName(String name) {
this.name = name;
}

View File

@@ -60,6 +60,7 @@ class CallCountingInterceptor implements MethodInterceptor {
private int count;
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
count++;
return methodInvocation.proceed();

View File

@@ -126,6 +126,7 @@ public final class BeanNamePointcutTests {
private int interceptionCount;
@Override
public void before(Method method, Object[] args, Object target) throws Throwable {
interceptionCount++;
}

View File

@@ -88,6 +88,7 @@ public final class DeclarationOrderIndependenceTests {
/* (non-Javadoc)
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
@Override
public void setBeanName(String name) {
this.beanName = name;
}
@@ -148,6 +149,7 @@ class TopsyTurvyTargetImpl implements TopsyTurvyTarget {
/* (non-Javadoc)
* @see org.springframework.aop.aspectj.TopsyTurvyTarget#doSomething()
*/
@Override
public void doSomething() {
this.x = 10;
}
@@ -155,6 +157,7 @@ class TopsyTurvyTargetImpl implements TopsyTurvyTarget {
/* (non-Javadoc)
* @see org.springframework.aop.aspectj.TopsyTurvyTarget#getX()
*/
@Override
public int getX() {
return x;
}
@@ -171,6 +174,7 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator {
/* (non-Javadoc)
* @see org.springframework.aop.aspectj.TopsyTurvyAspect.Collaborator#afterReturningAdviceFired()
*/
@Override
public void afterReturningAdviceFired() {
this.afterReturningFired = true;
}
@@ -178,6 +182,7 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator {
/* (non-Javadoc)
* @see org.springframework.aop.aspectj.TopsyTurvyAspect.Collaborator#aroundAdviceFired()
*/
@Override
public void aroundAdviceFired() {
this.aroundFired = true;
}
@@ -185,6 +190,7 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator {
/* (non-Javadoc)
* @see org.springframework.aop.aspectj.TopsyTurvyAspect.Collaborator#beforeAdviceFired()
*/
@Override
public void beforeAdviceFired() {
this.beforeFired = true;
}

View File

@@ -101,34 +101,42 @@ class SimpleBeanImpl implements SimpleBean {
private String name;
private String sex;
@Override
public int getAge() {
return age;
}
@Override
public float getMyFloat() {
return aFloat;
}
@Override
public String getName() {
return name;
}
@Override
public String getSex() {
return sex;
}
@Override
public void setAge(int age) {
this.age = age;
}
@Override
public void setMyFloat(float f) {
this.aFloat = f;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public void setSex(String sex) {
this.sex = sex;
}
@@ -143,6 +151,7 @@ class ProceedTestingAspect implements Ordered {
private int order;
public void setOrder(int order) { this.order = order; }
@Override
public int getOrder() { return this.order; }
public Object capitalize(ProceedingJoinPoint pjp, String value) throws Throwable {

View File

@@ -74,6 +74,7 @@ interface SerializableFoo extends Serializable { void foo(); }
class SubtypeMatchingTestClassA implements NonSerializableFoo {
@Override
public void foo() {}
}
@@ -81,6 +82,7 @@ class SubtypeMatchingTestClassA implements NonSerializableFoo {
@SuppressWarnings("serial")
class SubtypeMatchingTestClassB implements SerializableFoo {
@Override
public void foo() {}
}
@@ -89,6 +91,7 @@ interface Bar { void bar(Object o); }
class SubtypeMatchingTestClassC implements Bar {
@Override
public void bar(Object o) {}
}

View File

@@ -82,6 +82,7 @@ public final class TargetPointcutSelectionTests {
// include the advised method's implementation (instead a base class should include it)
public static abstract class AbstractTestImpl implements TestInterface {
@Override
public void interfaceMethod() {
}
}
@@ -107,6 +108,7 @@ public final class TargetPointcutSelectionTests {
public static class TestInterceptor extends TestAspect implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
increment();
return mi.proceed();

View File

@@ -108,6 +108,7 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
}
public static class TestImpl implements TestInterface {
@Override
public void doIt() {
}
}
@@ -119,11 +120,13 @@ public final class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
@TestAnnotation
public static class AnnotatedClassTestImpl implements TestInterface {
@Override
public void doIt() {
}
}
public static class AnnotatedMethodTestImpl implements TestInterface {
@Override
@TestAnnotation
public void doIt() {
}

View File

@@ -115,6 +115,7 @@ interface TestInterface {
class TestImpl implements TestInterface {
@Override
public void doIt() {
}
}

View File

@@ -118,22 +118,27 @@ final class Counter implements ICounter {
public Counter() {
}
@Override
public void increment() {
count++;
}
@Override
public void decrement() {
count--;
}
@Override
public int getCount() {
return count;
}
@Override
public void setCount(int counter) {
this.count = counter;
}
@Override
public void reset() {
this.count = 0;
}

View File

@@ -55,6 +55,7 @@ public final class AnnotationPointcutTests {
class TestMethodInterceptor implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation methodInvocation) throws Throwable {
return "this value";
}

View File

@@ -57,6 +57,7 @@ class InterfaceExtendingAspect implements AnInterface {
pjp.proceed();
}
@Override
public void interfaceMethod() {
}
}

View File

@@ -387,6 +387,7 @@ class PerTargetAspect implements Ordered {
++count;
}
@Override
public int getOrder() {
return this.order;
}
@@ -438,14 +439,17 @@ class DummyAspectWithParameter {
class DummyFactoryBean implements FactoryBean<Object> {
@Override
public Object getObject() throws Exception {
throw new UnsupportedOperationException();
}
@Override
public Class<?> getObjectType() {
throw new UnsupportedOperationException();
}
@Override
public boolean isSingleton() {
throw new UnsupportedOperationException();
}
@@ -573,12 +577,14 @@ class TestBeanAdvisor extends StaticMethodMatcherPointcutAdvisor {
public TestBeanAdvisor() {
setAdvice(new MethodBeforeAdvice() {
@Override
public void before(Method method, Object[] args, Object target) throws Throwable {
++count;
}
});
}
@Override
public boolean matches(Method method, Class<?> targetClass) {
return ITestBean.class.isAssignableFrom(targetClass);
}

View File

@@ -82,16 +82,19 @@ class AtAspectJAnnotationBindingTestAspect {
class ResourceArrayFactoryBean implements FactoryBean<Object> {
@Override
@TestAnnotation("some value")
public Object getObject() throws Exception {
return new Resource[0];
}
@Override
@TestAnnotation("some value")
public Class<?> getObjectType() {
return Resource[].class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -72,22 +72,26 @@ interface AnnotatedTestBean {
*/
class AnnotatedTestBeanImpl implements AnnotatedTestBean {
@Override
@TestAnnotation("this value")
public String doThis() {
return "doThis";
}
@Override
@TestAnnotation("that value")
public String doThat() {
return "doThat";
}
@Override
@TestAnnotation("array value")
public String[] doArray() {
return new String[] {"doThis", "doThat"};
}
// not annotated
@Override
public String doTheOther() {
return "doTheOther";
}

View File

@@ -206,6 +206,7 @@ class MultiplyReturnValueInterceptor implements MethodInterceptor {
return this.multiple;
}
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
++invocations;
int result = (Integer) mi.proceed();
@@ -219,6 +220,7 @@ class TraceAfterReturningAdvice implements AfterReturningAdvice {
public int afterTakesInt;
@Override
public void afterReturning(Object returnValue, Method method, Object[] args, Object target) throws Throwable {
++afterTakesInt;
}
@@ -226,6 +228,7 @@ class TraceAfterReturningAdvice implements AfterReturningAdvice {
public static Advisor advisor() {
return new DefaultPointcutAdvisor(
new StaticMethodMatcherPointcut() {
@Override
public boolean matches(Method method, Class<?> targetClass) {
return method.getParameterTypes().length == 1 &&
method.getParameterTypes()[0].equals(Integer.class);
@@ -261,6 +264,7 @@ class TraceBeforeAdvice implements MethodBeforeAdvice {
public int beforeStringReturn;
@Override
public void before(Method method, Object[] args, Object target) throws Throwable {
++beforeStringReturn;
}
@@ -268,6 +272,7 @@ class TraceBeforeAdvice implements MethodBeforeAdvice {
public static Advisor advisor() {
return new DefaultPointcutAdvisor(
new StaticMethodMatcherPointcut() {
@Override
public boolean matches(Method method, Class<?> targetClass) {
return method.getReturnType().equals(String.class);
}

View File

@@ -81,6 +81,7 @@ interface Service {
class ServiceImpl implements Service {
@Override
@Transaction
public void serveMe() {
}

View File

@@ -87,9 +87,11 @@ interface DerivedInterface<T> extends BaseInterface<T> {
class DerivedStringParameterizedClass implements DerivedInterface<String> {
@Override
public void genericDerivedInterfaceMethod(String t) {
}
@Override
public void genericBaseInterfaceMethod(String t) {
}
}

View File

@@ -82,9 +82,11 @@ public final class GenericParameterMatchingTests {
static class GenericImpl<T> implements GenericInterface<T> {
@Override
public void save(T bean) {
}
@Override
public void saveAll(Collection<T> beans) {
}
}

View File

@@ -409,6 +409,7 @@ public abstract class AbstractAopProxyTests {
final String s = "foo";
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (!context) {
assertNoInvocationContext();
@@ -457,6 +458,7 @@ public abstract class AbstractAopProxyTests {
final Exception expectedException = new Exception();
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw expectedException;
}
@@ -491,6 +493,7 @@ public abstract class AbstractAopProxyTests {
final Exception unexpectedException = new Exception();
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw unexpectedException;
}
@@ -523,6 +526,7 @@ public abstract class AbstractAopProxyTests {
final RuntimeException unexpectedException = new RuntimeException();
// Test return value
MethodInterceptor mi = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw unexpectedException;
}
@@ -573,6 +577,7 @@ public abstract class AbstractAopProxyTests {
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] {ITestBean.class, IOther.class});
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
TrapTargetInterceptor tii = new TrapTargetInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
// Assert that target matches BEFORE invocation returns
assertEquals("Target is correct", expectedTarget, invocation.getThis());
@@ -727,6 +732,7 @@ public abstract class AbstractAopProxyTests {
pc.addAdvice(di);
final long ts = 37;
pc.addAdvice(new DelegatingIntroductionInterceptor(new TimeStamped() {
@Override
public long getTimeStamp() {
return ts;
}
@@ -811,6 +817,7 @@ public abstract class AbstractAopProxyTests {
/**
* @see test.util.TimeStamped#getTimeStamp()
*/
@Override
public long getTimeStamp() {
throw new UnsupportedOperationException();
}
@@ -1132,6 +1139,7 @@ public abstract class AbstractAopProxyTests {
pc.addInterface(ITestBean.class);
MethodInterceptor twoBirthdayInterceptor = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
// Clone the invocation to proceed three times
// "The Moor's Last Sigh": this technology can cause premature aging
@@ -1144,6 +1152,7 @@ public abstract class AbstractAopProxyTests {
};
@SuppressWarnings("serial")
StaticMethodMatcherPointcutAdvisor advisor = new StaticMethodMatcherPointcutAdvisor(twoBirthdayInterceptor) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return "haveBirthday".equals(m.getName());
}
@@ -1173,6 +1182,7 @@ public abstract class AbstractAopProxyTests {
* Changes the name, then changes it back.
*/
MethodInterceptor nameReverter = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
MethodInvocation clone = ((ReflectiveMethodInvocation) mi).invocableClone();
String oldName = ((ITestBean) mi.getThis()).getName();
@@ -1186,6 +1196,7 @@ public abstract class AbstractAopProxyTests {
class NameSaver implements MethodInterceptor {
private List<Object> names = new LinkedList<Object>();
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
names.add(mi.getArguments()[0]);
return mi.proceed();
@@ -1219,12 +1230,14 @@ public abstract class AbstractAopProxyTests {
ProxyFactory pc = new ProxyFactory(target);
NopInterceptor overLoadVoids = new NopInterceptor();
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadVoids) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getName().equals("overload") && m.getParameterTypes().length == 0;
}
});
NopInterceptor overLoadInts = new NopInterceptor();
pc.addAdvisor(new StaticMethodMatcherPointcutAdvisor(overLoadInts) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getName().equals("overload") && m.getParameterTypes().length == 1 &&
m.getParameterTypes()[0].equals(int.class);
@@ -1255,19 +1268,23 @@ public abstract class AbstractAopProxyTests {
Advised config = (Advised) proxy;
// This class just checks proxy is bound before getTarget() call
config.setTargetSource(new TargetSource() {
@Override
public Class<?> getTargetClass() {
return TestBean.class;
}
@Override
public boolean isStatic() {
return false;
}
@Override
public Object getTarget() throws Exception {
assertEquals(proxy, AopContext.currentProxy());
return target;
}
@Override
public void releaseTarget(Object target) throws Exception {
}
});
@@ -1311,6 +1328,7 @@ public abstract class AbstractAopProxyTests {
CountingBeforeAdvice cba = new CountingBeforeAdvice();
@SuppressWarnings("serial")
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cba) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getParameterTypes().length == 0;
}
@@ -1343,6 +1361,7 @@ public abstract class AbstractAopProxyTests {
this.expectedValues = expectedValues;
this.valuesToAdd = valuesToAdd;
}
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
ReflectiveMethodInvocation rmi = (ReflectiveMethodInvocation) invocation;
for (Iterator<String> it = rmi.getUserAttributes().keySet().iterator(); it.hasNext(); ){
@@ -1390,6 +1409,7 @@ public abstract class AbstractAopProxyTests {
CountingMultiAdvice cca = new CountingMultiAdvice();
@SuppressWarnings("serial")
Advisor matchesNoArgs = new StaticMethodMatcherPointcutAdvisor(cca) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getParameterTypes().length == 0 || "exceptional".equals(m.getName());
}
@@ -1428,6 +1448,7 @@ public abstract class AbstractAopProxyTests {
final RuntimeException rex = new RuntimeException();
@SuppressWarnings("serial")
CountingBeforeAdvice ba = new CountingBeforeAdvice() {
@Override
public void before(Method m, Object[] args, Object target) throws Throwable {
super.before(m, args, target);
if (m.getName().startsWith("set"))
@@ -1471,6 +1492,7 @@ public abstract class AbstractAopProxyTests {
public void testAfterReturningAdvisorIsInvoked() {
class SummingAfterAdvice implements AfterReturningAdvice {
public int sum;
@Override
public void afterReturning(Object returnValue, Method m, Object[] args, Object target) throws Throwable {
sum += ((Integer) returnValue).intValue();
}
@@ -1478,6 +1500,7 @@ public abstract class AbstractAopProxyTests {
SummingAfterAdvice aa = new SummingAfterAdvice();
@SuppressWarnings("serial")
Advisor matchesInt = new StaticMethodMatcherPointcutAdvisor(aa) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getReturnType() == int.class;
}
@@ -1535,6 +1558,7 @@ public abstract class AbstractAopProxyTests {
MyThrowsHandler th = new MyThrowsHandler();
@SuppressWarnings("serial")
Advisor matchesEchoInvocations = new StaticMethodMatcherPointcutAdvisor(th) {
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getName().startsWith("echo");
}
@@ -1609,6 +1633,7 @@ public abstract class AbstractAopProxyTests {
private static class CheckMethodInvocationIsSameInAndOutInterceptor implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
Method m = mi.getMethod();
Object retval = mi.proceed();
@@ -1623,6 +1648,7 @@ public abstract class AbstractAopProxyTests {
*/
private static class CheckMethodInvocationViaThreadLocalIsSameInAndOutInterceptor implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
String task = "get invocation on way IN";
try {
@@ -1649,6 +1675,7 @@ public abstract class AbstractAopProxyTests {
*/
private static class ProxyMatcherInterceptor implements MethodInterceptor {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
Object proxy = AopContext.currentProxy();
Object ret = mi.proceed();
@@ -1667,6 +1694,7 @@ public abstract class AbstractAopProxyTests {
protected static class StringSetterNullReplacementAdvice extends DefaultPointcutAdvisor {
private static MethodInterceptor cleaner = new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
// We know it can only be invoked if there's a single parameter of type string
mi.getArguments()[0] = "";
@@ -1677,9 +1705,11 @@ public abstract class AbstractAopProxyTests {
public StringSetterNullReplacementAdvice() {
super(cleaner);
setPointcut(new DynamicMethodMatcherPointcut() {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
return args[0] == null;
}
@Override
public boolean matches(Method m, Class<?> targetClass) {
return m.getName().startsWith("set") &&
m.getParameterTypes().length == 1 &&
@@ -1698,6 +1728,7 @@ public abstract class AbstractAopProxyTests {
public TestDynamicPointcutAdvice(MethodInterceptor mi, final String pattern) {
super(mi);
setPointcut(new DynamicMethodMatcherPointcut() {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
boolean run = m.getName().indexOf(pattern) != -1;
if (run) ++count;
@@ -1716,11 +1747,13 @@ public abstract class AbstractAopProxyTests {
public TestDynamicPointcutForSettersOnly(MethodInterceptor mi, final String pattern) {
super(mi);
setPointcut(new DynamicMethodMatcherPointcut() {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
boolean run = m.getName().indexOf(pattern) != -1;
if (run) ++count;
return run;
}
@Override
public boolean matches(Method m, Class<?> clazz) {
return m.getName().startsWith("set");
}
@@ -1739,6 +1772,7 @@ public abstract class AbstractAopProxyTests {
super(mi);
this.pattern = pattern;
}
@Override
public boolean matches(Method m, Class<?> targetClass) {
boolean run = m.getName().indexOf(pattern) != -1;
if (run) ++count;
@@ -1757,6 +1791,7 @@ public abstract class AbstractAopProxyTests {
public Object target;
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
this.target = invocation.getThis();
return invocation.proceed();
@@ -1766,6 +1801,7 @@ public abstract class AbstractAopProxyTests {
private static class DummyIntroductionAdviceImpl implements DynamicIntroductionAdvice {
@Override
public boolean implementsInterface(Class<?> intf) {
return true;
}
@@ -1774,6 +1810,7 @@ public abstract class AbstractAopProxyTests {
public static class OwnSpouse extends TestBean {
@Override
public ITestBean getSpouse() {
return this;
}
@@ -1790,6 +1827,7 @@ public abstract class AbstractAopProxyTests {
return getClass().hashCode();
}
@Override
public void absquatulate() {
}
}
@@ -1811,14 +1849,17 @@ public abstract class AbstractAopProxyTests {
private int count;
@Override
public int getCount() {
return count;
}
@Override
public void incrementViaThis() {
this.increment();
}
@Override
public void incrementViaProxy() {
INeedsToSeeProxy thisViaProxy = (INeedsToSeeProxy) AopContext.currentProxy();
thisViaProxy.increment();
@@ -1829,6 +1870,7 @@ public abstract class AbstractAopProxyTests {
protected void checkAdvised(Advised advised) {
}
@Override
public void increment() {
++count;
}
@@ -1837,6 +1879,7 @@ public abstract class AbstractAopProxyTests {
public static class TargetChecker extends NeedsToSeeProxy {
@Override
protected void checkAdvised(Advised advised) {
// TODO replace this check: no longer possible
//assertEquals(advised.getTarget(), this);
@@ -1854,11 +1897,13 @@ public abstract class AbstractAopProxyTests {
this.expectedSource = expectedSource;
}
@Override
public void activated(AdvisedSupport advised) {
assertEquals(expectedSource, advised);
++activates;
}
@Override
public void adviceChanged(AdvisedSupport advised) {
assertEquals(expectedSource, advised);
++adviceChanges;
@@ -1870,10 +1915,12 @@ public abstract class AbstractAopProxyTests {
public int refreshes;
@Override
public void activated(AdvisedSupport advised) {
++refreshes;
}
@Override
public void adviceChanged(AdvisedSupport advised) {
++refreshes;
}
@@ -1894,17 +1941,21 @@ public abstract class AbstractAopProxyTests {
public static class Overloads implements IOverloads {
@Override
public void overload() {
}
@Override
public int overload(int i) {
return i;
}
@Override
public String overload(String s) {
return s;
}
@Override
public void noAdvice() {
}
}
@@ -1914,10 +1965,12 @@ public abstract class AbstractAopProxyTests {
public static class CountingMultiAdvice extends MethodCounter implements MethodBeforeAdvice,
AfterReturningAdvice, ThrowsAdvice {
@Override
public void before(Method m, Object[] args, Object target) throws Throwable {
count(m);
}
@Override
public void afterReturning(Object o, Method m, Object[] args, Object target)
throws Throwable {
count(m);
@@ -1983,6 +2036,7 @@ public abstract class AbstractAopProxyTests {
/**
* @see org.springframework.aop.TargetSource#getTargetClass()
*/
@Override
public Class<?> getTargetClass() {
return target.getClass();
}
@@ -1990,6 +2044,7 @@ public abstract class AbstractAopProxyTests {
/**
* @see org.springframework.aop.TargetSource#getTarget()
*/
@Override
public Object getTarget() throws Exception {
++gets;
return target;
@@ -1998,6 +2053,7 @@ public abstract class AbstractAopProxyTests {
/**
* @see org.springframework.aop.TargetSource#releaseTarget(java.lang.Object)
*/
@Override
public void releaseTarget(Object pTarget) throws Exception {
if (pTarget != this.target)
throw new RuntimeException("Released wrong target");
@@ -2016,6 +2072,7 @@ public abstract class AbstractAopProxyTests {
/**
* @see org.springframework.aop.TargetSource#isStatic()
*/
@Override
public boolean isStatic() {
return false;
}
@@ -2025,12 +2082,14 @@ public abstract class AbstractAopProxyTests {
static abstract class ExposedInvocationTestBean extends TestBean {
@Override
public String getName() {
MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation();
assertions(invocation);
return super.getName();
}
@Override
public void absquatulate() {
MethodInvocation invocation = ExposeInvocationInterceptor.currentInvocation();
assertions(invocation);
@@ -2042,6 +2101,7 @@ public abstract class AbstractAopProxyTests {
static class InvocationCheckExposedInvocationTestBean extends ExposedInvocationTestBean {
@Override
protected void assertions(MethodInvocation invocation) {
TestCase.assertTrue(invocation.getThis() == this);
TestCase.assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),

View File

@@ -58,6 +58,7 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
private static final String DEPENDENCY_CHECK_CONTEXT = CglibProxyTests.class.getSimpleName() + "-with-dependency-checking.xml";
@Override
protected Object createProxy(ProxyCreatorSupport as) {
as.setProxyTargetClass(true);
Object proxy = as.createAopProxy().getProxy();
@@ -65,11 +66,13 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
return proxy;
}
@Override
protected AopProxy createAopProxy(AdvisedSupport as) {
as.setProxyTargetClass(true);
return new CglibAopProxy(as);
}
@Override
protected boolean requiresTarget() {
return true;
}
@@ -207,10 +210,12 @@ public final class CglibProxyTests extends AbstractAopProxyTests implements Seri
MethodInterceptor advice = new NopInterceptor();
Pointcut pointcut = new Pointcut() {
@Override
public ClassFilter getClassFilter() {
return ClassFilter.TRUE;
}
@Override
public MethodMatcher getMethodMatcher() {
return MethodMatcher.TRUE;
}
@@ -492,6 +497,7 @@ class UnsupportedInterceptor implements MethodInterceptor {
/**
* @see org.aopalliance.intercept.MethodInterceptor#invoke(org.aopalliance.intercept.MethodInvocation)
*/
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
throw new UnsupportedOperationException(mi.getMethod().getName());
}

View File

@@ -42,6 +42,7 @@ import org.springframework.beans.TestBean;
@SuppressWarnings("serial")
public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements Serializable {
@Override
protected Object createProxy(ProxyCreatorSupport as) {
assertFalse("Not forcible CGLIB", as.isProxyTargetClass());
Object proxy = as.createAopProxy().getProxy();
@@ -49,6 +50,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
return proxy;
}
@Override
protected AopProxy createAopProxy(AdvisedSupport as) {
return new JdkDynamicAopProxy(as);
}
@@ -94,6 +96,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
public void testTargetCanGetInvocationWithPrivateClass() throws Throwable {
final ExposedInvocationTestBean expectedTarget = new ExposedInvocationTestBean() {
@Override
protected void assertions(MethodInvocation invocation) {
assertTrue(invocation.getThis() == this);
assertTrue("Invocation should be on ITestBean: " + invocation.getMethod(),
@@ -104,6 +107,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
AdvisedSupport pc = new AdvisedSupport(new Class<?>[] { ITestBean.class, IOther.class });
pc.addAdvice(ExposeInvocationInterceptor.INSTANCE);
TrapTargetInterceptor tii = new TrapTargetInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
// Assert that target matches BEFORE invocation returns
assertEquals("Target is correct", expectedTarget, invocation.getThis());
@@ -165,10 +169,12 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
public static class FooBar implements Foo, Bar {
@Override
public Bar getBarThis() {
return this;
}
@Override
public Foo getFooThis() {
return this;
}
@@ -189,6 +195,7 @@ public final class JdkDynamicProxyTests extends AbstractAopProxyTests implements
private final String name = "Rob Harrop";
@Override
public String getName() {
return this.name;
}

View File

@@ -307,6 +307,7 @@ public final class ProxyFactoryBeanTests {
final Exception ex = new UnsupportedOperationException("invoke");
// Add evil interceptor to head of list
config.addAdvice(0, new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
throw ex;
}
@@ -705,12 +706,14 @@ public final class ProxyFactoryBeanTests {
public PointcutForVoid() {
setAdvice(new MethodInterceptor() {
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
methodNames.add(invocation.getMethod().getName());
return invocation.proceed();
}
});
setPointcut(new DynamicMethodMatcherPointcut() {
@Override
public boolean matches(Method m, Class<?> targetClass, Object[] args) {
return m.getReturnType() == Void.TYPE;
}
@@ -734,10 +737,12 @@ public final class ProxyFactoryBeanTests {
*/
public static class GlobalAspectInterfaceInterceptor implements IntroductionInterceptor {
@Override
public boolean implementsInterface(Class<?> intf) {
return intf.equals(AddedGlobalInterface.class);
}
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
if (mi.getMethod().getDeclaringClass().equals(AddedGlobalInterface.class)) {
return new Integer(-1);
@@ -751,22 +756,27 @@ public final class ProxyFactoryBeanTests {
private IntroductionInterceptor gi = new GlobalAspectInterfaceInterceptor();
@Override
public ClassFilter getClassFilter() {
return ClassFilter.TRUE;
}
@Override
public Advice getAdvice() {
return this.gi;
}
@Override
public Class<?>[] getInterfaces() {
return new Class<?>[] { AddedGlobalInterface.class };
}
@Override
public boolean isPerInstance() {
return false;
}
@Override
public void validateInterfaces() {
}
}

View File

@@ -27,14 +27,17 @@ interface IEcho {
class Echo implements IEcho {
private int a;
@Override
public int echoException(int i, Throwable t) throws Throwable {
if (t != null)
throw t;
return i;
}
@Override
public void setA(int a) {
this.a = a;
}
@Override
public int getA() {
return a;
}

View File

@@ -96,10 +96,12 @@ interface SimpleBeforeAdvice extends BeforeAdvice {
@SuppressWarnings("serial")
class SimpleBeforeAdviceAdapter implements AdvisorAdapter, Serializable {
@Override
public boolean supportsAdvice(Advice advice) {
return (advice instanceof SimpleBeforeAdvice);
}
@Override
public MethodInterceptor getInterceptor(Advisor advisor) {
SimpleBeforeAdvice advice = (SimpleBeforeAdvice) advisor.getAdvice();
return new SimpleBeforeAdviceInterceptor(advice) ;
@@ -112,6 +114,7 @@ class SimpleBeforeAdviceImpl implements SimpleBeforeAdvice {
private int invocationCounter;
@Override
public void before() throws Throwable {
++invocationCounter;
}
@@ -131,6 +134,7 @@ final class SimpleBeforeAdviceInterceptor implements MethodInterceptor {
this.advice = advice;
}
@Override
public Object invoke(MethodInvocation mi) throws Throwable {
advice.before();
return mi.proceed();

View File

@@ -218,6 +218,7 @@ class CountingTestBean extends TestBean {
class SelectivePrototypeTargetSourceCreator extends AbstractBeanFactoryBasedTargetSourceCreator {
@Override
protected AbstractBeanFactoryBasedTargetSource createBeanFactoryBasedTargetSource(
Class<?> beanClass, String beanName) {
if (!beanName.startsWith("prototype")) {

View File

@@ -281,6 +281,7 @@ public final class AutoProxyCreatorTests {
this.proxyObject = proxyObject;
}
@Override
protected Object[] getAdvicesAndAdvisorsForBean(Class<?> beanClass, String name, TargetSource customTargetSource) {
if (StaticMessageSource.class.equals(beanClass)) {
return DO_NOT_PROXY;
@@ -308,6 +309,7 @@ public final class AutoProxyCreatorTests {
public int nrOfInvocations = 0;
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
if (!invocation.getMethod().getName().equals("finalize")) {
this.nrOfInvocations++;

View File

@@ -47,6 +47,7 @@ public final class BeanNameAutoProxyCreatorInitTests {
class NullChecker implements MethodBeforeAdvice {
@Override
public void before(Method method, Object[] args, Object target) throws Throwable {
check(args);
}

View File

@@ -205,6 +205,7 @@ class CreatesTestBean implements FactoryBean<Object> {
/**
* @see org.springframework.beans.factory.FactoryBean#getObject()
*/
@Override
public Object getObject() throws Exception {
return new TestBean();
}
@@ -212,6 +213,7 @@ class CreatesTestBean implements FactoryBean<Object> {
/**
* @see org.springframework.beans.factory.FactoryBean#getObjectType()
*/
@Override
public Class<?> getObjectType() {
return TestBean.class;
}
@@ -219,6 +221,7 @@ class CreatesTestBean implements FactoryBean<Object> {
/**
* @see org.springframework.beans.factory.FactoryBean#isSingleton()
*/
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -51,12 +51,14 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA
}
@Override
public void setBeanName(String beanName) {
if (this.beanName == null || beanName == null) {
this.beanName = beanName;
}
}
@Override
public String getBeanName() {
return beanName;
}
@@ -75,10 +77,12 @@ public class DerivedTestBean extends TestBean implements Serializable, BeanNameA
}
@Override
public void destroy() {
this.destroyed = true;
}
@Override
public boolean wasDestroyed() {
return destroyed;
}

View File

@@ -37,6 +37,7 @@ public class NestedTestBean implements INestedTestBean {
this.company = (company != null ? company : "");
}
@Override
public String getCompany() {
return company;
}

View File

@@ -31,22 +31,27 @@ public class SerializablePerson implements Person, Serializable {
private String name;
private int age;
@Override
public int getAge() {
return age;
}
@Override
public void setAge(int age) {
this.age = age;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@Override
public Object echo(Object o) throws Throwable {
if (o instanceof Throwable) {
throw (Throwable) o;

View File

@@ -137,6 +137,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
}
@Override
public void setBeanName(String beanName) {
this.beanName = beanName;
}
@@ -145,6 +146,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
return beanName;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}
@@ -161,10 +163,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
return postProcessed;
}
@Override
public String getName() {
return name;
}
@Override
public void setName(String name) {
this.name = name;
}
@@ -180,10 +184,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
}
}
@Override
public int getAge() {
return age;
}
@Override
public void setAge(int age) {
this.age = age;
}
@@ -196,14 +202,17 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.jedi = jedi;
}
@Override
public ITestBean getSpouse() {
return (spouses != null ? spouses[0] : null);
}
@Override
public void setSpouse(ITestBean spouse) {
this.spouses = new ITestBean[] {spouse};
}
@Override
public ITestBean[] getSpouses() {
return spouses;
}
@@ -230,10 +239,12 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.country = country;
}
@Override
public String[] getStringArray() {
return stringArray;
}
@Override
public void setStringArray(String[] stringArray) {
this.stringArray = stringArray;
}
@@ -302,6 +313,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.someProperties = someProperties;
}
@Override
public INestedTestBean getDoctor() {
return doctor;
}
@@ -310,6 +322,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.doctor = doctor;
}
@Override
public INestedTestBean getLawyer() {
return lawyer;
}
@@ -342,6 +355,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
this.someBoolean = someBoolean;
}
@Override
public IndexedTestBean getNestedIndexedBean() {
return nestedIndexedBean;
}
@@ -370,18 +384,21 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
/**
* @see org.springframework.beans.ITestBean#exceptional(Throwable)
*/
@Override
public void exceptional(Throwable t) throws Throwable {
if (t != null) {
throw t;
}
}
@Override
public void unreliableFileOperation() throws IOException {
throw new IOException();
}
/**
* @see org.springframework.beans.ITestBean#returnsThis()
*/
@Override
public Object returnsThis() {
return this;
}
@@ -389,9 +406,11 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
/**
* @see org.springframework.beans.IOther#absquatulate()
*/
@Override
public void absquatulate() {
}
@Override
public int haveBirthday() {
return age++;
}
@@ -421,6 +440,7 @@ public class TestBean implements BeanNameAware, BeanFactoryAware, ITestBean, IOt
return this.age;
}
@Override
public int compareTo(Object other) {
if (this.name != null && other instanceof TestBean) {
return this.name.compareTo(((TestBean) other).getName());

View File

@@ -317,6 +317,7 @@ public abstract class AbstractBeanFactoryTests extends TestCase {
public static class TestBeanEditor extends PropertyEditorSupport {
@Override
public void setAsText(String text) {
TestBean tb = new TestBean();
StringTokenizer st = new StringTokenizer(text, "_");

View File

@@ -74,6 +74,7 @@ public class DummyFactory
* Return if the bean managed by this factory is a singleton.
* @see org.springframework.beans.factory.FactoryBean#isSingleton()
*/
@Override
public boolean isSingleton() {
return this.singleton;
}
@@ -85,6 +86,7 @@ public class DummyFactory
this.singleton = singleton;
}
@Override
public void setBeanName(String beanName) {
this.beanName = beanName;
}
@@ -93,6 +95,7 @@ public class DummyFactory
return beanName;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = (AutowireCapableBeanFactory) beanFactory;
this.beanFactory.applyBeanPostProcessorsBeforeInitialization(this.testBean, this.beanName);
@@ -119,6 +122,7 @@ public class DummyFactory
return otherTestBean;
}
@Override
public void afterPropertiesSet() {
if (initialized) {
throw new RuntimeException("Cannot call afterPropertiesSet twice on the one bean");
@@ -144,6 +148,7 @@ public class DummyFactory
* and prototype mode.
* @see org.springframework.beans.factory.FactoryBean#getObject()
*/
@Override
public Object getObject() throws BeansException {
if (isSingleton()) {
return this.testBean;
@@ -158,11 +163,13 @@ public class DummyFactory
}
}
@Override
public Class<TestBean> getObjectType() {
return TestBean.class;
}
@Override
public void destroy() {
if (this.testBean != null) {
this.testBean.setName(null);

View File

@@ -53,6 +53,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
return initMethodDeclared;
}
@Override
public void setBeanName(String name) {
this.beanName = name;
}
@@ -61,6 +62,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
return beanName;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.owningFactory = beanFactory;
}
@@ -75,6 +77,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
this.postProcessedBeforeInit = true;
}
@Override
public void afterPropertiesSet() {
if (this.owningFactory == null) {
throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean");
@@ -126,6 +129,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
}
}
@Override
public void destroy() {
if (this.destroyed) {
throw new IllegalStateException("Already destroyed");
@@ -140,6 +144,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
public static class PostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
if (bean instanceof LifecycleBean) {
((LifecycleBean) bean).postProcessBeforeInit();
@@ -147,6 +152,7 @@ public class LifecycleBean implements BeanNameAware, BeanFactoryAware, Initializ
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
if (bean instanceof LifecycleBean) {
((LifecycleBean) bean).postProcessAfterInit();

View File

@@ -28,6 +28,7 @@ public class MustBeInitialized implements InitializingBean {
/**
* @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
*/
@Override
public void afterPropertiesSet() throws Exception {
this.inited = true;
}

View File

@@ -49,6 +49,7 @@ class UserServiceImpl extends GenericServiceImpl<Foo> {
protected Foo object;
@Override
@Inject
@Named("userObject")
public void setObject(Foo object) {

View File

@@ -44,6 +44,7 @@ public class SimpleMapScope implements Scope, Serializable {
}
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
synchronized (this.map) {
Object scopedObject = this.map.get(name);
@@ -55,16 +56,19 @@ public class SimpleMapScope implements Scope, Serializable {
}
}
@Override
public Object remove(String name) {
synchronized (this.map) {
return this.map.remove(name);
}
}
@Override
public void registerDestructionCallback(String name, Runnable callback) {
this.callbacks.add(callback);
}
@Override
public Object resolveContextualObject(String key) {
return null;
}
@@ -76,6 +80,7 @@ public class SimpleMapScope implements Scope, Serializable {
}
}
@Override
public String getConversationId() {
return null;
}

View File

@@ -40,6 +40,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
private final List<ImportDefinition> imports = new LinkedList<ImportDefinition>();
@Override
public void defaultsRegistered(DefaultsDefinition defaultsDefinition) {
this.defaults.add(defaultsDefinition);
}
@@ -48,6 +49,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
return Collections.unmodifiableList(this.defaults);
}
@Override
public void componentRegistered(ComponentDefinition componentDefinition) {
this.componentDefinitions.put(componentDefinition.getName(), componentDefinition);
}
@@ -61,6 +63,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
return collection.toArray(new ComponentDefinition[collection.size()]);
}
@Override
public void aliasRegistered(AliasDefinition aliasDefinition) {
List<AliasDefinition> aliases = this.aliasMap.get(aliasDefinition.getBeanName());
if(aliases == null) {
@@ -75,6 +78,7 @@ public class CollectingReaderEventListener implements ReaderEventListener {
return aliases == null ? null : Collections.unmodifiableList(aliases);
}
@Override
public void importProcessed(ImportDefinition importDefinition) {
this.imports.add(importDefinition);
}

View File

@@ -65,6 +65,7 @@ public final class DependenciesBean implements BeanFactoryAware {
return spouse;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.beanFactory = beanFactory;
}

View File

@@ -389,14 +389,17 @@ public final class QualifierAnnotationTests {
@Qualifier(FACTORY_QUALIFIER)
public static class QualifiedFactoryBean implements FactoryBean<Theta> {
@Override
public Theta getObject() {
return new Theta() {};
}
@Override
public Class<Theta> getObjectType() {
return Theta.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -256,6 +256,7 @@ class DummyBoImpl implements DummyBo {
this.dao = dao;
}
@Override
public void something() {
}
@@ -430,6 +431,7 @@ class FixedMethodReplacer implements MethodReplacer {
public static final String VALUE = "fixedMethodReplacer";
@Override
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable {
return VALUE;
}
@@ -513,6 +515,7 @@ abstract class OverrideOneMethod extends MethodReplaceCandidate implements Overr
protected abstract TestBean protectedOverrideSingleton();
@Override
public TestBean getPrototypeDependency(Object someParam) {
return new TestBean();
}
@@ -540,6 +543,7 @@ abstract class OverrideOneMethod extends MethodReplaceCandidate implements Overr
return "replaceMe:" + someParam;
}
@Override
public String replaceMe(String someParam) {
return "replaceMe:" + someParam;
}
@@ -595,6 +599,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
return initMethodDeclared;
}
@Override
public void setBeanName(String name) {
this.beanName = name;
}
@@ -603,6 +608,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
return beanName;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) {
this.owningFactory = beanFactory;
}
@@ -617,6 +623,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
this.postProcessedBeforeInit = true;
}
@Override
public void afterPropertiesSet() {
if (this.owningFactory == null) {
throw new RuntimeException("Factory didn't call setBeanFactory before afterPropertiesSet on lifecycle bean");
@@ -668,6 +675,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
}
}
@Override
public void destroy() {
if (this.destroyed) {
throw new IllegalStateException("Already destroyed");
@@ -682,6 +690,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
public static class PostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String name) throws BeansException {
if (bean instanceof ProtectedLifecycleBean) {
((ProtectedLifecycleBean) bean).postProcessBeforeInit();
@@ -689,6 +698,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String name) throws BeansException {
if (bean instanceof ProtectedLifecycleBean) {
((ProtectedLifecycleBean) bean).postProcessAfterInit();
@@ -706,6 +716,7 @@ class ProtectedLifecycleBean implements BeanNameAware, BeanFactoryAware, Initial
@SuppressWarnings("serial")
class ReverseMethodReplacer implements MethodReplacer, Serializable {
@Override
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable {
String s = (String) args[0];
return new StringBuffer(s).reverse().toString();

View File

@@ -1511,6 +1511,7 @@ public final class XmlBeanFactoryTests {
public Object lastArg;
@Override
public Object reimplement(Object obj, Method method, Object[] args) throws Throwable {
assertEquals(1, args.length);
assertEquals("doSomething", method.getName());
@@ -1558,6 +1559,7 @@ public final class XmlBeanFactoryTests {
constructed = true;
}
@Override
public void afterPropertiesSet() {
if (this.initMethodInvoked) {
fail();
@@ -1579,6 +1581,7 @@ public final class XmlBeanFactoryTests {
this.initMethodInvoked = true;
}
@Override
public void destroy() {
if (this.customDestroyed) {
fail();
@@ -1611,6 +1614,7 @@ public final class XmlBeanFactoryTests {
prepared = true;
}
@Override
public void destroy() {
destroyed = true;
}
@@ -1627,6 +1631,7 @@ public final class XmlBeanFactoryTests {
prepared = true;
}
@Override
public void destroy() {
destroyed = true;
}
@@ -1654,12 +1659,14 @@ public final class XmlBeanFactoryTests {
public void setInTheMiddleBean(InTheMiddleBean bean) {
}
@Override
public void afterPropertiesSet() {
if (!(PreparingBean1.prepared && PreparingBean2.prepared)) {
throw new IllegalStateException("Need prepared PreparingBeans!");
}
}
@Override
public void destroy() {
if (PreparingBean1.destroyed || PreparingBean2.destroyed) {
throw new IllegalStateException("Should not be destroyed after PreparingBeans");
@@ -1692,6 +1699,7 @@ public final class XmlBeanFactoryTests {
this.dependingBean = dependingBean;
}
@Override
public void destroy() {
if (this.dependingBean.destroyed) {
throw new IllegalStateException("Should not be destroyed after DependingBean");
@@ -1794,10 +1802,12 @@ public final class XmlBeanFactoryTests {
public static class WrappingPostProcessor implements BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
ProxyFactory pf = new ProxyFactory(bean);
return pf.getProxy();

View File

@@ -194,6 +194,7 @@ public class CustomNamespaceHandlerTests {
super(CLASS.getClassLoader());
}
@Override
public InputSource resolveEntity(String publicId, String systemId) throws IOException {
InputSource source = super.resolveEntity(publicId, systemId);
if (source == null) {
@@ -216,6 +217,7 @@ public class CustomNamespaceHandlerTests {
*/
final class TestNamespaceHandler extends NamespaceHandlerSupport {
@Override
public void init() {
registerBeanDefinitionParser("testBean", new TestBeanDefinitionParser());
registerBeanDefinitionParser("person", new PersonDefinitionParser());
@@ -228,6 +230,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
private static class TestBeanDefinitionParser implements BeanDefinitionParser {
@Override
public BeanDefinition parse(Element element, ParserContext parserContext) {
RootBeanDefinition definition = new RootBeanDefinition();
definition.setBeanClass(TestBean.class);
@@ -245,10 +248,12 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
private static final class PersonDefinitionParser extends AbstractSingleBeanDefinitionParser {
@Override
protected Class<?> getBeanClass(Element element) {
return TestBean.class;
}
@Override
protected void doParse(Element element, BeanDefinitionBuilder builder) {
builder.addPropertyValue("name", element.getAttribute("name"));
builder.addPropertyValue("age", element.getAttribute("age"));
@@ -257,6 +262,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
private static class PropertyModifyingBeanDefinitionDecorator implements BeanDefinitionDecorator {
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
Element element = (Element) node;
BeanDefinition def = definition.getBeanDefinition();
@@ -272,6 +278,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
private static class DebugBeanDefinitionDecorator extends AbstractInterceptorDrivenBeanDefinitionDecorator {
@Override
protected BeanDefinition createInterceptorDefinition(Node node) {
return new RootBeanDefinition(DebugInterceptor.class);
}
@@ -279,6 +286,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
private static class NopInterceptorBeanDefinitionDecorator extends AbstractInterceptorDrivenBeanDefinitionDecorator {
@Override
protected BeanDefinition createInterceptorDefinition(Node node) {
return new RootBeanDefinition(NopInterceptor.class);
}
@@ -286,6 +294,7 @@ final class TestNamespaceHandler extends NamespaceHandlerSupport {
private static class ObjectNameBeanDefinitionDecorator implements BeanDefinitionDecorator {
@Override
public BeanDefinitionHolder decorate(Node node, BeanDefinitionHolder definition, ParserContext parserContext) {
Attr objectNameAttribute = (Attr) node;
definition.getBeanDefinition().setAttribute("objectName", objectNameAttribute.getValue());

View File

@@ -32,105 +32,127 @@ public class AnnotatedClassCacheableService implements CacheableService<Object>
private final AtomicLong counter = new AtomicLong();
public static final AtomicLong nullInvocations = new AtomicLong();
@Override
public Object cache(Object arg1) {
return counter.getAndIncrement();
}
@Override
public Object conditional(int field) {
return null;
}
@Override
@CacheEvict("default")
public void invalidate(Object arg1) {
}
@Override
@CacheEvict("default")
public void evictWithException(Object arg1) {
throw new RuntimeException("exception thrown - evict should NOT occur");
}
@Override
@CacheEvict(value = "default", allEntries = true)
public void evictAll(Object arg1) {
}
@Override
@CacheEvict(value = "default", beforeInvocation = true)
public void evictEarly(Object arg1) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@CacheEvict(value = "default", key = "#p0")
public void evict(Object arg1, Object arg2) {
}
@Override
@CacheEvict(value = "default", key = "#p0", beforeInvocation = true)
public void invalidateEarly(Object arg1, Object arg2) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@Cacheable(value = "default", key = "#p0")
public Object key(Object arg1, Object arg2) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName + #root.caches[0].name")
public Object name(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName + #root.method.name + #root.targetClass + #root.target")
public Object rootVars(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut("default")
public Object update(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut(value = "default", condition = "#arg.equals(3)")
public Object conditionalUpdate(Object arg) {
return arg;
}
@Override
public Object nullValue(Object arg1) {
nullInvocations.incrementAndGet();
return null;
}
@Override
public Number nullInvocations() {
return nullInvocations.get();
}
@Override
public Long throwChecked(Object arg1) throws Exception {
throw new UnsupportedOperationException(arg1.toString());
}
@Override
public Long throwUnchecked(Object arg1) {
throw new UnsupportedOperationException();
}
// multi annotations
@Override
@Caching(cacheable = { @Cacheable("primary"), @Cacheable("secondary") })
public Object multiCache(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(evict = { @CacheEvict("primary"), @CacheEvict(value = "secondary", key = "#a0"), @CacheEvict(value = "primary", key = "#p0 + 'A'") })
public Object multiEvict(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(cacheable = { @Cacheable(value = "primary", key = "#root.methodName") }, evict = { @CacheEvict("secondary") })
public Object multiCacheAndEvict(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(cacheable = { @Cacheable(value = "primary", condition = "#a0 == 3") }, evict = { @CacheEvict("secondary") })
public Object multiConditionalCacheAndEvict(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(put = { @CachePut("primary"), @CachePut("secondary") })
public Object multiUpdate(Object arg1) {
return arg1;

View File

@@ -33,83 +33,100 @@ public class DefaultCacheableService implements CacheableService<Long> {
private final AtomicLong counter = new AtomicLong();
private final AtomicLong nullInvocations = new AtomicLong();
@Override
@Cacheable("default")
public Long cache(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CacheEvict("default")
public void invalidate(Object arg1) {
}
@Override
@CacheEvict("default")
public void evictWithException(Object arg1) {
throw new RuntimeException("exception thrown - evict should NOT occur");
}
@Override
@CacheEvict(value = "default", allEntries = true)
public void evictAll(Object arg1) {
}
@Override
@CacheEvict(value = "default", beforeInvocation = true)
public void evictEarly(Object arg1) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@CacheEvict(value = "default", key = "#p0")
public void evict(Object arg1, Object arg2) {
}
@Override
@CacheEvict(value = "default", key = "#p0", beforeInvocation = true)
public void invalidateEarly(Object arg1, Object arg2) {
throw new RuntimeException("exception thrown - evict should still occur");
}
@Override
@Cacheable(value = "default", condition = "#classField == 3")
public Long conditional(int classField) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#p0")
public Long key(Object arg1, Object arg2) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName")
public Long name(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Cacheable(value = "default", key = "#root.methodName + #root.method.name + #root.targetClass + #root.target")
public Long rootVars(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut("default")
public Long update(Object arg1) {
return counter.getAndIncrement();
}
@Override
@CachePut(value = "default", condition = "#arg.equals(3)")
public Long conditionalUpdate(Object arg) {
return Long.valueOf(arg.toString());
}
@Override
@Cacheable("default")
public Long nullValue(Object arg1) {
nullInvocations.incrementAndGet();
return null;
}
@Override
public Number nullInvocations() {
return nullInvocations.get();
}
@Override
@Cacheable("default")
public Long throwChecked(Object arg1) throws Exception {
throw new Exception(arg1.toString());
}
@Override
@Cacheable("default")
public Long throwUnchecked(Object arg1) {
throw new UnsupportedOperationException(arg1.toString());
@@ -117,26 +134,31 @@ public class DefaultCacheableService implements CacheableService<Long> {
// multi annotations
@Override
@Caching(cacheable = { @Cacheable("primary"), @Cacheable("secondary") })
public Long multiCache(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(evict = { @CacheEvict("primary"), @CacheEvict(value = "secondary", key = "#p0"), @CacheEvict(value = "primary", key = "#p0 + 'A'") })
public Long multiEvict(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(cacheable = { @Cacheable(value = "primary", key = "#root.methodName") }, evict = { @CacheEvict("secondary") })
public Long multiCacheAndEvict(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(cacheable = { @Cacheable(value = "primary", condition = "#p0 == 3") }, evict = { @CacheEvict("secondary") })
public Long multiConditionalCacheAndEvict(Object arg1) {
return counter.getAndIncrement();
}
@Override
@Caching(put = { @CachePut("primary"), @CachePut("secondary") })
public Long multiUpdate(Object arg1) {
return Long.valueOf(arg1.toString());

View File

@@ -115,6 +115,7 @@ public class EnableCachingTests extends AbstractAnnotationTests {
@Configuration
@EnableCaching
static class EnableCachingConfig implements CachingConfigurer {
@Override
@Bean
public CacheManager cacheManager() {
SimpleCacheManager cm = new SimpleCacheManager();
@@ -135,6 +136,7 @@ public class EnableCachingTests extends AbstractAnnotationTests {
return new AnnotatedClassCacheableService();
}
@Override
@Bean
public KeyGenerator keyGenerator() {
return new SomeKeyGenerator();
@@ -174,9 +176,11 @@ public class EnableCachingTests extends AbstractAnnotationTests {
@Bean
public CacheManager cm2() { return new NoOpCacheManager(); }
@Override
public CacheManager cacheManager() {
return cm1();
}
@Override
public KeyGenerator keyGenerator() {
return null;
}

View File

@@ -22,6 +22,7 @@ public class ACATester implements ApplicationContextAware {
private ApplicationContext ac;
@Override
public void setApplicationContext(ApplicationContext ctx) throws ApplicationContextException {
// check reinitialization
if (this.ac != null) {

View File

@@ -39,10 +39,12 @@ public abstract class AbstractApplicationContextTests extends AbstractListableBe
protected TestListener parentListener = new TestListener();
@Override
protected void setUp() throws Exception {
this.applicationContext = createContext();
}
@Override
protected BeanFactory getBeanFactory() {
return applicationContext;
}

View File

@@ -26,6 +26,7 @@ public class BeanThatBroadcasts implements ApplicationContextAware {
public int receivedCount;
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
if (applicationContext.getDisplayName().indexOf("listener") != -1) {

View File

@@ -43,6 +43,7 @@ public class BeanThatListens implements ApplicationListener<ApplicationEvent> {
}
@Override
public void onApplicationEvent(ApplicationEvent event) {
eventCount++;
if (beanThatBroadcasts != null) {

View File

@@ -30,18 +30,21 @@ public class LifecycleContextBean extends LifecycleBean implements ApplicationCo
protected ApplicationContext owningContext;
@Override
public void setBeanFactory(BeanFactory beanFactory) {
super.setBeanFactory(beanFactory);
if (this.owningContext != null)
throw new RuntimeException("Factory called setBeanFactory after setApplicationContext");
}
@Override
public void afterPropertiesSet() {
super.afterPropertiesSet();
if (this.owningContext == null)
throw new RuntimeException("Factory didn't call setAppliationContext before afterPropertiesSet on lifecycle bean");
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
if (this.owningFactory == null)
throw new RuntimeException("Factory called setApplicationContext before setBeanFactory");

View File

@@ -34,6 +34,7 @@ public class TestListener implements ApplicationListener<ApplicationEvent> {
eventCount = 0;
}
@Override
public void onApplicationEvent(ApplicationEvent e) {
++eventCount;
}

View File

@@ -47,6 +47,7 @@ public class ContextSingletonBeanFactoryLocatorTests extends SingletonBeanFactor
new XmlBeanFactory(new ClassPathResource("/org/springframework/beans/factory/access/beans2.xml"));
}
@Override
@Test
public void testBasicFunctionality() {
ContextSingletonBeanFactoryLocator facLoc = new ContextSingletonBeanFactoryLocator(
@@ -71,6 +72,7 @@ public class ContextSingletonBeanFactoryLocatorTests extends SingletonBeanFactor
* 2nd and subsequent calls will actually get back same locator instance. This is not
* really an issue, since the contained bean factories will still be loaded and released.
*/
@Override
@Test
public void testGetInstance() {
// Try with and without 'classpath*:' prefix, and with 'classpath:' prefix.

View File

@@ -159,18 +159,22 @@ public class AnnotationConfigApplicationContextTests {
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
context.register(AutowiredConfig.class);
context.getBeanFactory().addBeanPostProcessor(new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
return (bean instanceof TestBean ? null : bean);
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}
});
context.getBeanFactory().addBeanPostProcessor(new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
bean.getClass().getName();
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
bean.getClass().getName();
return bean;
@@ -230,14 +234,17 @@ public class AnnotationConfigApplicationContextTests {
static class UntypedFactoryBean implements FactoryBean<Object> {
@Override
public Object getObject() {
return null;
}
@Override
public Class<?> getObjectType() {
return null;
}
@Override
public boolean isSingleton() {
return false;
}

View File

@@ -151,6 +151,7 @@ public class AnnotationProcessorPerformanceTests {
private static class ResourceAnnotatedTestBean extends TestBean {
@Override
@Resource @Required
public void setSpouse(ITestBean spouse) {
super.setSpouse(spouse);
@@ -160,6 +161,7 @@ public class AnnotationProcessorPerformanceTests {
private static class AutowiredAnnotatedTestBean extends TestBean {
@Override
@Autowired @Required
public void setSpouse(ITestBean spouse) {
super.setSpouse(spouse);

View File

@@ -207,6 +207,7 @@ public class CommonAnnotationBeanPostProcessorTests {
bf.registerResolvableDependency(BeanFactory.class, bf);
bf.registerResolvableDependency(INestedTestBean.class, new ObjectFactory<Object>() {
@Override
public Object getObject() throws BeansException {
return new NestedTestBean();
}
@@ -452,6 +453,7 @@ public class CommonAnnotationBeanPostProcessorTests {
public static class InitDestroyBeanPostProcessor implements DestructionAwareBeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AnnotatedInitDestroyBean) {
assertFalse(((AnnotatedInitDestroyBean) bean).initCalled);
@@ -459,6 +461,7 @@ public class CommonAnnotationBeanPostProcessorTests {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
if (bean instanceof AnnotatedInitDestroyBean) {
assertTrue(((AnnotatedInitDestroyBean) bean).initCalled);
@@ -466,6 +469,7 @@ public class CommonAnnotationBeanPostProcessorTests {
return bean;
}
@Override
public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException {
if (bean instanceof AnnotatedInitDestroyBean) {
assertFalse(((AnnotatedInitDestroyBean) bean).destroyCalled);
@@ -566,6 +570,7 @@ public class CommonAnnotationBeanPostProcessorTests {
@Resource
private BeanFactory beanFactory;
@Override
@Resource
public void setTestBean2(TestBean testBean2) {
super.setTestBean2(testBean2);
@@ -597,6 +602,7 @@ public class CommonAnnotationBeanPostProcessorTests {
return testBean6;
}
@Override
@PostConstruct
protected void init2() {
if (this.testBean3 == null || this.testBean4 == null) {
@@ -605,6 +611,7 @@ public class CommonAnnotationBeanPostProcessorTests {
super.init2();
}
@Override
@PreDestroy
protected void destroy2() {
super.destroy2();
@@ -627,6 +634,7 @@ public class CommonAnnotationBeanPostProcessorTests {
@Resource
private BeanFactory beanFactory;
@Override
@EJB
public void setTestBean2(TestBean testBean2) {
super.setTestBean2(testBean2);
@@ -650,6 +658,7 @@ public class CommonAnnotationBeanPostProcessorTests {
return testBean4;
}
@Override
@PostConstruct
protected void init2() {
if (this.testBean3 == null || this.testBean4 == null) {
@@ -658,6 +667,7 @@ public class CommonAnnotationBeanPostProcessorTests {
super.init2();
}
@Override
@PreDestroy
protected void destroy2() {
super.destroy2();

View File

@@ -147,6 +147,7 @@ public class ComponentScanParserTests {
public static class CustomTypeFilter implements TypeFilter {
@Override
public boolean match(MetadataReader metadataReader, MetadataReaderFactory metadataReaderFactory) {
return metadataReader.getClassMetadata().getClassName().contains("Custom");
}

View File

@@ -75,6 +75,7 @@ public class ConfigurationClassAndBFPPTests {
@Bean
public BeanFactoryPostProcessor bfpp() {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
// no-op
}
@@ -90,6 +91,7 @@ public class ConfigurationClassAndBFPPTests {
@Bean
public static final BeanFactoryPostProcessor bfpp() {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
// no-op
}

View File

@@ -95,12 +95,15 @@ class DummyBean {
class MyFactoryBean implements FactoryBean<String> {
@Override
public String getObject() throws Exception {
return "foo";
}
@Override
public Class<String> getObjectType() {
return String.class;
}
@Override
public boolean isSingleton() {
return true;
}
@@ -115,15 +118,18 @@ class MyParameterizedFactoryBean<T> implements FactoryBean<T> {
this.obj = obj;
}
@Override
public T getObject() throws Exception {
return obj;
}
@Override
@SuppressWarnings("unchecked")
public Class<T> getObjectType() {
return (Class<T>)obj.getClass();
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -63,14 +63,17 @@ class Bar {
class FooFactoryBean implements FactoryBean<Foo> {
@Override
public Foo getObject() {
return new Foo();
}
@Override
public Class<Foo> getObjectType() {
return Foo.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -140,6 +140,7 @@ public class DestroyMethodInferenceTests {
static class WithInheritedCloseMethod implements Closeable {
boolean closed = false;
@Override
public void close() throws IOException {
closed = true;
}

View File

@@ -70,6 +70,7 @@ public class EnableLoadTimeWeavingTests {
@Configuration
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.DISABLED)
static class EnableLTWConfig_withAjWeavingDisabled implements LoadTimeWeavingConfigurer {
@Override
public LoadTimeWeaver getLoadTimeWeaver() {
LoadTimeWeaver mockLTW = createMock(LoadTimeWeaver.class);
// no expectations -> a class file transformer should NOT be added
@@ -81,6 +82,7 @@ public class EnableLoadTimeWeavingTests {
@Configuration
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.AUTODETECT)
static class EnableLTWConfig_withAjWeavingAutodetect implements LoadTimeWeavingConfigurer {
@Override
public LoadTimeWeaver getLoadTimeWeaver() {
LoadTimeWeaver mockLTW = createMock(LoadTimeWeaver.class);
// no expectations -> a class file transformer should NOT be added
@@ -93,6 +95,7 @@ public class EnableLoadTimeWeavingTests {
@Configuration
@EnableLoadTimeWeaving(aspectjWeaving=AspectJWeaving.ENABLED)
static class EnableLTWConfig_withAjWeavingEnabled implements LoadTimeWeavingConfigurer {
@Override
public LoadTimeWeaver getLoadTimeWeaver() {
LoadTimeWeaver mockLTW = createMock(LoadTimeWeaver.class);
mockLTW.addTransformer(isA(ClassFileTransformer.class));

View File

@@ -31,6 +31,7 @@ public class FooServiceDependentConverter implements Converter<String, org.sprin
this.fooService = fooService;
}
@Override
public org.springframework.beans.TestBean convert(String source) {
return new org.springframework.beans.TestBean(source);
}

View File

@@ -124,6 +124,7 @@ public class ImportAwareTests {
AnnotationMetadata importMetadata;
@Override
public void setImportMetadata(AnnotationMetadata importMetadata) {
this.importMetadata = importMetadata;
}
@@ -142,14 +143,17 @@ public class ImportAwareTests {
static class BPP implements BeanFactoryAware, BeanPostProcessor {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
}
}
@@ -175,6 +179,7 @@ public class ImportAwareTests {
static boolean called;
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata,
BeanDefinitionRegistry registry) {
BeanDefinition beanDefinition = new GenericBeanDefinition();

View File

@@ -75,18 +75,22 @@ public class ImportBeanDefinitionRegistrarTests {
static ResourceLoader resourceLoader;
static BeanFactory beanFactory;
@Override
public void setBeanClassLoader(ClassLoader classLoader) {
SampleRegistrar.classLoader = classLoader;
}
@Override
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
SampleRegistrar.beanFactory = beanFactory;
}
@Override
public void setResourceLoader(ResourceLoader resourceLoader) {
SampleRegistrar.resourceLoader = resourceLoader;
}
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
}
}

View File

@@ -132,6 +132,7 @@ public class NestedConfigurationClassTests {
@Configuration
static class S1Config extends L0Config {
@Override
@Bean
public TestBean overrideBean() {
return new TestBean("override-s1");

View File

@@ -209,10 +209,12 @@ public class Spr3775InitDestroyLifecycleTests {
public static class CustomInitializingDisposableBean extends CustomInitDestroyBean
implements InitializingBean, DisposableBean {
@Override
public void afterPropertiesSet() throws Exception {
this.initMethods.add("afterPropertiesSet");
}
@Override
public void destroy() throws Exception {
this.destroyMethods.add("destroy");
}
@@ -254,11 +256,13 @@ public class Spr3775InitDestroyLifecycleTests {
final List<String> initMethods = new ArrayList<String>();
final List<String> destroyMethods = new ArrayList<String>();
@Override
@PostConstruct
public void afterPropertiesSet() throws Exception {
this.initMethods.add("afterPropertiesSet");
}
@Override
@PreDestroy
public void destroy() throws Exception {
this.destroyMethods.add("destroy");

View File

@@ -85,14 +85,17 @@ public class Spr6602Tests {
public static class BarFactory implements FactoryBean<Bar> {
@Override
public Bar getObject() throws Exception {
return new Bar();
}
@Override
public Class<? extends Bar> getObjectType() {
return Bar.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.support.BeanDefinitionRegistry;
*/
public class TestBeanNameGenerator extends AnnotationBeanNameGenerator {
@Override
public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) {
String beanName = super.generateBeanName(definition, registry);
return "testing." + beanName;

View File

@@ -23,6 +23,7 @@ import org.springframework.beans.factory.config.BeanDefinition;
*/
public class TestScopeMetadataResolver implements ScopeMetadataResolver {
@Override
public ScopeMetadata resolveScopeMetadata(BeanDefinition beanDefinition) {
ScopeMetadata metadata = new ScopeMetadata();
metadata.setScopeName("myCustomScope");

View File

@@ -65,6 +65,7 @@ public class ConfigurationBeanNameTests {
public void registerOuterConfig_withBeanNameGenerator() {
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
ctx.setBeanNameGenerator(new AnnotationBeanNameGenerator() {
@Override
public String generateBeanName(
BeanDefinition definition, BeanDefinitionRegistry registry) {
return "custom-" + super.generateBeanName(definition, registry);

View File

@@ -70,6 +70,7 @@ public class ConfigurationClassCglibCallbackDeregistrationTests {
@Configuration
static class DisposableConfig implements DisposableBean {
boolean destroyed = false;
@Override
public void destroy() throws Exception {
this.destroyed = true;
}

View File

@@ -284,12 +284,14 @@ public class ConfigurationClassProcessingTests {
public void setNameSuffix(String nameSuffix) {
this.nameSuffix = nameSuffix;
}
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) {
if (bean instanceof ITestBean) {
((ITestBean) bean).setName(((ITestBean) bean).getName() + nameSuffix);
}
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String beanName) {
return bean;
}
@@ -302,6 +304,7 @@ public class ConfigurationClassProcessingTests {
//@Bean
public BeanFactoryPostProcessor beanFactoryPostProcessor() {
return new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
BeanDefinition bd = beanFactory.getBeanDefinition("beanPostProcessor");
bd.getPropertyValues().addPropertyValue("nameSuffix", "-processed-" + myProp);
@@ -334,6 +337,7 @@ public class ConfigurationClassProcessingTests {
super.setSpouse(spouse);
}
@Override
public void onApplicationEvent(ContextRefreshedEvent event) {
this.refreshed = true;
}

View File

@@ -379,6 +379,7 @@ public class ScopingTests {
private Map<String, Object> beans = new HashMap<String, Object>();
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
if (createNewScope) {
beans.clear();
@@ -396,18 +397,22 @@ public class ScopingTests {
return beans.get(name);
}
@Override
public String getConversationId() {
return null;
}
@Override
public void registerDestructionCallback(String name, Runnable callback) {
// do nothing
}
@Override
public Object remove(String name) {
return beans.remove(name);
}
@Override
public Object resolveContextualObject(String key) {
return null;
}

View File

@@ -67,6 +67,7 @@ class MyPostProcessor implements BeanFactoryPostProcessor {
public MyPostProcessor(Dependency someDependency) {
}
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
AbstractBeanDefinition bd = (AbstractBeanDefinition) beanFactory.getBeanDefinition("someDependency");
bd.setDescription("post processed by MyPostProcessor");

View File

@@ -28,6 +28,7 @@ import example.scannable.FooDao;
@Qualifier("testing")
public class StubFooDao implements FooDao {
@Override
public String findFoo(int id) {
return "bar";
}

View File

@@ -24,6 +24,7 @@ import example.scannable.FooDao;
@MyRepository
public class OtherFooDao implements FooDao {
@Override
public String findFoo(int id) {
return "other";
}

View File

@@ -23,6 +23,7 @@ import org.springframework.core.convert.converter.Converter;
*/
public class StringToBarConverter implements Converter<String, Bar> {
@Override
public Bar convert(String source) {
return new Bar(source);
}

View File

@@ -214,10 +214,12 @@ public class ApplicationContextEventTests {
public final Set<ApplicationEvent> seenEvents = new HashSet<ApplicationEvent>();
@Override
public void onApplicationEvent(ApplicationEvent event) {
this.seenEvents.add(event);
}
@Override
public int getOrder() {
return 0;
}
@@ -230,6 +232,7 @@ public class ApplicationContextEventTests {
public static abstract class MyOrderedListenerBase implements MyOrderedListenerIfc<MyEvent> {
@Override
public int getOrder() {
return 1;
}
@@ -244,6 +247,7 @@ public class ApplicationContextEventTests {
this.otherListener = otherListener;
}
@Override
public void onApplicationEvent(MyEvent event) {
assertTrue(otherListener.seenEvents.contains(event));
}
@@ -254,6 +258,7 @@ public class ApplicationContextEventTests {
public static final Set<ApplicationEvent> seenEvents = new HashSet<ApplicationEvent>();
@Override
public void onApplicationEvent(ApplicationEvent event) {
seenEvents.add(event);
}

View File

@@ -90,6 +90,7 @@ public class EventPublicationInterceptorTests {
final TestListener listener = new TestListener();
class TestContext extends StaticApplicationContext {
@Override
protected void onRefresh() throws BeansException {
addListener(listener);
}
@@ -140,14 +141,17 @@ public class EventPublicationInterceptorTests {
public static class FactoryBeanTestListener extends TestListener implements FactoryBean<Object> {
@Override
public Object getObject() throws Exception {
return "test";
}
@Override
public Class<String> getObjectType() {
return String.class;
}
@Override
public boolean isSingleton() {
return true;
}

View File

@@ -71,6 +71,7 @@ public class LifecycleEventTests extends TestCase {
private int stoppedCount;
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextStartedEvent) {
this.context = ((ContextStartedEvent) event).getApplicationContext();
@@ -100,14 +101,17 @@ public class LifecycleEventTests extends TestCase {
private boolean running;
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
this.running = true;
}
@Override
public void stop() {
this.running = false;
}

View File

@@ -57,14 +57,18 @@ public class ApplicationContextExpressionTests {
AnnotationConfigUtils.registerAnnotationConfigProcessors(ac);
ac.getBeanFactory().registerScope("myScope", new Scope() {
@Override
public Object get(String name, ObjectFactory<?> objectFactory) {
return objectFactory.getObject();
}
@Override
public Object remove(String name) {
return null;
}
@Override
public void registerDestructionCallback(String name, Runnable callback) {
}
@Override
public Object resolveContextualObject(String key) {
if (key.equals("mySpecialAttr")) {
return "42";
@@ -73,6 +77,7 @@ public class ApplicationContextExpressionTests {
return null;
}
}
@Override
public String getConversationId() {
return null;
}

View File

@@ -104,6 +104,7 @@ public class BeanFactoryPostProcessorTests {
public boolean wasCalled = false;
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
wasCalled = true;
}

View File

@@ -320,6 +320,7 @@ public final class ClassPathXmlApplicationContextTests {
@Test
public void testResourceAndInputStream() throws IOException {
ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(RESOURCE_CONTEXT) {
@Override
public Resource getResource(String location) {
if (TEST_PROPERTIES.equals(location)) {
return new ClassPathResource(TEST_PROPERTIES, ClassPathXmlApplicationContextTests.class);

View File

@@ -54,14 +54,17 @@ public class ConversionServiceFactoryBeanTests {
ConversionServiceFactoryBean factory = new ConversionServiceFactoryBean();
Set<Object> converters = new HashSet<Object>();
converters.add(new Converter<String, Foo>() {
@Override
public Foo convert(String source) {
return new Foo();
}
});
converters.add(new ConverterFactory<String, Bar>() {
@Override
public <T extends Bar> Converter<String, T> getConverter(Class<T> targetType) {
return new Converter<String, T> () {
@SuppressWarnings("unchecked")
@Override
public T convert(String source) {
return (T) new Bar();
}
@@ -69,9 +72,11 @@ public class ConversionServiceFactoryBeanTests {
}
});
converters.add(new GenericConverter() {
@Override
public Set<ConvertiblePair> getConvertibleTypes() {
return Collections.singleton(new ConvertiblePair(String.class, Baz.class));
}
@Override
public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) {
return new Baz();
}

View File

@@ -585,10 +585,12 @@ public class DefaultLifecycleProcessorTests {
this.stoppedBeans = stoppedBeans;
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
if (this.startedBeans != null) {
this.startedBeans.add(this);
@@ -596,6 +598,7 @@ public class DefaultLifecycleProcessorTests {
this.running = true;
}
@Override
public void stop() {
if (this.stoppedBeans != null) {
this.stoppedBeans.add(this);
@@ -627,10 +630,12 @@ public class DefaultLifecycleProcessorTests {
this.shutdownDelay = shutdownDelay;
}
@Override
public int getPhase() {
return this.phase;
}
@Override
public boolean isAutoStartup() {
return this.autoStartup;
}
@@ -639,12 +644,14 @@ public class DefaultLifecycleProcessorTests {
this.autoStartup = autoStartup;
}
@Override
public void stop(final Runnable callback) {
// calling stop() before the delay to preserve
// invocation order in the 'stoppedBeans' list
stop();
final int delay = this.shutdownDelay;
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(delay);
@@ -665,27 +672,33 @@ public class DefaultLifecycleProcessorTests {
public boolean running = false;
@Override
public boolean isAutoStartup() {
return true;
}
@Override
public void stop(Runnable callback) {
this.running = false;
callback.run();
}
@Override
public void start() {
this.running = true;
}
@Override
public void stop() {
this.running = false;
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public int getPhase() {
return 0;
}
@@ -698,39 +711,48 @@ public class DefaultLifecycleProcessorTests {
DummySmartLifecycleBean bean = new DummySmartLifecycleBean();
@Override
public Object getObject() throws Exception {
return this.bean;
}
@Override
public Class<?> getObjectType() {
return DummySmartLifecycleBean.class;
}
@Override
public boolean isSingleton() {
return true;
}
@Override
public boolean isAutoStartup() {
return true;
}
@Override
public void stop(Runnable callback) {
this.running = false;
callback.run();
}
@Override
public void start() {
this.running = true;
}
@Override
public void stop() {
this.running = false;
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public int getPhase() {
return 0;
}

View File

@@ -10,18 +10,22 @@ import org.springframework.context.ApplicationListener;
*/
public class FactoryBeanAndApplicationListener implements FactoryBean<String>, ApplicationListener<ApplicationEvent> {
@Override
public String getObject() throws Exception {
return "";
}
@Override
public Class<String> getObjectType() {
return String.class;
}
@Override
public boolean isSingleton() {
return true;
}
@Override
public void onApplicationEvent(ApplicationEvent event) {
}

View File

@@ -43,15 +43,18 @@ public class LifecycleTestBean implements Lifecycle {
return stopOrder;
}
@Override
public boolean isRunning() {
return this.running;
}
@Override
public void start() {
this.startOrder = ++startCounter;
this.running = true;
}
@Override
public void stop() {
this.stopOrder = ++stopCounter;
this.running = false;

View File

@@ -34,6 +34,7 @@ public class Logic implements BeanNameAware {
/* (non-Javadoc)
* @see org.springframework.beans.factory.BeanNameAware#setBeanName(java.lang.String)
*/
@Override
public void setBeanName(String name) {
this.name = name;
}

View File

@@ -25,6 +25,7 @@ import org.springframework.core.io.Resource;
*/
public class ResourceConverter implements Converter<String, Resource> {
@Override
public Resource convert(String source) {
return new FileSystemResource(source + ".xml");
}

View File

@@ -40,10 +40,12 @@ public class Service implements ApplicationContextAware, MessageSourceAware, Dis
private boolean properlyDestroyed = false;
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
@Override
public void setMessageSource(MessageSource messageSource) {
if (this.messageSource != null) {
throw new IllegalArgumentException("MessageSource should not be set twice");
@@ -64,9 +66,11 @@ public class Service implements ApplicationContextAware, MessageSourceAware, Dis
}
@Override
public void destroy() {
this.properlyDestroyed = true;
Thread thread = new Thread() {
@Override
public void run() {
Assert.isTrue(applicationContext.getBean("messageSource") instanceof StaticMessageSource);
try {

View File

@@ -49,11 +49,13 @@ public class SimpleThreadScopeTest {
public void getMultipleInstances() throws Exception {
final TestBean[] beans = new TestBean[2];
Thread thread1 = new Thread(new Runnable() {
@Override
public void run() {
beans[0] = applicationContext.getBean("threadScopedObject", TestBean.class);
}
});
Thread thread2 = new Thread(new Runnable() {
@Override
public void run() {
beans[1] = applicationContext.getBean("threadScopedObject", TestBean.class);
}

View File

@@ -43,6 +43,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
protected StaticApplicationContext sac;
/** Run for each test */
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<String, String>();
@@ -73,10 +74,12 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
}
/** Overridden */
@Override
public void testCount() {
assertCount(15);
}
@Override
public void testEvents() throws Exception {
TestApplicationEventMulticaster.counter = 0;
super.testEvents();
@@ -88,6 +91,7 @@ public class StaticApplicationContextMulticasterTests extends AbstractApplicatio
private static int counter = 0;
@Override
public void multicastEvent(ApplicationEvent event) {
super.multicastEvent(event);
counter++;

View File

@@ -39,6 +39,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes
protected StaticApplicationContext sac;
/** Run for each test */
@Override
protected ConfigurableApplicationContext createContext() throws Exception {
StaticApplicationContext parent = new StaticApplicationContext();
Map<String, String> m = new HashMap<String, String>();
@@ -66,6 +67,7 @@ public class StaticApplicationContextTests extends AbstractApplicationContextTes
}
/** Overridden */
@Override
public void testCount() {
assertCount(15);
}

Some files were not shown because too many files have changed in this diff Show More