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

Add test for SPR-14282 #128

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
37 changes: 37 additions & 0 deletions SPR-14282/README-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Repro project for SPR-0000

## Deploying

It is possible to deploy your application directly from the command-line
using maven. You can use either [cargo](http://cargo.codehaus.org/) or
the [jetty plugin](http://www.eclipse.org/jetty/documentation/current/jetty-maven-plugin.html)
to run on a wide range of containers.

### Cargo

By default Cargo is configured to start `Tomcat7` and can be invoked by
running `mvn package cargo:run`. Cargo can also run a [wide range of other
containers](http://cargo.codehaus.org/Containers) and you can easily add
yours by editing the `pom.xml`. For instance, a `tomcat8` profile
has been added and can be invoked via `mvn package cargo:run -Ptomcat8`.

You can remote debug the application, in your IDE, by using the following command:
`mvn package cargo:run -Ptomcat8 -Pdebug`. Note that you can customize the debug
port used with the `cargo.jvm.debug.port` maven property.

### Jetty

To deploy your application to jetty9, simply invoke `mvn jetty:run`. It
is possible to tune the exact jetty9 version you want to use by specifying
the version of the command line, e.g. `mvn jetty:run -Djetty.version=9.0.6.v20130930`

To run a different version of jetty, please fallback to cargo as the
coordinates of the maven plugin have changed. A sample `jetty8` profile is
created for reference and can be tuned to suit your needs. To deploy your
sample application to jetty8 run `mvn cargo:run -Pjetty8`

## Logging

This project contains a `log4j.properties` file in `src/main/resources` that you
may wish to configure to emit more detailed logging. The root logger is set to
`INFO` and a custom `org.springframework.web` logger is set to `DEBUG`.
20 changes: 20 additions & 0 deletions SPR-14282/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Simple Spring application template

This is a simple template for creating issue reproduction projects per
the [README in the root of this repository](https://github.com/spring-projects/spring-framework-issues#readme).
Please read that document completely before starting.

As described at the link above, do not edit this project directly! Rather
use the `./create-repro-project.sh` script to create a fresh copy to
a new directory having the same name as the JIRA issue you're trying
to reproduce and edit from there.

Both Gradle (`build.gradle`) and Maven (`pom.xml`) build scripts are
included for your convenience and choice. Once you've created your
copy of this directory, delete whichever build script you don't wish
to use, and then edit the remaining one to suit your needs.

Note that this project contains a `log4j.properties` file in
`src/test/resources` that you may wish to configure to emit more
detailed logging. The log level for `org.springframework` is set
to `WARN` by default.
84 changes: 84 additions & 0 deletions SPR-14282/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<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-14282</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

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

<java.version>1.8</java.version>
<spring.version>4.3.0.RC2</spring.version>
<slf4j.version>1.7.18</slf4j.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</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.12</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/libs-snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

</project>

5 changes: 5 additions & 0 deletions SPR-14282/src/main/java/org/springframework/issues/Bar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.springframework.issues;

public class Bar {

}
9 changes: 9 additions & 0 deletions SPR-14282/src/main/java/org/springframework/issues/Foo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.springframework.issues;

import org.springframework.beans.factory.annotation.Autowired;

public class Foo {

@Autowired
Bar bar;
}
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.springframework.issues;

import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat;

import org.junit.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
* 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.
*/
public class JavaConfigTests {

@Test
public void repro() {
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
ctx.register(Config.class);
ctx.refresh();

Foo foo = ctx.getBean(Foo.class);

assertThat(foo.bar, nullValue());
}
}

@Configuration
static class Config {

@Bean
public Foo foo() {
return new Foo();
}

@Bean
public Bar bar() {
return new Bar();
}

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

import static org.hamcrest.CoreMatchers.nullValue;
import static org.junit.Assert.assertThat;

import org.junit.Test;
import org.springframework.context.support.GenericXmlApplicationContext;

/**
* 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.
*/
public class XmlConfigTests {

@Test
public void repro() {
try(GenericXmlApplicationContext ctx = new GenericXmlApplicationContext()) {
ctx.load("classpath:org/springframework/issues/XmlConfigTests-context.xml");
ctx.refresh();

Foo foo = ctx.getBean(Foo.class);

assertThat(foo.bar, nullValue());
}
}

}
7 changes: 7 additions & 0 deletions SPR-14282/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
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd">

<bean id="foo" class="org.springframework.issues.Foo"/>

<bean id="bar" class="org.springframework.issues.Bar"/>

</beans>