Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
d0b8a848
Commit
d0b8a848
authored
Mar 01, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use settings.xml to pass repository into server integration tests
Closes gh-12293
parent
a1ee9bc6
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
36 deletions
+44
-36
ApplicationBuilder.java
...ngframework/boot/context/embedded/ApplicationBuilder.java
+12
-8
pom-template.xml
...ing-boot-server-tests/src/test/resources/pom-template.xml
+0
-28
settings-template.xml
...oot-server-tests/src/test/resources/settings-template.xml
+32
-0
No files found.
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/java/org/springframework/boot/context/embedded/ApplicationBuilder.java
View file @
d0b8a848
...
@@ -24,7 +24,6 @@ import java.io.IOException;
...
@@ -24,7 +24,6 @@ import java.io.IOException;
import
java.util.Collections
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.jar.JarOutputStream
;
import
java.util.jar.JarOutputStream
;
import
java.util.zip.ZipEntry
;
import
java.util.zip.ZipEntry
;
...
@@ -37,7 +36,6 @@ import org.apache.maven.shared.invoker.MavenInvocationException;
...
@@ -37,7 +36,6 @@ import org.apache.maven.shared.invoker.MavenInvocationException;
import
org.junit.rules.TemporaryFolder
;
import
org.junit.rules.TemporaryFolder
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.FileCopyUtils
;
import
org.springframework.util.StringUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
...
@@ -74,6 +72,7 @@ class ApplicationBuilder {
...
@@ -74,6 +72,7 @@ class ApplicationBuilder {
File
resourcesJar
=
createResourcesJar
();
File
resourcesJar
=
createResourcesJar
();
File
appFolder
=
new
File
(
containerFolder
,
"app"
);
File
appFolder
=
new
File
(
containerFolder
,
"app"
);
appFolder
.
mkdirs
();
appFolder
.
mkdirs
();
writeSettingsXml
(
appFolder
);
writePom
(
appFolder
,
resourcesJar
);
writePom
(
appFolder
,
resourcesJar
);
copyApplicationSource
(
appFolder
);
copyApplicationSource
(
appFolder
);
packageApplication
(
appFolder
);
packageApplication
(
appFolder
);
...
@@ -110,6 +109,16 @@ class ApplicationBuilder {
...
@@ -110,6 +109,16 @@ class ApplicationBuilder {
out
.
close
();
out
.
close
();
}
}
private
void
writeSettingsXml
(
File
appFolder
)
throws
IOException
{
Map
<
String
,
Object
>
context
=
new
HashMap
<>();
context
.
put
(
"repository"
,
System
.
getProperty
(
"repository"
));
FileWriter
out
=
new
FileWriter
(
new
File
(
appFolder
,
"settings.xml"
));
Mustache
.
compiler
().
escapeHTML
(
false
)
.
compile
(
new
FileReader
(
"src/test/resources/settings-template.xml"
))
.
execute
(
context
,
out
);
out
.
close
();
}
private
void
copyApplicationSource
(
File
appFolder
)
throws
IOException
{
private
void
copyApplicationSource
(
File
appFolder
)
throws
IOException
{
File
examplePackage
=
new
File
(
appFolder
,
"src/main/java/com/example"
);
File
examplePackage
=
new
File
(
appFolder
,
"src/main/java/com/example"
);
examplePackage
.
mkdirs
();
examplePackage
.
mkdirs
();
...
@@ -128,12 +137,7 @@ class ApplicationBuilder {
...
@@ -128,12 +137,7 @@ class ApplicationBuilder {
InvocationRequest
invocation
=
new
DefaultInvocationRequest
();
InvocationRequest
invocation
=
new
DefaultInvocationRequest
();
invocation
.
setBaseDirectory
(
appFolder
);
invocation
.
setBaseDirectory
(
appFolder
);
invocation
.
setGoals
(
Collections
.
singletonList
(
"package"
));
invocation
.
setGoals
(
Collections
.
singletonList
(
"package"
));
String
repository
=
System
.
getProperty
(
"repository"
);
invocation
.
setUserSettingsFile
(
new
File
(
appFolder
,
"settings.xml"
));
if
(
StringUtils
.
hasText
(
repository
)
&&
!
repository
.
equals
(
"${repository}"
))
{
Properties
properties
=
new
Properties
();
properties
.
put
(
"repository"
,
repository
);
invocation
.
setProperties
(
properties
);
}
InvocationResult
execute
=
new
DefaultInvoker
().
execute
(
invocation
);
InvocationResult
execute
=
new
DefaultInvoker
().
execute
(
invocation
);
assertThat
(
execute
.
getExitCode
()).
isEqualTo
(
0
);
assertThat
(
execute
.
getExitCode
()).
isEqualTo
(
0
);
}
}
...
...
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/resources/pom-template.xml
View file @
d0b8a848
...
@@ -61,32 +61,4 @@
...
@@ -61,32 +61,4 @@
</snapshots>
</snapshots>
</repository>
</repository>
</repositories>
</repositories>
<profiles>
<profile>
<id>
repository
</id>
<activation>
<property>
<name>
repository
</name>
</property>
</activation>
<repositories>
<repository>
<id>
repository
</id>
<url>
${repository}
</url>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>
repository
</id>
<url>
${repository}
</url>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</project>
</project>
spring-boot-tests/spring-boot-integration-tests/spring-boot-server-tests/src/test/resources/settings-template.xml
0 → 100644
View file @
d0b8a848
<?xml version="1.0" encoding="UTF-8"?>
<settings
xmlns=
"http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd"
>
<profiles>
<profile>
<id>
repository
</id>
<activation>
<property>
<name>
repository
</name>
</property>
</activation>
<repositories>
<repository>
<id>
repository
</id>
<url>
${repository}
</url>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>
repository
</id>
<url>
${repository}
</url>
<snapshots>
<enabled>
true
</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
</settings>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment