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

Demonstrate that SPR16033 is not fixed yet in 5.0.1.RELEASE #173

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-16033/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Repro project for SPR-16033

## 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`.
84 changes: 84 additions & 0 deletions SPR-16033/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-16033</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>5.0.1.RELEASE</spring.version>
<slf4j.version>1.7.22</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/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>

</project>

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

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

@Configuration
public class ConfigClass {
@Bean
public IDummy bean1() {
return new Dummy();
}

@Bean
public IDummy bean2() {
return new Dummy();
}

@Bean
public IDummy bean3() {
return new Dummy();
}

@Bean
public IDummy bean4() {
return null;
}
}
5 changes: 5 additions & 0 deletions SPR-16033/src/main/java/org/springframework/issues/Dummy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package org.springframework.issues;

public class Dummy implements IDummy {

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

public interface IDummy {

}
Empty file.
28 changes: 28 additions & 0 deletions SPR-16033/src/test/java/org/springframework/issues/ReproTests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.springframework.issues;

import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;

import java.util.Map;

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

public class ReproTests {

@Test
public void repro() {
try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
ctx.register(ConfigClass.class);
ctx.refresh();
Map<String, IDummy> beans = ctx.getBeansOfType(IDummy.class);
assertNotNull(beans.get("bean1"));
assertNotNull(beans.get("bean2"));
assertNotNull(beans.get("bean3"));
assertNull(beans.get("bean4"));

}

}

}
7 changes: 7 additions & 0 deletions SPR-16033/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
14 changes: 14 additions & 0 deletions SPR-16033/src/test/resources/org/springframework/issues/ctx.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:lang="http://www.springframework.org/schema/lang" xmlns:p="http://www.springframework.org/schema/p"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-4.3.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">
<context:component-scan base-package="org.springframework.issues" />

</beans>