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
5627caa7
Commit
5627caa7
authored
Jan 17, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move spring-boot tests utilities to main spring-boot.jar
Fixes gh-233
parent
d53a52cf
Changes
22
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
152 additions
and
48 deletions
+152
-48
pom.xml
spring-boot-cli/pom.xml
+0
-17
CliTester.java
...src/test/java/org/springframework/boot/cli/CliTester.java
+1
-1
OutputCapture.java
...java/org/springframework/boot/cli/util/OutputCapture.java
+127
-0
SampleAopApplicationTests.java
...p/src/test/java/sample/aop/SampleAopApplicationTests.java
+2
-2
SampleBatchApplicationTests.java
...c/test/java/sample/batch/SampleBatchApplicationTests.java
+1
-1
SampleMongoApplicationTests.java
...t/java/sample/data/mongo/SampleMongoApplicationTests.java
+1
-1
SampleRedisApplicationTests.java
...t/java/sample/data/redis/SampleRedisApplicationTests.java
+1
-1
SampleProfileApplicationTests.java
...st/java/sample/profile/SampleProfileApplicationTests.java
+1
-1
SampleSimpleApplicationTests.java
...test/java/sample/simple/SampleSimpleApplicationTests.java
+1
-1
SampleSpringXmlApplicationTests.java
...test/java/sample/xml/SampleSpringXmlApplicationTests.java
+1
-1
pom.xml
spring-boot-starters/spring-boot-starter-parent/pom.xml
+0
-6
pom.xml
spring-boot-starters/spring-boot-starter-test/pom.xml
+0
-6
pom.xml
spring-boot/pom.xml
+10
-5
EnvironmentTestUtils.java
...a/org/springframework/boot/test/EnvironmentTestUtils.java
+0
-0
OutputCapture.java
...ain/java/org/springframework/boot/test/OutputCapture.java
+1
-1
SpringApplicationConfiguration.java
...ngframework/boot/test/SpringApplicationConfiguration.java
+0
-0
SpringApplicationContextLoader.java
...ngframework/boot/test/SpringApplicationContextLoader.java
+0
-0
SimpleMainTests.java
...c/test/java/org/springframework/boot/SimpleMainTests.java
+1
-0
LoggingApplicationListenerTests.java
...oot/context/listener/LoggingApplicationListenerTests.java
+1
-1
JavaLoggerSystemTests.java
...ingframework/boot/logging/java/JavaLoggerSystemTests.java
+1
-1
Log4JLoggingSystemTests.java
...framework/boot/logging/log4j/Log4JLoggingSystemTests.java
+1
-1
LogbackLoggingSystemTests.java
...ework/boot/logging/logback/LogbackLoggingSystemTests.java
+1
-1
No files found.
spring-boot-cli/pom.xml
View file @
5627caa7
...
...
@@ -130,23 +130,6 @@
<scope>
provided
</scope>
</dependency>
<!-- Test -->
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
spring-boot
</artifactId>
<version>
${project.version}
</version>
<classifier>
tests
</classifier>
<scope>
test
</scope>
<exclusions>
<exclusion>
<groupId>
${project.groupId}
</groupId>
<artifactId>
spring-boot
</artifactId>
</exclusion>
<exclusion>
<groupId>
commons-logging
</groupId>
<artifactId>
commons-logging
</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>
org.javassist
</groupId>
<artifactId>
javassist
</artifactId>
...
...
spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java
View file @
5627caa7
...
...
@@ -32,12 +32,12 @@ import org.junit.Assume;
import
org.junit.rules.TestRule
;
import
org.junit.runner.Description
;
import
org.junit.runners.model.Statement
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.cli.command.AbstractCommand
;
import
org.springframework.boot.cli.command.OptionParsingCommand
;
import
org.springframework.boot.cli.command.grab.GrabCommand
;
import
org.springframework.boot.cli.command.run.RunCommand
;
import
org.springframework.boot.cli.command.test.TestCommand
;
import
org.springframework.boot.cli.util.OutputCapture
;
/**
* {@link TestRule} that can be used to invoke CLI commands.
...
...
spring-boot-cli/src/test/java/org/springframework/boot/cli/util/OutputCapture.java
0 → 100644
View file @
5627caa7
/*
* 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
.
cli
.
util
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.PrintStream
;
import
org.junit.rules.TestRule
;
import
org.junit.runner.Description
;
import
org.junit.runners.model.Statement
;
/**
* Capture output from System.out and System.err.
*
* @author Phillip Webb
*/
public
class
OutputCapture
implements
TestRule
{
private
CaptureOutputStream
captureOut
;
private
CaptureOutputStream
captureErr
;
private
ByteArrayOutputStream
copy
;
@Override
public
Statement
apply
(
final
Statement
base
,
Description
description
)
{
return
new
Statement
()
{
@Override
public
void
evaluate
()
throws
Throwable
{
captureOutput
();
try
{
base
.
evaluate
();
}
finally
{
releaseOutput
();
}
}
};
}
protected
void
captureOutput
()
{
this
.
copy
=
new
ByteArrayOutputStream
();
this
.
captureOut
=
new
CaptureOutputStream
(
System
.
out
,
this
.
copy
);
this
.
captureErr
=
new
CaptureOutputStream
(
System
.
err
,
this
.
copy
);
System
.
setOut
(
new
PrintStream
(
this
.
captureOut
));
System
.
setErr
(
new
PrintStream
(
this
.
captureErr
));
}
protected
void
releaseOutput
()
{
System
.
setOut
(
this
.
captureOut
.
getOriginal
());
System
.
setErr
(
this
.
captureErr
.
getOriginal
());
this
.
copy
=
null
;
}
public
void
flush
()
{
try
{
this
.
captureOut
.
flush
();
this
.
captureErr
.
flush
();
}
catch
(
IOException
ex
)
{
// ignore
}
}
@Override
public
String
toString
()
{
flush
();
return
this
.
copy
.
toString
();
}
private
static
class
CaptureOutputStream
extends
OutputStream
{
private
final
PrintStream
original
;
private
final
OutputStream
copy
;
public
CaptureOutputStream
(
PrintStream
original
,
OutputStream
copy
)
{
this
.
original
=
original
;
this
.
copy
=
copy
;
}
@Override
public
void
write
(
int
b
)
throws
IOException
{
this
.
copy
.
write
(
b
);
this
.
original
.
write
(
b
);
this
.
original
.
flush
();
}
@Override
public
void
write
(
byte
[]
b
)
throws
IOException
{
write
(
b
,
0
,
b
.
length
);
}
@Override
public
void
write
(
byte
[]
b
,
int
off
,
int
len
)
throws
IOException
{
this
.
copy
.
write
(
b
,
off
,
len
);
this
.
original
.
write
(
b
,
off
,
len
);
}
public
PrintStream
getOriginal
()
{
return
this
.
original
;
}
@Override
public
void
flush
()
throws
IOException
{
this
.
copy
.
flush
();
this
.
original
.
flush
();
}
}
}
spring-boot-samples/spring-boot-sample-aop/src/test/java/sample/aop/SampleAopApplicationTests.java
View file @
5627caa7
...
...
@@ -20,9 +20,9 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
sample.aop.SampleAopApplication
;
import
org.springframework.boot.test.OutputCapture
;
import
sample.aop.SampleAopApplication
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
/**
...
...
spring-boot-samples/spring-boot-sample-batch/src/test/java/sample/batch/SampleBatchApplicationTests.java
View file @
5627caa7
...
...
@@ -18,8 +18,8 @@ package sample.batch;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.test.OutputCapture
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
spring-boot-samples/spring-boot-sample-data-mongodb/src/test/java/sample/data/mongo/SampleMongoApplicationTests.java
View file @
5627caa7
...
...
@@ -22,7 +22,7 @@ import java.io.IOException;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.
test.
OutputCapture
;
import
org.springframework.core.NestedCheckedException
;
/**
...
...
spring-boot-samples/spring-boot-sample-data-redis/src/test/java/sample/data/redis/SampleRedisApplicationTests.java
View file @
5627caa7
...
...
@@ -18,7 +18,7 @@ package sample.data.redis;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.
test.
OutputCapture
;
import
org.springframework.data.redis.RedisConnectionFailureException
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
spring-boot-samples/spring-boot-sample-profile/src/test/java/sample/profile/SampleProfileApplicationTests.java
View file @
5627caa7
...
...
@@ -20,7 +20,7 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.
test.
OutputCapture
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
spring-boot-samples/spring-boot-sample-simple/src/test/java/sample/simple/SampleSimpleApplicationTests.java
View file @
5627caa7
...
...
@@ -20,7 +20,7 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.
test.
OutputCapture
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
spring-boot-samples/spring-boot-sample-xml/src/test/java/sample/xml/SampleSpringXmlApplicationTests.java
View file @
5627caa7
...
...
@@ -18,7 +18,7 @@ package sample.xml;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.
test.
OutputCapture
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
spring-boot-starters/spring-boot-starter-parent/pom.xml
View file @
5627caa7
...
...
@@ -32,12 +32,6 @@
<artifactId>
spring-boot
</artifactId>
<version>
0.5.0.BUILD-SNAPSHOT
</version>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot
</artifactId>
<version>
0.5.0.BUILD-SNAPSHOT
</version>
<classifier>
tests
</classifier>
</dependency>
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter
</artifactId>
...
...
spring-boot-starters/spring-boot-starter-test/pom.xml
View file @
5627caa7
...
...
@@ -18,12 +18,6 @@
<artifactId>
spring-boot-starter-logging
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
spring-boot
</artifactId>
<classifier>
tests
</classifier>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
spring-boot/pom.xml
View file @
5627caa7
...
...
@@ -39,6 +39,11 @@
<artifactId>
javax.servlet-api
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
log4j
</groupId>
<artifactId>
log4j
</artifactId>
...
...
@@ -89,6 +94,11 @@
<artifactId>
jul-to-slf4j
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
<optional>
true
</optional>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-web
</artifactId>
...
...
@@ -115,11 +125,6 @@
<artifactId>
tomcat-embed-logging-juli
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-webmvc
</artifactId>
...
...
spring-boot/src/
test
/java/org/springframework/boot/test/EnvironmentTestUtils.java
→
spring-boot/src/
main
/java/org/springframework/boot/test/EnvironmentTestUtils.java
View file @
5627caa7
File moved
spring-boot/src/
test/java/org/springframework/boo
t/OutputCapture.java
→
spring-boot/src/
main/java/org/springframework/boot/tes
t/OutputCapture.java
View file @
5627caa7
...
...
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package
org
.
springframework
.
boot
;
package
org
.
springframework
.
boot
.
test
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
...
...
spring-boot/src/
test
/java/org/springframework/boot/test/SpringApplicationConfiguration.java
→
spring-boot/src/
main
/java/org/springframework/boot/test/SpringApplicationConfiguration.java
View file @
5627caa7
File moved
spring-boot/src/
test
/java/org/springframework/boot/test/SpringApplicationContextLoader.java
→
spring-boot/src/
main
/java/org/springframework/boot/test/SpringApplicationContextLoader.java
View file @
5627caa7
File moved
spring-boot/src/test/java/org/springframework/boot/SimpleMainTests.java
View file @
5627caa7
...
...
@@ -22,6 +22,7 @@ import java.util.List;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
...
...
spring-boot/src/test/java/org/springframework/boot/context/listener/LoggingApplicationListenerTests.java
View file @
5627caa7
...
...
@@ -27,12 +27,12 @@ import org.junit.Before;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.TemporaryFolder
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.SpringApplicationStartEvent
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.logging.java.JavaLoggingSystem
;
import
org.springframework.boot.test.EnvironmentTestUtils
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.context.support.GenericApplicationContext
;
import
static
org
.
hamcrest
.
Matchers
.
containsString
;
...
...
spring-boot/src/test/java/org/springframework/boot/logging/java/JavaLoggerSystemTests.java
View file @
5627caa7
...
...
@@ -23,8 +23,8 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.StringUtils
;
...
...
spring-boot/src/test/java/org/springframework/boot/logging/log4j/Log4JLoggingSystemTests.java
View file @
5627caa7
...
...
@@ -21,8 +21,8 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.util.StringUtils
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
...
...
spring-boot/src/test/java/org/springframework/boot/logging/logback/LogbackLoggingSystemTests.java
View file @
5627caa7
...
...
@@ -22,8 +22,8 @@ import org.junit.After;
import
org.junit.Before
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.springframework.boot.OutputCapture
;
import
org.springframework.boot.logging.LogLevel
;
import
org.springframework.boot.test.OutputCapture
;
import
org.springframework.util.StringUtils
;
import
static
org
.
hamcrest
.
Matchers
.
equalTo
;
...
...
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