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
894940d7
Commit
894940d7
authored
Nov 04, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for dispatcher registration
parent
b631c113
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
EmbeddedServletContainerAutoConfigurationTests.java
...e/web/EmbeddedServletContainerAutoConfigurationTests.java
+27
-0
No files found.
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/EmbeddedServletContainerAutoConfigurationTests.java
View file @
894940d7
...
...
@@ -27,6 +27,7 @@ import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletCont
import
org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer
;
import
org.springframework.boot.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.MockEmbeddedServletContainerFactory
;
import
org.springframework.boot.context.embedded.ServletRegistrationBean
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.stereotype.Component
;
...
...
@@ -74,6 +75,17 @@ public class EmbeddedServletContainerAutoConfigurationTests {
assertEquals
(
2
,
this
.
context
.
getBeanNamesForType
(
DispatcherServlet
.
class
).
length
);
}
@Test
public
void
contextAlreadyHasDispatcherServletAndRegistration
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
(
DispatcherServletWithRegistrationConfiguration
.
class
,
EmbeddedContainerConfiguration
.
class
,
EmbeddedServletContainerAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
);
verifyContext
();
assertEquals
(
1
,
this
.
context
.
getBeanNamesForType
(
DispatcherServlet
.
class
).
length
);
}
@Test
public
void
containerHasNoServletContext
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
(
...
...
@@ -139,6 +151,21 @@ public class EmbeddedServletContainerAutoConfigurationTests {
}
@Configuration
public
static
class
DispatcherServletWithRegistrationConfiguration
{
@Bean
(
name
=
DispatcherServletAutoConfiguration
.
DEFAULT_DISPATCHER_SERVLET_BEAN_NAME
)
public
DispatcherServlet
dispatcherServlet
()
{
return
new
DispatcherServlet
();
}
@Bean
public
ServletRegistrationBean
dispatcherRegistration
()
{
return
new
ServletRegistrationBean
(
dispatcherServlet
(),
"/app/*"
);
}
}
@Component
public
static
class
EnsureContainerHasNoServletContext
implements
BeanPostProcessor
{
...
...
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