ssacher-tgm / mockito

Automatically exported from code.google.com/p/mockito
0 stars 0 forks source link

Allows mocks to be AOP-ed #196

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I'd like to test an AOP advice on a mock within a Spring context. This throws a 
NotAMockException.

Currently, MockUtil.isMockitoMock() seems to be returning false if the mock 
instance was additionally enhanced by CGLIB (for example, as a result of an AOP 
advice applied on it, thought there could potentially be other use cases).

What steps will reproduce the problem?
1. Declare a Mockito mock as a Spring bean
2. Create a Spring AOP advice
3. Declare an AOP pointcut on a Spring bean from step 1
4. Try to call verify(mockBean).methodToVerify() in the test

What is the expected output? What do you see instead?
I expected a successful completion of the verify() call, got a 
NotAMockException instead.

What version of the product are you using? On what operating system?
Mockito 1.8.4, WindowsXP

Please provide any additional information below.
I realize this might be a rare use case... Thought I'd report it anyways.

Thanks!
Al

Original issue reported on code.google.com by albel...@gmail.com on 11 Jun 2010 at 2:27

GoogleCodeExporter commented 8 years ago
can you provide a tiny distro that demos this behavior? How do I declare a 
Mockito mock as a Spring bean?

Original comment by szcze...@gmail.com on 14 Jun 2010 at 9:03

GoogleCodeExporter commented 8 years ago
You won't have to ask your huge fans twice :)
- test.zip is using CGLIB directly
- springTest.zip is using Spring AOP on a Mockito bean

In order to use JdkDynamicAopProxy instead of CGLIB in the springTest example, 
remove [proxy-target-class="true"] in 
src\main\resources\spring\spring-config.xml

Thanks,
Al

Original comment by albel...@gmail.com on 15 Jun 2010 at 1:24

Attachments:

GoogleCodeExporter commented 8 years ago
Thanks for the nice zips Al :)

Will be fixed soon.

Original comment by szcze...@gmail.com on 16 Jun 2010 at 11:11

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r2020.

Original comment by szcze...@gmail.com on 16 Jun 2010 at 11:23

GoogleCodeExporter commented 8 years ago

Original comment by szcze...@gmail.com on 3 Jul 2011 at 12:43