This repository has been archived by the owner on Dec 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 169
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dave Syer
committed
Jun 2, 2014
1 parent
59e3cf9
commit b546943
Showing
3 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<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-11844</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
<packaging>jar</packaging> | ||
|
||
<parent> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-parent</artifactId> | ||
<version>1.1.0.BUILD-SNAPSHOT</version> | ||
</parent> | ||
|
||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<java.version>1.6</java.version> | ||
<spring.version>4.0.5.RELEASE</spring.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-data-jpa</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.h2database</groupId> | ||
<artifactId>h2</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<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.
75 changes: 75 additions & 0 deletions
75
SPR-11844/src/test/java/org/springframework/issues/ReproTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package org.springframework.issues; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
import org.junit.Test; | ||
import org.springframework.boot.autoconfigure.PropertyPlaceholderAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration; | ||
import org.springframework.boot.autoconfigure.orm.jpa.JpaBaseConfiguration; | ||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.context.annotation.ImportSelector; | ||
import org.springframework.core.type.AnnotationMetadata; | ||
|
||
/** | ||
* 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 ReproTests { | ||
|
||
@Test | ||
public void ok() throws Exception { | ||
assertNotNull(getClass().getClassLoader().loadClass( | ||
JpaBaseConfiguration.class.getName())); | ||
} | ||
|
||
/** | ||
* This one is fine because it uses an ImportSelector (the same would be true if using | ||
* <code>@EnableAutoConfiguration</code>). | ||
*/ | ||
@Test | ||
public void clean() throws Exception { | ||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); | ||
context.register(MainConfiguration.class); | ||
context.refresh(); | ||
assertNotNull(context); | ||
} | ||
|
||
/** | ||
* This one is fails because it uses <code>@Import</code> (and | ||
* {@link HibernateJpaAutoConfiguration} has an unloadable nested class). | ||
*/ | ||
@Test | ||
public void dirty() throws Exception { | ||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); | ||
context.register(ImportConfiguration.class); | ||
context.refresh(); | ||
assertNotNull(context); | ||
} | ||
|
||
@Configuration | ||
@Import({ DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class, | ||
PropertyPlaceholderAutoConfiguration.class }) | ||
protected static class ImportConfiguration { | ||
} | ||
|
||
@Configuration | ||
@Import(Selector.class) | ||
protected static class MainConfiguration { | ||
} | ||
|
||
protected static class Selector implements ImportSelector { | ||
|
||
@Override | ||
public String[] selectImports(AnnotationMetadata importingClassMetadata) { | ||
return new String[] { DataSourceAutoConfiguration.class.getName(), | ||
HibernateJpaAutoConfiguration.class.getName(), | ||
PropertyPlaceholderAutoConfiguration.class.getName() }; | ||
} | ||
|
||
} | ||
|
||
} |