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
6061dd49
Commit
6061dd49
authored
Dec 02, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Increase timeout in DevTools integration tests and improve diagnostics
parent
c5af34be
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
62 additions
and
23 deletions
+62
-23
ApplicationLauncher.java
...ingframework/boot/devtools/tests/ApplicationLauncher.java
+1
-1
DevToolsIntegrationTests.java
...amework/boot/devtools/tests/DevToolsIntegrationTests.java
+7
-5
JvmLauncher.java
.../org/springframework/boot/devtools/tests/JvmLauncher.java
+31
-5
LaunchedApplication.java
...ingframework/boot/devtools/tests/LaunchedApplication.java
+8
-1
LocalApplicationLauncher.java
...amework/boot/devtools/tests/LocalApplicationLauncher.java
+5
-3
RemoteApplicationLauncher.java
...mework/boot/devtools/tests/RemoteApplicationLauncher.java
+10
-8
No files found.
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/ApplicationLauncher.java
View file @
6061dd49
...
@@ -23,6 +23,6 @@ package org.springframework.boot.devtools.tests;
...
@@ -23,6 +23,6 @@ package org.springframework.boot.devtools.tests;
*/
*/
public
interface
ApplicationLauncher
{
public
interface
ApplicationLauncher
{
LaunchedApplication
launchApplication
(
J
ava
Launcher
javaLauncher
)
throws
Exception
;
LaunchedApplication
launchApplication
(
J
vm
Launcher
javaLauncher
)
throws
Exception
;
}
}
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/DevToolsIntegrationTests.java
View file @
6061dd49
...
@@ -57,7 +57,7 @@ public class DevToolsIntegrationTests {
...
@@ -57,7 +57,7 @@ public class DevToolsIntegrationTests {
private
final
ApplicationLauncher
applicationLauncher
;
private
final
ApplicationLauncher
applicationLauncher
;
@Rule
@Rule
public
J
avaLauncher
javaLauncher
=
new
Java
Launcher
();
public
J
vmLauncher
javaLauncher
=
new
Jvm
Launcher
();
@Parameters
(
name
=
"{0}"
)
@Parameters
(
name
=
"{0}"
)
public
static
Object
[]
parameters
()
{
public
static
Object
[]
parameters
()
{
...
@@ -106,7 +106,6 @@ public class DevToolsIntegrationTests {
...
@@ -106,7 +106,6 @@ public class DevToolsIntegrationTests {
controller
(
"com.example.ControllerOne"
).
build
();
controller
(
"com.example.ControllerOne"
).
build
();
assertThat
(
template
.
getForEntity
(
"http://localhost:"
+
awaitServerPort
()
+
"/one"
,
assertThat
(
template
.
getForEntity
(
"http://localhost:"
+
awaitServerPort
()
+
"/one"
,
String
.
class
).
getStatusCode
()).
isEqualTo
(
HttpStatus
.
NOT_FOUND
);
String
.
class
).
getStatusCode
()).
isEqualTo
(
HttpStatus
.
NOT_FOUND
);
}
}
@Test
@Test
...
@@ -138,11 +137,14 @@ public class DevToolsIntegrationTests {
...
@@ -138,11 +137,14 @@ public class DevToolsIntegrationTests {
}
}
private
int
awaitServerPort
()
throws
Exception
{
private
int
awaitServerPort
()
throws
Exception
{
long
end
=
System
.
currentTimeMillis
()
+
2
0000
;
long
end
=
System
.
currentTimeMillis
()
+
3
0000
;
while
(
this
.
serverPortFile
.
length
()
==
0
)
{
while
(
this
.
serverPortFile
.
length
()
==
0
)
{
if
(
System
.
currentTimeMillis
()
>
end
)
{
if
(
System
.
currentTimeMillis
()
>
end
)
{
throw
new
IllegalStateException
(
throw
new
IllegalStateException
(
String
.
format
(
"server.port file was not written within 20 seconds"
);
"server.port file was not written within 30 seconds. "
+
"Application output:%n%s"
,
FileCopyUtils
.
copyToString
(
new
FileReader
(
this
.
launchedApplication
.
getStandardOut
()))));
}
}
Thread
.
sleep
(
100
);
Thread
.
sleep
(
100
);
}
}
...
...
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/J
ava
Launcher.java
→
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/J
vm
Launcher.java
View file @
6061dd49
...
@@ -27,9 +27,12 @@ import org.junit.runner.Description;
...
@@ -27,9 +27,12 @@ import org.junit.runner.Description;
import
org.junit.runners.model.Statement
;
import
org.junit.runners.model.Statement
;
/**
/**
* @author awilkinson
* JUnit {@link TestRule} that launched a JVM and redirects its output to a test
* method-specific location.
*
* @author Andy Wilkinson
*/
*/
public
class
Java
Launcher
implements
TestRule
{
class
Jvm
Launcher
implements
TestRule
{
private
File
outputDirectory
;
private
File
outputDirectory
;
...
@@ -41,13 +44,36 @@ public class JavaLauncher implements TestRule {
...
@@ -41,13 +44,36 @@ public class JavaLauncher implements TestRule {
return
base
;
return
base
;
}
}
Process
launch
(
String
name
,
String
classpath
,
String
...
args
)
throws
IOException
{
LaunchedJvm
launch
(
String
name
,
String
classpath
,
String
...
args
)
throws
IOException
{
List
<
String
>
command
=
new
ArrayList
<
String
>(
Arrays
List
<
String
>
command
=
new
ArrayList
<
String
>(
Arrays
.
asList
(
System
.
getProperty
(
"java.home"
)
+
"/bin/java"
,
"-cp"
,
classpath
));
.
asList
(
System
.
getProperty
(
"java.home"
)
+
"/bin/java"
,
"-cp"
,
classpath
));
command
.
addAll
(
Arrays
.
asList
(
args
));
command
.
addAll
(
Arrays
.
asList
(
args
));
return
new
ProcessBuilder
(
command
.
toArray
(
new
String
[
command
.
size
()]))
File
standardOut
=
new
File
(
this
.
outputDirectory
,
name
+
".out"
);
Process
process
=
new
ProcessBuilder
(
command
.
toArray
(
new
String
[
command
.
size
()]))
.
redirectError
(
new
File
(
this
.
outputDirectory
,
name
+
".err"
))
.
redirectError
(
new
File
(
this
.
outputDirectory
,
name
+
".err"
))
.
redirectOutput
(
new
File
(
this
.
outputDirectory
,
name
+
".out"
)).
start
();
.
redirectOutput
(
standardOut
).
start
();
return
new
LaunchedJvm
(
process
,
standardOut
);
}
static
class
LaunchedJvm
{
private
final
Process
process
;
private
final
File
standardOut
;
LaunchedJvm
(
Process
process
,
File
standardOut
)
{
this
.
process
=
process
;
this
.
standardOut
=
standardOut
;
}
Process
getProcess
()
{
return
this
.
process
;
}
File
getStandardOut
()
{
return
this
.
standardOut
;
}
}
}
}
}
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/LaunchedApplication.java
View file @
6061dd49
...
@@ -27,10 +27,13 @@ class LaunchedApplication {
...
@@ -27,10 +27,13 @@ class LaunchedApplication {
private
final
File
classesDirectory
;
private
final
File
classesDirectory
;
private
final
File
standardOut
;
private
final
Process
[]
processes
;
private
final
Process
[]
processes
;
LaunchedApplication
(
File
classesDirectory
,
Process
...
processes
)
{
LaunchedApplication
(
File
classesDirectory
,
File
standardOut
,
Process
...
processes
)
{
this
.
classesDirectory
=
classesDirectory
;
this
.
classesDirectory
=
classesDirectory
;
this
.
standardOut
=
standardOut
;
this
.
processes
=
processes
;
this
.
processes
=
processes
;
}
}
...
@@ -40,6 +43,10 @@ class LaunchedApplication {
...
@@ -40,6 +43,10 @@ class LaunchedApplication {
}
}
}
}
File
getStandardOut
()
{
return
this
.
standardOut
;
}
File
getClassesDirectory
()
{
File
getClassesDirectory
()
{
return
this
.
classesDirectory
;
return
this
.
classesDirectory
;
}
}
...
...
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/LocalApplicationLauncher.java
View file @
6061dd49
...
@@ -20,6 +20,7 @@ import java.io.File;
...
@@ -20,6 +20,7 @@ import java.io.File;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.boot.devtools.tests.JvmLauncher.LaunchedJvm
;
import
org.springframework.util.FileSystemUtils
;
import
org.springframework.util.FileSystemUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -31,11 +32,12 @@ import org.springframework.util.StringUtils;
...
@@ -31,11 +32,12 @@ import org.springframework.util.StringUtils;
public
class
LocalApplicationLauncher
implements
ApplicationLauncher
{
public
class
LocalApplicationLauncher
implements
ApplicationLauncher
{
@Override
@Override
public
LaunchedApplication
launchApplication
(
J
avaLauncher
java
Launcher
)
public
LaunchedApplication
launchApplication
(
J
vmLauncher
jvm
Launcher
)
throws
Exception
{
throws
Exception
{
Process
process
=
java
Launcher
.
launch
(
"local"
,
createApplicationClassPath
(),
LaunchedJvm
jvm
=
jvm
Launcher
.
launch
(
"local"
,
createApplicationClassPath
(),
"com.example.DevToolsTestApplication"
,
"--server.port=0"
);
"com.example.DevToolsTestApplication"
,
"--server.port=0"
);
return
new
LaunchedApplication
(
new
File
(
"target/app"
),
process
);
return
new
LaunchedApplication
(
new
File
(
"target/app"
),
jvm
.
getStandardOut
(),
jvm
.
getProcess
());
}
}
protected
String
createApplicationClassPath
()
throws
Exception
{
protected
String
createApplicationClassPath
()
throws
Exception
{
...
...
spring-boot-integration-tests/spring-boot-devtools-tests/src/test/java/org/springframework/boot/devtools/tests/RemoteApplicationLauncher.java
View file @
6061dd49
...
@@ -21,6 +21,7 @@ import java.util.ArrayList;
...
@@ -21,6 +21,7 @@ import java.util.ArrayList;
import
java.util.List
;
import
java.util.List
;
import
org.springframework.boot.devtools.RemoteSpringApplication
;
import
org.springframework.boot.devtools.RemoteSpringApplication
;
import
org.springframework.boot.devtools.tests.JvmLauncher.LaunchedJvm
;
import
org.springframework.util.FileSystemUtils
;
import
org.springframework.util.FileSystemUtils
;
import
org.springframework.util.SocketUtils
;
import
org.springframework.util.SocketUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -34,18 +35,19 @@ import org.springframework.util.StringUtils;
...
@@ -34,18 +35,19 @@ import org.springframework.util.StringUtils;
abstract
class
RemoteApplicationLauncher
implements
ApplicationLauncher
{
abstract
class
RemoteApplicationLauncher
implements
ApplicationLauncher
{
@Override
@Override
public
LaunchedApplication
launchApplication
(
J
ava
Launcher
javaLauncher
)
public
LaunchedApplication
launchApplication
(
J
vm
Launcher
javaLauncher
)
throws
Exception
{
throws
Exception
{
int
port
=
SocketUtils
.
findAvailableTcpPort
();
int
port
=
SocketUtils
.
findAvailableTcpPort
();
Process
application
=
javaLauncher
.
launch
(
"app"
,
createApplicationClassPath
()
,
LaunchedJvm
applicationJvm
=
javaLauncher
.
launch
(
"app"
,
"com.example.DevToolsTestApplication"
,
"--server.port="
+
port
,
createApplicationClassPath
(),
"com.example.DevToolsTestApplication"
,
"--spring.devtools.remote.secret=secret"
);
"--s
erver.port="
+
port
,
"--s
pring.devtools.remote.secret=secret"
);
Process
remoteSpringApplication
=
javaLauncher
.
launch
(
"remote-spring-application"
,
LaunchedJvm
remoteSpringApplicationJvm
=
javaLauncher
.
launch
(
createRemoteSpringApplicationClassPath
(),
"remote-spring-application"
,
createRemoteSpringApplicationClassPath
(),
RemoteSpringApplication
.
class
.
getName
(),
RemoteSpringApplication
.
class
.
getName
(),
"--spring.devtools.remote.secret=secret"
,
"http://localhost:"
+
port
);
"--spring.devtools.remote.secret=secret"
,
"http://localhost:"
+
port
);
return
new
LaunchedApplication
(
new
File
(
"target/remote"
),
application
,
return
new
LaunchedApplication
(
new
File
(
"target/remote"
),
remoteSpringApplication
);
applicationJvm
.
getStandardOut
(),
applicationJvm
.
getProcess
(),
remoteSpringApplicationJvm
.
getProcess
());
}
}
protected
abstract
String
createApplicationClassPath
()
throws
Exception
;
protected
abstract
String
createApplicationClassPath
()
throws
Exception
;
...
...
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