Skip to content
This repository was archived by the owner on Dec 15, 2021. It is now read-only.

Commit 2358468

Browse files
committed
Add repro for SPR-12749
1 parent 0cb6d39 commit 2358468

File tree

7 files changed

+189
-0
lines changed

7 files changed

+189
-0
lines changed

SPR-12749/pom.xml

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>org.springframework.issues</groupId>
5+
<artifactId>SPR-12749</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<packaging>jar</packaging>
8+
9+
<properties>
10+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
11+
12+
<java.version>1.6</java.version>
13+
<spring.version>4.1.4.RELEASE</spring.version>
14+
<slf4j.version>1.7.5</slf4j.version>
15+
</properties>
16+
17+
<dependencies>
18+
<dependency>
19+
<groupId>org.springframework</groupId>
20+
<artifactId>spring-context</artifactId>
21+
<version>${spring.version}</version>
22+
</dependency>
23+
24+
<dependency>
25+
<groupId>org.springframework</groupId>
26+
<artifactId>spring-test</artifactId>
27+
<version>${spring.version}</version>
28+
</dependency>
29+
30+
<dependency>
31+
<groupId>org.slf4j</groupId>
32+
<artifactId>slf4j-api</artifactId>
33+
<version>${slf4j.version}</version>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.slf4j</groupId>
37+
<artifactId>slf4j-log4j12</artifactId>
38+
<version>${slf4j.version}</version>
39+
<scope>runtime</scope>
40+
</dependency>
41+
42+
<dependency>
43+
<groupId>junit</groupId>
44+
<artifactId>junit</artifactId>
45+
<version>4.11</version>
46+
<scope>test</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-compiler-plugin</artifactId>
55+
<version>2.5.1</version>
56+
<configuration>
57+
<source>${java.version}</source>
58+
<target>${java.version}</target>
59+
</configuration>
60+
</plugin>
61+
<plugin>
62+
<groupId>org.apache.maven.plugins</groupId>
63+
<artifactId>maven-surefire-plugin</artifactId>
64+
<version>2.12.4</version>
65+
<configuration>
66+
<includes>
67+
<include>**/*Tests.java</include>
68+
<include>**/*Test.java</include>
69+
</includes>
70+
<excludes>
71+
<exclude>**/*Abstract*.java</exclude>
72+
</excludes>
73+
</configuration>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
78+
<repositories>
79+
<repository>
80+
<id>spring-maven-snapshot</id>
81+
<name>Springframework Maven Snapshot Repository</name>
82+
<url>http://repo.spring.io/snapshot</url>
83+
<snapshots>
84+
<enabled>true</enabled>
85+
</snapshots>
86+
</repository>
87+
</repositories>
88+
89+
</project>
90+

SPR-12749/src/main/resources/.gitignore

Whitespace-only changes.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.springframework.issues;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
import org.springframework.test.context.ContextConfiguration;
9+
import org.springframework.test.context.TestExecutionListeners;
10+
11+
@Target(ElementType.TYPE)
12+
@Retention(RetentionPolicy.RUNTIME)
13+
@ContextConfiguration(classes = {SpringConfig.class})
14+
@TestExecutionListeners({MyTestExecutionListener.class})
15+
public @interface MyMetaAnnotation {
16+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/**
2+
*
3+
*/
4+
package org.springframework.issues;
5+
6+
import org.springframework.test.context.TestContext;
7+
import org.springframework.test.context.TestExecutionListener;
8+
9+
/**
10+
* @author derickso
11+
*
12+
*/
13+
public class MyTestExecutionListener implements TestExecutionListener {
14+
protected static volatile boolean listenerRun = false;
15+
16+
@Override
17+
public void beforeTestClass(TestContext testContext) throws Exception {
18+
listenerRun = true;
19+
}
20+
21+
@Override
22+
public void prepareTestInstance(TestContext testContext) throws Exception {
23+
listenerRun = true;
24+
}
25+
26+
@Override
27+
public void beforeTestMethod(TestContext testContext) throws Exception {
28+
listenerRun = true;
29+
}
30+
31+
@Override
32+
public void afterTestMethod(TestContext testContext) throws Exception {
33+
}
34+
35+
@Override
36+
public void afterTestClass(TestContext testContext) throws Exception {
37+
}
38+
39+
public static boolean isListenerRun() {
40+
return listenerRun;
41+
}
42+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package org.springframework.issues;
2+
3+
import org.junit.Assert;
4+
import org.junit.Test;
5+
import org.springframework.test.context.TestExecutionListeners;
6+
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
7+
import org.springframework.test.util.MetaAnnotationUtils;
8+
import org.springframework.test.util.MetaAnnotationUtils.AnnotationDescriptor;
9+
10+
/**
11+
* Unit test that reproduces an issue reported against SPR JIRA. @Test methods within
12+
* need not pass with the green bar! Rather they should fail in such a way that
13+
* demonstrates the reported issue.
14+
*/
15+
@MyMetaAnnotation
16+
public class ReproTests extends AbstractJUnit4SpringContextTests {
17+
@Test
18+
public void repro() {
19+
AnnotationDescriptor<TestExecutionListeners> descriptor = MetaAnnotationUtils.findAnnotationDescriptor(ReproTests.class,
20+
TestExecutionListeners.class);
21+
Assert.assertTrue(MyTestExecutionListener.isListenerRun());
22+
Class<?>[] classes = (Class<?>[]) descriptor.getAnnotationAttributes().get("value");
23+
Assert.assertEquals(1, classes.length);
24+
Assert.assertEquals(MyTestExecutionListener.class, classes[0]);
25+
}
26+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package org.springframework.issues;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.Configuration;
5+
6+
@Configuration
7+
public class SpringConfig {
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
log4j.rootCategory=ERROR, stdout
2+
3+
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
4+
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
5+
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n
6+
7+
log4j.category.org.springframework=WARN

0 commit comments

Comments
 (0)