I'm running PowerMock 1.6.5 and attempting to mock the creation of a AnnotationConfigApplicationContext.class object. I'm receiving the TooManyConstructorsFound exception and my attempts to resolve have continuously failed:

PowerMock.expectNew(AnnotationConfigApplicationContext.class,EasyMock.isA(MyConfig.class)).andReturn(mockedAnnotationConfigAppContext);

The error reports two constructors:

AnnotationConfigApplicationContext( org.springframework.beans.factory.support.DefaultListableBeanFactory.class )
AnnotationConfigApplicationContext( [Ljava.lang.class;.class )

I've tried running the expectNew(Class<T> type, Class parameterType, Object Arguments) but it consistently returns constructor not found errors. Frankly, I don't know what syntax is expected here. I've also tried MemberModifier.suppress(MemberMatcher.constructorsDeclaredIn(AnnotationConfigApplicationContext.class) as well but it's completely ignored and the TooManyConstructorsFound error is once again returned. Any ideas?

0 Answers