Skip to content

Commit

Permalink
Add failing test and ignore it
Browse files Browse the repository at this point in the history
When the user overrides a version property from the parent pom
it isn't used currently (workaround is to add the dependency
explicitly).
  • Loading branch information
Dave Syer committed Jan 4, 2017
1 parent 116897b commit 992ec8f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;

import org.assertj.core.api.Condition;
import org.junit.Ignore;
import org.junit.Test;

import org.springframework.boot.loader.archive.Archive;
Expand All @@ -34,21 +35,21 @@
*/
public class ArchiveUtilsTests {

private ArchiveUtils factory = new ArchiveUtils();
private ArchiveUtils utils = new ArchiveUtils();

@Test
public void dependenciesWithPlaceholders() throws Exception {
Archive child = new ExplodedArchive(
new File("src/test/resources/apps/placeholders"));
List<Archive> result = factory.extract(child, "thin");
List<Archive> result = utils.extract(child, "thin");
assertThat(result).isNotEmpty();
}

@Test
public void dependenciesWithParent() throws Exception {
Archive child = new ExplodedArchive(
new File("src/test/resources/apps/parent-properties"));
List<Archive> result = factory.extract(child, "thin");
List<Archive> result = utils.extract(child, "thin");
assertThat(result).isNotEmpty();
// Weird combo of spring version picked from the wrong property (but it resolves,
// which is the test)
Expand All @@ -59,15 +60,25 @@ public void dependenciesWithParent() throws Exception {
public void dependenciesWithProjectVariables() throws Exception {
Archive child = new ExplodedArchive(
new File("src/test/resources/apps/projectvariables"));
List<Archive> result = factory.extract(child, "thin");
List<Archive> result = utils.extract(child, "thin");
assertThat(result).isNotEmpty();
}

@Test
@Ignore // TODO: fix this
public void dependenciesWithParentOverride() throws Exception {
Archive child = new ExplodedArchive(
new File("src/test/resources/apps/parent-properties-override"));
List<Archive> result = utils.extract(child, "thin");
assertThat(result).isNotEmpty();
assertThat(result).areAtLeastOne(UrlContains.value("spring-core/4.3.5.RELEASE"));
}

@Test
public void dependenciesWithMavenArchiveOldStyle() throws Exception {
Archive child = ArchiveUtils.getArchive(
"maven://org.springframework.boot:spring-boot-cli:jar:full:1.3.8.RELEASE");
List<Archive> result = factory.extract(child, "thin");
List<Archive> result = utils.extract(child, "thin");
assertThat(result).isNotEmpty();
assertThat(result)
.areAtLeastOne(UrlContains.value("maven-aether-provider-3.2.1"));
Expand All @@ -77,7 +88,7 @@ public void dependenciesWithMavenArchiveOldStyle() throws Exception {
public void dependenciesWithMavenArchiveBootInf() throws Exception {
Archive child = ArchiveUtils.getArchive(
"maven://org.springframework.boot:spring-boot-cli:jar:full:1.4.2.RELEASE");
List<Archive> result = factory.extract(child, "thin");
List<Archive> result = utils.extract(child, "thin");
assertThat(result).isNotEmpty();
assertThat(result)
.areAtLeastOne(UrlContains.value("maven-aether-provider-3.2.1"));
Expand All @@ -86,7 +97,7 @@ public void dependenciesWithMavenArchiveBootInf() throws Exception {
@Test
public void libsWithProfile() throws Exception {
Archive child = new ExplodedArchive(new File("src/test/resources/apps/eureka"));
List<Archive> result = factory.extract(child, "thin", "extra");
List<Archive> result = utils.extract(child, "thin", "extra");
assertThat(result).size().isGreaterThan(3);
assertThat(result).areAtLeastOne(UrlContains.value("spring-boot-1.4.1.RELEASE"));
}
Expand All @@ -97,7 +108,7 @@ public void overlappingJarsWithDifferentVersions() throws Exception {
new File("src/test/resources/app-with-web-and-cloud-config.jar"));
Archive child = new JarFileArchive(
new File("src/test/resources/app-with-web-in-lib-properties.jar"));
List<Archive> result = factory.subtract(parent, child, "thin");
List<Archive> result = utils.subtract(parent, child, "thin");
assertThat(result).isEmpty();
}

Expand All @@ -106,7 +117,7 @@ public void childWithDatabase() throws Exception {
Archive parent = new JarFileArchive(
new File("src/test/resources/app-with-web-and-cloud-config.jar"));
Archive child = new ExplodedArchive(new File("src/test/resources/apps/db"));
List<Archive> result = factory.subtract(parent, child, "thin");
List<Archive> result = utils.subtract(parent, child, "thin");
assertThat(result).size().isGreaterThan(3);
assertThat(result).areAtLeastOne(UrlContains.value("spring-jdbc"));
assertThat(result).doNotHave(UrlContains.value("spring-boot/"));
Expand All @@ -117,7 +128,7 @@ public void childWithEureka() throws Exception {
Archive parent = new ExplodedArchive(
new File("src/test/resources/apps/web-and-cloud"));
Archive child = new ExplodedArchive(new File("src/test/resources/apps/eureka"));
List<Archive> result = factory.subtract(parent, child, "thin");
List<Archive> result = utils.subtract(parent, child, "thin");
assertThat(result).size().isGreaterThan(3);
assertThat(result)
.areAtLeastOne(UrlContains.value("spring-cloud-netflix-eureka-client"));
Expand All @@ -129,7 +140,7 @@ public void childWithEurekaAndJarParent() throws Exception {
Archive parent = new JarFileArchive(
new File("src/test/resources/app-with-web-and-cloud-config.jar"));
Archive child = new ExplodedArchive(new File("src/test/resources/apps/eureka"));
List<Archive> result = factory.subtract(parent, child, "thin");
List<Archive> result = utils.subtract(parent, child, "thin");
assertThat(result).size().isGreaterThan(3);
assertThat(result)
.areAtLeastOne(UrlContains.value("spring-cloud-netflix-eureka-client"));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.example</groupId>
<artifactId>simple</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>simple</name>
<description>Demo project for Spring Boot</description>

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.4.1.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring.version>4.3.5.RELEASE</spring.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>

</project>

0 comments on commit 992ec8f

Please sign in to comment.