[ https://issues.apache.org/jira/browse/DELTASPIKE-707?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15228147#comment-15228147 ]
John D. Ament commented on DELTASPIKE-707: ------------------------------------------ [~famod] this ticket's been closed for a really long time. I'd suggest bringing it up on the discussion channels (dev@ or user@) to brain storm ideas. I'm curious to see what you have, as I have needs to do something similar. > AbstractMockManager does not support interfaces mocked by mockito > ----------------------------------------------------------------- > > Key: DELTASPIKE-707 > URL: https://issues.apache.org/jira/browse/DELTASPIKE-707 > Project: DeltaSpike > Issue Type: Bug > Components: TestControl > Affects Versions: 1.0.2 > Environment: Mockito 1.9.5 > JDK 1.7u51 > Reporter: Falko Modler > > Following the > [manual|https://deltaspike.apache.org/test-control.html#mock-frameworks], I > tried to mock {{EntitityManager}} in my test class: > {noformat} > @RunWith(CdiTestRunner.class) > public class SomeTest { > @Inject > private DynamicMockManager mockManager; > @Test > public void mockitoMockAsCdiBean() { > mockManager.addMock(Mockito.mock(EntityManager.class)); > [...] > } > } > {noformat} > Unfortunately this doesn't work as {{AbstractMockManager}} fails with: > {noformat} > java.lang.IllegalArgumentException: > $javax.persistence.EntityManager$$EnhancerByMockitoWithCGLIB$$b065dd9c isn't > a supported approach for mocking -> please extend from the original class. > at > org.apache.deltaspike.testcontrol.impl.mock.AbstractMockManager.addMock(AbstractMockManager.java:45) > {noformat} > Following (rather ugly) workaound fixes the problem: > {noformat} > @Typed(EntityManager.class) > public static abstract class EntityManagerMockBase implements > EntityManager { > } > {noformat} > {noformat} > mockManager.addMock(Mockito.mock(EntityManagerMockBase.class)); > {noformat} > If this problem cannot be solved then the documentation should at least > mention that mocking does not work for interfaces and how to work around that. -- This message was sent by Atlassian JIRA (v6.3.4#6332)