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
9db55a3b
Commit
9db55a3b
authored
Nov 28, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add explicit test for config file and SpringApplication
parent
131cfd61
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
8 deletions
+22
-8
SampleSpringXmlApplication.java
...framework/boot/sample/xml/SampleSpringXmlApplication.java
+0
-1
PropertiesPropertySourceLoader.java
...framework/boot/config/PropertiesPropertySourceLoader.java
+9
-0
LogbackLoggingSystem.java
...gframework/boot/logging/logback/LogbackLoggingSystem.java
+2
-1
SpringApplicationTests.java
...java/org/springframework/boot/SpringApplicationTests.java
+10
-2
LoggingApplicationContextInitializerTests.java
...nitializer/LoggingApplicationContextInitializerTests.java
+1
-1
logback-test.xml
spring-boot/src/test/resources/logback-test.xml
+0
-3
No files found.
spring-boot-samples/spring-boot-sample-xml/src/main/java/org/springframework/boot/sample/xml/SampleSpringXmlApplication.java
View file @
9db55a3b
...
...
@@ -32,7 +32,6 @@ public class SampleSpringXmlApplication implements CommandLineRunner {
}
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// TODO: to make this a pure XML example, will need <boot:auto-configure/>
SpringApplication
.
run
(
"classpath:/META-INF/application-context.xml"
,
args
);
}
}
spring-boot/src/main/java/org/springframework/boot/config/PropertiesPropertySourceLoader.java
View file @
9db55a3b
...
...
@@ -19,6 +19,8 @@ package org.springframework.boot.config;
import
java.io.IOException
;
import
java.util.Properties
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.core.env.PropertiesPropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.io.Resource
;
...
...
@@ -31,6 +33,8 @@ import org.springframework.core.io.support.PropertiesLoaderUtils;
*/
public
class
PropertiesPropertySourceLoader
implements
PropertySourceLoader
{
private
static
Log
logger
=
LogFactory
.
getLog
(
PropertiesPropertySourceLoader
.
class
);
@Override
public
boolean
supports
(
Resource
resource
)
{
return
resource
.
getFilename
().
endsWith
(
".properties"
);
...
...
@@ -40,6 +44,11 @@ public class PropertiesPropertySourceLoader implements PropertySourceLoader {
public
PropertySource
<?>
load
(
Resource
resource
)
{
try
{
Properties
properties
=
loadProperties
(
resource
);
// N.B. this is off by default unless user has supplied logback config in
// standard location
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
"Properties loaded from "
+
resource
+
": "
+
properties
);
}
return
new
PropertiesPropertySource
(
resource
.
getDescription
(),
properties
);
}
catch
(
IOException
ex
)
{
...
...
spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java
View file @
9db55a3b
...
...
@@ -59,7 +59,8 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem {
}
public
LogbackLoggingSystem
(
ClassLoader
classLoader
)
{
super
(
classLoader
,
"logback.xml"
);
super
(
classLoader
,
"logback-test.groovy"
,
"logback-test.xml"
,
"logback.groovy"
,
"logback.xml"
);
}
@Override
...
...
spring-boot/src/test/java/org/springframework/boot/SpringApplicationTests.java
View file @
9db55a3b
...
...
@@ -273,6 +273,16 @@ public class SpringApplicationTests {
assertEquals
(
"bar"
,
environment
.
getProperty
(
"foo"
));
}
@Test
public
void
proprtiesFileEnhancesEnvironment
()
throws
Exception
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
application
.
setWebEnvironment
(
false
);
ConfigurableEnvironment
environment
=
new
StandardEnvironment
();
application
.
setEnvironment
(
environment
);
application
.
run
();
assertEquals
(
"bucket"
,
environment
.
getProperty
(
"foo"
));
}
@Test
public
void
emptyCommandLinePropertySourceNotAdded
()
throws
Exception
{
SpringApplication
application
=
new
SpringApplication
(
ExampleConfig
.
class
);
...
...
@@ -404,8 +414,6 @@ public class SpringApplicationTests {
// FIXME test initializers
// FIXME test config files?
public
static
class
SpyApplicationContext
extends
AnnotationConfigApplicationContext
{
ConfigurableApplicationContext
applicationContext
=
spy
(
new
AnnotationConfigApplicationContext
());
...
...
spring-boot/src/test/java/org/springframework/boot/context/initializer/LoggingApplicationContextInitializerTests.java
View file @
9db55a3b
...
...
@@ -153,7 +153,7 @@ public class LoggingApplicationContextInitializerTests {
@Test
public
void
parseArgsDisabled
()
throws
Exception
{
this
.
initializer
.
setParseArgs
(
false
);
this
.
initializer
.
initialize
(
this
.
springApplication
,
new
String
[]
{
"--debug"
}
);
TestUtils
.
addEnviroment
(
this
.
context
,
"debug"
);
this
.
initializer
.
initialize
(
this
.
context
);
this
.
logger
.
debug
(
"testatdebug"
);
assertThat
(
this
.
outputCapture
.
toString
(),
not
(
containsString
(
"testatdebug"
)));
...
...
spring-boot/src/test/resources/logback-test.xml
View file @
9db55a3b
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<property
name=
"LOG_PATTERN"
value=
"[%d{yyyy-MM-dd HH:mm:ss.SSS}] spring - ${PID:-????} %5p [%t] --- %c{1}: %m%n"
/>
<property
name=
"LOG_FILE"
value=
"${LOG_FILE:-${LOG_PATH:-/tmp/logs/service.log}}"
/>
<appender
name=
"CONSOLE"
class=
"ch.qos.logback.core.ConsoleAppender"
>
<encoder>
<pattern>
${LOG_PATTERN}
</pattern>
</encoder>
</appender>
<logger
name=
"org.springframework.boot.context.annotation"
level=
"TRACE"
/>
<logger
name=
"org.springframework.boot.context.initializer"
level=
"TRACE"
/>
<logger
name=
"org.springframework.boot.config"
level=
"TRACE"
/>
<logger
name=
"org.thymeleaf"
level=
"TRACE"
/>
<root
level=
"INFO"
>
...
...
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