Skip to content

Commit beea69d

Browse files
committed
polishing .aop tests
1 parent 56e868b commit beea69d

12 files changed

Lines changed: 54 additions & 24 deletions

‎org.springframework.aop/src/test/java/org/springframework/aop/aspectj/autoproxy/AspectJNamespaceHandlerTests.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import org.springframework.aop.config.AopConfigUtils;
2424
import org.springframework.aop.config.AopNamespaceUtils;
2525
import org.springframework.beans.factory.config.BeanDefinition;
26-
import org.springframework.beans.factory.parsing.CollectingReaderEventListener;
2726
import org.springframework.beans.factory.parsing.PassThroughSourceExtractor;
2827
import org.springframework.beans.factory.parsing.SourceExtractor;
2928
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
@@ -32,6 +31,8 @@
3231
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
3332
import org.springframework.beans.factory.xml.XmlReaderContext;
3433

34+
import test.parsing.CollectingReaderEventListener;
35+
3536
/**
3637
* @author Rob Harrop
3738
* @author Chris Beams

org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAspectEventTests.xml renamed to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests-context.xml

File renamed without changes.

org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml renamed to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests-directPointcutEvents.xml

File renamed without changes.

org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutEventTests.xml renamed to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests-pointcutEvents.xml

File renamed without changes.

org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml renamed to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests-pointcutRefEvents.xml

File renamed without changes.

‎org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerEventTests.java‎

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,35 @@
2626
import org.springframework.beans.factory.config.BeanDefinition;
2727
import org.springframework.beans.factory.config.BeanReference;
2828
import org.springframework.beans.factory.parsing.BeanComponentDefinition;
29-
import org.springframework.beans.factory.parsing.CollectingReaderEventListener;
3029
import org.springframework.beans.factory.parsing.ComponentDefinition;
3130
import org.springframework.beans.factory.parsing.CompositeComponentDefinition;
3231
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
3332
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
3433
import org.springframework.core.io.ClassPathResource;
3534

35+
import test.parsing.CollectingReaderEventListener;
36+
3637
/**
3738
* @author Rob Harrop
3839
* @author Juergen Hoeller
3940
* @author Chris Beams
4041
*/
4142
public final class AopNamespaceHandlerEventTests {
4243

44+
private static final Class<?> CLASS = AopNamespaceHandlerEventTests.class;
45+
private static final String CLASSNAME = CLASS.getSimpleName();
46+
47+
private static final String CONTEXT = CLASSNAME + "-context.xml";
48+
private static final String POINTCUT_EVENTS_CONTEXT = CLASSNAME + "-pointcutEvents.xml";
49+
private static final String POINTCUT_REF_CONTEXT = CLASSNAME + "-pointcutRefEvents.xml";
50+
private static final String DIRECT_POINTCUT_EVENTS_CONTEXT = CLASSNAME + "-directPointcutEvents.xml";
51+
4352
private CollectingReaderEventListener eventListener = new CollectingReaderEventListener();
4453

4554
private XmlBeanDefinitionReader reader;
4655

4756
private DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
57+
4858

4959

5060
@Before
@@ -55,7 +65,7 @@ public void setUp() throws Exception {
5565

5666
@Test
5767
public void testPointcutEvents() throws Exception {
58-
loadBeansFrom("aopNamespaceHandlerPointcutEventTests.xml");
68+
loadBeansFrom(POINTCUT_EVENTS_CONTEXT);
5969
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
6070
assertEquals("Incorrect number of events fired", 1, componentDefinitions.length);
6171
assertTrue("No holder with nested components", componentDefinitions[0] instanceof CompositeComponentDefinition);
@@ -79,7 +89,7 @@ public void testPointcutEvents() throws Exception {
7989

8090
@Test
8191
public void testAdvisorEventsWithPointcutRef() throws Exception {
82-
loadBeansFrom("aopNamespaceHandlerAdvisorWithPointcutRefEventTests.xml");
92+
loadBeansFrom(POINTCUT_REF_CONTEXT);
8393
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
8494
assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
8595

@@ -108,7 +118,7 @@ public void testAdvisorEventsWithPointcutRef() throws Exception {
108118

109119
@Test
110120
public void testAdvisorEventsWithDirectPointcut() throws Exception {
111-
loadBeansFrom("aopNamespaceHandlerAdvisorWithDirectPointcutEventTests.xml");
121+
loadBeansFrom(DIRECT_POINTCUT_EVENTS_CONTEXT);
112122
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
113123
assertEquals("Incorrect number of events fired", 2, componentDefinitions.length);
114124

@@ -137,7 +147,7 @@ public void testAdvisorEventsWithDirectPointcut() throws Exception {
137147

138148
@Test
139149
public void testAspectEvent() throws Exception {
140-
loadBeansFrom("aopNamespaceHandlerAspectEventTests.xml");
150+
loadBeansFrom(CONTEXT);
141151
ComponentDefinition[] componentDefinitions = this.eventListener.getComponentDefinitions();
142152
assertEquals("Incorrect number of events fired", 5, componentDefinitions.length);
143153

org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutDuplicationTests.xml renamed to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutDuplication.xml

File renamed without changes.

org.springframework.aop/src/test/java/org/springframework/aop/config/aopNamespaceHandlerPointcutMissingTests.xml renamed to org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests-pointcutMissing.xml

File renamed without changes.

‎org.springframework.aop/src/test/java/org/springframework/aop/config/AopNamespaceHandlerPointcutErrorTests.java‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,20 @@
2929
* @author Chris Beams
3030
*/
3131
public final class AopNamespaceHandlerPointcutErrorTests {
32+
33+
private static final Class<?> CLASS = AopNamespaceHandlerPointcutErrorTests.class;
34+
private static final String CLASSNAME = CLASS.getSimpleName();
35+
36+
private static final ClassPathResource DUPLICATION_CONTEXT =
37+
new ClassPathResource(CLASSNAME + "-pointcutDuplication.xml", CLASS);
38+
39+
private static final ClassPathResource MISSING_CONTEXT =
40+
new ClassPathResource(CLASSNAME + "-pointcutMissing.xml", CLASS);
3241

3342
@Test
3443
public void testDuplicatePointcutConfig() {
3544
try {
36-
new XmlBeanFactory(new ClassPathResource(
37-
"org/springframework/aop/config/aopNamespaceHandlerPointcutDuplicationTests.xml"));
45+
new XmlBeanFactory(DUPLICATION_CONTEXT);
3846
fail("parsing should have caused a BeanDefinitionStoreException");
3947
}
4048
catch (BeanDefinitionStoreException ex) {
@@ -45,8 +53,7 @@ public void testDuplicatePointcutConfig() {
4553
@Test
4654
public void testMissingPointcutConfig() {
4755
try {
48-
new XmlBeanFactory(new ClassPathResource(
49-
"org/springframework/aop/config/aopNamespaceHandlerPointcutMissingTests.xml"));
56+
new XmlBeanFactory(MISSING_CONTEXT);
5057
fail("parsing should have caused a BeanDefinitionStoreException");
5158
}
5259
catch (BeanDefinitionStoreException ex) {

org.springframework.aop/src/test/java/org/springframework/aop/config/topLevelAop.xml renamed to org.springframework.aop/src/test/java/org/springframework/aop/config/TopLevelAopTagTests-context.xml

File renamed without changes.

0 commit comments

Comments
 (0)