How to EasyMock a call to a method that returns a wildcarded generic?

Viewed 4845

We're looking at switching to Spring 3.0 and running into problems with the intersection of Spring 3.0, EasyMock, and Java Generics.

In one place, we're mocking a Spring 3.0 AbstractBeanFactory, specifically this method:

public Class<?> getType(String name) throws NoSuchBeanDefinitionException { ... }

Under earlier versions of Spring, this returns a non-generic and all was well. With the generic, however, we run into trouble with this:

expect(mockBeanFactory.getType(CLASS_NAME)).andReturn(SOME_CLASS);

Because getType returns Class<?>, andReturn requires Class<?> as a parameter, which simply doesn't work properly.

Is there a known workaround to this?

2 Answers
Related