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
845aeecb
Commit
845aeecb
authored
Nov 22, 2013
by
Christian Dupuis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Properly close application context in tests
parent
cd896917
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
33 additions
and
7 deletions
+33
-7
CrshAutoConfigurationTests.java
...oot/actuate/autoconfigure/CrshAutoConfigurationTests.java
+1
-2
EndpointAutoConfigurationTests.java
...actuate/autoconfigure/EndpointAutoConfigurationTests.java
+8
-0
EndpointWebMvcAutoConfigurationTests.java
...e/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
+1
-3
ManagementSecurityAutoConfigurationTests.java
...toconfigure/ManagementSecurityAutoConfigurationTests.java
+8
-0
SpringApplicationHierarchyTests.java
...ctuate/autoconfigure/SpringApplicationHierarchyTests.java
+7
-1
AbstractEndpointTests.java
...ramework/boot/actuate/endpoint/AbstractEndpointTests.java
+8
-1
No files found.
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/CrshAutoConfigurationTests.java
View file @
845aeecb
...
@@ -67,10 +67,9 @@ public class CrshAutoConfigurationTests {
...
@@ -67,10 +67,9 @@ public class CrshAutoConfigurationTests {
private
AnnotationConfigWebApplicationContext
context
;
private
AnnotationConfigWebApplicationContext
context
;
@After
@After
public
void
tearDown
()
{
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
this
.
context
.
close
();
this
.
context
=
null
;
}
}
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointAutoConfigurationTests.java
View file @
845aeecb
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.TestUtils
;
import
org.springframework.boot.TestUtils
;
...
@@ -53,6 +54,13 @@ public class EndpointAutoConfigurationTests {
...
@@ -53,6 +54,13 @@ public class EndpointAutoConfigurationTests {
this
.
context
.
refresh
();
this
.
context
.
refresh
();
}
}
@After
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
@Test
public
void
endpoints
()
throws
Exception
{
public
void
endpoints
()
throws
Exception
{
assertNotNull
(
this
.
context
.
getBean
(
BeansEndpoint
.
class
));
assertNotNull
(
this
.
context
.
getBean
(
BeansEndpoint
.
class
));
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/EndpointWebMvcAutoConfigurationTests.java
View file @
845aeecb
...
@@ -59,11 +59,9 @@ public class EndpointWebMvcAutoConfigurationTests {
...
@@ -59,11 +59,9 @@ public class EndpointWebMvcAutoConfigurationTests {
@After
@After
public
void
close
()
{
public
void
close
()
{
try
{
if
(
this
.
applicationContext
!=
null
)
{
this
.
applicationContext
.
close
();
this
.
applicationContext
.
close
();
}
}
catch
(
Exception
ex
)
{
}
}
}
@Test
@Test
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/ManagementSecurityAutoConfigurationTests.java
View file @
845aeecb
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
package
org
.
springframework
.
boot
.
actuate
.
autoconfigure
;
import
org.junit.After
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.TestUtils
;
import
org.springframework.boot.TestUtils
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReportLoggingInitializer
;
import
org.springframework.boot.autoconfigure.AutoConfigurationReportLoggingInitializer
;
...
@@ -52,6 +53,13 @@ public class ManagementSecurityAutoConfigurationTests {
...
@@ -52,6 +53,13 @@ public class ManagementSecurityAutoConfigurationTests {
private
AnnotationConfigWebApplicationContext
context
;
private
AnnotationConfigWebApplicationContext
context
;
@After
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
@Test
public
void
testWebConfiguration
()
throws
Exception
{
public
void
testWebConfiguration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
this
.
context
=
new
AnnotationConfigWebApplicationContext
();
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/autoconfigure/SpringApplicationHierarchyTests.java
View file @
845aeecb
...
@@ -21,6 +21,7 @@ import org.junit.Test;
...
@@ -21,6 +21,7 @@ import org.junit.Test;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.EnableAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.autoconfigure.web.ServerPropertiesAutoConfiguration
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.boot.builder.SpringApplicationBuilder
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
import
org.springframework.context.ConfigurableApplicationContext
;
/**
/**
...
@@ -34,6 +35,10 @@ public class SpringApplicationHierarchyTests {
...
@@ -34,6 +35,10 @@ public class SpringApplicationHierarchyTests {
@After
@After
public
void
after
()
{
public
void
after
()
{
if
(
this
.
context
!=
null
)
{
if
(
this
.
context
!=
null
)
{
ApplicationContext
parentContext
=
this
.
context
.
getParent
();
if
(
parentContext
instanceof
ConfigurableApplicationContext
)
{
((
ConfigurableApplicationContext
)
parentContext
).
close
();
}
this
.
context
.
close
();
this
.
context
.
close
();
}
}
}
}
...
@@ -55,7 +60,8 @@ public class SpringApplicationHierarchyTests {
...
@@ -55,7 +60,8 @@ public class SpringApplicationHierarchyTests {
public
static
class
Child
{
public
static
class
Child
{
}
}
@EnableAutoConfiguration
(
exclude
=
{
ServerPropertiesAutoConfiguration
.
class
})
@EnableAutoConfiguration
(
exclude
=
{
ServerPropertiesAutoConfiguration
.
class
,
JolokiaAutoConfiguration
.
class
})
public
static
class
Parent
{
public
static
class
Parent
{
}
}
...
...
spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/AbstractEndpointTests.java
View file @
845aeecb
...
@@ -18,10 +18,10 @@ package org.springframework.boot.actuate.endpoint;
...
@@ -18,10 +18,10 @@ package org.springframework.boot.actuate.endpoint;
import
java.util.Collections
;
import
java.util.Collections
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.TestUtils
;
import
org.springframework.boot.TestUtils
;
import
org.springframework.boot.actuate.endpoint.Endpoint
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.context.annotation.AnnotationConfigApplicationContext
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.MapPropertySource
;
import
org.springframework.core.env.PropertySource
;
import
org.springframework.core.env.PropertySource
;
...
@@ -68,6 +68,13 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
...
@@ -68,6 +68,13 @@ public abstract class AbstractEndpointTests<T extends Endpoint<?>> {
this
.
context
.
refresh
();
this
.
context
.
refresh
();
}
}
@After
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
@Test
public
void
producesMediaType
()
{
public
void
producesMediaType
()
{
assertThat
(
getEndpointBean
().
getProduces
(),
equalTo
(
this
.
produces
));
assertThat
(
getEndpointBean
().
getProduces
(),
equalTo
(
this
.
produces
));
...
...
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