使用Spring@Configuration设置Easymock以便模拟EntityManagerFactory对象?

使用Spring@Configuration设置Easymock以便模拟EntityManagerFactory对象?,spring,unit-testing,easymock,Spring,Unit Testing,Easymock,我想设置我的Spring单元测试,以自动使用EasyMock模拟EntityManagerFactory对象,而无需在@Configuration中定义这些对象 我已经知道了如何设置Spring,以便它自动为任何未定义的普通对象使用EasyMock.createMock See https://stackoverflow.com/questions/17687240/spring-delegate-to-custom-proxy-wrapper-for-interface-injection

我想设置我的Spring单元测试,以自动使用EasyMock模拟EntityManagerFactory对象,而无需在@Configuration中定义这些对象

我已经知道了如何设置Spring,以便它自动为任何未定义的普通对象使用EasyMock.createMock

See  https://stackoverflow.com/questions/17687240/spring-delegate-to-custom-proxy-wrapper-for-interface-injection
这需要创建我自己的SimpleAutowireCandidateResolver,它为默认AutowireCandidateResolver.getSuggestedValue调用未定义的任何对象调用EasyMock.createMock

然而,事实证明EntityManagerFactory对象不使用getSuggestedValue

如果我将以下内容添加到Spring@配置中,它可以正常工作:

@Bean
public EntityManagerFactory someUnitNameIDefined() {return EasyMock.createMock(EntityManagerFactory.class);}
然而,我在不同的项目中有很多实体管理器,我只希望对于我在@Configuration中没有定义自己的任何实体管理器,它默认为上述行为

是否有类似DefaultListableBeanFactory.setAutowireCandidateResolver的东西可用于PersistenceAnnotationBeanPostProcessor(似乎是解析实体管理器的类)