Skip to content

Commit dcb1d6a

Browse files
author
Dave Syer
committed
Stricter test, but at the cost of having to run invoker
1 parent 920b9c2 commit dcb1d6a

File tree

5 files changed

+44
-8
lines changed

5 files changed

+44
-8
lines changed

launcher/src/main/java/org/springframework/boot/loader/thin/DependencyResolver.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,10 @@ private List<ArtifactRepository> mavenRepositories(MavenSettings settings, Repos
331331
Properties properties) {
332332
List<ArtifactRepository> list = new ArrayList<>();
333333
if (session.isOffline()) {
334+
if (properties.containsKey(ThinJarLauncher.THIN_ROOT)) {
335+
addRepositoryIfMissing(settings, session, list, "local", "file://" + properties.getProperty(THIN_ROOT),
336+
true, true);
337+
}
334338
return list;
335339
}
336340
if (properties.containsKey(ThinJarLauncher.THIN_ROOT)) {

launcher/src/test/java/org/springframework/boot/loader/thin/ThinJarLauncherTests.java

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import org.eclipse.aether.artifact.DefaultArtifact;
2626
import org.eclipse.aether.graph.Dependency;
2727
import org.junit.After;
28-
import org.junit.Ignore;
2928
import org.junit.Rule;
3029
import org.junit.Test;
3130
import org.junit.rules.ExpectedException;
@@ -127,7 +126,7 @@ public void dryrun() throws Exception {
127126
public void classpath() throws Exception {
128127
String[] args = new String[] { "--thin.classpath", "--thin.archive=src/test/resources/apps/basic" };
129128
ThinJarLauncher.main(args);
130-
assertThat(output.toString()).contains("spring-web-4.3.3.RELEASE.jar" + File.pathSeparator);
129+
assertThat(output.toString()).contains("spring-web-5.2.7.RELEASE.jar" + File.pathSeparator);
131130
}
132131

133132
@Test
@@ -150,7 +149,7 @@ public void compute() throws Exception {
150149
String[] args = new String[] { "--thin.classpath=properties", "--thin.archive=src/test/resources/apps/basic" };
151150
ThinJarLauncher.main(args);
152151
assertThat(output.toString())
153-
.contains("dependencies.spring-web=org.springframework:spring-web:4.3.3.RELEASE\n");
152+
.contains("dependencies.spring-web=org.springframework:spring-web:5.2.7.RELEASE\n");
154153
}
155154

156155
@Test
@@ -314,8 +313,24 @@ public void settingsReadFromRootWithThinRoot() throws Exception {
314313
}
315314

316315
@Test
317-
@Ignore
318316
public void commandLineOffline() throws Exception {
317+
// Once online to prime the cache
318+
String[] args = new String[] { "--thin.root=target/thin/test", "--thin.dryrun=true",
319+
"--thin.archive=src/test/resources/apps/basic", "--debug" };
320+
ThinJarLauncher.main(args);
321+
DependencyResolver.close();
322+
// Then go offline with the same args
323+
DependencyResolver.close();
324+
args = new String[] { "--thin.root=target/thin/test", "--thin.dryrun=true", "--thin.offline=true",
325+
"--thin.archive=src/test/resources/apps/basic", "--debug" };
326+
// assertThat(deleteRecursively(new
327+
// File("target/thin/test/repository/org/springframework/spring-core"))).isTrue();
328+
ThinJarLauncher.main(args);
329+
assertThat(new File("target/thin/test/repository/org/springframework/spring-core").exists()).isTrue();
330+
}
331+
332+
@Test
333+
public void commandLineOfflineSnapshots() throws Exception {
319334
// Once online to prime the cache
320335
String[] args = new String[] { "--thin.root=target/thin/test", "--thin.dryrun=true",
321336
"--thin.archive=src/test/resources/apps/snapshots-with-repos", "--debug" };
@@ -325,7 +340,8 @@ public void commandLineOffline() throws Exception {
325340
DependencyResolver.close();
326341
args = new String[] { "--thin.root=target/thin/test", "--thin.dryrun=true", "--thin.offline=true",
327342
"--thin.archive=src/test/resources/apps/snapshots-with-repos", "--debug" };
328-
assertThat(deleteRecursively(new File("target/thin/test/repository/org/springframework/spring-core"))).isTrue();
343+
// assertThat(deleteRecursively(new
344+
// File("target/thin/test/repository/org/springframework/spring-core"))).isTrue();
329345
ThinJarLauncher.main(args);
330346
assertThat(new File("target/thin/test/repository/org/springframework/spring-core").exists()).isTrue();
331347
}

launcher/src/test/resources/apps/basic/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
<parent>
1515
<groupId>org.springframework.boot</groupId>
1616
<artifactId>spring-boot-starter-parent</artifactId>
17-
<version>1.4.1.RELEASE</version>
17+
<version>2.3.1.RELEASE</version>
1818
<relativePath /> <!-- lookup parent from repository -->
1919
</parent>
2020

2121
<properties>
2222
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2323
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
2424
<java.version>1.8</java.version>
25-
<spring-boot.version>1.5.3.RELEASE</spring-boot.version>
25+
<spring-boot.version>2.3.1.RELEASE</spring-boot.version>
2626
<wrapper.version>1.0.26.BUILD-SNAPSHOT</wrapper.version>
2727
</properties>
2828

samples/tests/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,20 @@
217217
<streamLogs>true</streamLogs>
218218
</configuration>
219219
</execution>
220+
<execution>
221+
<id>prepare-samples</id>
222+
<phase>process-test-resources</phase>
223+
<goals>
224+
<goal>run</goal>
225+
</goals>
226+
<configuration>
227+
<pom>${basedir}/../app/pom.xml</pom>
228+
<cloneProjectsTo>${project.build.directory}/it/app</cloneProjectsTo>
229+
<settingsFile>src/it/settings.xml</settingsFile>
230+
<addTestClassPath>true</addTestClassPath>
231+
<streamLogs>true</streamLogs>
232+
</configuration>
233+
</execution>
220234
</executions>
221235
</plugin>
222236
</plugins>

samples/tests/src/test/java/com/example/AppMavenIT.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ public boolean matches(File value) {
5757

5858
@Test
5959
public void launcherDownloaded() {
60-
File downloaded = new File("../app/target/thin/root/repository/org/springframework/boot/experimental");
60+
// This one fails unless you run the invoke plugin from the command line (per the
61+
// pom)
62+
File downloaded = new File("target/it/app/target/thin/root/repository/org/springframework/boot/experimental");
6163
assertThat(downloaded).exists();
6264
downloaded = new File(downloaded,
6365
"spring-boot-thin-launcher/1.0.26.BUILD-SNAPSHOT/spring-boot-thin-launcher-1.0.26.BUILD-SNAPSHOT-exec.jar");

0 commit comments

Comments
 (0)