diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java index 2f70f1b6c7..123fadb111 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java @@ -822,12 +822,16 @@ class CglibAopProxy implements AopProxy, Serializable { } // We must always proxy equals, to direct calls to this. if (AopUtils.isEqualsMethod(method)) { - logger.debug("Found 'equals' method: " + method); + if (logger.isDebugEnabled()) { + logger.debug("Found 'equals' method: " + method); + } return INVOKE_EQUALS; } // We must always calculate hashCode based on the proxy. if (AopUtils.isHashCodeMethod(method)) { - logger.debug("Found 'hashCode' method: " + method); + if (logger.isDebugEnabled()) { + logger.debug("Found 'hashCode' method: " + method); + } return INVOKE_HASHCODE; } Class targetClass = this.advised.getTargetClass(); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java index 938e17fe0d..665b4d410b 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java @@ -156,6 +156,9 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver synchronized (this) { handlerMappings = this.handlerMappings; if (handlerMappings == null) { + if (logger.isDebugEnabled()) { + logger.debug("Loading NamespaceHandler mappings from [" + this.handlerMappingsLocation + "]"); + } try { Properties mappings = PropertiesLoaderUtils.loadAllProperties(this.handlerMappingsLocation, this.classLoader); diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java index a443aa1264..7ad748ebc5 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2017 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -126,7 +126,7 @@ public class PluggableSchemaResolver implements EntityResolver { } catch (FileNotFoundException ex) { if (logger.isDebugEnabled()) { - logger.debug("Couldn't find XML schema [" + systemId + "]: " + resource, ex); + logger.debug("Could not find XML schema [" + systemId + "]: " + resource, ex); } } } diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java index 8832fd045b..1166461dd1 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java @@ -105,7 +105,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { private boolean namespaceAware = false; - private Class documentReaderClass = DefaultBeanDefinitionDocumentReader.class; + private Class documentReaderClass = + DefaultBeanDefinitionDocumentReader.class; private ProblemReporter problemReporter = new FailFastProblemReporter(); @@ -313,7 +314,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { public int loadBeanDefinitions(EncodedResource encodedResource) throws BeanDefinitionStoreException { Assert.notNull(encodedResource, "EncodedResource must not be null"); if (logger.isInfoEnabled()) { - logger.info("Loading XML bean definitions from " + encodedResource.getResource()); + logger.info("Loading XML bean definitions from " + encodedResource); } Set currentResources = this.resourcesCurrentlyBeingLoaded.get(); @@ -429,9 +430,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { getValidationModeForResource(resource), isNamespaceAware()); } - /** - * Gets the validation mode for the specified {@link Resource}. If no explicit + * Get the validation mode for the specified {@link Resource}. If no explicit * validation mode has been configured then the validation mode is * {@link #detectValidationMode detected}. *

Override this method if you would like full control over the validation @@ -453,7 +453,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { } /** - * Detects which kind of validation to perform on the XML file identified + * Detect which kind of validation to perform on the XML file identified * by the supplied {@link Resource}. If the file has a {@code DOCTYPE} * definition then DTD validation is used otherwise XSD validation is assumed. *

Override this method if you would like to customize resolution @@ -515,7 +515,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { * @see #setDocumentReaderClass */ protected BeanDefinitionDocumentReader createBeanDefinitionDocumentReader() { - return BeanDefinitionDocumentReader.class.cast(BeanUtils.instantiateClass(this.documentReaderClass)); + return BeanUtils.instantiateClass(this.documentReaderClass); } /** diff --git a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java index f8dbf4c1db..2479b0177d 100644 --- a/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java +++ b/spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,29 +30,28 @@ public class PropertiesBeanDefinitionReaderTests { private final DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory(); - private final PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader( - beanFactory); + private final PropertiesBeanDefinitionReader reader = new PropertiesBeanDefinitionReader(this.beanFactory); @Test public void withSimpleConstructorArg() { this.reader.loadBeanDefinitions(new ClassPathResource("simpleConstructorArg.properties", getClass())); - TestBean bean = (TestBean)this.beanFactory.getBean("testBean"); + TestBean bean = (TestBean) this.beanFactory.getBean("testBean"); assertEquals("Rob Harrop", bean.getName()); } @Test - public void withConstructorArgRef() throws Exception { + public void withConstructorArgRef() { this.reader.loadBeanDefinitions(new ClassPathResource("refConstructorArg.properties", getClass())); - TestBean rob = (TestBean)this.beanFactory.getBean("rob"); - TestBean sally = (TestBean)this.beanFactory.getBean("sally"); + TestBean rob = (TestBean) this.beanFactory.getBean("rob"); + TestBean sally = (TestBean) this.beanFactory.getBean("sally"); assertEquals(sally, rob.getSpouse()); } @Test - public void withMultipleConstructorsArgs() throws Exception { + public void withMultipleConstructorsArgs() { this.reader.loadBeanDefinitions(new ClassPathResource("multiConstructorArgs.properties", getClass())); - TestBean bean = (TestBean)this.beanFactory.getBean("testBean"); + TestBean bean = (TestBean) this.beanFactory.getBean("testBean"); assertEquals("Rob Harrop", bean.getName()); assertEquals(23, bean.getAge()); } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java index bbf0dfcb8a..e52d19e525 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java @@ -44,10 +44,11 @@ public class AfterAdviceBindingTests { private TestBean testBeanTarget; + @Before - public void setUp() throws Exception { + public void setup() throws Exception { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); AdviceBindingTestAspect afterAdviceAspect = (AdviceBindingTestAspect) ctx.getBean("testAspect"); testBeanProxy = (ITestBean) ctx.getBean("testBean"); @@ -60,6 +61,7 @@ public class AfterAdviceBindingTests { afterAdviceAspect.setCollaborator(mockCollaborator); } + @Test public void testOneIntArg() { testBeanProxy.setAge(5); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java index d811a87994..cd410db92a 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,14 +48,10 @@ public class AfterReturningAdviceBindingTests { private AfterReturningAdviceBindingCollaborator mockCollaborator; - public void setAfterReturningAdviceAspect(AfterReturningAdviceBindingTestAspect anAspect) { - this.afterAdviceAspect = anAspect; - } - @Before - public void setUp() throws Exception { + public void setup() throws Exception { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); afterAdviceAspect = (AfterReturningAdviceBindingTestAspect) ctx.getBean("testAspect"); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java index 997162274f..4526dd89d9 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,10 +39,11 @@ public class AfterThrowingAdviceBindingTests { private AfterThrowingAdviceBindingCollaborator mockCollaborator; + @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBean = (ITestBean) ctx.getBean("testBean"); afterThrowingAdviceAspect = (AfterThrowingAdviceBindingTestAspect) ctx.getBean("testAspect"); @@ -51,6 +52,7 @@ public class AfterThrowingAdviceBindingTests { afterThrowingAdviceAspect.setCollaborator(mockCollaborator); } + @Test(expected = Throwable.class) public void testSimpleAfterThrowing() throws Throwable { this.testBean.exceptional(new Throwable()); @@ -132,5 +134,4 @@ final class AfterThrowingAdviceBindingTestAspect { public void noArgsOnRuntimeExceptionMatch() { this.collaborator.noArgsOnRuntimeExceptionMatch(); } - } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java index c1c68d5335..99f84d00bd 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java @@ -49,9 +49,9 @@ public class AspectAndAdvicePrecedenceTests { @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); highPrecedenceAspect = (PrecedenceTestAspect) ctx.getBean("highPrecedenceAspect"); lowPrecedenceAspect = (PrecedenceTestAspect) ctx.getBean("lowPrecedenceAspect"); highPrecedenceSpringAdvice = (SimpleSpringBeforeAdvice) ctx.getBean("highPrecedenceSpringAdvice"); @@ -59,7 +59,6 @@ public class AspectAndAdvicePrecedenceTests { testBean = (ITestBean) ctx.getBean("testBean"); } - // ========== end of test case set up, start of tests proper =================== @Test public void testAdviceOrder() { diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java index 457110bb28..c716d2fe37 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java @@ -37,14 +37,16 @@ public class AspectJExpressionPointcutAdvisorTests { private CallCountingInterceptor interceptor; + @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBean = (ITestBean) ctx.getBean("testBean"); interceptor = (CallCountingInterceptor) ctx.getBean("interceptor"); } + @Test public void testPointcutting() { assertEquals("Count should be 0", 0, interceptor.getCount()); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java index 1c8573390a..8e9e6ee496 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -45,8 +45,7 @@ public class BeanNamePointcutAtAspectTests { @org.junit.Before - @SuppressWarnings("resource") - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); @@ -55,6 +54,7 @@ public class BeanNamePointcutAtAspectTests { testBean3 = (ITestBean) ctx.getBean("testBean3"); } + @Test public void testMatchingBeanName() { assertTrue("Expected a proxy", testBean1 instanceof Advised); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java index cf6e831d96..cf6599e143 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -55,7 +55,7 @@ public class BeanNamePointcutTests { @Before - public void setUp() { + public void setup() { ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBean1 = (ITestBean) ctx.getBean("testBean1"); testBean2 = (ITestBean) ctx.getBean("testBean2"); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java index 9121ab34f0..bfed14eef2 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -44,14 +44,11 @@ public class BeforeAdviceBindingTests { private TestBean testBeanTarget; - protected String getConfigPath() { - return "before-advice-tests.xml"; - } @Before - public void setUp() throws Exception { + public void setup() throws Exception { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBeanProxy = (ITestBean) ctx.getBean("testBean"); assertTrue(AopUtils.isAopProxy(testBeanProxy)); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclarationOrderIndependenceTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclarationOrderIndependenceTests.java index bafc712494..f7704065df 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclarationOrderIndependenceTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclarationOrderIndependenceTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,14 +39,14 @@ public class DeclarationOrderIndependenceTests { @Before - @SuppressWarnings("resource") - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); aspect = (TopsyTurvyAspect) ctx.getBean("topsyTurvyAspect"); target = (TopsyTurvyTarget) ctx.getBean("topsyTurvyTarget"); } + @Test public void testTargetIsSerializable() { assertTrue("target bean is serializable",this.target instanceof Serializable); @@ -135,10 +135,9 @@ class TopsyTurvyAspect { interface TopsyTurvyTarget { - public abstract void doSomething(); - - public abstract int getX(); + void doSomething(); + int getX(); } @@ -155,7 +154,6 @@ class TopsyTurvyTargetImpl implements TopsyTurvyTarget { public int getX() { return x; } - } @@ -179,5 +177,4 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator { public void beforeAdviceFired() { this.beforeFired = true; } - } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsDelegateRefTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsDelegateRefTests.java index 0e556fe063..ebe8cb7182 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsDelegateRefTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsDelegateRefTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,14 +35,15 @@ public class DeclareParentsDelegateRefTests { @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); noMethodsBean = (NoMethodsBean) ctx.getBean("noMethodsBean"); counter = (Counter) ctx.getBean("counter"); counter.reset(); } + @Test public void testIntroductionWasMade() { assertTrue("Introduction must have been made", noMethodsBean instanceof ICounter); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java index 43373cd42e..e7d168a05a 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2013 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,7 @@ import org.junit.Test; import test.mixin.Lockable; import org.springframework.aop.support.AopUtils; -import org.springframework.context.ApplicationContext; import org.springframework.context.support.ClassPathXmlApplicationContext; -import org.springframework.tests.Assume; -import org.springframework.tests.TestGroup; import org.springframework.tests.sample.beans.ITestBean; import static org.junit.Assert.*; @@ -37,18 +34,22 @@ public class DeclareParentsTests { private ITestBean testBeanProxy; - private ApplicationContext ctx; + private Object introductionObject; - @Before - public void setUp() throws Exception { - ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + @Before + public void setup() { + ClassPathXmlApplicationContext ctx = + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBeanProxy = (ITestBean) ctx.getBean("testBean"); - assertTrue(AopUtils.isAopProxy(testBeanProxy)); + introductionObject = ctx.getBean("introduction"); } + @Test public void testIntroductionWasMade() { + assertTrue(AopUtils.isAopProxy(testBeanProxy)); + assertFalse("Introduction should not be proxied", AopUtils.isAopProxy(introductionObject)); assertTrue("Introduction must have been made", testBeanProxy instanceof Lockable); } @@ -58,11 +59,6 @@ public class DeclareParentsTests { // on the introduction, in which case this would not be a problem. @Test public void testLockingWorks() { - Assume.group(TestGroup.LONG_RUNNING); - - Object introductionObject = ctx.getBean("introduction"); - assertFalse("Introduction should not be proxied", AopUtils.isAopProxy(introductionObject)); - Lockable lockable = (Lockable) testBeanProxy; assertFalse(lockable.locked()); @@ -90,5 +86,4 @@ class NonAnnotatedMakeLockable { throw new IllegalStateException("locked"); } } - -} \ No newline at end of file +} diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/ProceedTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/ProceedTests.java index 10ef204df2..1d7feb4d27 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/ProceedTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/ProceedTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,14 +43,15 @@ public class ProceedTests { @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBean = (SimpleBean) ctx.getBean("testBean"); firstTestAspect = (ProceedTestingAspect) ctx.getBean("firstTestAspect"); secondTestAspect = (ProceedTestingAspect) ctx.getBean("secondTestAspect"); } + @Test public void testSimpleProceedWithChangedArgs() { this.testBean.setName("abc"); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/SharedPointcutWithArgsMismatchTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/SharedPointcutWithArgsMismatchTests.java index 7ed664f8fc..7865aff868 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/SharedPointcutWithArgsMismatchTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/SharedPointcutWithArgsMismatchTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,18 +33,18 @@ public class SharedPointcutWithArgsMismatchTests { @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); toBeAdvised = (ToBeAdvised) ctx.getBean("toBeAdvised"); } + @Test public void testMismatchedArgBinding() { this.toBeAdvised.foo("Hello"); } - } @@ -66,4 +66,3 @@ class MyAspect { System.out.println(x); } } - diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/SubtypeSensitiveMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/SubtypeSensitiveMatchingTests.java index b1107b19e8..6194644fad 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/SubtypeSensitiveMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/SubtypeSensitiveMatchingTests.java @@ -40,14 +40,15 @@ public class SubtypeSensitiveMatchingTests { @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); nonSerializableBean = (NonSerializableFoo) ctx.getBean("testClassA"); serializableBean = (SerializableFoo) ctx.getBean("testClassB"); bar = (Bar) ctx.getBean("testClassC"); } + @Test public void testBeansAreProxiedOnStaticMatch() { assertTrue("bean with serializable type should be proxied", @@ -68,11 +69,15 @@ public class SubtypeSensitiveMatchingTests { } + //strange looking interfaces are just to set up certain test conditions... + interface NonSerializableFoo { void foo(); } + interface SerializableFoo extends Serializable { void foo(); } + class SubtypeMatchingTestClassA implements NonSerializableFoo { @Override @@ -80,6 +85,7 @@ class SubtypeMatchingTestClassA implements NonSerializableFoo { } + @SuppressWarnings("serial") class SubtypeMatchingTestClassB implements SerializableFoo { @@ -88,8 +94,10 @@ class SubtypeMatchingTestClassB implements SerializableFoo { } + interface Bar { void bar(Object o); } + class SubtypeMatchingTestClassC implements Bar { @Override diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/TargetPointcutSelectionTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/TargetPointcutSelectionTests.java index 6e84778a35..0d96088686 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/TargetPointcutSelectionTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/TargetPointcutSelectionTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.springframework.aop.aspectj; import org.aopalliance.intercept.MethodInterceptor; import org.aopalliance.intercept.MethodInvocation; - import org.junit.Before; import org.junit.Test; @@ -47,11 +46,9 @@ public class TargetPointcutSelectionTests { @Before - @SuppressWarnings("resource") - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); - testImpl1 = (TestInterface) ctx.getBean("testImpl1"); testImpl2 = (TestInterface) ctx.getBean("testImpl2"); testAspectForTestImpl1 = (TestAspect) ctx.getBean("testAspectForTestImpl1"); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java index 65efa67ed9..3509730214 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2015 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +22,7 @@ import java.lang.annotation.RetentionPolicy; import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Before; import org.junit.Test; + import org.springframework.context.support.ClassPathXmlApplicationContext; import static org.junit.Assert.*; @@ -40,11 +41,11 @@ public class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests { private Counter counter; + @org.junit.Before - @SuppressWarnings("resource") - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBean = (TestInterface) ctx.getBean("testBean"); testAnnotatedClassBean = (TestInterface) ctx.getBean("testAnnotatedClassBean"); testAnnotatedMethodBean = (TestInterface) ctx.getBean("testAnnotatedMethodBean"); @@ -52,6 +53,7 @@ public class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests { counter.reset(); } + @Test public void thisAsClassDoesNotMatch() { testBean.doIt(); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java index d19d3c66dd..13e43938fa 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java @@ -39,18 +39,16 @@ public class ThisAndTargetSelectionOnlyPointcutsTests { private Counter thisAsInterfaceAndTargetAsInterfaceCounter; private Counter thisAsInterfaceAndTargetAsClassCounter; + @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); - + new ClassPathXmlApplicationContext(getClass().getSimpleName() + ".xml", getClass()); testBean = (TestInterface) ctx.getBean("testBean"); - thisAsClassCounter = (Counter) ctx.getBean("thisAsClassCounter"); thisAsInterfaceCounter = (Counter) ctx.getBean("thisAsInterfaceCounter"); targetAsClassCounter = (Counter) ctx.getBean("targetAsClassCounter"); targetAsInterfaceCounter = (Counter) ctx.getBean("targetAsInterfaceCounter"); - thisAsClassAndTargetAsClassCounter = (Counter) ctx.getBean("thisAsClassAndTargetAsClassCounter"); thisAsInterfaceAndTargetAsInterfaceCounter = (Counter) ctx.getBean("thisAsInterfaceAndTargetAsInterfaceCounter"); thisAsInterfaceAndTargetAsClassCounter = (Counter) ctx.getBean("thisAsInterfaceAndTargetAsClassCounter"); @@ -59,12 +57,12 @@ public class ThisAndTargetSelectionOnlyPointcutsTests { thisAsInterfaceCounter.reset(); targetAsClassCounter.reset(); targetAsInterfaceCounter.reset(); - thisAsClassAndTargetAsClassCounter.reset(); thisAsInterfaceAndTargetAsInterfaceCounter.reset(); thisAsInterfaceAndTargetAsClassCounter.reset(); } + @Test public void testThisAsClassDoesNotMatch() { testBean.doIt(); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTests.java index a7f24b51ba..0c626a752a 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -33,7 +33,7 @@ public class AnnotationBindingTests { @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); testBean = (AnnotatedTestBean) ctx.getBean("testBean"); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java index 08ff456fb2..c5e18734f9 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java @@ -40,7 +40,7 @@ public class AtAspectJAnnotationBindingTests { @Before - public void setUp() { + public void setup() { ctx = new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); testBean = (AnnotatedTestBean) ctx.getBean("testBean"); } @@ -84,7 +84,7 @@ class ResourceArrayFactoryBean implements FactoryBean { @Override @TestAnnotation("some value") - public Object getObject() throws Exception { + public Object getObject() { return new Resource[0]; } diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java index d64913d61c..cf62cc7575 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2016 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +48,9 @@ public class AfterReturningGenericTypeMatchingTests { @Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); counterAspect = (CounterAspect) ctx.getBean("counterAspect"); counterAspect.reset(); @@ -58,6 +58,7 @@ public class AfterReturningGenericTypeMatchingTests { testBean = (GenericReturnTypeVariationClass) ctx.getBean("testBean"); } + @Test public void testReturnTypeExactMatching() { testBean.getStrings(); diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java index 6168fa1d34..f999c4f17f 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -48,9 +48,9 @@ public class GenericBridgeMethodMatchingTests { @SuppressWarnings("unchecked") @org.junit.Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); counterAspect = (GenericCounterAspect) ctx.getBean("counterAspect"); counterAspect.count = 0; diff --git a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericParameterMatchingTests.java b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericParameterMatchingTests.java index 2bea833ec1..af95ba6d89 100644 --- a/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericParameterMatchingTests.java +++ b/spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericParameterMatchingTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2012 the original author or authors. + * Copyright 2002-2018 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -43,9 +43,9 @@ public class GenericParameterMatchingTests { @SuppressWarnings("unchecked") @org.junit.Before - public void setUp() { + public void setup() { ClassPathXmlApplicationContext ctx = - new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); + new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-context.xml", getClass()); counterAspect = (CounterAspect) ctx.getBean("counterAspect"); counterAspect.reset();