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
a7663c88
Commit
a7663c88
authored
Jan 28, 2018
by
dreis2211
Committed by
Stephane Nicoll
Jan 29, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace casted Mockito.any() calls
Closes gh-11817
parent
ab02e48c
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
41 additions
and
41 deletions
+41
-41
AuthenticationAuditListenerTests.java
...ot/actuate/security/AuthenticationAuditListenerTests.java
+2
-2
RemoteClientConfigurationTests.java
...evtools/remote/client/RemoteClientConfigurationTests.java
+3
-3
MockRestarter.java
.../springframework/boot/devtools/restart/MockRestarter.java
+2
-2
OnInitializedRestarterConditionTests.java
...evtools/restart/OnInitializedRestarterConditionTests.java
+2
-2
MockitoTestExecutionListenerTests.java
.../test/mock/mockito/MockitoTestExecutionListenerTests.java
+2
-2
RootUriRequestExpectationManagerTests.java
...est/web/client/RootUriRequestExpectationManagerTests.java
+2
-2
TestRestTemplateTests.java
...framework/boot/test/web/client/TestRestTemplateTests.java
+2
-2
MockServletWebServer.java
...rk/boot/testsupport/web/servlet/MockServletWebServer.java
+3
-3
ConcurrentReferenceCachingMetadataReaderFactoryTests.java
...ConcurrentReferenceCachingMetadataReaderFactoryTests.java
+3
-3
RestTemplateBuilderTests.java
...ngframework/boot/web/client/RestTemplateBuilderTests.java
+1
-1
RootUriTemplateHandlerTests.java
...ramework/boot/web/client/RootUriTemplateHandlerTests.java
+2
-2
UndertowServletWebServerFactoryTests.java
...bedded/undertow/UndertowServletWebServerFactoryTests.java
+3
-3
AbstractFilterRegistrationBeanTests.java
...boot/web/servlet/AbstractFilterRegistrationBeanTests.java
+2
-2
ServletRegistrationBeanTests.java
...mework/boot/web/servlet/ServletRegistrationBeanTests.java
+5
-5
ServletWebServerApplicationContextTests.java
...vlet/context/ServletWebServerApplicationContextTests.java
+6
-6
AbstractServletWebServerFactoryTests.java
.../servlet/server/AbstractServletWebServerFactoryTests.java
+1
-1
No files found.
spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/security/AuthenticationAuditListenerTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -68,7 +68,7 @@ public class AuthenticationAuditListenerTests {
this
.
listener
.
onApplicationEvent
(
new
InteractiveAuthenticationSuccessEvent
(
new
UsernamePasswordAuthenticationToken
(
"user"
,
"password"
),
getClass
()));
// No need to audit this one (it shadows a regular AuthenticationSuccessEvent)
verify
(
this
.
publisher
,
never
()).
publishEvent
(
(
ApplicationEvent
)
any
(
));
verify
(
this
.
publisher
,
never
()).
publishEvent
(
any
(
ApplicationEvent
.
class
));
}
@Test
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/remote/client/RemoteClientConfigurationTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -178,8 +178,8 @@ public class RemoteClientConfigurationTests {
public
Dispatcher
dispatcher
()
throws
IOException
{
Dispatcher
dispatcher
=
mock
(
Dispatcher
.
class
);
ServerHttpRequest
anyRequest
=
(
ServerHttpRequest
)
any
(
);
ServerHttpResponse
anyResponse
=
(
ServerHttpResponse
)
any
(
);
ServerHttpRequest
anyRequest
=
any
(
ServerHttpRequest
.
class
);
ServerHttpResponse
anyResponse
=
any
(
ServerHttpResponse
.
class
);
given
(
dispatcher
.
handle
(
anyRequest
,
anyResponse
)).
willReturn
(
true
);
return
dispatcher
;
}
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/MockRestarter.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -60,7 +60,7 @@ public class MockRestarter implements TestRule {
private
void
setup
()
{
Restarter
.
setInstance
(
this
.
mock
);
given
(
this
.
mock
.
getInitialUrls
()).
willReturn
(
new
URL
[]
{});
given
(
this
.
mock
.
getOrAddAttribute
(
anyString
(),
(
ObjectFactory
)
any
(
)))
given
(
this
.
mock
.
getOrAddAttribute
(
anyString
(),
any
(
ObjectFactory
.
class
)))
.
willAnswer
((
invocation
)
->
{
String
name
=
(
String
)
invocation
.
getArguments
()[
0
];
ObjectFactory
factory
=
(
ObjectFactory
)
invocation
.
getArguments
()[
1
];
...
...
spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/restart/OnInitializedRestarterConditionTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -78,7 +78,7 @@ public class OnInitializedRestarterConditionTests {
public
static
void
main
(
String
...
args
)
{
RestartInitializer
initializer
=
mock
(
RestartInitializer
.
class
);
given
(
initializer
.
getInitialUrls
(
(
Thread
)
any
(
))).
willReturn
(
new
URL
[
0
]);
given
(
initializer
.
getInitialUrls
(
any
(
Thread
.
class
))).
willReturn
(
new
URL
[
0
]);
Restarter
.
initialize
(
new
String
[
0
],
false
,
initializer
);
ConfigurableApplicationContext
context
=
new
AnnotationConfigApplicationContext
(
Config
.
class
);
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/MockitoTestExecutionListenerTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -74,7 +74,7 @@ public class MockitoTestExecutionListenerTests {
WithMockBean
instance
=
new
WithMockBean
();
this
.
listener
.
prepareTestInstance
(
mockTestContext
(
instance
));
verify
(
this
.
postProcessor
).
inject
(
this
.
fieldCaptor
.
capture
(),
eq
(
instance
),
(
MockDefinition
)
any
(
));
any
(
MockDefinition
.
class
));
assertThat
(
this
.
fieldCaptor
.
getValue
().
getName
()).
isEqualTo
(
"mockBean"
);
}
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/RootUriRequestExpectationManagerTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -118,7 +118,7 @@ public class RootUriRequestExpectationManagerTests {
throws
Exception
{
ClientHttpRequest
request
=
mock
(
ClientHttpRequest
.
class
);
given
(
request
.
getURI
()).
willReturn
(
new
URI
(
this
.
uri
+
"/hello"
));
given
(
this
.
delegate
.
validateRequest
(
(
ClientHttpRequest
)
any
(
)))
given
(
this
.
delegate
.
validateRequest
(
any
(
ClientHttpRequest
.
class
)))
.
willThrow
(
new
AssertionError
(
"Request URI expected:</hello> was:<http://example.com/bad>"
));
this
.
thrown
.
expect
(
AssertionError
.
class
);
...
...
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java
View file @
a7663c88
...
...
@@ -336,7 +336,7 @@ public class TestRestTemplateTests {
request
.
setResponse
(
new
MockClientHttpResponse
(
new
byte
[
0
],
HttpStatus
.
OK
));
URI
absoluteUri
=
URI
.
create
(
"http://localhost:8080/a/b/c.txt?param=%7Bsomething%7D"
);
given
(
requestFactory
.
createRequest
(
eq
(
absoluteUri
),
(
HttpMethod
)
any
(
)))
given
(
requestFactory
.
createRequest
(
eq
(
absoluteUri
),
any
(
HttpMethod
.
class
)))
.
willReturn
(
request
);
RestTemplate
delegate
=
new
RestTemplate
();
TestRestTemplate
template
=
new
TestRestTemplate
(
delegate
);
...
...
@@ -346,7 +346,7 @@ public class TestRestTemplateTests {
template
.
setUriTemplateHandler
(
uriTemplateHandler
);
callback
.
doWithTestRestTemplate
(
template
,
URI
.
create
(
"/a/b/c.txt?param=%7Bsomething%7D"
));
verify
(
requestFactory
).
createRequest
(
eq
(
absoluteUri
),
(
HttpMethod
)
any
(
));
verify
(
requestFactory
).
createRequest
(
eq
(
absoluteUri
),
any
(
HttpMethod
.
class
));
}
private
void
assertBasicAuthorizationInterceptorCredentials
(
...
...
spring-boot-project/spring-boot-tools/spring-boot-test-support/src/main/java/org/springframework/boot/testsupport/web/servlet/MockServletWebServer.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -66,7 +66,7 @@ public abstract class MockServletWebServer {
private
void
initialize
()
{
try
{
this
.
servletContext
=
mock
(
ServletContext
.
class
);
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
(
Servlet
)
any
(
)))
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
any
(
Servlet
.
class
)))
.
willAnswer
((
invocation
)
->
{
RegisteredServlet
registeredServlet
=
new
RegisteredServlet
(
(
Servlet
)
invocation
.
getArguments
()[
1
]);
...
...
@@ -74,7 +74,7 @@ public abstract class MockServletWebServer {
.
add
(
registeredServlet
);
return
registeredServlet
.
getRegistration
();
});
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
(
Filter
)
any
(
)))
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
any
(
Filter
.
class
)))
.
willAnswer
((
invocation
)
->
{
RegisteredFilter
registeredFilter
=
new
RegisteredFilter
(
(
Filter
)
invocation
.
getArguments
()[
1
]);
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/type/classreading/ConcurrentReferenceCachingMetadataReaderFactoryTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -43,7 +43,7 @@ public class ConcurrentReferenceCachingMetadataReaderFactoryTests {
MetadataReader
metadataReader1
=
factory
.
getMetadataReader
(
getClass
().
getName
());
MetadataReader
metadataReader2
=
factory
.
getMetadataReader
(
getClass
().
getName
());
assertThat
(
metadataReader1
).
isSameAs
(
metadataReader2
);
verify
(
factory
,
times
(
1
)).
createMetadataReader
(
(
Resource
)
any
(
));
verify
(
factory
,
times
(
1
)).
createMetadataReader
(
any
(
Resource
.
class
));
}
@Test
...
...
@@ -54,7 +54,7 @@ public class ConcurrentReferenceCachingMetadataReaderFactoryTests {
factory
.
clearCache
();
MetadataReader
metadataReader2
=
factory
.
getMetadataReader
(
getClass
().
getName
());
assertThat
(
metadataReader1
).
isNotEqualTo
(
sameInstance
(
metadataReader2
));
verify
(
factory
,
times
(
2
)).
createMetadataReader
(
(
Resource
)
any
(
));
verify
(
factory
,
times
(
2
)).
createMetadataReader
(
any
(
Resource
.
class
));
}
private
static
class
TestConcurrentReferenceCachingMetadataReaderFactory
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RestTemplateBuilderTests.java
View file @
a7663c88
...
...
@@ -350,7 +350,7 @@ public class RestTemplateBuilderTests {
public
void
customizersShouldBeAppliedLast
()
{
RestTemplate
template
=
spy
(
new
RestTemplate
());
this
.
builder
.
additionalCustomizers
((
restTemplate
)
->
verify
(
restTemplate
)
.
setRequestFactory
(
(
ClientHttpRequestFactory
)
any
(
)));
.
setRequestFactory
(
any
(
ClientHttpRequestFactory
.
class
)));
this
.
builder
.
configure
(
template
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/client/RootUriTemplateHandlerTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -61,7 +61,7 @@ public class RootUriTemplateHandlerTests {
this
.
uri
=
new
URI
(
"http://example.com/hello"
);
this
.
handler
=
new
RootUriTemplateHandler
(
"http://example.com"
,
this
.
delegate
);
given
(
this
.
delegate
.
expand
(
anyString
(),
any
(
Map
.
class
))).
willReturn
(
this
.
uri
);
given
(
this
.
delegate
.
expand
(
anyString
(),
(
Object
[])
any
(
))).
willReturn
(
this
.
uri
);
given
(
this
.
delegate
.
expand
(
anyString
(),
any
(
Object
[].
class
))).
willReturn
(
this
.
uri
);
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/undertow/UndertowServletWebServerFactoryTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -106,7 +106,7 @@ public class UndertowServletWebServerFactoryTests
this
.
webServer
=
factory
.
getWebServer
();
InOrder
ordered
=
inOrder
((
Object
[])
customizers
);
for
(
UndertowBuilderCustomizer
customizer
:
customizers
)
{
ordered
.
verify
(
customizer
).
customize
(
(
Builder
)
any
(
));
ordered
.
verify
(
customizer
).
customize
(
any
(
Builder
.
class
));
}
}
...
...
@@ -139,7 +139,7 @@ public class UndertowServletWebServerFactoryTests
this
.
webServer
=
factory
.
getWebServer
();
InOrder
ordered
=
inOrder
((
Object
[])
customizers
);
for
(
UndertowDeploymentInfoCustomizer
customizer
:
customizers
)
{
ordered
.
verify
(
customizer
).
customize
(
(
DeploymentInfo
)
any
(
));
ordered
.
verify
(
customizer
).
customize
(
any
(
DeploymentInfo
.
class
));
}
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/AbstractFilterRegistrationBeanTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -61,7 +61,7 @@ public abstract class AbstractFilterRegistrationBeanTests {
@Before
public
void
setupMocks
()
{
MockitoAnnotations
.
initMocks
(
this
);
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
(
Filter
)
any
(
)))
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
any
(
Filter
.
class
)))
.
willReturn
(
this
.
registration
);
}
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/ServletRegistrationBeanTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -68,9 +68,9 @@ public class ServletRegistrationBeanTests {
@Before
public
void
setupMocks
()
{
MockitoAnnotations
.
initMocks
(
this
);
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
(
Servlet
)
any
(
)))
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
any
(
Servlet
.
class
)))
.
willReturn
(
this
.
registration
);
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
(
Filter
)
any
(
)))
given
(
this
.
servletContext
.
addFilter
(
anyString
(),
any
(
Filter
.
class
)))
.
willReturn
(
this
.
filterRegistration
);
}
...
...
@@ -88,7 +88,7 @@ public class ServletRegistrationBeanTests {
public
void
startupWithDoubleRegistration
()
throws
Exception
{
ServletRegistrationBean
<
MockServlet
>
bean
=
new
ServletRegistrationBean
<>(
this
.
servlet
);
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
(
Servlet
)
any
(
)))
given
(
this
.
servletContext
.
addServlet
(
anyString
(),
any
(
Servlet
.
class
)))
.
willReturn
(
null
);
bean
.
onStartup
(
this
.
servletContext
);
verify
(
this
.
servletContext
).
addServlet
(
"mockServlet"
,
this
.
servlet
);
...
...
@@ -207,7 +207,7 @@ public class ServletRegistrationBeanTests {
ServletRegistrationBean
<
MockServlet
>
bean
=
new
ServletRegistrationBean
<>(
this
.
servlet
,
false
);
bean
.
onStartup
(
this
.
servletContext
);
verify
(
this
.
registration
,
never
()).
addMapping
(
(
String
[])
any
(
));
verify
(
this
.
registration
,
never
()).
addMapping
(
any
(
String
[].
class
));
}
}
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/context/ServletWebServerApplicationContextTests.java
View file @
a7663c88
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -371,8 +371,8 @@ public class ServletWebServerApplicationContextTests {
this
.
context
.
refresh
();
ServletContext
servletContext
=
getWebServerFactory
().
getServletContext
();
verify
(
initializer
).
onStartup
(
servletContext
);
verify
(
servletContext
).
addServlet
(
anyString
(),
(
Servlet
)
any
(
));
verify
(
servletContext
).
addFilter
(
anyString
(),
(
Filter
)
any
(
));
verify
(
servletContext
).
addServlet
(
anyString
(),
any
(
Servlet
.
class
));
verify
(
servletContext
).
addFilter
(
anyString
(),
any
(
Filter
.
class
));
}
@Test
...
...
@@ -388,8 +388,8 @@ public class ServletWebServerApplicationContextTests {
this
.
context
.
registerBeanDefinition
(
"filterBean"
,
beanDefinition
(
filter
));
this
.
context
.
refresh
();
ServletContext
servletContext
=
getWebServerFactory
().
getServletContext
();
verify
(
servletContext
,
atMost
(
1
)).
addServlet
(
anyString
(),
(
Servlet
)
any
(
));
verify
(
servletContext
,
atMost
(
1
)).
addFilter
(
anyString
(),
(
Filter
)
any
(
));
verify
(
servletContext
,
atMost
(
1
)).
addServlet
(
anyString
(),
any
(
Servlet
.
class
));
verify
(
servletContext
,
atMost
(
1
)).
addFilter
(
anyString
(),
any
(
Filter
.
class
));
}
@Test
...
...
@@ -402,7 +402,7 @@ public class ServletWebServerApplicationContextTests {
this
.
context
.
registerBeanDefinition
(
"filterBean"
,
beanDefinition
(
filter
));
this
.
context
.
refresh
();
ServletContext
servletContext
=
getWebServerFactory
().
getServletContext
();
verify
(
servletContext
,
atMost
(
1
)).
addFilter
(
anyString
(),
(
Filter
)
any
(
));
verify
(
servletContext
,
atMost
(
1
)).
addFilter
(
anyString
(),
any
(
Filter
.
class
));
}
@Test
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/servlet/server/AbstractServletWebServerFactoryTests.java
View file @
a7663c88
...
...
@@ -313,7 +313,7 @@ public abstract class AbstractServletWebServerFactoryTests {
this
.
webServer
.
start
();
InOrder
ordered
=
inOrder
((
Object
[])
initializers
);
for
(
ServletContextInitializer
initializer
:
initializers
)
{
ordered
.
verify
(
initializer
).
onStartup
(
(
ServletContext
)
any
(
));
ordered
.
verify
(
initializer
).
onStartup
(
any
(
ServletContext
.
class
));
}
}
...
...
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