forked from spring-projects/spring-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
9 changed files
with
304 additions
and
16 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
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
92 changes: 92 additions & 0 deletions
92
spring-boot-tools/spring-boot-loader/src/it/executable-props/pom.xml
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,92 @@ | ||
<?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>org.springframework.boot.launcher.it</groupId> | ||
<artifactId>executable-props</artifactId> | ||
<version>0.0.1.BUILD-SNAPSHOT</version> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.1</version> | ||
<configuration> | ||
<source>1.6</source> | ||
<target>1.6</target> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>2.9</version> | ||
<executions> | ||
<execution> | ||
<id>unpack</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>unpack</goal> | ||
</goals> | ||
<configuration> | ||
<artifactItems> | ||
<artifactItem> | ||
<groupId>@project.groupId@</groupId> | ||
<artifactId>@project.artifactId@</artifactId> | ||
<version>@project.version@</version> | ||
<type>jar</type> | ||
</artifactItem> | ||
</artifactItems> | ||
<outputDirectory>${project.build.directory}/assembly</outputDirectory> | ||
</configuration> | ||
</execution> | ||
<execution> | ||
<id>copy</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${project.build.directory}/assembly/lib</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<plugin> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<version>2.4</version> | ||
<configuration> | ||
<descriptors> | ||
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor> | ||
</descriptors> | ||
<archive> | ||
<manifest> | ||
<mainClass>org.springframework.boot.loader.PropertiesLauncher</mainClass> | ||
</manifest> | ||
<manifestEntries> | ||
<Start-Class>org.springframework.boot.load.it.props.EmbeddedJarStarter</Start-Class> | ||
</manifestEntries> | ||
</archive> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>jar-with-dependencies</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework</groupId> | ||
<artifactId>spring-context</artifactId> | ||
<version>4.1.4.RELEASE</version> | ||
</dependency> | ||
</dependencies> | ||
</project> |
26 changes: 26 additions & 0 deletions
26
...ls/spring-boot-loader/src/it/executable-props/src/main/assembly/jar-with-dependencies.xml
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,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<assembly | ||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> | ||
<id>full</id> | ||
<formats> | ||
<format>jar</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<dependencySets> | ||
<dependencySet> | ||
<useProjectArtifact/> | ||
<includes> | ||
<include>${project.groupId}:${project.artifactId}</include> | ||
</includes> | ||
<unpack>true</unpack> | ||
</dependencySet> | ||
</dependencySets> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}/assembly</directory> | ||
<outputDirectory>/</outputDirectory> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
33 changes: 33 additions & 0 deletions
33
...cutable-props/src/main/java/org/springframework/launcher/it/props/EmbeddedJarStarter.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,33 @@ | ||
/* | ||
* Copyright 2012-2013 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.load.it.props; | ||
|
||
import org.springframework.context.annotation.AnnotationConfigApplicationContext; | ||
|
||
/** | ||
* Main class to start the embedded server. | ||
* | ||
* @author Phillip Webb | ||
*/ | ||
public final class EmbeddedJarStarter { | ||
|
||
public static void main(String[] args) throws Exception { | ||
AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(SpringConfiguration.class); | ||
context.getBean(SpringConfiguration.class).run(args); | ||
context.close(); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...utable-props/src/main/java/org/springframework/launcher/it/props/SpringConfiguration.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,53 @@ | ||
/* | ||
* Copyright 2012-2013 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.springframework.boot.load.it.props; | ||
|
||
import java.io.IOException; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.core.io.support.PropertiesLoaderUtils; | ||
|
||
/** | ||
* Spring configuration. | ||
* | ||
* @author Phillip Webb | ||
*/ | ||
@Configuration | ||
@ComponentScan | ||
public class SpringConfiguration { | ||
|
||
private String message = "Jar"; | ||
|
||
@PostConstruct | ||
public void init() throws IOException { | ||
String value = PropertiesLoaderUtils.loadAllProperties("application.properties").getProperty("message"); | ||
if (value!=null) { | ||
this.message = value; | ||
} | ||
|
||
} | ||
|
||
public void run(String... args) { | ||
System.err.println("Hello Embedded " + this.message + "!"); | ||
} | ||
|
||
|
||
|
||
} |
1 change: 1 addition & 0 deletions
1
...ools/spring-boot-loader/src/it/executable-props/src/main/resources/application.properties
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 @@ | ||
message: World |
32 changes: 32 additions & 0 deletions
32
spring-boot-tools/spring-boot-loader/src/it/executable-props/verify.groovy
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,32 @@ | ||
def jarfile = './target/executable-props-0.0.1.BUILD-SNAPSHOT-full.jar' | ||
|
||
new File("${basedir}/application.properties").delete() | ||
|
||
String exec(String command) { | ||
def proc = command.execute([], basedir) | ||
proc.waitFor() | ||
proc.err.text | ||
} | ||
|
||
String out = exec("java -jar ${jarfile}") | ||
assert out.contains('Hello Embedded World!'), | ||
'Using -jar my.jar should use the application.properties from the jar\n' + out | ||
|
||
out = exec("java -cp ${jarfile} org.springframework.boot.loader.PropertiesLauncher") | ||
assert out.contains('Hello Embedded World!'), | ||
'Using -cp my.jar with PropertiesLauncher should use the application.properties from the jar\n' + out | ||
|
||
new File("${basedir}/application.properties").withWriter { it -> it << "message: Foo" } | ||
out = exec("java -jar ${jarfile}") | ||
assert out.contains('Hello Embedded World!'), | ||
'Should use the application.properties from the jar in preference to local filesystem\n' + out | ||
|
||
out = exec("java -Dloader.path=.,lib -jar ${jarfile}") | ||
assert out.contains('Hello Embedded Foo!'), | ||
'With loader.path=.,lib should use the application.properties from the local filesystem\n' + out | ||
|
||
new File("${basedir}/target/application.properties").withWriter { it -> it << "message: Spam" } | ||
|
||
out = exec("java -Dloader.path=target,.,lib -jar ${jarfile}") | ||
assert out.contains('Hello Embedded Spam!'), | ||
'With loader.path=target,.,lib should use the application.properties from the target directory\n' + out |
Oops, something went wrong.