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

Add repro for SPR-12749 #92

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 90 additions & 0 deletions SPR-12749/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.springframework.issues</groupId>
<artifactId>SPR-12749</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<java.version>1.6</java.version>
<spring.version>4.1.4.RELEASE</spring.version>
<slf4j.version>1.7.5</slf4j.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>${slf4j.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>${slf4j.version}</version>
<scope>runtime</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<configuration>
<includes>
<include>**/*Tests.java</include>
<include>**/*Test.java</include>
</includes>
<excludes>
<exclude>**/*Abstract*.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>

<repositories>
<repository>
<id>spring-maven-snapshot</id>
<name>Springframework Maven Snapshot Repository</name>
<url>http://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

</project>

Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.springframework.issues;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@ContextConfiguration(classes = {SpringConfig.class})
@TestExecutionListeners({MyTestExecutionListener.class})
public @interface MyMetaAnnotation {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/**
*
*/
package org.springframework.issues;

import org.springframework.test.context.TestContext;
import org.springframework.test.context.TestExecutionListener;

/**
* @author derickso
*
*/
public class MyTestExecutionListener implements TestExecutionListener {
protected static volatile boolean listenerRun = false;

@Override
public void beforeTestClass(TestContext testContext) throws Exception {
listenerRun = true;
}

@Override
public void prepareTestInstance(TestContext testContext) throws Exception {
listenerRun = true;
}

@Override
public void beforeTestMethod(TestContext testContext) throws Exception {
listenerRun = true;
}

@Override
public void afterTestMethod(TestContext testContext) throws Exception {
}

@Override
public void afterTestClass(TestContext testContext) throws Exception {
}

public static boolean isListenerRun() {
return listenerRun;
}
}
26 changes: 26 additions & 0 deletions SPR-12749/src/test/java/org/springframework/issues/ReproTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.springframework.issues;

import org.junit.Assert;
import org.junit.Test;
import org.springframework.test.context.TestExecutionListeners;
import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
import org.springframework.test.util.MetaAnnotationUtils;
import org.springframework.test.util.MetaAnnotationUtils.AnnotationDescriptor;

/**
* Unit test that reproduces an issue reported against SPR JIRA. @Test methods within
* need not pass with the green bar! Rather they should fail in such a way that
* demonstrates the reported issue.
*/
@MyMetaAnnotation
public class ReproTests extends AbstractJUnit4SpringContextTests {
@Test
public void repro() {
AnnotationDescriptor<TestExecutionListeners> descriptor = MetaAnnotationUtils.findAnnotationDescriptor(ReproTests.class,
TestExecutionListeners.class);
Assert.assertTrue(MyTestExecutionListener.isListenerRun());
Class<?>[] classes = (Class<?>[]) descriptor.getAnnotationAttributes().get("value");
Assert.assertEquals(1, classes.length);
Assert.assertEquals(MyTestExecutionListener.class, classes[0]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.springframework.issues;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SpringConfig {
}
7 changes: 7 additions & 0 deletions SPR-12749/src/test/resources/log4j.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
log4j.rootCategory=ERROR, stdout

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d %p [%c] - <%m>%n

log4j.category.org.springframework=WARN