Browse Source

Polishing

(cherry picked from commit 1fd6248d84)
pull/1916/head
Juergen Hoeller 6 years ago
parent
commit
6839570187
  1. 8
      spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java
  2. 3
      spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java
  3. 4
      spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java
  4. 12
      spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java
  5. 17
      spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java
  6. 6
      spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java
  7. 10
      spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java
  8. 9
      spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java
  9. 5
      spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java
  10. 6
      spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java
  11. 6
      spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java
  12. 4
      spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java
  13. 9
      spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java
  14. 15
      spring-context/src/test/java/org/springframework/aop/aspectj/DeclarationOrderIndependenceTests.java
  15. 7
      spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsDelegateRefTests.java
  16. 27
      spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java
  17. 7
      spring-context/src/test/java/org/springframework/aop/aspectj/ProceedTests.java
  18. 9
      spring-context/src/test/java/org/springframework/aop/aspectj/SharedPointcutWithArgsMismatchTests.java
  19. 12
      spring-context/src/test/java/org/springframework/aop/aspectj/SubtypeSensitiveMatchingTests.java
  20. 7
      spring-context/src/test/java/org/springframework/aop/aspectj/TargetPointcutSelectionTests.java
  21. 10
      spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java
  22. 10
      spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java
  23. 4
      spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTests.java
  24. 4
      spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java
  25. 7
      spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java
  26. 6
      spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java
  27. 6
      spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericParameterMatchingTests.java

8
spring-aop/src/main/java/org/springframework/aop/framework/CglibAopProxy.java

@ -822,12 +822,16 @@ class CglibAopProxy implements AopProxy, Serializable { @@ -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();

3
spring-beans/src/main/java/org/springframework/beans/factory/xml/DefaultNamespaceHandlerResolver.java

@ -156,6 +156,9 @@ public class DefaultNamespaceHandlerResolver implements NamespaceHandlerResolver @@ -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);

4
spring-beans/src/main/java/org/springframework/beans/factory/xml/PluggableSchemaResolver.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);
}
}
}

12
spring-beans/src/main/java/org/springframework/beans/factory/xml/XmlBeanDefinitionReader.java

@ -105,7 +105,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { @@ -105,7 +105,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader {
private boolean namespaceAware = false;
private Class<?> documentReaderClass = DefaultBeanDefinitionDocumentReader.class;
private Class<? extends BeanDefinitionDocumentReader> documentReaderClass =
DefaultBeanDefinitionDocumentReader.class;
private ProblemReporter problemReporter = new FailFastProblemReporter();
@ -313,7 +314,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { @@ -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<EncodedResource> currentResources = this.resourcesCurrentlyBeingLoaded.get();
@ -429,9 +430,8 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { @@ -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}.
* <p>Override this method if you would like full control over the validation
@ -453,7 +453,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { @@ -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.
* <p>Override this method if you would like to customize resolution
@ -515,7 +515,7 @@ public class XmlBeanDefinitionReader extends AbstractBeanDefinitionReader { @@ -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);
}
/**

17
spring-beans/src/test/java/org/springframework/beans/factory/support/PropertiesBeanDefinitionReaderTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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());
}

6
spring-context/src/test/java/org/springframework/aop/aspectj/AfterAdviceBindingTests.java

@ -44,10 +44,11 @@ public class AfterAdviceBindingTests { @@ -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 { @@ -60,6 +61,7 @@ public class AfterAdviceBindingTests {
afterAdviceAspect.setCollaborator(mockCollaborator);
}
@Test
public void testOneIntArg() {
testBeanProxy.setAge(5);

10
spring-context/src/test/java/org/springframework/aop/aspectj/AfterReturningAdviceBindingTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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");

9
spring-context/src/test/java/org/springframework/aop/aspectj/AfterThrowingAdviceBindingTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -132,5 +134,4 @@ final class AfterThrowingAdviceBindingTestAspect {
public void noArgsOnRuntimeExceptionMatch() {
this.collaborator.noArgsOnRuntimeExceptionMatch();
}
}

5
spring-context/src/test/java/org/springframework/aop/aspectj/AspectAndAdvicePrecedenceTests.java

@ -49,9 +49,9 @@ public class AspectAndAdvicePrecedenceTests { @@ -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 { @@ -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() {

6
spring-context/src/test/java/org/springframework/aop/aspectj/AspectJExpressionPointcutAdvisorTests.java

@ -37,14 +37,16 @@ public class AspectJExpressionPointcutAdvisorTests { @@ -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());

6
spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutAtAspectTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -55,6 +54,7 @@ public class BeanNamePointcutAtAspectTests {
testBean3 = (ITestBean) ctx.getBean("testBean3");
}
@Test
public void testMatchingBeanName() {
assertTrue("Expected a proxy", testBean1 instanceof Advised);

4
spring-context/src/test/java/org/springframework/aop/aspectj/BeanNamePointcutTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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");

9
spring-context/src/test/java/org/springframework/aop/aspectj/BeforeAdviceBindingTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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));

15
spring-context/src/test/java/org/springframework/aop/aspectj/DeclarationOrderIndependenceTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -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 { @@ -155,7 +154,6 @@ class TopsyTurvyTargetImpl implements TopsyTurvyTarget {
public int getX() {
return x;
}
}
@ -179,5 +177,4 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator { @@ -179,5 +177,4 @@ class AspectCollaborator implements TopsyTurvyAspect.Collaborator {
public void beforeAdviceFired() {
this.beforeFired = true;
}
}

7
spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsDelegateRefTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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);

27
spring-context/src/test/java/org/springframework/aop/aspectj/DeclareParentsTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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 { @@ -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 { @@ -90,5 +86,4 @@ class NonAnnotatedMakeLockable {
throw new IllegalStateException("locked");
}
}
}
}

7
spring-context/src/test/java/org/springframework/aop/aspectj/ProceedTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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");

9
spring-context/src/test/java/org/springframework/aop/aspectj/SharedPointcutWithArgsMismatchTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -66,4 +66,3 @@ class MyAspect {
System.out.println(x);
}
}

12
spring-context/src/test/java/org/springframework/aop/aspectj/SubtypeSensitiveMatchingTests.java

@ -40,14 +40,15 @@ public class SubtypeSensitiveMatchingTests { @@ -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 { @@ -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 { @@ -80,6 +85,7 @@ class SubtypeMatchingTestClassA implements NonSerializableFoo {
}
@SuppressWarnings("serial")
class SubtypeMatchingTestClassB implements SerializableFoo {
@ -88,8 +94,10 @@ class SubtypeMatchingTestClassB implements SerializableFoo { @@ -88,8 +94,10 @@ class SubtypeMatchingTestClassB implements SerializableFoo {
}
interface Bar { void bar(Object o); }
class SubtypeMatchingTestClassC implements Bar {
@Override

7
spring-context/src/test/java/org/springframework/aop/aspectj/TargetPointcutSelectionTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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");

10
spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsAtAspectJTests.java

@ -1,5 +1,5 @@ @@ -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; @@ -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 { @@ -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 { @@ -52,6 +53,7 @@ public class ThisAndTargetSelectionOnlyPointcutsAtAspectJTests {
counter.reset();
}
@Test
public void thisAsClassDoesNotMatch() {
testBean.doIt();

10
spring-context/src/test/java/org/springframework/aop/aspectj/ThisAndTargetSelectionOnlyPointcutsTests.java

@ -39,18 +39,16 @@ public class ThisAndTargetSelectionOnlyPointcutsTests { @@ -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 { @@ -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();

4
spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AnnotationBindingTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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");

4
spring-context/src/test/java/org/springframework/aop/aspectj/autoproxy/AtAspectJAnnotationBindingTests.java

@ -40,7 +40,7 @@ public class AtAspectJAnnotationBindingTests { @@ -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<Object> { @@ -84,7 +84,7 @@ class ResourceArrayFactoryBean implements FactoryBean<Object> {
@Override
@TestAnnotation("some value")
public Object getObject() throws Exception {
public Object getObject() {
return new Resource[0];
}

7
spring-context/src/test/java/org/springframework/aop/aspectj/generic/AfterReturningGenericTypeMatchingTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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 { @@ -58,6 +58,7 @@ public class AfterReturningGenericTypeMatchingTests {
testBean = (GenericReturnTypeVariationClass) ctx.getBean("testBean");
}
@Test
public void testReturnTypeExactMatching() {
testBean.getStrings();

6
spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericBridgeMethodMatchingTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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;

6
spring-context/src/test/java/org/springframework/aop/aspectj/generic/GenericParameterMatchingTests.java

@ -1,5 +1,5 @@ @@ -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 { @@ -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();

Loading…
Cancel
Save