title: How to EasyMock a call to a method that returns a wildcarded generic?
body: <p>We're looking at switching to Spring 3.0 and running into problems with the intersection of Spring 3.0, EasyMock, and Java Generics.</p>
  
  <p>In one place, we're mocking a Spring 3.0 AbstractBeanFactory, specifically this method:</p>
  
  <pre><code>public Class&lt;?&gt; getType(String name) throws NoSuchBeanDefinitionException { ... }
  </code></pre>
  
  <p>Under earlier versions of Spring, this returns a non-generic and all was well.  With the generic, however, we run into trouble with this:</p>
  
  <pre><code>expect(mockBeanFactory.getType(CLASS_NAME)).andReturn(SOME_CLASS);
  </code></pre>
  
  <p>Because <code>getType</code> returns <code>Class&lt;?&gt;</code>, <code>andReturn</code> requires <code>Class&lt;?&gt;</code> as a parameter, which simply doesn't work properly.</p>
  
  <p>Is there a known workaround to this?</p>