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
c3816bfe
Commit
c3816bfe
authored
Jul 14, 2019
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish output capture names
parent
cdf43a74
Changes
73
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
73 changed files
with
328 additions
and
335 deletions
+328
-335
PrometheusMetricsExportAutoConfigurationTests.java
...etheus/PrometheusMetricsExportAutoConfigurationTests.java
+4
-4
RestTemplateMetricsConfigurationTests.java
...ics/web/client/RestTemplateMetricsConfigurationTests.java
+4
-4
WebClientMetricsConfigurationTests.java
...etrics/web/client/WebClientMetricsConfigurationTests.java
+4
-4
WebFluxMetricsAutoConfigurationTests.java
...cs/web/reactive/WebFluxMetricsAutoConfigurationTests.java
+4
-5
WebMvcMetricsAutoConfigurationTests.java
...rics/web/servlet/WebMvcMetricsAutoConfigurationTests.java
+4
-5
ManagementContextAutoConfigurationTests.java
...e/web/server/ManagementContextAutoConfigurationTests.java
+2
-2
EndpointIdTests.java
...pringframework/boot/actuate/endpoint/EndpointIdTests.java
+2
-2
FreeMarkerAutoConfigurationTests.java
...onfigure/freemarker/FreeMarkerAutoConfigurationTests.java
+6
-6
H2ConsoleAutoConfigurationTests.java
...oot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java
+2
-2
ConditionEvaluationReportLoggingListenerTests.java
...ogging/ConditionEvaluationReportLoggingListenerTests.java
+12
-12
QuartzAutoConfigurationTests.java
...ot/autoconfigure/quartz/QuartzAutoConfigurationTests.java
+2
-2
SecurityFilterAutoConfigurationEarlyInitializationTests.java
...urityFilterAutoConfigurationEarlyInitializationTests.java
+2
-4
UserDetailsServiceAutoConfigurationTests.java
...ity/servlet/UserDetailsServiceAutoConfigurationTests.java
+10
-11
TaskExecutionAutoConfigurationTests.java
...toconfigure/task/TaskExecutionAutoConfigurationTests.java
+3
-3
ThymeleafReactiveAutoConfigurationTests.java
...re/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java
+4
-4
ThymeleafServletAutoConfigurationTests.java
...ure/thymeleaf/ThymeleafServletAutoConfigurationTests.java
+4
-4
DefaultErrorWebExceptionHandlerIntegrationTests.java
...rror/DefaultErrorWebExceptionHandlerIntegrationTests.java
+2
-2
ErrorMvcAutoConfigurationTests.java
...ure/web/servlet/error/ErrorMvcAutoConfigurationTests.java
+2
-2
ClassLoaderIntegrationTests.java
...springframework/boot/cli/ClassLoaderIntegrationTests.java
+2
-2
CliTester.java
...src/test/java/org/springframework/boot/cli/CliTester.java
+4
-4
DirectorySourcesIntegrationTests.java
...gframework/boot/cli/DirectorySourcesIntegrationTests.java
+2
-2
GrabCommandIntegrationTests.java
...springframework/boot/cli/GrabCommandIntegrationTests.java
+2
-2
ReproIntegrationTests.java
...a/org/springframework/boot/cli/ReproIntegrationTests.java
+2
-2
RunCommandIntegrationTests.java
.../springframework/boot/cli/RunCommandIntegrationTests.java
+2
-2
SampleIntegrationTests.java
.../org/springframework/boot/cli/SampleIntegrationTests.java
+2
-2
RemoteClientConfigurationTests.java
...evtools/remote/client/RemoteClientConfigurationTests.java
+6
-6
RestartApplicationListenerTests.java
...oot/devtools/restart/RestartApplicationListenerTests.java
+2
-2
RestarterTests.java
...springframework/boot/devtools/restart/RestarterTests.java
+3
-4
HttpTunnelConnectionTests.java
...oot/devtools/tunnel/client/HttpTunnelConnectionTests.java
+2
-2
SpringApplicationBuilderExampleTests.java
...ot/docs/builder/SpringApplicationBuilderExampleTests.java
+2
-2
PropertiesMigrationListenerTests.java
...properties/migrator/PropertiesMigrationListenerTests.java
+2
-2
SpringBootDependencyInjectionTestExecutionListenerTests.java
...ingBootDependencyInjectionTestExecutionListenerTests.java
+2
-2
MockMvcSpringBootTestIntegrationTests.java
...ervlet/mockmvc/MockMvcSpringBootTestIntegrationTests.java
+2
-2
WebMvcTestPrintAlwaysIntegrationTests.java
...ervlet/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java
+2
-2
WebMvcTestPrintDefaultIntegrationTests.java
...rvlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java
+4
-4
WebMvcTestPrintDefaultOverrideIntegrationTests.java
...ckmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java
+2
-2
WebMvcTestPrintOverrideIntegrationTests.java
...vlet/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java
+2
-2
PropertiesLauncherTests.java
.../springframework/boot/loader/PropertiesLauncherTests.java
+5
-5
BannerTests.java
...t/src/test/java/org/springframework/boot/BannerTests.java
+6
-6
SimpleMainTests.java
...c/test/java/org/springframework/boot/SimpleMainTests.java
+8
-8
SpringApplicationTests.java
...java/org/springframework/boot/SpringApplicationTests.java
+26
-24
ConfigurationWarningsApplicationContextInitializerTests.java
...figurationWarningsApplicationContextInitializerTests.java
+18
-18
ConfigFileApplicationListenerTests.java
...ot/context/config/ConfigFileApplicationListenerTests.java
+14
-15
LoggingApplicationListenerIntegrationTests.java
...t/logging/LoggingApplicationListenerIntegrationTests.java
+2
-2
LoggingApplicationListenerTests.java
...boot/context/logging/LoggingApplicationListenerTests.java
+43
-43
ConfigurationPropertiesTests.java
...boot/context/properties/ConfigurationPropertiesTests.java
+2
-2
FailureAnalyzersIntegrationTests.java
...rk/boot/diagnostics/FailureAnalyzersIntegrationTests.java
+2
-2
SpringBootJoranConfiguratorTests.java
...oot/logging/logback/SpringBootJoranConfiguratorTests.java
+12
-12
SslConnectorCustomizerTests.java
...boot/web/embedded/tomcat/SslConnectorCustomizerTests.java
+2
-3
TomcatServletWebServerFactoryTests.java
...b/embedded/tomcat/TomcatServletWebServerFactoryTests.java
+2
-2
ServletWebServerApplicationContextTests.java
...vlet/context/ServletWebServerApplicationContextTests.java
+3
-4
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+4
-4
ErrorPageFilterTests.java
...mework/boot/web/servlet/support/ErrorPageFilterTests.java
+6
-6
SpringBootServletInitializerTests.java
...eb/servlet/support/SpringBootServletInitializerTests.java
+2
-2
SampleActiveMqTests.java
...src/test/java/smoketest/activemq/SampleActiveMqTests.java
+2
-2
SampleActuatorLog4J2ApplicationTests.java
...actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java
+2
-2
SampleAopApplicationTests.java
...rc/test/java/smoketest/aop/SampleAopApplicationTests.java
+4
-4
SampleBatchApplicationTests.java
...est/java/smoketest/batch/SampleBatchApplicationTests.java
+2
-2
SampleCouchbaseApplicationTests.java
...etest/data/couchbase/SampleCouchbaseApplicationTests.java
+2
-2
SampleElasticsearchApplicationTests.java
...ta/elasticsearch/SampleElasticsearchApplicationTests.java
+2
-2
SampleNeo4jApplicationTests.java
...ava/smoketest/data/neo4j/SampleNeo4jApplicationTests.java
+2
-2
SampleRedisApplicationTests.java
...ava/smoketest/data/redis/SampleRedisApplicationTests.java
+2
-2
SampleSolrApplicationTests.java
.../java/smoketest/data/solr/SampleSolrApplicationTests.java
+2
-2
SampleJooqApplicationTests.java
.../test/java/smoketest/jooq/SampleJooqApplicationTests.java
+2
-2
SampleAtomikosApplicationTests.java
...va/smoketest/atomikos/SampleAtomikosApplicationTests.java
+2
-2
SampleBitronixApplicationTests.java
...va/smoketest/bitronix/SampleBitronixApplicationTests.java
+2
-2
SampleLiquibaseApplicationTests.java
.../smoketest/liquibase/SampleLiquibaseApplicationTests.java
+2
-2
SampleLogbackApplicationTests.java
...java/smoketest/logback/SampleLogbackApplicationTests.java
+4
-4
SampleProfileApplicationTests.java
...java/smoketest/profile/SampleProfileApplicationTests.java
+8
-8
SampleQuartzApplicationTests.java
...t/java/smoketest/quartz/SampleQuartzApplicationTests.java
+3
-3
SampleSimpleApplicationTests.java
...t/java/smoketest/simple/SampleSimpleApplicationTests.java
+4
-4
SampleWsApplicationTests.java
.../java/smoketest/webservices/SampleWsApplicationTests.java
+2
-2
SampleSpringXmlApplicationTests.java
...t/java/smoketest/xml/SampleSpringXmlApplicationTests.java
+2
-2
No files found.
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -124,23 +124,23 @@ class PrometheusMetricsExportAutoConfigurationTests {
}
@Test
void
withPushGatewayEnabled
(
CapturedOutput
capturedO
utput
)
{
void
withPushGatewayEnabled
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
ManagementContextAutoConfiguration
.
class
))
.
withPropertyValues
(
"management.metrics.export.prometheus.pushgateway.enabled=true"
)
.
withUserConfiguration
(
BaseConfiguration
.
class
).
run
((
context
)
->
{
assertThat
(
capturedO
utput
).
doesNotContain
(
"Invalid PushGateway base url"
);
assertThat
(
o
utput
).
doesNotContain
(
"Invalid PushGateway base url"
);
hasGatewayURL
(
context
,
"http://localhost:9091/metrics/job/"
);
});
}
@Test
@Deprecated
void
withCustomLegacyPushGatewayURL
(
CapturedOutput
capturedO
utput
)
{
void
withCustomLegacyPushGatewayURL
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
ManagementContextAutoConfiguration
.
class
))
.
withPropertyValues
(
"management.metrics.export.prometheus.pushgateway.enabled=true"
,
"management.metrics.export.prometheus.pushgateway.base-url=localhost:9090"
)
.
withUserConfiguration
(
BaseConfiguration
.
class
).
run
((
context
)
->
{
assertThat
(
capturedO
utput
).
contains
(
"Invalid PushGateway base url"
).
contains
(
"localhost:9090"
);
assertThat
(
o
utput
).
contains
(
"Invalid PushGateway base url"
).
contains
(
"localhost:9090"
);
hasGatewayURL
(
context
,
"http://localhost:9090/metrics/job/"
);
});
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/RestTemplateMetricsConfigurationTests.java
View file @
c3816bfe
...
...
@@ -75,21 +75,21 @@ class RestTemplateMetricsConfigurationTests {
}
@Test
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
capturedO
utput
)
{
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.web.client.max-uri-tags=2"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.client.requests"
).
meters
()).
hasSize
(
2
);
assertThat
(
capturedO
utput
).
contains
(
"Reached the maximum number of URI tags for 'http.client.requests'."
)
assertThat
(
o
utput
).
contains
(
"Reached the maximum number of URI tags for 'http.client.requests'."
)
.
contains
(
"Are you using 'uriVariables'?"
);
});
}
@Test
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
capturedO
utput
)
{
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.web.client.max-uri-tags=5"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.client.requests"
).
meters
()).
hasSize
(
3
);
assertThat
(
capturedO
utput
)
assertThat
(
o
utput
)
.
doesNotContain
(
"Reached the maximum number of URI tags for 'http.client.requests'."
)
.
doesNotContain
(
"Are you using 'uriVariables'?"
);
});
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/client/WebClientMetricsConfigurationTests.java
View file @
c3816bfe
...
...
@@ -74,21 +74,21 @@ class WebClientMetricsConfigurationTests {
}
@Test
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
capturedO
utput
)
{
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.web.client.max-uri-tags=2"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.client.requests"
).
meters
()).
hasSize
(
2
);
assertThat
(
capturedO
utput
).
contains
(
"Reached the maximum number of URI tags for 'http.client.requests'."
)
assertThat
(
o
utput
).
contains
(
"Reached the maximum number of URI tags for 'http.client.requests'."
)
.
contains
(
"Are you using 'uriVariables'?"
);
});
}
@Test
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
capturedO
utput
)
{
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withPropertyValues
(
"management.metrics.web.client.max-uri-tags=5"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.client.requests"
).
meters
()).
hasSize
(
3
);
assertThat
(
capturedO
utput
)
assertThat
(
o
utput
)
.
doesNotContain
(
"Reached the maximum number of URI tags for 'http.client.requests'."
)
.
doesNotContain
(
"Are you using 'uriVariables'?"
);
});
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/reactive/WebFluxMetricsAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -66,25 +66,24 @@ class WebFluxMetricsAutoConfigurationTests {
}
@Test
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
capturedO
utput
)
{
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
WebFluxAutoConfiguration
.
class
))
.
withUserConfiguration
(
TestController
.
class
)
.
withPropertyValues
(
"management.metrics.web.server.max-uri-tags=2"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.server.requests"
).
meters
()).
hasSize
(
2
);
assertThat
(
capturedOutput
)
.
contains
(
"Reached the maximum number of URI tags "
+
"for 'http.server.requests'"
);
assertThat
(
output
).
contains
(
"Reached the maximum number of URI tags for 'http.server.requests'"
);
});
}
@Test
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
capturedO
utput
)
{
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withConfiguration
(
AutoConfigurations
.
of
(
WebFluxAutoConfiguration
.
class
))
.
withUserConfiguration
(
TestController
.
class
)
.
withPropertyValues
(
"management.metrics.web.server.max-uri-tags=5"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.server.requests"
).
meters
()).
hasSize
(
3
);
assertThat
(
capturedO
utput
)
assertThat
(
o
utput
)
.
doesNotContain
(
"Reached the maximum number of URI tags for 'http.server.requests'"
);
});
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -104,25 +104,24 @@ class WebMvcMetricsAutoConfigurationTests {
}
@Test
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
capturedO
utput
)
{
void
afterMaxUrisReachedFurtherUrisAreDenied
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withUserConfiguration
(
TestController
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
MetricsAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
))
.
withPropertyValues
(
"management.metrics.web.server.max-uri-tags=2"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.server.requests"
).
meters
()).
hasSize
(
2
);
assertThat
(
capturedOutput
)
.
contains
(
"Reached the maximum number of URI tags "
+
"for 'http.server.requests'"
);
assertThat
(
output
).
contains
(
"Reached the maximum number of URI tags for 'http.server.requests'"
);
});
}
@Test
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
capturedO
utput
)
{
void
shouldNotDenyNorLogIfMaxUrisIsNotReached
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withUserConfiguration
(
TestController
.
class
)
.
withConfiguration
(
AutoConfigurations
.
of
(
MetricsAutoConfiguration
.
class
,
WebMvcAutoConfiguration
.
class
))
.
withPropertyValues
(
"management.metrics.web.server.max-uri-tags=5"
).
run
((
context
)
->
{
MeterRegistry
registry
=
getInitializedMeterRegistry
(
context
);
assertThat
(
registry
.
get
(
"http.server.requests"
).
meters
()).
hasSize
(
3
);
assertThat
(
capturedO
utput
)
assertThat
(
o
utput
)
.
doesNotContain
(
"Reached the maximum number of URI tags "
+
"for 'http.server.requests'"
);
});
}
...
...
spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementContextAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -43,7 +43,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
ManagementContextAutoConfigurationTests
{
@Test
void
childManagementContextShouldStartForEmbeddedServer
(
CapturedOutput
capturedO
utput
)
{
void
childManagementContextShouldStartForEmbeddedServer
(
CapturedOutput
o
utput
)
{
WebApplicationContextRunner
contextRunner
=
new
WebApplicationContextRunner
(
AnnotationConfigServletWebServerApplicationContext:
:
new
)
.
withConfiguration
(
AutoConfigurations
.
of
(
ManagementContextAutoConfiguration
.
class
,
...
...
@@ -51,7 +51,7 @@ class ManagementContextAutoConfigurationTests {
ServletManagementContextAutoConfiguration
.
class
,
WebEndpointAutoConfiguration
.
class
,
EndpointAutoConfiguration
.
class
));
contextRunner
.
withPropertyValues
(
"server.port=0"
,
"management.server.port=0"
)
.
run
((
context
)
->
assertThat
(
tomcatStartedOccurencesIn
(
capturedO
utput
)).
isEqualTo
(
2
));
.
run
((
context
)
->
assertThat
(
tomcatStartedOccurencesIn
(
o
utput
)).
isEqualTo
(
2
));
}
private
int
tomcatStartedOccurencesIn
(
CharSequence
output
)
{
...
...
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/EndpointIdTests.java
View file @
c3816bfe
...
...
@@ -85,10 +85,10 @@ class EndpointIdTests {
}
@Test
void
ofWhenContainsDeprecatedCharsLogsWarning
(
CapturedOutput
capturedO
utput
)
{
void
ofWhenContainsDeprecatedCharsLogsWarning
(
CapturedOutput
o
utput
)
{
EndpointId
.
resetLoggedWarnings
();
EndpointId
.
of
(
"foo-bar"
);
assertThat
(
capturedOutput
.
toString
()
)
assertThat
(
output
)
.
contains
(
"Endpoint ID 'foo-bar' contains invalid characters, please migrate to a valid format"
);
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/freemarker/FreeMarkerAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -55,30 +55,30 @@ public class FreeMarkerAutoConfigurationTests {
}
@Test
void
nonExistentTemplateLocation
(
CapturedOutput
capturedO
utput
)
{
void
nonExistentTemplateLocation
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withPropertyValues
(
"spring.freemarker.templateLoaderPath:"
+
"classpath:/does-not-exist/,classpath:/also-does-not-exist"
)
.
run
((
context
)
->
assertThat
(
capturedO
utput
).
contains
(
"Cannot find template location"
));
.
run
((
context
)
->
assertThat
(
o
utput
).
contains
(
"Cannot find template location"
));
}
@Test
void
emptyTemplateLocation
(
CapturedOutput
capturedO
utput
)
{
void
emptyTemplateLocation
(
CapturedOutput
o
utput
)
{
File
emptyDirectory
=
new
File
(
this
.
buildOutput
.
getTestResourcesLocation
(),
"empty-templates/empty-directory"
);
emptyDirectory
.
mkdirs
();
this
.
contextRunner
.
withPropertyValues
(
"spring.freemarker.templateLoaderPath:"
+
"classpath:/empty-templates/empty-directory/"
)
.
run
((
context
)
->
assertThat
(
capturedO
utput
).
doesNotContain
(
"Cannot find template location"
));
.
run
((
context
)
->
assertThat
(
o
utput
).
doesNotContain
(
"Cannot find template location"
));
}
@Test
void
nonExistentLocationAndEmptyLocation
(
CapturedOutput
capturedO
utput
)
{
void
nonExistentLocationAndEmptyLocation
(
CapturedOutput
o
utput
)
{
new
File
(
this
.
buildOutput
.
getTestResourcesLocation
(),
"empty-templates/empty-directory"
).
mkdirs
();
this
.
contextRunner
.
withPropertyValues
(
"spring.freemarker.templateLoaderPath:"
+
"classpath:/does-not-exist/,classpath:/empty-templates/empty-directory/"
)
.
run
((
context
)
->
assertThat
(
capturedO
utput
).
doesNotContain
(
"Cannot find template location"
));
.
run
((
context
)
->
assertThat
(
o
utput
).
doesNotContain
(
"Cannot find template location"
));
}
public
static
class
DataModel
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/h2/H2ConsoleAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -125,12 +125,12 @@ class H2ConsoleAutoConfigurationTests {
@Test
@ExtendWith
(
OutputCaptureExtension
.
class
)
void
dataSourceUrlIsLoggedWhenAvailable
(
CapturedOutput
capturedO
utput
)
throws
BeansException
,
SQLException
{
void
dataSourceUrlIsLoggedWhenAvailable
(
CapturedOutput
o
utput
)
throws
BeansException
,
SQLException
{
this
.
context
.
register
(
DataSourceAutoConfiguration
.
class
,
H2ConsoleAutoConfiguration
.
class
);
TestPropertyValues
.
of
(
"spring.h2.console.enabled:true"
).
applyTo
(
this
.
context
);
this
.
context
.
refresh
();
try
(
Connection
connection
=
this
.
context
.
getBean
(
DataSource
.
class
).
getConnection
())
{
assertThat
(
capturedO
utput
).
contains
(
"Database available at '"
+
connection
.
getMetaData
().
getURL
()
+
"'"
);
assertThat
(
o
utput
).
contains
(
"Database available at '"
+
connection
.
getMetaData
().
getURL
()
+
"'"
);
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/logging/ConditionEvaluationReportLoggingListenerTests.java
View file @
c3816bfe
...
...
@@ -59,47 +59,47 @@ class ConditionEvaluationReportLoggingListenerTests {
private
ConditionEvaluationReportLoggingListener
initializer
=
new
ConditionEvaluationReportLoggingListener
();
@Test
void
logsDebugOnContextRefresh
(
CapturedOutput
capturedO
utput
)
{
void
logsDebugOnContextRefresh
(
CapturedOutput
o
utput
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
this
.
initializer
.
initialize
(
context
);
context
.
register
(
Config
.
class
);
context
.
refresh
();
withDebugLogging
(()
->
this
.
initializer
.
onApplicationEvent
(
new
ContextRefreshedEvent
(
context
)));
assertThat
(
capturedO
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
);
assertThat
(
o
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
);
}
@Test
void
logsDebugOnError
(
CapturedOutput
capturedO
utput
)
{
void
logsDebugOnError
(
CapturedOutput
o
utput
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
this
.
initializer
.
initialize
(
context
);
context
.
register
(
ErrorConfig
.
class
);
assertThatExceptionOfType
(
Exception
.
class
).
isThrownBy
(
context:
:
refresh
)
.
satisfies
((
ex
)
->
withDebugLogging
(()
->
this
.
initializer
.
onApplicationEvent
(
new
ApplicationFailedEvent
(
new
SpringApplication
(),
new
String
[
0
],
context
,
ex
))));
assertThat
(
capturedO
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
);
assertThat
(
o
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
);
}
@Test
void
logsInfoOnErrorIfDebugDisabled
(
CapturedOutput
capturedO
utput
)
{
void
logsInfoOnErrorIfDebugDisabled
(
CapturedOutput
o
utput
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
this
.
initializer
.
initialize
(
context
);
context
.
register
(
ErrorConfig
.
class
);
assertThatExceptionOfType
(
Exception
.
class
).
isThrownBy
(
context:
:
refresh
).
satisfies
((
ex
)
->
this
.
initializer
.
onApplicationEvent
(
new
ApplicationFailedEvent
(
new
SpringApplication
(),
new
String
[
0
],
context
,
ex
)));
assertThat
(
capturedO
utput
)
assertThat
(
o
utput
)
.
contains
(
"Error starting"
+
" ApplicationContext. To display the conditions report re-run"
+
" your application with 'debug' enabled."
);
}
@Test
void
logsOutput
(
CapturedOutput
capturedO
utput
)
{
void
logsOutput
(
CapturedOutput
o
utput
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
this
.
initializer
.
initialize
(
context
);
context
.
register
(
Config
.
class
);
ConditionEvaluationReport
.
get
(
context
.
getBeanFactory
()).
recordExclusions
(
Arrays
.
asList
(
"com.foo.Bar"
));
context
.
refresh
();
withDebugLogging
(()
->
this
.
initializer
.
onApplicationEvent
(
new
ContextRefreshedEvent
(
context
)));
assertThat
(
capturedO
utput
).
contains
(
"not a servlet web application (OnWebApplicationCondition)"
);
assertThat
(
o
utput
).
contains
(
"not a servlet web application (OnWebApplicationCondition)"
);
}
@Test
...
...
@@ -122,7 +122,7 @@ class ConditionEvaluationReportLoggingListenerTests {
}
@Test
void
listenerWithInfoLevelShouldLogAtInfo
(
CapturedOutput
capturedO
utput
)
{
void
listenerWithInfoLevelShouldLogAtInfo
(
CapturedOutput
o
utput
)
{
AnnotationConfigApplicationContext
context
=
new
AnnotationConfigApplicationContext
();
ConditionEvaluationReportLoggingListener
initializer
=
new
ConditionEvaluationReportLoggingListener
(
LogLevel
.
INFO
);
...
...
@@ -130,7 +130,7 @@ class ConditionEvaluationReportLoggingListenerTests {
context
.
register
(
Config
.
class
);
context
.
refresh
();
initializer
.
onApplicationEvent
(
new
ContextRefreshedEvent
(
context
));
assertThat
(
capturedO
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
);
assertThat
(
o
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
);
}
@Test
...
...
@@ -141,10 +141,10 @@ class ConditionEvaluationReportLoggingListenerTests {
}
@Test
void
noErrorIfNotInitialized
(
CapturedOutput
capturedO
utput
)
{
void
noErrorIfNotInitialized
(
CapturedOutput
o
utput
)
{
this
.
initializer
.
onApplicationEvent
(
new
ApplicationFailedEvent
(
new
SpringApplication
(),
new
String
[
0
],
null
,
new
RuntimeException
(
"Planned"
)));
assertThat
(
capturedO
utput
).
contains
(
"Unable to provide the conditions report"
);
assertThat
(
o
utput
).
contains
(
"Unable to provide the conditions report"
);
}
private
void
withDebugLogging
(
Runnable
runnable
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/quartz/QuartzAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -154,7 +154,7 @@ class QuartzAutoConfigurationTests {
}
@Test
void
withConfiguredJobAndTrigger
(
CapturedOutput
capturedO
utput
)
{
void
withConfiguredJobAndTrigger
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withUserConfiguration
(
QuartzFullConfiguration
.
class
)
.
withPropertyValues
(
"test-name=withConfiguredJobAndTrigger"
).
run
((
context
)
->
{
assertThat
(
context
).
hasSingleBean
(
Scheduler
.
class
);
...
...
@@ -162,7 +162,7 @@ class QuartzAutoConfigurationTests {
assertThat
(
scheduler
.
getJobDetail
(
JobKey
.
jobKey
(
"fooJob"
))).
isNotNull
();
assertThat
(
scheduler
.
getTrigger
(
TriggerKey
.
triggerKey
(
"fooTrigger"
))).
isNotNull
();
Thread
.
sleep
(
1000L
);
assertThat
(
capturedO
utput
).
contains
(
"withConfiguredJobAndTrigger"
).
contains
(
"jobDataValue"
);
assertThat
(
o
utput
).
contains
(
"withConfiguredJobAndTrigger"
).
contains
(
"jobDataValue"
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/SecurityFilterAutoConfigurationEarlyInitializationTests.java
View file @
c3816bfe
...
...
@@ -55,17 +55,15 @@ import org.springframework.web.bind.annotation.RestController;
class
SecurityFilterAutoConfigurationEarlyInitializationTests
{
@Test
void
testSecurityFilterDoesNotCauseEarlyInitialization
(
CapturedOutput
capturedO
utput
)
{
void
testSecurityFilterDoesNotCauseEarlyInitialization
(
CapturedOutput
o
utput
)
{
try
(
AnnotationConfigServletWebServerApplicationContext
context
=
new
AnnotationConfigServletWebServerApplicationContext
())
{
TestPropertyValues
.
of
(
"server.port:0"
).
applyTo
(
context
);
context
.
register
(
Config
.
class
);
context
.
refresh
();
int
port
=
context
.
getWebServer
().
getPort
();
String
password
=
capturedOutput
.
toString
().
split
(
"Using generated security password: "
)[
1
].
split
(
"\n"
)[
0
]
.
trim
();
String
password
=
output
.
toString
().
split
(
"Using generated security password: "
)[
1
].
split
(
"\n"
)[
0
].
trim
();
new
TestRestTemplate
(
"user"
,
password
).
getForEntity
(
"http://localhost:"
+
port
,
Object
.
class
);
// If early initialization occurred a ConverterNotFoundException is thrown
}
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/security/servlet/UserDetailsServiceAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -60,40 +60,40 @@ class UserDetailsServiceAutoConfigurationTests {
.
withConfiguration
(
AutoConfigurations
.
of
(
UserDetailsServiceAutoConfiguration
.
class
));
@Test
void
testDefaultUsernamePassword
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultUsernamePassword
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
run
((
context
)
->
{
UserDetailsService
manager
=
context
.
getBean
(
UserDetailsService
.
class
);
assertThat
(
capturedOutput
.
toString
()
).
contains
(
"Using generated security password:"
);
assertThat
(
output
).
contains
(
"Using generated security password:"
);
assertThat
(
manager
.
loadUserByUsername
(
"user"
)).
isNotNull
();
});
}
@Test
void
defaultUserNotCreatedIfAuthenticationManagerBeanPresent
(
CapturedOutput
capturedO
utput
)
{
void
defaultUserNotCreatedIfAuthenticationManagerBeanPresent
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withUserConfiguration
(
TestAuthenticationManagerConfiguration
.
class
).
run
((
context
)
->
{
AuthenticationManager
manager
=
context
.
getBean
(
AuthenticationManager
.
class
);
assertThat
(
manager
)
.
isEqualTo
(
context
.
getBean
(
TestAuthenticationManagerConfiguration
.
class
).
authenticationManager
);
assertThat
(
capturedOutput
.
toString
()
).
doesNotContain
(
"Using generated security password: "
);
assertThat
(
output
).
doesNotContain
(
"Using generated security password: "
);
TestingAuthenticationToken
token
=
new
TestingAuthenticationToken
(
"foo"
,
"bar"
);
assertThat
(
manager
.
authenticate
(
token
)).
isNotNull
();
});
}
@Test
void
defaultUserNotCreatedIfUserDetailsServiceBeanPresent
(
CapturedOutput
capturedO
utput
)
{
void
defaultUserNotCreatedIfUserDetailsServiceBeanPresent
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withUserConfiguration
(
TestUserDetailsServiceConfiguration
.
class
).
run
((
context
)
->
{
UserDetailsService
userDetailsService
=
context
.
getBean
(
UserDetailsService
.
class
);
assertThat
(
capturedOutput
.
toString
()
).
doesNotContain
(
"Using generated security password: "
);
assertThat
(
output
).
doesNotContain
(
"Using generated security password: "
);
assertThat
(
userDetailsService
.
loadUserByUsername
(
"foo"
)).
isNotNull
();
});
}
@Test
void
defaultUserNotCreatedIfAuthenticationProviderBeanPresent
(
CapturedOutput
capturedO
utput
)
{
void
defaultUserNotCreatedIfAuthenticationProviderBeanPresent
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withUserConfiguration
(
TestAuthenticationProviderConfiguration
.
class
).
run
((
context
)
->
{
AuthenticationProvider
provider
=
context
.
getBean
(
AuthenticationProvider
.
class
);
assertThat
(
capturedOutput
.
toString
()
).
doesNotContain
(
"Using generated security password: "
);
assertThat
(
output
).
doesNotContain
(
"Using generated security password: "
);
TestingAuthenticationToken
token
=
new
TestingAuthenticationToken
(
"foo"
,
"bar"
);
assertThat
(
provider
.
authenticate
(
token
)).
isNotNull
();
});
...
...
@@ -131,10 +131,9 @@ class UserDetailsServiceAutoConfigurationTests {
}
@Test
void
generatedPasswordShouldNotBePrintedIfAuthenticationManagerBuilderIsUsed
(
CapturedOutput
capturedO
utput
)
{
void
generatedPasswordShouldNotBePrintedIfAuthenticationManagerBuilderIsUsed
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withUserConfiguration
(
TestConfigWithAuthenticationManagerBuilder
.
class
)
.
run
(((
context
)
->
assertThat
(
capturedOutput
.
toString
())
.
doesNotContain
(
"Using generated security password: "
)));
.
run
(((
context
)
->
assertThat
(
output
).
doesNotContain
(
"Using generated security password: "
)));
}
private
void
testPasswordEncoding
(
Class
<?>
configClass
,
String
providedPassword
,
String
expectedPassword
)
{
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/task/TaskExecutionAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -98,13 +98,13 @@ class TaskExecutionAutoConfigurationTests {
}
@Test
void
taskExecutorAutoConfigured
(
CapturedOutput
capturedO
utput
)
{
void
taskExecutorAutoConfigured
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
run
((
context
)
->
{
assertThat
(
capturedO
utput
).
doesNotContain
(
"Initializing ExecutorService"
);
assertThat
(
o
utput
).
doesNotContain
(
"Initializing ExecutorService"
);
assertThat
(
context
).
hasSingleBean
(
Executor
.
class
);
assertThat
(
context
).
hasBean
(
"applicationTaskExecutor"
);
assertThat
(
context
).
getBean
(
"applicationTaskExecutor"
).
isInstanceOf
(
ThreadPoolTaskExecutor
.
class
);
assertThat
(
capturedO
utput
).
contains
(
"Initializing ExecutorService"
);
assertThat
(
o
utput
).
contains
(
"Initializing ExecutorService"
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafReactiveAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -159,16 +159,16 @@ class ThymeleafReactiveAutoConfigurationTests {
}
@Test
void
templateLocationDoesNotExist
(
CapturedOutput
capturedO
utput
)
{
void
templateLocationDoesNotExist
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withPropertyValues
(
"spring.thymeleaf.prefix:classpath:/no-such-directory/"
)
.
run
((
context
)
->
assertThat
(
capturedO
utput
).
contains
(
"Cannot find template location"
));
.
run
((
context
)
->
assertThat
(
o
utput
).
contains
(
"Cannot find template location"
));
}
@Test
void
templateLocationEmpty
(
CapturedOutput
capturedO
utput
)
{
void
templateLocationEmpty
(
CapturedOutput
o
utput
)
{
new
File
(
this
.
buildOutput
.
getTestResourcesLocation
(),
"empty-templates/empty-directory"
).
mkdirs
();
this
.
contextRunner
.
withPropertyValues
(
"spring.thymeleaf.prefix:classpath:/empty-templates/empty-directory/"
)
.
run
((
context
)
->
assertThat
(
capturedO
utput
).
doesNotContain
(
"Cannot find template location"
));
.
run
((
context
)
->
assertThat
(
o
utput
).
doesNotContain
(
"Cannot find template location"
));
}
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafServletAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -165,16 +165,16 @@ class ThymeleafServletAutoConfigurationTests {
}
@Test
void
templateLocationDoesNotExist
(
CapturedOutput
capturedO
utput
)
{
void
templateLocationDoesNotExist
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
withPropertyValues
(
"spring.thymeleaf.prefix:classpath:/no-such-directory/"
)
.
run
((
context
)
->
assertThat
(
capturedO
utput
).
contains
(
"Cannot find template location"
));
.
run
((
context
)
->
assertThat
(
o
utput
).
contains
(
"Cannot find template location"
));
}
@Test
void
templateLocationEmpty
(
CapturedOutput
capturedO
utput
)
{
void
templateLocationEmpty
(
CapturedOutput
o
utput
)
{
new
File
(
this
.
buildOutput
.
getTestResourcesLocation
(),
"empty-templates/empty-directory"
).
mkdirs
();
this
.
contextRunner
.
withPropertyValues
(
"spring.thymeleaf.prefix:classpath:/empty-templates/empty-directory/"
)
.
run
((
context
)
->
assertThat
(
capturedO
utput
).
doesNotContain
(
"Cannot find template location"
));
.
run
((
context
)
->
assertThat
(
o
utput
).
doesNotContain
(
"Cannot find template location"
));
}
@Test
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/reactive/error/DefaultErrorWebExceptionHandlerIntegrationTests.java
View file @
c3816bfe
...
...
@@ -72,7 +72,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests {
.
withUserConfiguration
(
Application
.
class
);
@Test
void
jsonError
(
CapturedOutput
capturedO
utput
)
{
void
jsonError
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
run
((
context
)
->
{
WebTestClient
client
=
getWebClient
(
context
);
client
.
get
().
uri
(
"/"
).
exchange
().
expectStatus
().
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
).
expectBody
()
...
...
@@ -80,7 +80,7 @@ class DefaultErrorWebExceptionHandlerIntegrationTests {
.
isEqualTo
(
HttpStatus
.
INTERNAL_SERVER_ERROR
.
getReasonPhrase
()).
jsonPath
(
"path"
).
isEqualTo
((
"/"
))
.
jsonPath
(
"message"
).
isEqualTo
(
"Expected!"
).
jsonPath
(
"exception"
).
doesNotExist
().
jsonPath
(
"trace"
)
.
doesNotExist
().
jsonPath
(
"requestId"
).
isEqualTo
(
this
.
logIdFilter
.
getLogId
());
assertThat
(
capturedO
utput
).
contains
(
"500 Server Error for HTTP GET \"/\""
)
assertThat
(
o
utput
).
contains
(
"500 Server Error for HTTP GET \"/\""
)
.
contains
(
"java.lang.IllegalStateException: Expected!"
);
});
}
...
...
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/ErrorMvcAutoConfigurationTests.java
View file @
c3816bfe
...
...
@@ -63,7 +63,7 @@ class ErrorMvcAutoConfigurationTests {
}
@Test
void
renderWhenAlreadyCommittedLogsMessage
(
CapturedOutput
capturedO
utput
)
{
void
renderWhenAlreadyCommittedLogsMessage
(
CapturedOutput
o
utput
)
{
this
.
contextRunner
.
run
((
context
)
->
{
View
errorView
=
context
.
getBean
(
"error"
,
View
.
class
);
ErrorAttributes
errorAttributes
=
context
.
getBean
(
ErrorAttributes
.
class
);
...
...
@@ -71,7 +71,7 @@ class ErrorMvcAutoConfigurationTests {
true
);
errorView
.
render
(
errorAttributes
.
getErrorAttributes
(
webRequest
,
true
),
webRequest
.
getRequest
(),
webRequest
.
getResponse
());
assertThat
(
capturedO
utput
).
contains
(
"Cannot render error page for request [/path] "
assertThat
(
o
utput
).
contains
(
"Cannot render error page for request [/path] "
+
"and exception [Exception message] as the response has "
+
"already been committed. As a result, the response may "
+
"have the wrong status code."
);
});
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/ClassLoaderIntegrationTests.java
View file @
c3816bfe
...
...
@@ -36,8 +36,8 @@ class ClassLoaderIntegrationTests {
@RegisterExtension
CliTester
cli
;
ClassLoaderIntegrationTests
(
CapturedOutput
capturedO
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/"
,
capturedO
utput
);
ClassLoaderIntegrationTests
(
CapturedOutput
o
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/"
,
o
utput
);
}
@Test
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/CliTester.java
View file @
c3816bfe
...
...
@@ -63,7 +63,7 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
private
final
BuildOutput
buildOutput
=
new
BuildOutput
(
getClass
());
private
final
CapturedOutput
capturedO
utput
;
private
final
CapturedOutput
o
utput
;
private
String
previousOutput
=
""
;
...
...
@@ -75,7 +75,7 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
private
File
serverPortFile
;
public
CliTester
(
String
prefix
,
CapturedOutput
capturedO
utput
)
{
public
CliTester
(
String
prefix
,
CapturedOutput
o
utput
)
{
this
.
prefix
=
prefix
;
try
{
this
.
temp
=
Files
.
createTempDirectory
(
"cli-tester"
).
toFile
();
...
...
@@ -83,7 +83,7 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
catch
(
IOException
ex
)
{
throw
new
IllegalStateException
(
"Failed to create temp directory"
);
}
this
.
capturedOutput
=
capturedO
utput
;
this
.
output
=
o
utput
;
}
public
void
setTimeout
(
long
timeout
)
{
...
...
@@ -182,7 +182,7 @@ public class CliTester implements BeforeEachCallback, AfterEachCallback {
}
private
String
getOutput
()
{
String
output
=
this
.
capturedO
utput
.
toString
().
substring
(
this
.
previousOutput
.
length
());
String
output
=
this
.
o
utput
.
toString
().
substring
(
this
.
previousOutput
.
length
());
this
.
previousOutput
=
output
;
return
output
;
}
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/DirectorySourcesIntegrationTests.java
View file @
c3816bfe
...
...
@@ -36,8 +36,8 @@ class DirectorySourcesIntegrationTests {
@RegisterExtension
CliTester
cli
;
DirectorySourcesIntegrationTests
(
CapturedOutput
capturedO
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/dir-sample/"
,
capturedO
utput
);
DirectorySourcesIntegrationTests
(
CapturedOutput
o
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/dir-sample/"
,
o
utput
);
}
@Test
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/GrabCommandIntegrationTests.java
View file @
c3816bfe
...
...
@@ -44,8 +44,8 @@ class GrabCommandIntegrationTests {
@RegisterExtension
CliTester
cli
;
GrabCommandIntegrationTests
(
CapturedOutput
capturedO
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/grab-samples/"
,
capturedO
utput
);
GrabCommandIntegrationTests
(
CapturedOutput
o
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/grab-samples/"
,
o
utput
);
}
@BeforeEach
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/ReproIntegrationTests.java
View file @
c3816bfe
...
...
@@ -41,8 +41,8 @@ class ReproIntegrationTests {
@RegisterExtension
CliTester
cli
;
ReproIntegrationTests
(
CapturedOutput
capturedO
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/repro-samples/"
,
capturedO
utput
);
ReproIntegrationTests
(
CapturedOutput
o
utput
)
{
this
.
cli
=
new
CliTester
(
"src/test/resources/repro-samples/"
,
o
utput
);
}
@Test
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/RunCommandIntegrationTests.java
View file @
c3816bfe
...
...
@@ -41,8 +41,8 @@ class RunCommandIntegrationTests {
@RegisterExtension
CliTester
cli
;
RunCommandIntegrationTests
(
CapturedOutput
capturedO
utput
)
{
this
.
cli
=
new
CliTester
(
"src/it/resources/run-command/"
,
capturedO
utput
);
RunCommandIntegrationTests
(
CapturedOutput
o
utput
)
{
this
.
cli
=
new
CliTester
(
"src/it/resources/run-command/"
,
o
utput
);
}
private
Properties
systemProperties
=
new
Properties
();
...
...
spring-boot-project/spring-boot-cli/src/test/java/org/springframework/boot/cli/SampleIntegrationTests.java
View file @
c3816bfe
...
...
@@ -43,8 +43,8 @@ class SampleIntegrationTests {
@RegisterExtension
CliTester
cli
;
SampleIntegrationTests
(
CapturedOutput
capturedO
utput
)
{
this
.
cli
=
new
CliTester
(
"samples/"
,
capturedO
utput
);
SampleIntegrationTests
(
CapturedOutput
o
utput
)
{
this
.
cli
=
new
CliTester
(
"samples/"
,
o
utput
);
}
@Test
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java
View file @
c3816bfe
...
...
@@ -78,21 +78,21 @@ class RemoteClientConfigurationTests {
}
@Test
void
warnIfRestartDisabled
(
CapturedOutput
capturedO
utput
)
{
void
warnIfRestartDisabled
(
CapturedOutput
o
utput
)
{
configure
(
"spring.devtools.remote.restart.enabled:false"
);
assertThat
(
capturedO
utput
).
contains
(
"Remote restart is disabled"
);
assertThat
(
o
utput
).
contains
(
"Remote restart is disabled"
);
}
@Test
void
warnIfNotHttps
(
CapturedOutput
capturedO
utput
)
{
void
warnIfNotHttps
(
CapturedOutput
o
utput
)
{
configure
(
"http://localhost"
,
true
);
assertThat
(
capturedO
utput
).
contains
(
"is insecure"
);
assertThat
(
o
utput
).
contains
(
"is insecure"
);
}
@Test
void
doesntWarnIfUsingHttps
(
CapturedOutput
capturedO
utput
)
{
void
doesntWarnIfUsingHttps
(
CapturedOutput
o
utput
)
{
configure
(
"https://localhost"
,
true
);
assertThat
(
capturedO
utput
).
doesNotContain
(
"is insecure"
);
assertThat
(
o
utput
).
doesNotContain
(
"is insecure"
);
}
@Test
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestartApplicationListenerTests.java
View file @
c3816bfe
...
...
@@ -80,11 +80,11 @@ class RestartApplicationListenerTests {
}
@Test
void
disableWithSystemProperty
(
CapturedOutput
capturedO
utput
)
{
void
disableWithSystemProperty
(
CapturedOutput
o
utput
)
{
System
.
setProperty
(
ENABLED_PROPERTY
,
"false"
);
testInitialize
(
false
);
assertThat
(
Restarter
.
getInstance
()).
hasFieldOrPropertyWithValue
(
"enabled"
,
false
);
assertThat
(
capturedO
utput
).
contains
(
"Restart disabled due to System property"
);
assertThat
(
o
utput
).
contains
(
"Restart disabled due to System property"
);
}
private
void
testInitialize
(
boolean
failed
)
{
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/RestarterTests.java
View file @
c3816bfe
...
...
@@ -76,14 +76,13 @@ class RestarterTests {
}
@Test
void
testRestart
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testRestart
(
CapturedOutput
o
utput
)
throws
Exception
{
Restarter
.
clearInstance
();
Thread
thread
=
new
Thread
(
SampleApplication:
:
main
);
thread
.
start
();
Thread
.
sleep
(
2600
);
String
output
=
capturedOutput
.
toString
();
assertThat
(
StringUtils
.
countOccurrencesOf
(
output
,
"Tick 0"
)).
isGreaterThan
(
1
);
assertThat
(
StringUtils
.
countOccurrencesOf
(
output
,
"Tick 1"
)).
isGreaterThan
(
1
);
assertThat
(
StringUtils
.
countOccurrencesOf
(
output
.
toString
(),
"Tick 0"
)).
isGreaterThan
(
1
);
assertThat
(
StringUtils
.
countOccurrencesOf
(
output
.
toString
(),
"Tick 1"
)).
isGreaterThan
(
1
);
assertThat
(
CloseCountingApplicationListener
.
closed
).
isGreaterThan
(
0
);
}
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/client/HttpTunnelConnectionTests.java
View file @
c3816bfe
...
...
@@ -139,11 +139,11 @@ class HttpTunnelConnectionTests {
}
@Test
void
connectFailureLogsWarning
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
connectFailureLogsWarning
(
CapturedOutput
o
utput
)
throws
Exception
{
this
.
requestFactory
.
willRespond
(
new
ConnectException
());
TunnelChannel
tunnel
=
openTunnel
(
true
);
assertThat
(
tunnel
.
isOpen
()).
isFalse
();
assertThat
(
capturedO
utput
).
contains
(
"Failed to connect to remote application at http://localhost:12345"
);
assertThat
(
o
utput
).
contains
(
"Failed to connect to remote application at http://localhost:12345"
);
}
private
void
write
(
TunnelChannel
channel
,
String
string
)
throws
IOException
{
...
...
spring-boot-project/spring-boot-docs/src/test/java/org/springframework/boot/docs/builder/SpringApplicationBuilderExampleTests.java
View file @
c3816bfe
...
...
@@ -33,11 +33,11 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SpringApplicationBuilderExampleTests
{
@Test
void
contextHierarchyWithDisabledBanner
(
CapturedOutput
capturedO
utput
)
{
void
contextHierarchyWithDisabledBanner
(
CapturedOutput
o
utput
)
{
System
.
setProperty
(
"spring.main.web-application-type"
,
"none"
);
try
{
new
SpringApplicationBuilderExample
().
hierarchyWithDisabledBanner
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
doesNotContain
(
":: Spring Boot ::"
);
assertThat
(
o
utput
).
doesNotContain
(
":: Spring Boot ::"
);
}
finally
{
System
.
clearProperty
(
"spring.main.web-application-type"
);
...
...
spring-boot-project/spring-boot-properties-migrator/src/test/java/org/springframework/boot/context/properties/migrator/PropertiesMigrationListenerTests.java
View file @
c3816bfe
...
...
@@ -46,9 +46,9 @@ class PropertiesMigrationListenerTests {
}
@Test
void
sampleReport
(
CapturedOutput
capturedO
utput
)
{
void
sampleReport
(
CapturedOutput
o
utput
)
{
this
.
context
=
createSampleApplication
().
run
(
"--banner.charset=UTF8"
);
assertThat
(
capturedO
utput
).
contains
(
"commandLineArgs"
).
contains
(
"spring.banner.charset"
)
assertThat
(
o
utput
).
contains
(
"commandLineArgs"
).
contains
(
"spring.banner.charset"
)
.
contains
(
"Each configuration key has been temporarily mapped"
)
.
doesNotContain
(
"Please refer to the migration guide"
);
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/SpringBootDependencyInjectionTestExecutionListenerTests.java
View file @
c3816bfe
...
...
@@ -53,7 +53,7 @@ class SpringBootDependencyInjectionTestExecutionListenerTests {
}
@Test
void
prepareFailingTestInstanceShouldPrintReport
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
prepareFailingTestInstanceShouldPrintReport
(
CapturedOutput
o
utput
)
throws
Exception
{
TestContext
testContext
=
mock
(
TestContext
.
class
);
given
(
testContext
.
getTestInstance
()).
willThrow
(
new
IllegalStateException
());
SpringApplication
application
=
new
SpringApplication
(
Config
.
class
);
...
...
@@ -66,7 +66,7 @@ class SpringBootDependencyInjectionTestExecutionListenerTests {
catch
(
IllegalStateException
ex
)
{
// Expected
}
assertThat
(
capturedO
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
).
contains
(
"Positive matches"
)
assertThat
(
o
utput
).
contains
(
"CONDITIONS EVALUATION REPORT"
).
contains
(
"Positive matches"
)
.
contains
(
"Negative matches"
);
}
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/MockMvcSpringBootTestIntegrationTests.java
View file @
c3816bfe
...
...
@@ -57,9 +57,9 @@ class MockMvcSpringBootTestIntegrationTests {
private
MockMvc
mvc
;
@Test
void
shouldFindController1
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
shouldFindController1
(
CapturedOutput
o
utput
)
throws
Exception
{
this
.
mvc
.
perform
(
get
(
"/one"
)).
andExpect
(
content
().
string
(
"one"
)).
andExpect
(
status
().
isOk
());
assertThat
(
capturedO
utput
).
contains
(
"Request URI = /one"
);
assertThat
(
o
utput
).
contains
(
"Request URI = /one"
);
}
@Test
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintAlwaysIntegrationTests.java
View file @
c3816bfe
...
...
@@ -47,9 +47,9 @@ class WebMvcTestPrintAlwaysIntegrationTests {
private
MockMvc
mvc
;
@Test
void
shouldPrint
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
shouldPrint
(
CapturedOutput
o
utput
)
throws
Exception
{
this
.
mvc
.
perform
(
get
(
"/one"
)).
andExpect
(
content
().
string
(
"one"
)).
andExpect
(
status
().
isOk
());
assertThat
(
capturedO
utput
).
contains
(
"Request URI = /one"
);
assertThat
(
o
utput
).
contains
(
"Request URI = /one"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultIntegrationTests.java
View file @
c3816bfe
...
...
@@ -47,15 +47,15 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
class
WebMvcTestPrintDefaultIntegrationTests
{
@Test
void
shouldNotPrint
(
CapturedOutput
capturedO
utput
)
{
void
shouldNotPrint
(
CapturedOutput
o
utput
)
{
executeTests
(
ShouldNotPrint
.
class
);
assertThat
(
capturedO
utput
).
doesNotContain
(
"HTTP Method"
);
assertThat
(
o
utput
).
doesNotContain
(
"HTTP Method"
);
}
@Test
void
shouldPrint
(
CapturedOutput
capturedO
utput
)
{
void
shouldPrint
(
CapturedOutput
o
utput
)
{
executeTests
(
ShouldPrint
.
class
);
assertThat
(
capturedO
utput
).
contains
(
"HTTP Method"
);
assertThat
(
o
utput
).
contains
(
"HTTP Method"
);
}
private
void
executeTests
(
Class
<?>
testClass
)
{
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintDefaultOverrideIntegrationTests.java
View file @
c3816bfe
...
...
@@ -47,9 +47,9 @@ class WebMvcTestPrintDefaultOverrideIntegrationTests {
private
MockMvc
mvc
;
@Test
void
shouldFindController1
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
shouldFindController1
(
CapturedOutput
o
utput
)
throws
Exception
{
this
.
mvc
.
perform
(
get
(
"/one"
)).
andExpect
(
content
().
string
(
"one"
)).
andExpect
(
status
().
isOk
());
assertThat
(
capturedO
utput
).
doesNotContain
(
"Request URI = /one"
);
assertThat
(
o
utput
).
doesNotContain
(
"Request URI = /one"
);
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPrintOverrideIntegrationTests.java
View file @
c3816bfe
...
...
@@ -48,9 +48,9 @@ class WebMvcTestPrintOverrideIntegrationTests {
private
MockMvc
mvc
;
@Test
void
shouldNotPrint
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
shouldNotPrint
(
CapturedOutput
o
utput
)
throws
Exception
{
this
.
mvc
.
perform
(
get
(
"/one"
)).
andExpect
(
content
().
string
(
"one"
)).
andExpect
(
status
().
isOk
());
assertThat
(
capturedO
utput
).
doesNotContain
(
"Request URI = /one"
);
assertThat
(
o
utput
).
doesNotContain
(
"Request URI = /one"
);
}
}
spring-boot-project/spring-boot-tools/spring-boot-loader/src/test/java/org/springframework/boot/loader/PropertiesLauncherTests.java
View file @
c3816bfe
...
...
@@ -59,13 +59,13 @@ class PropertiesLauncherTests {
private
ClassLoader
contextClassLoader
;
private
CapturedOutput
capturedO
utput
;
private
CapturedOutput
o
utput
;
@BeforeEach
void
setup
(
CapturedOutput
capturedOutput
)
{
this
.
contextClassLoader
=
Thread
.
currentThread
().
getContextClassLoader
();
System
.
setProperty
(
"loader.home"
,
new
File
(
"src/test/resources"
).
getAbsolutePath
());
this
.
capturedO
utput
=
capturedOutput
;
this
.
o
utput
=
capturedOutput
;
}
@AfterEach
...
...
@@ -312,8 +312,8 @@ class PropertiesLauncherTests {
manifest
.
getMainAttributes
().
putValue
(
"Loader-Path"
,
"/foo.jar, /bar"
);
File
manifestFile
=
new
File
(
this
.
tempDir
,
"META-INF/MANIFEST.MF"
);
manifestFile
.
getParentFile
().
mkdirs
();
try
(
FileOutputStream
output
=
new
FileOutputStream
(
manifestFile
))
{
manifest
.
write
(
output
);
try
(
FileOutputStream
manifestStream
=
new
FileOutputStream
(
manifestFile
))
{
manifest
.
write
(
manifestStream
);
}
PropertiesLauncher
launcher
=
new
PropertiesLauncher
();
assertThat
((
List
<
String
>)
ReflectionTestUtils
.
getField
(
launcher
,
"paths"
)).
containsExactly
(
"/foo.jar"
,
"/bar/"
);
...
...
@@ -344,7 +344,7 @@ class PropertiesLauncherTests {
while
(!
timeout
&&
count
<
100
)
{
count
++;
Thread
.
sleep
(
50L
);
timeout
=
this
.
capturedO
utput
.
toString
().
contains
(
value
);
timeout
=
this
.
o
utput
.
toString
().
contains
(
value
);
}
assertThat
(
timeout
).
as
(
"Timed out waiting for ("
+
value
+
")"
).
isTrue
();
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/BannerTests.java
View file @
c3816bfe
...
...
@@ -68,25 +68,25 @@ class BannerTests {
}
@Test
void
testDefaultBanner
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultBanner
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
createSpringApplication
();
this
.
context
=
application
.
run
();
assertThat
(
capturedO
utput
).
contains
(
":: Spring Boot ::"
);
assertThat
(
o
utput
).
contains
(
":: Spring Boot ::"
);
}
@Test
void
testDefaultBannerInLog
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultBannerInLog
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
createSpringApplication
();
this
.
context
=
application
.
run
();
assertThat
(
capturedO
utput
).
contains
(
":: Spring Boot ::"
);
assertThat
(
o
utput
).
contains
(
":: Spring Boot ::"
);
}
@Test
void
testCustomBanner
(
CapturedOutput
capturedO
utput
)
{
void
testCustomBanner
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
createSpringApplication
();
application
.
setBanner
(
new
DummyBanner
());
this
.
context
=
application
.
run
();
assertThat
(
capturedO
utput
).
contains
(
"My Banner"
);
assertThat
(
o
utput
).
contains
(
"My Banner"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SimpleMainTests.java
View file @
c3816bfe
...
...
@@ -49,27 +49,27 @@ class SimpleMainTests {
}
@Test
void
basePackageScan
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
basePackageScan
(
CapturedOutput
o
utput
)
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
ClassUtils
.
getPackageName
(
getClass
())
+
".sampleconfig"
));
assertThat
(
capturedO
utput
).
contains
(
SPRING_STARTUP
);
assertThat
(
o
utput
).
contains
(
SPRING_STARTUP
);
}
@Test
void
configClassContext
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
configClassContext
(
CapturedOutput
o
utput
)
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
getClass
().
getName
()));
assertThat
(
capturedO
utput
).
contains
(
SPRING_STARTUP
);
assertThat
(
o
utput
).
contains
(
SPRING_STARTUP
);
}
@Test
void
xmlContext
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
xmlContext
(
CapturedOutput
o
utput
)
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
"org/springframework/boot/sample-beans.xml"
));
assertThat
(
capturedO
utput
).
contains
(
SPRING_STARTUP
);
assertThat
(
o
utput
).
contains
(
SPRING_STARTUP
);
}
@Test
void
mixedContext
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
mixedContext
(
CapturedOutput
o
utput
)
throws
Exception
{
SpringApplication
.
main
(
getArgs
(
getClass
().
getName
(),
"org/springframework/boot/sample-beans.xml"
));
assertThat
(
capturedO
utput
).
contains
(
SPRING_STARTUP
);
assertThat
(
o
utput
).
contains
(
SPRING_STARTUP
);
}
private
String
[]
getArgs
(
String
...
args
)
{
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
View file @
c3816bfe
...
...
@@ -188,24 +188,24 @@ class SpringApplicationTests {
}
@Test
void
customBanner
(
CapturedOutput
capturedO
utput
)
{
void
customBanner
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
spy
(
new
SpringApplication
(
ExampleConfig
.
class
));
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
this
.
context
=
application
.
run
(
"--spring.banner.location=classpath:test-banner.txt"
);
assertThat
(
capturedO
utput
).
startsWith
(
"Running a Test!"
);
assertThat
(
o
utput
).
startsWith
(
"Running a Test!"
);
}
@Test
void
customBannerWithProperties
(
CapturedOutput
capturedO
utput
)
{
void
customBannerWithProperties
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
spy
(
new
SpringApplication
(
ExampleConfig
.
class
));
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
this
.
context
=
application
.
run
(
"--spring.banner.location=classpath:test-banner-with-placeholder.txt"
,
"--test.property=123456"
);
assertThat
(
capturedO
utput
).
containsPattern
(
"Running a Test!\\s+123456"
);
assertThat
(
o
utput
).
containsPattern
(
"Running a Test!\\s+123456"
);
}
@Test
void
imageBannerAndTextBanner
(
CapturedOutput
capturedO
utput
)
{
void
imageBannerAndTextBanner
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
MockResourceLoader
resourceLoader
=
new
MockResourceLoader
();
resourceLoader
.
addResource
(
"banner.gif"
,
"black-and-white.gif"
);
...
...
@@ -213,47 +213,47 @@ class SpringApplicationTests {
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
application
.
setResourceLoader
(
resourceLoader
);
application
.
run
();
assertThat
(
capturedO
utput
).
contains
(
"@@@@"
).
contains
(
"Foo Bar"
);
assertThat
(
o
utput
).
contains
(
"@@@@"
).
contains
(
"Foo Bar"
);
}
@Test
void
imageBannerLoads
(
CapturedOutput
capturedO
utput
)
{
void
imageBannerLoads
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
MockResourceLoader
resourceLoader
=
new
MockResourceLoader
();
resourceLoader
.
addResource
(
"banner.gif"
,
"black-and-white.gif"
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
application
.
setResourceLoader
(
resourceLoader
);
application
.
run
();
assertThat
(
capturedO
utput
).
contains
(
"@@@@@@"
);
assertThat
(
o
utput
).
contains
(
"@@@@@@"
);
}
@Test
void
logsNoActiveProfiles
(
CapturedOutput
capturedO
utput
)
{
void
logsNoActiveProfiles
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
this
.
context
=
application
.
run
();
assertThat
(
capturedO
utput
).
contains
(
"No active profile set, falling back to default profiles: default"
);
assertThat
(
o
utput
).
contains
(
"No active profile set, falling back to default profiles: default"
);
}
@Test
void
logsActiveProfiles
(
CapturedOutput
capturedO
utput
)
{
void
logsActiveProfiles
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
this
.
context
=
application
.
run
(
"--spring.profiles.active=myprofiles"
);
assertThat
(
capturedO
utput
).
contains
(
"The following profiles are active: myprofile"
);
assertThat
(
o
utput
).
contains
(
"The following profiles are active: myprofile"
);
}
@Test
void
enableBannerInLogViaProperty
(
CapturedOutput
capturedO
utput
)
{
void
enableBannerInLogViaProperty
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
spy
(
new
SpringApplication
(
ExampleConfig
.
class
));
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
this
.
context
=
application
.
run
(
"--spring.main.banner-mode=log"
);
verify
(
application
,
atLeastOnce
()).
setBannerMode
(
Banner
.
Mode
.
LOG
);
assertThat
(
capturedO
utput
).
contains
(
"o.s.b.SpringApplication"
);
assertThat
(
o
utput
).
contains
(
"o.s.b.SpringApplication"
);
}
@Test
void
setIgnoreBeanInfoPropertyByDefault
(
CapturedOutput
capturedO
utput
)
{
void
setIgnoreBeanInfoPropertyByDefault
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
this
.
context
=
application
.
run
();
...
...
@@ -627,7 +627,7 @@ class SpringApplicationTests {
@Test
@SuppressWarnings
(
"unchecked"
)
void
runnersAreCalledAfterStartedIsLoggedAndBeforeApplicationReadyEventIsPublished
(
CapturedOutput
capturedO
utput
)
void
runnersAreCalledAfterStartedIsLoggedAndBeforeApplicationReadyEventIsPublished
(
CapturedOutput
o
utput
)
throws
Exception
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
ApplicationRunner
applicationRunner
=
mock
(
ApplicationRunner
.
class
);
...
...
@@ -635,11 +635,11 @@ class SpringApplicationTests {
application
.
addInitializers
((
context
)
->
{
ConfigurableListableBeanFactory
beanFactory
=
context
.
getBeanFactory
();
beanFactory
.
registerSingleton
(
"commandLineRunner"
,
(
CommandLineRunner
)
(
args
)
->
{
assertThat
(
capturedO
utput
).
contains
(
"Started"
);
assertThat
(
o
utput
).
contains
(
"Started"
);
commandLineRunner
.
run
(
args
);
});
beanFactory
.
registerSingleton
(
"applicationRunner"
,
(
ApplicationRunner
)
(
args
)
->
{
assertThat
(
capturedO
utput
).
contains
(
"Started"
);
assertThat
(
o
utput
).
contains
(
"Started"
);
applicationRunner
.
run
(
args
);
});
});
...
...
@@ -706,7 +706,7 @@ class SpringApplicationTests {
}
@Test
void
failureInReadyEventListenerCloseApplicationContext
(
CapturedOutput
capturedO
utput
)
{
void
failureInReadyEventListenerCloseApplicationContext
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
ExitCodeListener
exitCodeListener
=
new
ExitCodeListener
();
...
...
@@ -720,7 +720,7 @@ class SpringApplicationTests {
verify
(
listener
).
onApplicationEvent
(
isA
(
ApplicationReadyEvent
.
class
));
verify
(
listener
,
never
()).
onApplicationEvent
(
isA
(
ApplicationFailedEvent
.
class
));
assertThat
(
exitCodeListener
.
getExitCode
()).
isEqualTo
(
11
);
assertThat
(
capturedO
utput
).
contains
(
"Application run failed"
);
assertThat
(
o
utput
).
contains
(
"Application run failed"
);
}
@Test
...
...
@@ -815,7 +815,7 @@ class SpringApplicationTests {
}
@Test
void
exceptionFromRefreshIsHandledGracefully
(
CapturedOutput
capturedO
utput
)
{
void
exceptionFromRefreshIsHandledGracefully
(
CapturedOutput
o
utput
)
{
final
SpringBootExceptionHandler
handler
=
mock
(
SpringBootExceptionHandler
.
class
);
SpringApplication
application
=
new
SpringApplication
(
RefreshFailureConfig
.
class
)
{
...
...
@@ -832,7 +832,7 @@ class SpringApplicationTests {
ArgumentCaptor
<
RuntimeException
>
exceptionCaptor
=
ArgumentCaptor
.
forClass
(
RuntimeException
.
class
);
verify
(
handler
).
registerLoggedException
(
exceptionCaptor
.
capture
());
assertThat
(
exceptionCaptor
.
getValue
()).
hasCauseInstanceOf
(
RefreshFailureException
.
class
);
assertThat
(
capturedO
utput
).
doesNotContain
(
"NullPointerException"
);
assertThat
(
o
utput
).
doesNotContain
(
"NullPointerException"
);
}
@Test
...
...
@@ -1046,19 +1046,21 @@ class SpringApplicationTests {
}
@Test
void
failureResultsInSingleStackTrace
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
failureResultsInSingleStackTrace
(
CapturedOutput
o
utput
)
throws
Exception
{
ThreadGroup
group
=
new
ThreadGroup
(
"main"
);
Thread
thread
=
new
Thread
(
group
,
"main"
)
{
@Override
public
void
run
()
{
SpringApplication
application
=
new
SpringApplication
(
FailingConfig
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
application
.
run
();
}
};
thread
.
start
();
thread
.
join
(
6000
);
assertThat
(
capturedO
utput
).
containsOnlyOnce
(
"Caused by: java.lang.RuntimeException: ExpectedError"
);
assertThat
(
o
utput
).
containsOnlyOnce
(
"Caused by: java.lang.RuntimeException: ExpectedError"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/ConfigurationWarningsApplicationContextInitializerTests.java
View file @
c3816bfe
...
...
@@ -54,57 +54,57 @@ class ConfigurationWarningsApplicationContextInitializerTests {
+
"start due to a @ComponentScan of 'org.springframework'."
;
@Test
void
logWarningInDefaultPackage
(
CapturedOutput
capturedO
utput
)
{
void
logWarningInDefaultPackage
(
CapturedOutput
o
utput
)
{
load
(
InDefaultPackageConfiguration
.
class
);
assertThat
(
capturedO
utput
).
contains
(
DEFAULT_SCAN_WARNING
);
assertThat
(
o
utput
).
contains
(
DEFAULT_SCAN_WARNING
);
}
@Test
void
logWarningInDefaultPackageAndMetaAnnotation
(
CapturedOutput
capturedO
utput
)
{
void
logWarningInDefaultPackageAndMetaAnnotation
(
CapturedOutput
o
utput
)
{
load
(
InDefaultPackageWithMetaAnnotationConfiguration
.
class
);
assertThat
(
capturedO
utput
).
contains
(
DEFAULT_SCAN_WARNING
);
assertThat
(
o
utput
).
contains
(
DEFAULT_SCAN_WARNING
);
}
@Test
void
noLogIfInRealPackage
(
CapturedOutput
capturedO
utput
)
{
void
noLogIfInRealPackage
(
CapturedOutput
o
utput
)
{
load
(
InRealPackageConfiguration
.
class
);
assertThat
(
capturedO
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
assertThat
(
o
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
}
@Test
void
noLogWithoutComponentScanAnnotation
(
CapturedOutput
capturedO
utput
)
{
void
noLogWithoutComponentScanAnnotation
(
CapturedOutput
o
utput
)
{
load
(
InDefaultPackageWithoutScanConfiguration
.
class
);
assertThat
(
capturedO
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
assertThat
(
o
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
}
@Test
void
noLogIfHasValue
(
CapturedOutput
capturedO
utput
)
{
void
noLogIfHasValue
(
CapturedOutput
o
utput
)
{
load
(
InDefaultPackageWithValueConfiguration
.
class
);
assertThat
(
capturedO
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
assertThat
(
o
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
}
@Test
void
noLogIfHasBasePackages
(
CapturedOutput
capturedO
utput
)
{
void
noLogIfHasBasePackages
(
CapturedOutput
o
utput
)
{
load
(
InDefaultPackageWithBasePackagesConfiguration
.
class
);
assertThat
(
capturedO
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
assertThat
(
o
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
}
@Test
void
noLogIfHasBasePackageClasses
(
CapturedOutput
capturedO
utput
)
{
void
noLogIfHasBasePackageClasses
(
CapturedOutput
o
utput
)
{
load
(
InDefaultPackageWithBasePackageClassesConfiguration
.
class
);
assertThat
(
capturedO
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
assertThat
(
o
utput
).
doesNotContain
(
DEFAULT_SCAN_WARNING
);
}
@Test
void
logWarningInOrgSpringPackage
(
CapturedOutput
capturedO
utput
)
{
void
logWarningInOrgSpringPackage
(
CapturedOutput
o
utput
)
{
load
(
InOrgSpringPackageConfiguration
.
class
);
assertThat
(
capturedO
utput
).
contains
(
ORGSPRING_SCAN_WARNING
);
assertThat
(
o
utput
).
contains
(
ORGSPRING_SCAN_WARNING
);
}
@Test
void
logWarningIfScanningProblemPackages
(
CapturedOutput
capturedO
utput
)
{
void
logWarningIfScanningProblemPackages
(
CapturedOutput
o
utput
)
{
load
(
InRealButScanningProblemPackages
.
class
);
assertThat
(
capturedO
utput
).
contains
(
"Your ApplicationContext is unlikely to start due to a "
assertThat
(
o
utput
).
contains
(
"Your ApplicationContext is unlikely to start due to a "
+
"@ComponentScan of the default package, 'org.springframework'."
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/config/ConfigFileApplicationListenerTests.java
View file @
c3816bfe
...
...
@@ -418,54 +418,54 @@ class ConfigFileApplicationListenerTests {
}
@Test
void
profilesAddedToEnvironmentAndViaProperty
(
CapturedOutput
capturedO
utput
)
{
void
profilesAddedToEnvironmentAndViaProperty
(
CapturedOutput
o
utput
)
{
// External profile takes precedence over profile added via the environment
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.profiles.active=other"
);
this
.
environment
.
addActiveProfile
(
"dev"
);
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
);
assertThat
(
this
.
environment
.
getActiveProfiles
()).
contains
(
"dev"
,
"other"
);
assertThat
(
this
.
environment
.
getProperty
(
"my.property"
)).
isEqualTo
(
"fromotherpropertiesfile"
);
validateProfilePreference
(
capturedO
utput
,
null
,
"dev"
,
"other"
);
validateProfilePreference
(
o
utput
,
null
,
"dev"
,
"other"
);
}
@Test
void
profilesAddedToEnvironmentViaActiveAndIncludeProperty
(
CapturedOutput
capturedO
utput
)
{
void
profilesAddedToEnvironmentViaActiveAndIncludeProperty
(
CapturedOutput
o
utput
)
{
// Active profile property takes precedence
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.profiles.active=dev"
,
"spring.profiles.include=other"
);
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
);
assertThat
(
this
.
environment
.
getActiveProfiles
()).
containsExactly
(
"other"
,
"dev"
);
assertThat
(
this
.
environment
.
getProperty
(
"my.property"
)).
isEqualTo
(
"fromdevpropertiesfile"
);
validateProfilePreference
(
capturedO
utput
,
null
,
"other"
,
"dev"
);
validateProfilePreference
(
o
utput
,
null
,
"other"
,
"dev"
);
}
@Test
void
profilesAddedViaIncludePropertyAndActivatedViaAnotherPropertySource
(
CapturedOutput
capturedO
utput
)
{
void
profilesAddedViaIncludePropertyAndActivatedViaAnotherPropertySource
(
CapturedOutput
o
utput
)
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.profiles.include=dev,simple"
);
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
);
assertThat
(
this
.
environment
.
getActiveProfiles
()).
containsExactly
(
"dev"
,
"simple"
,
"other"
);
validateProfilePreference
(
capturedO
utput
,
"dev"
,
"simple"
,
"other"
);
validateProfilePreference
(
o
utput
,
"dev"
,
"simple"
,
"other"
);
}
@Test
void
profilesAddedToEnvironmentAndViaPropertyDuplicate
(
CapturedOutput
capturedO
utput
)
{
void
profilesAddedToEnvironmentAndViaPropertyDuplicate
(
CapturedOutput
o
utput
)
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.profiles.active=dev,other"
);
this
.
environment
.
addActiveProfile
(
"dev"
);
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
);
assertThat
(
this
.
environment
.
getActiveProfiles
()).
contains
(
"dev"
,
"other"
);
assertThat
(
this
.
environment
.
getProperty
(
"my.property"
)).
isEqualTo
(
"fromotherpropertiesfile"
);
validateProfilePreference
(
capturedO
utput
,
null
,
"dev"
,
"other"
);
validateProfilePreference
(
o
utput
,
null
,
"dev"
,
"other"
);
}
@Test
void
profilesAddedToEnvironmentAndViaPropertyDuplicateEnvironmentWins
(
CapturedOutput
capturedO
utput
)
{
void
profilesAddedToEnvironmentAndViaPropertyDuplicateEnvironmentWins
(
CapturedOutput
o
utput
)
{
TestPropertySourceUtils
.
addInlinedPropertiesToEnvironment
(
this
.
environment
,
"spring.profiles.active=other,dev"
);
this
.
environment
.
addActiveProfile
(
"other"
);
this
.
initializer
.
postProcessEnvironment
(
this
.
environment
,
this
.
application
);
assertThat
(
this
.
environment
.
getActiveProfiles
()).
contains
(
"dev"
,
"other"
);
assertThat
(
this
.
environment
.
getProperty
(
"my.property"
)).
isEqualTo
(
"fromdevpropertiesfile"
);
validateProfilePreference
(
capturedO
utput
,
null
,
"other"
,
"dev"
);
validateProfilePreference
(
o
utput
,
null
,
"other"
,
"dev"
);
}
@Test
...
...
@@ -475,12 +475,11 @@ class ConfigFileApplicationListenerTests {
new
ApplicationEnvironmentPreparedEvent
(
this
.
application
,
new
String
[
0
],
this
.
environment
));
}
private
void
validateProfilePreference
(
CapturedOutput
capturedO
utput
,
String
...
profiles
)
{
private
void
validateProfilePreference
(
CapturedOutput
o
utput
,
String
...
profiles
)
{
ApplicationPreparedEvent
event
=
new
ApplicationPreparedEvent
(
new
SpringApplication
(),
new
String
[
0
],
new
AnnotationConfigApplicationContext
());
withDebugLogging
(()
->
this
.
initializer
.
onApplicationEvent
(
event
));
String
log
=
capturedOutput
.
toString
();
String
log
=
output
.
toString
();
// First make sure that each profile got processed only once
for
(
String
profile
:
profiles
)
{
String
reason
=
"Wrong number of occurrences for profile '"
+
profile
+
"' --> "
+
log
;
...
...
@@ -787,7 +786,7 @@ class ConfigFileApplicationListenerTests {
}
@Test
void
activateProfileFromProfileSpecificProperties
(
CapturedOutput
capturedO
utput
)
{
void
activateProfileFromProfileSpecificProperties
(
CapturedOutput
o
utput
)
{
SpringApplication
application
=
new
SpringApplication
(
Config
.
class
);
application
.
setWebApplicationType
(
WebApplicationType
.
NONE
);
this
.
context
=
application
.
run
(
"--spring.profiles.active=includeprofile"
);
...
...
@@ -797,7 +796,7 @@ class ConfigFileApplicationListenerTests {
assertThat
(
environment
).
has
(
matchingProfile
(
"morespecific"
));
assertThat
(
environment
).
has
(
matchingProfile
(
"yetmorespecific"
));
assertThat
(
environment
).
doesNotHave
(
matchingProfile
(
"missing"
));
assertThat
(
capturedO
utput
)
assertThat
(
o
utput
)
.
contains
(
"The following profiles are active: includeprofile,specific,morespecific,yetmorespecific"
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerIntegrationTests.java
View file @
c3816bfe
...
...
@@ -67,7 +67,7 @@ class LoggingApplicationListenerIntegrationTests {
}
@Test
void
loggingPerformedDuringChildApplicationStartIsNotLost
(
CapturedOutput
capturedO
utput
)
{
void
loggingPerformedDuringChildApplicationStartIsNotLost
(
CapturedOutput
o
utput
)
{
new
SpringApplicationBuilder
(
Config
.
class
).
web
(
WebApplicationType
.
NONE
).
child
(
Config
.
class
)
.
web
(
WebApplicationType
.
NONE
).
listeners
(
new
ApplicationListener
<
ApplicationStartingEvent
>()
{
...
...
@@ -79,7 +79,7 @@ class LoggingApplicationListenerIntegrationTests {
}
}).
run
();
assertThat
(
capturedO
utput
).
contains
(
"Child application starting"
);
assertThat
(
o
utput
).
contains
(
"Child application starting"
);
}
@Component
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/logging/LoggingApplicationListenerTests.java
View file @
c3816bfe
This diff is collapsed.
Click to expand it.
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/context/properties/ConfigurationPropertiesTests.java
View file @
c3816bfe
...
...
@@ -504,9 +504,9 @@ class ConfigurationPropertiesTests {
}
@Test
void
loadWhenHasMultiplePropertySourcesPlaceholderConfigurerShouldLogWarning
(
CapturedOutput
capturedO
utput
)
{
void
loadWhenHasMultiplePropertySourcesPlaceholderConfigurerShouldLogWarning
(
CapturedOutput
o
utput
)
{
load
(
MultiplePropertySourcesPlaceholderConfigurerConfiguration
.
class
);
assertThat
(
capturedO
utput
).
contains
(
"Multiple PropertySourcesPlaceholderConfigurer beans registered"
);
assertThat
(
o
utput
).
contains
(
"Multiple PropertySourcesPlaceholderConfigurer beans registered"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/diagnostics/FailureAnalyzersIntegrationTests.java
View file @
c3816bfe
...
...
@@ -40,10 +40,10 @@ import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
class
FailureAnalyzersIntegrationTests
{
@Test
void
analysisIsPerformed
(
CapturedOutput
capturedO
utput
)
{
void
analysisIsPerformed
(
CapturedOutput
o
utput
)
{
assertThatExceptionOfType
(
Exception
.
class
).
isThrownBy
(
()
->
new
SpringApplicationBuilder
(
TestConfiguration
.
class
).
web
(
WebApplicationType
.
NONE
).
run
());
assertThat
(
capturedO
utput
).
contains
(
"APPLICATION FAILED TO START"
);
assertThat
(
o
utput
).
contains
(
"APPLICATION FAILED TO START"
);
}
@Configuration
(
proxyBeanMethods
=
false
)
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/logging/logback/SpringBootJoranConfiguratorTests.java
View file @
c3816bfe
...
...
@@ -57,11 +57,11 @@ class SpringBootJoranConfiguratorTests {
private
Logger
logger
;
private
CapturedOutput
capturedO
utput
;
private
CapturedOutput
o
utput
;
@BeforeEach
void
setup
(
CapturedOutput
capturedO
utput
)
{
this
.
capturedOutput
=
capturedO
utput
;
void
setup
(
CapturedOutput
o
utput
)
{
this
.
output
=
o
utput
;
this
.
environment
=
new
MockEnvironment
();
this
.
initializationContext
=
new
LoggingInitializationContext
(
this
.
environment
);
this
.
configurator
=
new
SpringBootJoranConfigurator
(
this
.
initializationContext
);
...
...
@@ -81,7 +81,7 @@ class SpringBootJoranConfiguratorTests {
this
.
environment
.
setActiveProfiles
(
"production"
);
initialize
(
"production-profile.xml"
);
this
.
logger
.
trace
(
"Hello"
);
assertThat
(
this
.
capturedO
utput
).
contains
(
"Hello"
);
assertThat
(
this
.
o
utput
).
contains
(
"Hello"
);
}
@Test
...
...
@@ -89,7 +89,7 @@ class SpringBootJoranConfiguratorTests {
this
.
environment
.
setActiveProfiles
(
"production"
);
initialize
(
"multi-profile-names.xml"
);
this
.
logger
.
trace
(
"Hello"
);
assertThat
(
this
.
capturedO
utput
).
contains
(
"Hello"
);
assertThat
(
this
.
o
utput
).
contains
(
"Hello"
);
}
@Test
...
...
@@ -97,14 +97,14 @@ class SpringBootJoranConfiguratorTests {
this
.
environment
.
setActiveProfiles
(
"test"
);
initialize
(
"multi-profile-names.xml"
);
this
.
logger
.
trace
(
"Hello"
);
assertThat
(
this
.
capturedO
utput
).
contains
(
"Hello"
);
assertThat
(
this
.
o
utput
).
contains
(
"Hello"
);
}
@Test
void
profileNotActive
()
throws
Exception
{
initialize
(
"production-profile.xml"
);
this
.
logger
.
trace
(
"Hello"
);
assertThat
(
this
.
capturedO
utput
).
doesNotContain
(
"Hello"
);
assertThat
(
this
.
o
utput
).
doesNotContain
(
"Hello"
);
}
@Test
...
...
@@ -112,7 +112,7 @@ class SpringBootJoranConfiguratorTests {
this
.
environment
.
setActiveProfiles
(
"production"
);
initialize
(
"profile-expression.xml"
);
this
.
logger
.
trace
(
"Hello"
);
assertThat
(
this
.
capturedO
utput
).
contains
(
"Hello"
);
assertThat
(
this
.
o
utput
).
contains
(
"Hello"
);
}
@Test
...
...
@@ -120,7 +120,7 @@ class SpringBootJoranConfiguratorTests {
this
.
environment
.
setActiveProfiles
(
"test"
);
initialize
(
"profile-expression.xml"
);
this
.
logger
.
trace
(
"Hello"
);
assertThat
(
this
.
capturedO
utput
).
contains
(
"Hello"
);
assertThat
(
this
.
o
utput
).
contains
(
"Hello"
);
}
@Test
...
...
@@ -128,7 +128,7 @@ class SpringBootJoranConfiguratorTests {
this
.
environment
.
setActiveProfiles
(
"development"
);
initialize
(
"profile-expression.xml"
);
this
.
logger
.
trace
(
"Hello"
);
assertThat
(
this
.
capturedO
utput
).
doesNotContain
(
"Hello"
);
assertThat
(
this
.
o
utput
).
doesNotContain
(
"Hello"
);
}
@Test
...
...
@@ -195,10 +195,10 @@ class SpringBootJoranConfiguratorTests {
initialize
(
"nested.xml"
);
this
.
logger
.
trace
(
"Hello"
);
if
(
expected
)
{
assertThat
(
this
.
capturedO
utput
).
contains
(
"Hello"
);
assertThat
(
this
.
o
utput
).
contains
(
"Hello"
);
}
else
{
assertThat
(
this
.
capturedO
utput
).
doesNotContain
(
"Hello"
);
assertThat
(
this
.
o
utput
).
doesNotContain
(
"Hello"
);
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/SslConnectorCustomizerTests.java
View file @
c3816bfe
...
...
@@ -160,8 +160,7 @@ class SslConnectorCustomizerTests {
}
@Test
void
customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl
(
CapturedOutput
capturedOutput
)
throws
Exception
{
void
customizeWhenSslStoreProviderPresentShouldIgnorePasswordFromSsl
(
CapturedOutput
output
)
throws
Exception
{
System
.
setProperty
(
"javax.net.ssl.trustStorePassword"
,
"trustStoreSecret"
);
Ssl
ssl
=
new
Ssl
();
ssl
.
setKeyPassword
(
"password"
);
...
...
@@ -174,7 +173,7 @@ class SslConnectorCustomizerTests {
customizer
.
customize
(
connector
);
this
.
tomcat
.
start
();
assertThat
(
connector
.
getState
()).
isEqualTo
(
LifecycleState
.
STARTED
);
assertThat
(
capturedO
utput
).
doesNotContain
(
"Password verification failed"
);
assertThat
(
o
utput
).
doesNotContain
(
"Password verification failed"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/tomcat/TomcatServletWebServerFactoryTests.java
View file @
c3816bfe
...
...
@@ -328,9 +328,9 @@ class TomcatServletWebServerFactoryTests extends AbstractServletWebServerFactory
}
@Test
void
startupFailureDoesNotResultInUnstoppedThreadsBeingReported
(
CapturedOutput
capturedO
utput
)
throws
IOException
{
void
startupFailureDoesNotResultInUnstoppedThreadsBeingReported
(
CapturedOutput
o
utput
)
throws
IOException
{
super
.
portClashOfPrimaryConnectorResultsInPortInUseException
();
assertThat
(
capturedO
utput
).
doesNotContain
(
"appears to have started a thread named [main]"
);
assertThat
(
o
utput
).
doesNotContain
(
"appears to have started a thread named [main]"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java
View file @
c3816bfe
...
...
@@ -419,9 +419,9 @@ class ServletWebServerApplicationContextTests {
}
@Test
void
servletRequestCanBeInjectedEarly
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
servletRequestCanBeInjectedEarly
(
CapturedOutput
o
utput
)
throws
Exception
{
// gh-14990
int
initialOutputLength
=
capturedO
utput
.
length
();
int
initialOutputLength
=
o
utput
.
length
();
addWebServerFactoryBean
();
RootBeanDefinition
beanDefinition
=
new
RootBeanDefinition
(
WithAutowiredServletRequest
.
class
);
beanDefinition
.
setAutowireMode
(
AbstractBeanDefinition
.
AUTOWIRE_CONSTRUCTOR
);
...
...
@@ -431,8 +431,7 @@ class ServletWebServerApplicationContextTests {
assertThat
(
bean
.
getRequest
()).
isNotNull
();
});
this
.
context
.
refresh
();
String
output
=
capturedOutput
.
toString
().
substring
(
initialOutputLength
);
assertThat
(
output
).
doesNotContain
(
"Replacing scope"
);
assertThat
(
output
.
toString
().
substring
(
initialOutputLength
)).
doesNotContain
(
"Replacing scope"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
c3816bfe
...
...
@@ -167,7 +167,7 @@ public abstract class AbstractServletWebServerFactoryTests {
}
@Test
void
startCalledTwice
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
startCalledTwice
(
CapturedOutput
o
utput
)
throws
Exception
{
AbstractServletWebServerFactory
factory
=
getFactory
();
this
.
webServer
=
factory
.
getWebServer
(
exampleServletRegistration
());
this
.
webServer
.
start
();
...
...
@@ -175,7 +175,7 @@ public abstract class AbstractServletWebServerFactoryTests {
this
.
webServer
.
start
();
assertThat
(
this
.
webServer
.
getPort
()).
isEqualTo
(
port
);
assertThat
(
getResponse
(
getLocalUrl
(
"/hello"
))).
isEqualTo
(
"Hello World"
);
assertThat
(
capturedO
utput
).
containsOnlyOnce
(
"started on port"
);
assertThat
(
o
utput
).
containsOnlyOnce
(
"started on port"
);
}
@Test
...
...
@@ -264,12 +264,12 @@ public abstract class AbstractServletWebServerFactoryTests {
}
@Test
void
contextPathIsLoggedOnStartup
(
CapturedOutput
capturedO
utput
)
{
void
contextPathIsLoggedOnStartup
(
CapturedOutput
o
utput
)
{
AbstractServletWebServerFactory
factory
=
getFactory
();
factory
.
setContextPath
(
"/custom"
);
this
.
webServer
=
factory
.
getWebServer
(
exampleServletRegistration
());
this
.
webServer
.
start
();
assertThat
(
capturedO
utput
).
containsOnlyOnce
(
"with context path '/custom'"
);
assertThat
(
o
utput
).
containsOnlyOnce
(
"with context path '/custom'"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/ErrorPageFilterTests.java
View file @
c3816bfe
...
...
@@ -125,7 +125,7 @@ class ErrorPageFilterTests {
}
@Test
void
responseCommittedWhenFromClientAbortException
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
responseCommittedWhenFromClientAbortException
(
CapturedOutput
o
utput
)
throws
Exception
{
this
.
filter
.
addErrorPages
(
new
ErrorPage
(
"/error"
));
this
.
response
.
setCommitted
(
true
);
this
.
chain
=
new
TestFilterChain
((
request
,
response
,
chain
)
->
{
...
...
@@ -134,7 +134,7 @@ class ErrorPageFilterTests {
});
this
.
filter
.
doFilter
(
this
.
request
,
this
.
response
,
this
.
chain
);
assertThat
(
this
.
response
.
isCommitted
()).
isTrue
();
assertThat
(
capturedO
utput
).
doesNotContain
(
"Cannot forward"
);
assertThat
(
o
utput
).
doesNotContain
(
"Cannot forward"
);
}
@Test
...
...
@@ -342,7 +342,7 @@ class ErrorPageFilterTests {
}
@Test
void
errorMessageForRequestWithoutPathInfo
(
CapturedOutput
capturedO
utput
)
throws
IOException
,
ServletException
{
void
errorMessageForRequestWithoutPathInfo
(
CapturedOutput
o
utput
)
throws
IOException
,
ServletException
{
this
.
request
.
setServletPath
(
"/test"
);
this
.
filter
.
addErrorPages
(
new
ErrorPage
(
"/error"
));
this
.
chain
=
new
TestFilterChain
((
request
,
response
,
chain
)
->
{
...
...
@@ -350,11 +350,11 @@ class ErrorPageFilterTests {
throw
new
RuntimeException
();
});
this
.
filter
.
doFilter
(
this
.
request
,
this
.
response
,
this
.
chain
);
assertThat
(
capturedO
utput
).
contains
(
"request [/test]"
);
assertThat
(
o
utput
).
contains
(
"request [/test]"
);
}
@Test
void
errorMessageForRequestWithPathInfo
(
CapturedOutput
capturedO
utput
)
throws
IOException
,
ServletException
{
void
errorMessageForRequestWithPathInfo
(
CapturedOutput
o
utput
)
throws
IOException
,
ServletException
{
this
.
request
.
setServletPath
(
"/test"
);
this
.
request
.
setPathInfo
(
"/alpha"
);
this
.
filter
.
addErrorPages
(
new
ErrorPage
(
"/error"
));
...
...
@@ -363,7 +363,7 @@ class ErrorPageFilterTests {
throw
new
RuntimeException
();
});
this
.
filter
.
doFilter
(
this
.
request
,
this
.
response
,
this
.
chain
);
assertThat
(
capturedO
utput
).
contains
(
"request [/test/alpha]"
);
assertThat
(
o
utput
).
contains
(
"request [/test/alpha]"
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/support/SpringBootServletInitializerTests.java
View file @
c3816bfe
...
...
@@ -61,8 +61,8 @@ class SpringBootServletInitializerTests {
private
SpringApplication
application
;
@AfterEach
void
verifyLoggingOutput
(
CapturedOutput
capturedO
utput
)
{
assertThat
(
capturedO
utput
).
doesNotContain
(
StandardServletEnvironment
.
class
.
getSimpleName
());
void
verifyLoggingOutput
(
CapturedOutput
o
utput
)
{
assertThat
(
o
utput
).
doesNotContain
(
StandardServletEnvironment
.
class
.
getSimpleName
());
}
@Test
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-activemq/src/test/java/smoketest/activemq/SampleActiveMqTests.java
View file @
c3816bfe
...
...
@@ -39,10 +39,10 @@ class SampleActiveMqTests {
private
Producer
producer
;
@Test
void
sendSimpleMessage
(
CapturedOutput
capturedO
utput
)
throws
InterruptedException
{
void
sendSimpleMessage
(
CapturedOutput
o
utput
)
throws
InterruptedException
{
this
.
producer
.
send
(
"Test message"
);
Thread
.
sleep
(
1000L
);
assertThat
(
capturedO
utput
).
contains
(
"Test message"
);
assertThat
(
o
utput
).
contains
(
"Test message"
);
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-actuator-log4j2/src/test/java/smoketest/actuator/log4j2/SampleActuatorLog4J2ApplicationTests.java
View file @
c3816bfe
...
...
@@ -52,9 +52,9 @@ class SampleActuatorLog4J2ApplicationTests {
private
MockMvc
mvc
;
@Test
void
testLogger
(
CapturedOutput
capturedO
utput
)
{
void
testLogger
(
CapturedOutput
o
utput
)
{
logger
.
info
(
"Hello World"
);
assertThat
(
capturedO
utput
).
contains
(
"Hello World"
);
assertThat
(
o
utput
).
contains
(
"Hello World"
);
}
@Test
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-aop/src/test/java/smoketest/aop/SampleAopApplicationTests.java
View file @
c3816bfe
...
...
@@ -53,15 +53,15 @@ class SampleAopApplicationTests {
}
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
throws
Exception
{
SampleAopApplication
.
main
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
contains
(
"Hello Phil"
);
assertThat
(
o
utput
).
contains
(
"Hello Phil"
);
}
@Test
void
testCommandLineOverrides
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testCommandLineOverrides
(
CapturedOutput
o
utput
)
throws
Exception
{
SampleAopApplication
.
main
(
new
String
[]
{
"--name=Gordon"
});
assertThat
(
capturedO
utput
).
contains
(
"Hello Gordon"
);
assertThat
(
o
utput
).
contains
(
"Hello Gordon"
);
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-batch/src/test/java/smoketest/batch/SampleBatchApplicationTests.java
View file @
c3816bfe
...
...
@@ -29,9 +29,9 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleBatchApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
{
assertThat
(
SpringApplication
.
exit
(
SpringApplication
.
run
(
SampleBatchApplication
.
class
))).
isEqualTo
(
0
);
assertThat
(
capturedO
utput
).
contains
(
"completed with the following parameters"
);
assertThat
(
o
utput
).
contains
(
"completed with the following parameters"
);
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-couchbase/src/test/java/smoketest/data/couchbase/SampleCouchbaseApplicationTests.java
View file @
c3816bfe
...
...
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleCouchbaseApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
{
try
{
new
SpringApplicationBuilder
(
SampleCouchbaseApplication
.
class
).
run
(
"--server.port=0"
);
}
...
...
@@ -40,7 +40,7 @@ class SampleCouchbaseApplicationTests {
return
;
}
}
assertThat
(
capturedO
utput
).
contains
(
"firstName='Alice', lastName='Smith'"
);
assertThat
(
o
utput
).
contains
(
"firstName='Alice', lastName='Smith'"
);
}
private
boolean
serverNotRunning
(
RuntimeException
ex
)
{
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-elasticsearch/src/test/java/smoketest/data/elasticsearch/SampleElasticsearchApplicationTests.java
View file @
c3816bfe
...
...
@@ -36,7 +36,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleElasticsearchApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
{
try
{
new
SpringApplicationBuilder
(
SampleElasticsearchApplication
.
class
).
run
();
}
...
...
@@ -46,7 +46,7 @@ class SampleElasticsearchApplicationTests {
}
throw
ex
;
}
assertThat
(
capturedO
utput
).
contains
(
"firstName='Alice', lastName='Smith'"
);
assertThat
(
o
utput
).
contains
(
"firstName='Alice', lastName='Smith'"
);
}
private
boolean
elasticsearchRunning
(
Exception
ex
)
{
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-neo4j/src/test/java/smoketest/data/neo4j/SampleNeo4jApplicationTests.java
View file @
c3816bfe
...
...
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleNeo4jApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
{
try
{
SampleNeo4jApplication
.
main
(
new
String
[
0
]);
}
...
...
@@ -43,7 +43,7 @@ class SampleNeo4jApplicationTests {
return
;
}
}
assertThat
(
capturedO
utput
).
contains
(
"firstName='Alice', lastName='Smith'"
);
assertThat
(
o
utput
).
contains
(
"firstName='Alice', lastName='Smith'"
);
}
private
boolean
neo4jServerRunning
(
Throwable
ex
)
{
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-redis/src/test/java/smoketest/data/redis/SampleRedisApplicationTests.java
View file @
c3816bfe
...
...
@@ -34,7 +34,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleRedisApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
{
try
{
SampleRedisApplication
.
main
(
new
String
[
0
]);
}
...
...
@@ -43,7 +43,7 @@ class SampleRedisApplicationTests {
return
;
}
}
assertThat
(
capturedO
utput
).
contains
(
"Found key spring.boot.redis.test"
);
assertThat
(
o
utput
).
contains
(
"Found key spring.boot.redis.test"
);
}
private
boolean
redisServerRunning
(
Throwable
ex
)
{
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-data-solr/src/test/java/smoketest/data/solr/SampleSolrApplicationTests.java
View file @
c3816bfe
...
...
@@ -29,7 +29,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleSolrApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
throws
Exception
{
try
{
SampleSolrApplication
.
main
(
new
String
[
0
]);
}
...
...
@@ -38,7 +38,7 @@ class SampleSolrApplicationTests {
return
;
}
}
assertThat
(
capturedO
utput
).
contains
(
"name=Sony Playstation"
);
assertThat
(
o
utput
).
contains
(
"name=Sony Playstation"
);
}
@SuppressWarnings
(
"serial"
)
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jooq/src/test/java/smoketest/jooq/SampleJooqApplicationTests.java
View file @
c3816bfe
...
...
@@ -33,9 +33,9 @@ class SampleJooqApplicationTests {
private
static
final
String
[]
NO_ARGS
=
{};
@Test
void
outputResults
(
CapturedOutput
capturedO
utput
)
{
void
outputResults
(
CapturedOutput
o
utput
)
{
SampleJooqApplication
.
main
(
NO_ARGS
);
assertThat
(
capturedO
utput
).
contains
(
"jOOQ Fetch 1 Greg Turnquest"
).
contains
(
"jOOQ Fetch 2 Craig Walls"
)
assertThat
(
o
utput
).
contains
(
"jOOQ Fetch 1 Greg Turnquest"
).
contains
(
"jOOQ Fetch 2 Craig Walls"
)
.
contains
(
"jOOQ SQL "
+
"[Learning Spring Boot : Greg Turnquest, "
+
"Spring Boot in Action : Craig Walls]"
);
}
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-atomikos/src/test/java/smoketest/atomikos/SampleAtomikosApplicationTests.java
View file @
c3816bfe
...
...
@@ -34,9 +34,9 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleAtomikosApplicationTests
{
@Test
void
testTransactionRollback
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testTransactionRollback
(
CapturedOutput
o
utput
)
throws
Exception
{
SampleAtomikosApplication
.
main
(
new
String
[]
{});
assertThat
(
capturedO
utput
.
toString
()).
has
(
substring
(
1
,
"---->"
)).
has
(
substring
(
1
,
"----> josh"
))
assertThat
(
o
utput
.
toString
()).
has
(
substring
(
1
,
"---->"
)).
has
(
substring
(
1
,
"----> josh"
))
.
has
(
substring
(
2
,
"Count is 1"
)).
has
(
substring
(
1
,
"Simulated error"
));
}
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-jta-bitronix/src/test/java/smoketest/bitronix/SampleBitronixApplicationTests.java
View file @
c3816bfe
...
...
@@ -37,9 +37,9 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleBitronixApplicationTests
{
@Test
void
testTransactionRollback
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testTransactionRollback
(
CapturedOutput
o
utput
)
throws
Exception
{
SampleBitronixApplication
.
main
(
new
String
[]
{});
assertThat
(
capturedO
utput
.
toString
()).
has
(
substring
(
1
,
"---->"
)).
has
(
substring
(
1
,
"----> josh"
))
assertThat
(
o
utput
.
toString
()).
has
(
substring
(
1
,
"---->"
)).
has
(
substring
(
1
,
"----> josh"
))
.
has
(
substring
(
2
,
"Count is 1"
)).
has
(
substring
(
1
,
"Simulated error"
));
}
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-liquibase/src/test/java/smoketest/liquibase/SampleLiquibaseApplicationTests.java
View file @
c3816bfe
...
...
@@ -31,7 +31,7 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleLiquibaseApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
throws
Exception
{
try
{
SampleLiquibaseApplication
.
main
(
new
String
[]
{
"--server.port=0"
});
}
...
...
@@ -40,7 +40,7 @@ class SampleLiquibaseApplicationTests {
return
;
}
}
assertThat
(
capturedO
utput
).
contains
(
"Successfully acquired change log lock"
)
assertThat
(
o
utput
).
contains
(
"Successfully acquired change log lock"
)
.
contains
(
"Creating database history "
+
"table with name: PUBLIC.DATABASECHANGELOG"
)
.
contains
(
"Table person created"
)
.
contains
(
"ChangeSet classpath:/db/"
+
"changelog/db.changelog-master.yaml::1::"
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-logback/src/test/java/smoketest/logback/SampleLogbackApplicationTests.java
View file @
c3816bfe
...
...
@@ -28,15 +28,15 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleLogbackApplicationTests
{
@Test
void
testLoadedCustomLogbackConfig
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testLoadedCustomLogbackConfig
(
CapturedOutput
o
utput
)
throws
Exception
{
SampleLogbackApplication
.
main
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
contains
(
"Sample Debug Message"
).
doesNotContain
(
"Sample Trace Message"
);
assertThat
(
o
utput
).
contains
(
"Sample Debug Message"
).
doesNotContain
(
"Sample Trace Message"
);
}
@Test
void
testProfile
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testProfile
(
CapturedOutput
o
utput
)
throws
Exception
{
SampleLogbackApplication
.
main
(
new
String
[]
{
"--spring.profiles.active=staging"
});
assertThat
(
capturedO
utput
).
contains
(
"Sample Debug Message"
).
contains
(
"Sample Trace Message"
);
assertThat
(
o
utput
).
contains
(
"Sample Debug Message"
).
contains
(
"Sample Trace Message"
);
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-profile/src/test/java/smoketest/profile/SampleProfileApplicationTests.java
View file @
c3816bfe
...
...
@@ -47,20 +47,20 @@ class SampleProfileApplicationTests {
}
@Test
void
testDefaultProfile
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultProfile
(
CapturedOutput
o
utput
)
{
SampleProfileApplication
.
main
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
contains
(
"Hello Phil"
);
assertThat
(
o
utput
).
contains
(
"Hello Phil"
);
}
@Test
void
testGoodbyeProfile
(
CapturedOutput
capturedO
utput
)
{
void
testGoodbyeProfile
(
CapturedOutput
o
utput
)
{
System
.
setProperty
(
"spring.profiles.active"
,
"goodbye"
);
SampleProfileApplication
.
main
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
contains
(
"Goodbye Everyone"
);
assertThat
(
o
utput
).
contains
(
"Goodbye Everyone"
);
}
@Test
void
testGenericProfile
(
CapturedOutput
capturedO
utput
)
{
void
testGenericProfile
(
CapturedOutput
o
utput
)
{
/*
* This is a profile that requires a new environment property, and one which is
* only overridden in the current working directory. That file also only contains
...
...
@@ -69,13 +69,13 @@ class SampleProfileApplicationTests {
*/
System
.
setProperty
(
"spring.profiles.active"
,
"generic"
);
SampleProfileApplication
.
main
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
contains
(
"Bonjour Phil"
);
assertThat
(
o
utput
).
contains
(
"Bonjour Phil"
);
}
@Test
void
testGoodbyeProfileFromCommandline
(
CapturedOutput
capturedO
utput
)
{
void
testGoodbyeProfileFromCommandline
(
CapturedOutput
o
utput
)
{
SampleProfileApplication
.
main
(
new
String
[]
{
"--spring.profiles.active=goodbye"
});
assertThat
(
capturedO
utput
).
contains
(
"Goodbye Everyone"
);
assertThat
(
o
utput
).
contains
(
"Goodbye Everyone"
);
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-quartz/src/test/java/smoketest/quartz/SampleQuartzApplicationTests.java
View file @
c3816bfe
...
...
@@ -35,13 +35,13 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleQuartzApplicationTests
{
@Test
void
quartzJobIsTriggered
(
CapturedOutput
capturedO
utput
)
throws
InterruptedException
{
void
quartzJobIsTriggered
(
CapturedOutput
o
utput
)
throws
InterruptedException
{
try
(
ConfigurableApplicationContext
context
=
SpringApplication
.
run
(
SampleQuartzApplication
.
class
))
{
long
end
=
System
.
currentTimeMillis
()
+
5000
;
while
((!
capturedO
utput
.
toString
().
contains
(
"Hello World!"
))
&&
System
.
currentTimeMillis
()
<
end
)
{
while
((!
o
utput
.
toString
().
contains
(
"Hello World!"
))
&&
System
.
currentTimeMillis
()
<
end
)
{
Thread
.
sleep
(
100
);
}
assertThat
(
capturedO
utput
).
contains
(
"Hello World!"
);
assertThat
(
o
utput
).
contains
(
"Hello World!"
);
}
}
...
...
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-simple/src/test/java/smoketest/simple/SampleSimpleApplicationTests.java
View file @
c3816bfe
...
...
@@ -53,15 +53,15 @@ class SampleSimpleApplicationTests {
}
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
{
SampleSimpleApplication
.
main
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
contains
(
"Hello Phil"
);
assertThat
(
o
utput
).
contains
(
"Hello Phil"
);
}
@Test
void
testCommandLineOverrides
(
CapturedOutput
capturedO
utput
)
{
void
testCommandLineOverrides
(
CapturedOutput
o
utput
)
{
SampleSimpleApplication
.
main
(
new
String
[]
{
"--name=Gordon"
,
"--duration=1m"
});
assertThat
(
capturedO
utput
).
contains
(
"Hello Gordon for 60 seconds"
);
assertThat
(
o
utput
).
contains
(
"Hello Gordon for 60 seconds"
);
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-webservices/src/test/java/smoketest/webservices/SampleWsApplicationTests.java
View file @
c3816bfe
...
...
@@ -49,7 +49,7 @@ class SampleWsApplicationTests {
}
@Test
void
testSendingHolidayRequest
(
CapturedOutput
capturedO
utput
)
{
void
testSendingHolidayRequest
(
CapturedOutput
o
utput
)
{
final
String
request
=
"<hr:HolidayRequest xmlns:hr=\"https://company.example.com/hr/schemas\">"
+
" <hr:Holiday>"
+
" <hr:StartDate>2013-10-20</hr:StartDate>"
+
" <hr:EndDate>2013-11-22</hr:EndDate>"
+
" </hr:Holiday>"
+
" <hr:Employee>"
...
...
@@ -58,7 +58,7 @@ class SampleWsApplicationTests {
StreamSource
source
=
new
StreamSource
(
new
StringReader
(
request
));
StreamResult
result
=
new
StreamResult
(
System
.
out
);
this
.
webServiceTemplate
.
sendSourceAndReceiveToResult
(
source
,
result
);
assertThat
(
capturedO
utput
).
contains
(
"Booking holiday for"
);
assertThat
(
o
utput
).
contains
(
"Booking holiday for"
);
}
}
spring-boot-tests/spring-boot-smoke-tests/spring-boot-smoke-test-xml/src/test/java/smoketest/xml/SampleSpringXmlApplicationTests.java
View file @
c3816bfe
...
...
@@ -28,9 +28,9 @@ import static org.assertj.core.api.Assertions.assertThat;
class
SampleSpringXmlApplicationTests
{
@Test
void
testDefaultSettings
(
CapturedOutput
capturedO
utput
)
throws
Exception
{
void
testDefaultSettings
(
CapturedOutput
o
utput
)
throws
Exception
{
SampleSpringXmlApplication
.
main
(
new
String
[
0
]);
assertThat
(
capturedO
utput
).
contains
(
"Hello World"
);
assertThat
(
o
utput
).
contains
(
"Hello World"
);
}
}
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