Merge branch '1.5.x'
This commit is contained in:
commit
4119da1d9e
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2014 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -36,6 +36,7 @@ import static org.junit.Assert.assertTrue;
|
|||
* Integration test for {@link JarCommand}.
|
||||
*
|
||||
* @author Andy Wilkinson
|
||||
* @author Stephane Nicoll
|
||||
*/
|
||||
public class JarCommandIT {
|
||||
|
||||
|
@ -98,12 +99,16 @@ public class JarCommandIT {
|
|||
|
||||
assertThat(invocation.getErrorOutput(), equalTo(""));
|
||||
assertThat(invocation.getStandardOutput(), containsString("Hello World!"));
|
||||
assertThat(invocation.getStandardOutput(), containsString("/public/public.txt"));
|
||||
assertThat(invocation.getStandardOutput(),
|
||||
containsString("/resources/resource.txt"));
|
||||
assertThat(invocation.getStandardOutput(), containsString("/static/static.txt"));
|
||||
containsString("/BOOT-INF/classes!/public/public.txt"));
|
||||
assertThat(invocation.getStandardOutput(),
|
||||
containsString("/templates/template.txt"));
|
||||
containsString("/BOOT-INF/classes!/resources/resource.txt"));
|
||||
assertThat(invocation.getStandardOutput(),
|
||||
containsString("/BOOT-INF/classes!/static/static.txt"));
|
||||
assertThat(invocation.getStandardOutput(),
|
||||
containsString("/BOOT-INF/classes!/templates/template.txt"));
|
||||
assertThat(invocation.getStandardOutput(),
|
||||
containsString("/BOOT-INF/classes!/root.properties"));
|
||||
assertThat(invocation.getStandardOutput(), containsString("Goodbye Mama"));
|
||||
}
|
||||
|
||||
|
|
|
@ -26,14 +26,13 @@ import org.springframework.boot.cli.infrastructure.CommandLineInvoker.Invocation
|
|||
import org.springframework.boot.loader.tools.JavaExecutable;
|
||||
import org.springframework.util.SocketUtils;
|
||||
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Integration test for {@link WarCommand}.
|
||||
*
|
||||
* @author Andrey Stolyarov
|
||||
* @author Henri Kerola
|
||||
*/
|
||||
public class WarCommandIT {
|
||||
|
||||
|
@ -47,18 +46,18 @@ public class WarCommandIT {
|
|||
Invocation invocation = this.cli.invoke("war", war.getAbsolutePath(),
|
||||
"war.groovy");
|
||||
invocation.await();
|
||||
assertTrue(war.exists());
|
||||
assertThat(war.exists()).isTrue();
|
||||
Process process = new JavaExecutable()
|
||||
.processBuilder("-jar", war.getAbsolutePath(), "--server.port=" + port)
|
||||
.start();
|
||||
invocation = new Invocation(process);
|
||||
invocation.await();
|
||||
assertThat(invocation.getOutput(), containsString("onStart error"));
|
||||
assertThat(invocation.getOutput(), containsString("Tomcat started"));
|
||||
assertThat(invocation.getOutput(),
|
||||
containsString("/WEB-INF/lib-provided/tomcat-embed-core"));
|
||||
assertThat(invocation.getOutput(),
|
||||
containsString("/WEB-INF/lib-provided/tomcat-embed-core"));
|
||||
assertThat(invocation.getOutput()).contains("onStart error");
|
||||
assertThat(invocation.getOutput()).contains("Tomcat started");
|
||||
assertThat(invocation.getOutput())
|
||||
.contains("/WEB-INF/lib-provided/tomcat-embed-core");
|
||||
assertThat(invocation.getOutput())
|
||||
.contains("WEB-INF/classes!/root.properties");
|
||||
process.destroy();
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ class Example implements CommandLineRunner {
|
|||
println getClass().getResource('/resources/resource.txt')
|
||||
println getClass().getResource('/static/static.txt')
|
||||
println getClass().getResource('/templates/template.txt')
|
||||
println getClass().getResource('/root.properties')
|
||||
println template('template.txt', [world:'Mama'])
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ class WarExample implements CommandLineRunner {
|
|||
|
||||
void run(String... args) {
|
||||
println getClass().getResource('/org/apache/tomcat/InstanceManager.class')
|
||||
println getClass().getResource('/root.properties')
|
||||
throw new RuntimeException("onStart error")
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -73,6 +73,7 @@ import org.springframework.util.Assert;
|
|||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
* @author Andrey Stolyarov
|
||||
* @author Henri Kerola
|
||||
*/
|
||||
abstract class ArchiveCommand extends OptionParsingCommand {
|
||||
|
||||
|
@ -104,6 +105,10 @@ abstract class ArchiveCommand extends OptionParsingCommand {
|
|||
this.layout = layout;
|
||||
}
|
||||
|
||||
protected Layout getLayout() {
|
||||
return this.layout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doOptions() {
|
||||
this.includeOption = option("include",
|
||||
|
@ -278,13 +283,18 @@ abstract class ArchiveCommand extends OptionParsingCommand {
|
|||
libraries.add(new Library(entry.getFile(), LibraryScope.COMPILE));
|
||||
}
|
||||
else {
|
||||
writer.writeEntry(entry.getName(),
|
||||
new FileInputStream(entry.getFile()));
|
||||
writeClasspathEntry(writer, entry);
|
||||
}
|
||||
}
|
||||
return libraries;
|
||||
}
|
||||
|
||||
protected void writeClasspathEntry(JarWriter writer,
|
||||
MatchedResource entry) throws IOException {
|
||||
writer.writeEntry(entry.getName(),
|
||||
new FileInputStream(entry.getFile()));
|
||||
}
|
||||
|
||||
protected abstract LibraryScope getLibraryScope(File file);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright 2012-2015 the original author or authors.
|
||||
* Copyright 2012-2016 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -17,6 +17,7 @@
|
|||
package org.springframework.boot.cli.command.archive;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import org.springframework.boot.cli.command.Command;
|
||||
|
@ -29,6 +30,7 @@ import org.springframework.boot.loader.tools.LibraryScope;
|
|||
*
|
||||
* @author Andrey Stolyarov
|
||||
* @author Phillip Webb
|
||||
* @author Henri Kerola
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public class WarCommand extends ArchiveCommand {
|
||||
|
@ -61,6 +63,13 @@ public class WarCommand extends ArchiveCommand {
|
|||
super.addCliClasses(writer);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void writeClasspathEntry(JarWriter writer,
|
||||
ResourceMatcher.MatchedResource entry) throws IOException {
|
||||
writer.writeEntry(getLayout().getClassesLocation() + entry.getName(),
|
||||
new FileInputStream(entry.getFile()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue