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
360f4e17
Commit
360f4e17
authored
May 11, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support for PageableHandlerMethodArgumentResolver in WebMvcTest
Closes gh-13066
parent
5e87a3d2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
1 deletion
+59
-1
spring.factories
...utoconfigure/src/main/resources/META-INF/spring.factories
+1
-0
ExampleController2.java
...autoconfigure/web/servlet/mockmvc/ExampleController2.java
+8
-1
WebMvcTestPageableIntegrationTests.java
...b/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java
+50
-0
No files found.
spring-boot-project/spring-boot-test-autoconfigure/src/main/resources/META-INF/spring.factories
View file @
360f4e17
...
@@ -120,6 +120,7 @@ org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAut
...
@@ -120,6 +120,7 @@ org.springframework.boot.autoconfigure.web.reactive.function.client.WebClientAut
# AutoConfigureWebMvc auto-configuration imports
# AutoConfigureWebMvc auto-configuration imports
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc=\
org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc=\
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.context.MessageSourceAutoConfiguration,\
org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration,\
org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\
org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration,\
org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.groovy.template.GroovyTemplateAutoConfiguration,\
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration,\
...
...
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/ExampleController2.java
View file @
360f4e17
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
servlet
.
mockmvc
;
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
servlet
.
mockmvc
;
import
org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
;
import
org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
...
@@ -42,4 +43,10 @@ public class ExampleController2 {
...
@@ -42,4 +43,10 @@ public class ExampleController2 {
return
id
.
getId
()
+
"two"
;
return
id
.
getId
()
+
"two"
;
}
}
@GetMapping
(
"/paged"
)
@ResponseBody
public
String
paged
(
Pageable
pageable
)
{
return
String
.
format
(
"%s:%s"
,
pageable
.
getPageNumber
(),
pageable
.
getPageSize
());
}
}
}
spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/web/servlet/mockmvc/WebMvcTestPageableIntegrationTests.java
0 → 100644
View file @
360f4e17
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
test
.
autoconfigure
.
web
.
servlet
.
mockmvc
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
import
org.springframework.test.web.servlet.MockMvc
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.
get
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
content
;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.
status
;
/**
* Integration tests for {@link WebMvcTest} and Pageable support.
*
* @author Stephane Nicoll
*/
@RunWith
(
SpringRunner
.
class
)
@WebMvcTest
(
secure
=
false
)
public
class
WebMvcTestPageableIntegrationTests
{
@Autowired
private
MockMvc
mvc
;
@Test
public
void
shouldSupportPageable
()
throws
Exception
{
this
.
mvc
.
perform
(
get
(
"/paged"
).
param
(
"page"
,
"2"
).
param
(
"size"
,
"42"
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
"2:42"
));
}
}
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