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
579c6feb
Commit
579c6feb
authored
Jul 27, 2017
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
eacb6b13
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
15 deletions
+15
-15
AbstractApplicationContextRunnerTests.java
...context/runner/AbstractApplicationContextRunnerTests.java
+14
-14
WebApplicationContextRunnerTests.java
...test/context/runner/WebApplicationContextRunnerTests.java
+1
-1
No files found.
spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/AbstractApplicationContextRunnerTests.java
View file @
579c6feb
...
@@ -54,7 +54,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -54,7 +54,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
public
void
runWithSystemPropertiesShouldSetAndRemoveProperties
()
{
public
void
runWithSystemPropertiesShouldSetAndRemoveProperties
()
{
String
key
=
"test."
+
UUID
.
randomUUID
().
toString
();
String
key
=
"test."
+
UUID
.
randomUUID
().
toString
();
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
get
().
withSystemProperties
(
key
+
"=value"
).
run
((
loaded
)
->
{
get
().
withSystemProperties
(
key
+
"=value"
).
run
((
context
)
->
{
assertThat
(
System
.
getProperties
()).
containsEntry
(
key
,
"value"
);
assertThat
(
System
.
getProperties
()).
containsEntry
(
key
,
"value"
);
});
});
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
...
@@ -66,8 +66,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -66,8 +66,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
String
key
=
"test."
+
UUID
.
randomUUID
().
toString
();
String
key
=
"test."
+
UUID
.
randomUUID
().
toString
();
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
get
().
withSystemProperties
(
key
+
"=value"
)
get
().
withSystemProperties
(
key
+
"=value"
)
.
withUserConfiguration
(
FailingConfig
.
class
).
run
((
loaded
)
->
{
.
withUserConfiguration
(
FailingConfig
.
class
).
run
((
context
)
->
{
assertThat
(
loaded
).
hasFailed
();
assertThat
(
context
).
hasFailed
();
});
});
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
assertThat
(
System
.
getProperties
().
containsKey
(
key
)).
isFalse
();
}
}
...
@@ -79,7 +79,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -79,7 +79,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
System
.
setProperty
(
key
,
"value"
);
System
.
setProperty
(
key
,
"value"
);
try
{
try
{
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
get
().
withSystemProperties
(
key
+
"=newValue"
).
run
((
loaded
)
->
{
get
().
withSystemProperties
(
key
+
"=newValue"
).
run
((
context
)
->
{
assertThat
(
System
.
getProperties
()).
containsEntry
(
key
,
"newValue"
);
assertThat
(
System
.
getProperties
()).
containsEntry
(
key
,
"newValue"
);
});
});
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
...
@@ -96,7 +96,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -96,7 +96,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
System
.
setProperty
(
key
,
"value"
);
System
.
setProperty
(
key
,
"value"
);
try
{
try
{
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
get
().
withSystemProperties
(
key
+
"="
).
run
((
loaded
)
->
{
get
().
withSystemProperties
(
key
+
"="
).
run
((
context
)
->
{
assertThat
(
System
.
getProperties
()).
doesNotContainKey
(
key
);
assertThat
(
System
.
getProperties
()).
doesNotContainKey
(
key
);
});
});
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
assertThat
(
System
.
getProperties
().
getProperty
(
key
)).
isEqualTo
(
"value"
);
...
@@ -109,8 +109,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -109,8 +109,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
@Test
@Test
public
void
runWithMultiplePropertyValuesShouldAllAllValues
()
throws
Exception
{
public
void
runWithMultiplePropertyValuesShouldAllAllValues
()
throws
Exception
{
get
().
withPropertyValues
(
"test.foo=1"
).
withPropertyValues
(
"test.bar=2"
)
get
().
withPropertyValues
(
"test.foo=1"
).
withPropertyValues
(
"test.bar=2"
)
.
run
((
loaded
)
->
{
.
run
((
context
)
->
{
Environment
environment
=
loaded
.
getEnvironment
();
Environment
environment
=
context
.
getEnvironment
();
assertThat
(
environment
.
getProperty
(
"test.foo"
)).
isEqualTo
(
"1"
);
assertThat
(
environment
.
getProperty
(
"test.foo"
)).
isEqualTo
(
"1"
);
assertThat
(
environment
.
getProperty
(
"test.bar"
)).
isEqualTo
(
"2"
);
assertThat
(
environment
.
getProperty
(
"test.bar"
)).
isEqualTo
(
"2"
);
});
});
...
@@ -120,8 +120,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -120,8 +120,8 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
public
void
runWithPropertyValuesWhenHasExistingShouldReplaceValue
()
public
void
runWithPropertyValuesWhenHasExistingShouldReplaceValue
()
throws
Exception
{
throws
Exception
{
get
().
withPropertyValues
(
"test.foo=1"
).
withPropertyValues
(
"test.foo=2"
)
get
().
withPropertyValues
(
"test.foo=1"
).
withPropertyValues
(
"test.foo=2"
)
.
run
((
loaded
)
->
{
.
run
((
context
)
->
{
Environment
environment
=
loaded
.
getEnvironment
();
Environment
environment
=
context
.
getEnvironment
();
assertThat
(
environment
.
getProperty
(
"test.foo"
)).
isEqualTo
(
"2"
);
assertThat
(
environment
.
getProperty
(
"test.foo"
)).
isEqualTo
(
"2"
);
});
});
}
}
...
@@ -129,7 +129,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -129,7 +129,7 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
@Test
@Test
public
void
runWithConfigurationsShouldRegisterConfigurations
()
throws
Exception
{
public
void
runWithConfigurationsShouldRegisterConfigurations
()
throws
Exception
{
get
().
withUserConfiguration
(
FooConfig
.
class
)
get
().
withUserConfiguration
(
FooConfig
.
class
)
.
run
((
loaded
)
->
assertThat
(
loaded
).
hasBean
(
"foo"
));
.
run
((
context
)
->
assertThat
(
context
).
hasBean
(
"foo"
));
}
}
@Test
@Test
...
@@ -137,23 +137,23 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
...
@@ -137,23 +137,23 @@ public abstract class AbstractApplicationContextRunnerTests<T extends AbstractAp
throws
Exception
{
throws
Exception
{
get
().
withUserConfiguration
(
FooConfig
.
class
)
get
().
withUserConfiguration
(
FooConfig
.
class
)
.
withConfiguration
(
UserConfigurations
.
of
(
BarConfig
.
class
))
.
withConfiguration
(
UserConfigurations
.
of
(
BarConfig
.
class
))
.
run
((
loaded
)
->
assertThat
(
loaded
).
hasBean
(
"foo"
).
hasBean
(
"bar"
));
.
run
((
context
)
->
assertThat
(
context
).
hasBean
(
"foo"
).
hasBean
(
"bar"
));
}
}
@Test
@Test
public
void
runWithFailedContextShouldReturnFailedAssertableContext
()
public
void
runWithFailedContextShouldReturnFailedAssertableContext
()
throws
Exception
{
throws
Exception
{
get
().
withUserConfiguration
(
FailingConfig
.
class
)
get
().
withUserConfiguration
(
FailingConfig
.
class
)
.
run
((
loaded
)
->
assertThat
(
loaded
).
hasFailed
());
.
run
((
context
)
->
assertThat
(
context
).
hasFailed
());
}
}
@Test
@Test
public
void
runWithClassLoaderShouldSetClassLoader
()
throws
Exception
{
public
void
runWithClassLoaderShouldSetClassLoader
()
throws
Exception
{
get
().
withClassLoader
(
get
().
withClassLoader
(
new
HidePackagesClassLoader
(
Gson
.
class
.
getPackage
().
getName
()))
new
HidePackagesClassLoader
(
Gson
.
class
.
getPackage
().
getName
()))
.
run
((
loaded
)
->
{
.
run
((
context
)
->
{
try
{
try
{
ClassUtils
.
forName
(
Gson
.
class
.
getName
(),
loaded
.
getClassLoader
());
ClassUtils
.
forName
(
Gson
.
class
.
getName
(),
context
.
getClassLoader
());
fail
(
"Should have thrown a ClassNotFoundException"
);
fail
(
"Should have thrown a ClassNotFoundException"
);
}
}
catch
(
ClassNotFoundException
e
)
{
catch
(
ClassNotFoundException
e
)
{
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/context/runner/WebApplicationContextRunnerTests.java
View file @
579c6feb
...
@@ -35,7 +35,7 @@ public class WebApplicationContextRunnerTests extends
...
@@ -35,7 +35,7 @@ public class WebApplicationContextRunnerTests extends
@Test
@Test
public
void
contextShouldHaveMockServletContext
()
throws
Exception
{
public
void
contextShouldHaveMockServletContext
()
throws
Exception
{
get
().
run
((
loaded
)
->
assertThat
(
loaded
.
getServletContext
())
get
().
run
((
context
)
->
assertThat
(
context
.
getServletContext
())
.
isInstanceOf
(
MockServletContext
.
class
));
.
isInstanceOf
(
MockServletContext
.
class
));
}
}
...
...
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