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
c1675c2d
Commit
c1675c2d
authored
Jan 28, 2018
by
dreis2211
Committed by
Stephane Nicoll
Jan 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use InvocationOnMock.getArgument() where possible
Closes gh-11818
parent
fac89703
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
9 deletions
+9
-9
MockCachingProvider.java
...boot/autoconfigure/cache/support/MockCachingProvider.java
+3
-3
MockRestarter.java
.../springframework/boot/devtools/restart/MockRestarter.java
+2
-2
HttpTunnelServerTests.java
...rk/boot/devtools/tunnel/server/HttpTunnelServerTests.java
+2
-2
MockServletWebServer.java
...rk/boot/testsupport/web/servlet/MockServletWebServer.java
+2
-2
No files found.
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/cache/support/MockCachingProvider.java
View file @
c1675c2d
/*
/*
* 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.
...
@@ -50,12 +50,12 @@ public class MockCachingProvider implements CachingProvider {
...
@@ -50,12 +50,12 @@ public class MockCachingProvider implements CachingProvider {
final
Map
<
String
,
Cache
>
caches
=
new
HashMap
<>();
final
Map
<
String
,
Cache
>
caches
=
new
HashMap
<>();
given
(
cacheManager
.
getCacheNames
()).
willReturn
(
caches
.
keySet
());
given
(
cacheManager
.
getCacheNames
()).
willReturn
(
caches
.
keySet
());
given
(
cacheManager
.
getCache
(
anyString
())).
willAnswer
((
invocation
)
->
{
given
(
cacheManager
.
getCache
(
anyString
())).
willAnswer
((
invocation
)
->
{
String
cacheName
=
(
String
)
invocation
.
getArguments
()[
0
]
;
String
cacheName
=
invocation
.
getArgument
(
0
)
;
return
caches
.
get
(
cacheName
);
return
caches
.
get
(
cacheName
);
});
});
given
(
cacheManager
.
createCache
(
anyString
(),
any
(
Configuration
.
class
)))
given
(
cacheManager
.
createCache
(
anyString
(),
any
(
Configuration
.
class
)))
.
will
((
invocation
)
->
{
.
will
((
invocation
)
->
{
String
cacheName
=
(
String
)
invocation
.
getArguments
()[
0
]
;
String
cacheName
=
invocation
.
getArgument
(
0
)
;
Cache
cache
=
mock
(
Cache
.
class
);
Cache
cache
=
mock
(
Cache
.
class
);
given
(
cache
.
getName
()).
willReturn
(
cacheName
);
given
(
cache
.
getName
()).
willReturn
(
cacheName
);
caches
.
put
(
cacheName
,
cache
);
caches
.
put
(
cacheName
,
cache
);
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/MockRestarter.java
View file @
c1675c2d
...
@@ -62,8 +62,8 @@ public class MockRestarter implements TestRule {
...
@@ -62,8 +62,8 @@ public class MockRestarter implements TestRule {
given
(
this
.
mock
.
getInitialUrls
()).
willReturn
(
new
URL
[]
{});
given
(
this
.
mock
.
getInitialUrls
()).
willReturn
(
new
URL
[]
{});
given
(
this
.
mock
.
getOrAddAttribute
(
anyString
(),
any
(
ObjectFactory
.
class
)))
given
(
this
.
mock
.
getOrAddAttribute
(
anyString
(),
any
(
ObjectFactory
.
class
)))
.
willAnswer
((
invocation
)
->
{
.
willAnswer
((
invocation
)
->
{
String
name
=
(
String
)
invocation
.
getArguments
()[
0
]
;
String
name
=
invocation
.
getArgument
(
0
)
;
ObjectFactory
factory
=
(
ObjectFactory
)
invocation
.
getArguments
()[
1
]
;
ObjectFactory
factory
=
invocation
.
getArgument
(
1
)
;
Object
attribute
=
MockRestarter
.
this
.
attributes
.
get
(
name
);
Object
attribute
=
MockRestarter
.
this
.
attributes
.
get
(
name
);
if
(
attribute
==
null
)
{
if
(
attribute
==
null
)
{
attribute
=
factory
.
getObject
();
attribute
=
factory
.
getObject
();
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/tunnel/server/HttpTunnelServerTests.java
View file @
c1675c2d
/*
/*
* 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.
...
@@ -90,7 +90,7 @@ public class HttpTunnelServerTests {
...
@@ -90,7 +90,7 @@ public class HttpTunnelServerTests {
this
.
server
=
new
HttpTunnelServer
(
this
.
serverConnection
);
this
.
server
=
new
HttpTunnelServer
(
this
.
serverConnection
);
given
(
this
.
serverConnection
.
open
(
anyInt
())).
willAnswer
((
invocation
)
->
{
given
(
this
.
serverConnection
.
open
(
anyInt
())).
willAnswer
((
invocation
)
->
{
MockServerChannel
channel
=
HttpTunnelServerTests
.
this
.
serverChannel
;
MockServerChannel
channel
=
HttpTunnelServerTests
.
this
.
serverChannel
;
channel
.
setTimeout
(
(
Integer
)
invocation
.
getArguments
()[
0
]
);
channel
.
setTimeout
(
invocation
.
getArgument
(
0
)
);
return
channel
;
return
channel
;
});
});
this
.
servletRequest
=
new
MockHttpServletRequest
();
this
.
servletRequest
=
new
MockHttpServletRequest
();
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java
View file @
c1675c2d
...
@@ -69,7 +69,7 @@ public abstract class MockServletWebServer {
...
@@ -69,7 +69,7 @@ public abstract class MockServletWebServer {
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
any
(
Servlet
.
class
)))
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
any
(
Servlet
.
class
)))
.
willAnswer
((
invocation
)
->
{
.
willAnswer
((
invocation
)
->
{
RegisteredServlet
registeredServlet
=
new
RegisteredServlet
(
RegisteredServlet
registeredServlet
=
new
RegisteredServlet
(
(
Servlet
)
invocation
.
getArguments
()[
1
]
);
invocation
.
getArgument
(
1
)
);
MockServletWebServer
.
this
.
registeredServlets
MockServletWebServer
.
this
.
registeredServlets
.
add
(
registeredServlet
);
.
add
(
registeredServlet
);
return
registeredServlet
.
getRegistration
();
return
registeredServlet
.
getRegistration
();
...
@@ -77,7 +77,7 @@ public abstract class MockServletWebServer {
...
@@ -77,7 +77,7 @@ public abstract class MockServletWebServer {
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
any
(
Filter
.
class
)))
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
any
(
Filter
.
class
)))
.
willAnswer
((
invocation
)
->
{
.
willAnswer
((
invocation
)
->
{
RegisteredFilter
registeredFilter
=
new
RegisteredFilter
(
RegisteredFilter
registeredFilter
=
new
RegisteredFilter
(
(
Filter
)
invocation
.
getArguments
()[
1
]
);
invocation
.
getArgument
(
1
)
);
MockServletWebServer
.
this
.
registeredFilters
.
add
(
registeredFilter
);
MockServletWebServer
.
this
.
registeredFilters
.
add
(
registeredFilter
);
return
registeredFilter
.
getRegistration
();
return
registeredFilter
.
getRegistration
();
});
});
...
...
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