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
b2873fbc
Commit
b2873fbc
authored
Jul 26, 2013
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add WebMvcAutoConfigurationTests
[Fixes #53027833]
parent
9e144093
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
94 additions
and
4 deletions
+94
-4
WebMvcAutoConfigurationTests.java
...ework/autoconfigure/web/WebMvcAutoConfigurationTests.java
+94
-4
No files found.
spring-autoconfigure/src/test/java/org/springframework/autoconfigure/web/WebMvcAutoConfigurationTests.java
View file @
b2873fbc
...
@@ -16,17 +16,107 @@
...
@@ -16,17 +16,107 @@
package
org
.
springframework
.
autoconfigure
.
web
;
package
org
.
springframework
.
autoconfigure
.
web
;
import
org.junit.Ignore
;
import
java.util.Map
;
import
org.springframework.autoconfigure.web.WebMvcAutoConfiguration
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
org.junit.After
;
import
org.junit.Rule
;
import
org.junit.Test
;
import
org.junit.rules.ExpectedException
;
import
org.springframework.bootstrap.context.embedded.AnnotationConfigEmbeddedWebApplicationContext
;
import
org.springframework.bootstrap.context.embedded.EmbeddedServletContainerCustomizerBeanPostProcessor
;
import
org.springframework.bootstrap.context.embedded.EmbeddedServletContainerFactory
;
import
org.springframework.bootstrap.context.embedded.MockEmbeddedServletContainerFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.servlet.HandlerAdapter
;
import
org.springframework.web.servlet.HandlerMapping
;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.ViewResolver
;
import
org.springframework.web.servlet.view.AbstractView
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
/**
/**
* Tests for {@link WebMvcAutoConfiguration}.
* Tests for {@link WebMvcAutoConfiguration}.
*
*
* @author Phillip Webb
* @author Phillip Webb
* @author Dave Syer
*/
*/
@Ignore
public
class
WebMvcAutoConfigurationTests
{
public
class
WebMvcAutoConfigurationTests
{
// FIXME
private
static
final
MockEmbeddedServletContainerFactory
containerFactory
=
new
MockEmbeddedServletContainerFactory
();
@Rule
public
ExpectedException
thrown
=
ExpectedException
.
none
();
private
AnnotationConfigEmbeddedWebApplicationContext
context
;
@After
public
void
close
()
{
if
(
this
.
context
!=
null
)
{
this
.
context
.
close
();
}
}
@Test
public
void
handerAdaptersCreated
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
3
,
this
.
context
.
getBeanNamesForType
(
HandlerAdapter
.
class
).
length
);
}
@Test
public
void
handerMappingsCreated
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
WebMvcAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
6
,
this
.
context
.
getBeanNamesForType
(
HandlerMapping
.
class
).
length
);
}
@Test
public
void
viewResolversCreatedIfViewsPresent
()
throws
Exception
{
this
.
context
=
new
AnnotationConfigEmbeddedWebApplicationContext
();
this
.
context
.
register
(
Config
.
class
,
ViewConfig
.
class
,
WebMvcAutoConfiguration
.
class
);
this
.
context
.
refresh
();
assertEquals
(
2
,
this
.
context
.
getBeanNamesForType
(
ViewResolver
.
class
).
length
);
}
@Configuration
protected
static
class
ViewConfig
{
@Bean
public
View
jsonView
()
{
return
new
AbstractView
()
{
@Override
protected
void
renderMergedOutputModel
(
Map
<
String
,
Object
>
model
,
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
response
.
getOutputStream
().
write
(
"Hello World"
.
getBytes
());
}
};
}
}
@Configuration
protected
static
class
Config
{
@Bean
public
EmbeddedServletContainerFactory
containerFactory
()
{
return
containerFactory
;
}
@Bean
public
EmbeddedServletContainerCustomizerBeanPostProcessor
embeddedServletContainerCustomizerBeanPostProcessor
()
{
return
new
EmbeddedServletContainerCustomizerBeanPostProcessor
();
}
}
}
}
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