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
dfd477aa
Commit
dfd477aa
authored
Dec 11, 2018
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.1.x'
parents
d77b52ca
38e4d330
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
31 deletions
+5
-31
SpyBeanWithAopProxyTests.java
...work/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java
+5
-31
No files found.
spring-boot-project/spring-boot-test/src/test/java/org/springframework/boot/test/mock/mockito/SpyBeanWithAopProxyTests.java
View file @
dfd477aa
/*
/*
* 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.
...
@@ -16,12 +16,10 @@
...
@@ -16,12 +16,10 @@
package
org
.
springframework
.
boot
.
test
.
mock
.
mockito
;
package
org
.
springframework
.
boot
.
test
.
mock
.
mockito
;
import
java.lang.reflect.Method
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.Test
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.junit.jupiter.api.extension.ExtendWith
;
import
org.mockito.ArgumentMatchers
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.CacheManager
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.cache.annotation.Cacheable
;
...
@@ -34,10 +32,10 @@ import org.springframework.context.annotation.Configuration;
...
@@ -34,10 +32,10 @@ import org.springframework.context.annotation.Configuration;
import
org.springframework.context.annotation.Import
;
import
org.springframework.context.annotation.Import
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.test.context.junit.jupiter.SpringExtension
;
import
org.springframework.util.ClassUtils
;
import
org.springframework.util.ReflectionUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
ArgumentMatchers
.
anyBoolean
;
import
static
org
.
mockito
.
ArgumentMatchers
.
eq
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
times
;
import
static
org
.
mockito
.
Mockito
.
verify
;
import
static
org
.
mockito
.
Mockito
.
verify
;
...
@@ -60,32 +58,8 @@ public class SpyBeanWithAopProxyTests {
...
@@ -60,32 +58,8 @@ public class SpyBeanWithAopProxyTests {
Long
d2
=
this
.
dateService
.
getDate
(
false
);
Long
d2
=
this
.
dateService
.
getDate
(
false
);
assertThat
(
d1
).
isEqualTo
(
d2
);
assertThat
(
d1
).
isEqualTo
(
d2
);
verify
(
this
.
dateService
,
times
(
1
)).
getDate
(
false
);
verify
(
this
.
dateService
,
times
(
1
)).
getDate
(
false
);
verify
(
this
.
dateService
,
times
(
1
)).
getDate
(
matchesFalse
());
verify
(
this
.
dateService
,
times
(
1
)).
getDate
(
eq
(
false
));
verify
(
this
.
dateService
,
times
(
1
)).
getDate
(
matchesAnyBoolean
());
verify
(
this
.
dateService
,
times
(
1
)).
getDate
(
anyBoolean
());
}
private
boolean
matchesFalse
()
{
if
(
isTestingMockito1
())
{
Method
method
=
ReflectionUtils
.
findMethod
(
ClassUtils
.
resolveClassName
(
"org.mockito.Matchers"
,
null
),
"eq"
,
Boolean
.
TYPE
);
return
(
boolean
)
ReflectionUtils
.
invokeMethod
(
method
,
null
,
false
);
}
return
ArgumentMatchers
.
eq
(
false
);
}
private
boolean
matchesAnyBoolean
()
{
if
(
isTestingMockito1
())
{
Method
method
=
ReflectionUtils
.
findMethod
(
ClassUtils
.
resolveClassName
(
"org.mockito.Matchers"
,
null
),
"anyBoolean"
);
return
(
boolean
)
ReflectionUtils
.
invokeMethod
(
method
,
null
);
}
return
ArgumentMatchers
.
anyBoolean
();
}
private
boolean
isTestingMockito1
()
{
return
ClassUtils
.
isPresent
(
"org.mockito.ReturnValues"
,
null
);
}
}
@Configuration
@Configuration
...
...
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