title: Easy mock does not recognize mocked service
body: <p>I encounter this strange issues while testing one of my services...
  I am mocking two services with easymock 3.0 and injecting them with Spring, but i get a "java.lang.IllegalArgumentException: Not a mock: $Proxy43" exception at one of them. I am declaring them the same way in my configuration file, like this:</p>
  
  <pre><code>&lt;bean id="recurringSchedulesJobsService" class="org.easymock.EasyMock" factory-method="createMock"&gt;
      &lt;constructor-arg value="com.spmsoftware.recurringschedules.service.RecurringSchedulesJobsService"/&gt;
  &lt;/bean&gt;
  
  &lt;bean id="jobPeriodService" class="org.easymock.EasyMock" factory-method="createMock"&gt;
      &lt;constructor-arg value="com.spmsoftware.jobdefinition.service.JobPeriodService"/&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>In my junit tests, i'm using them the folowing way:</p>
  
  <pre><code>@Autowired
  private RecurringSchedulesJobsService recurringSchedulesJobsService;
  @Autowired
  private JobPeriodService jobPeriodService;
  
  @Before
  public void setUp() throws Exception {
      reset(recurringSchedulesJobsService);
      expect(recurringSchedulesJobsService.getBasedOnRecurringScheduleId(RECURRING_SCHEDULE_ID)).andReturn(buildRecurringScheduleJob());
      replay(recurringSchedulesJobsService);
  
      reset(jobPeriodService);
      expect(jobPeriodService.findPeriodByJobId(RECURRING_SCHEDULE_JOB_ID)).andReturn(buildJobDefinitionPeriod());
      replay(jobPeriodService);
  }
  </code></pre>
  
  <p>recurringSchedulesJobsService gets mocked and when i comment the second service, it behaves as expected. jobPeriodService, on the other hand, is not recognized as a mock. Instead i get this exception:</p>
  
  <pre><code>java.lang.IllegalArgumentException: Not a mock: $Proxy43
  at org.easymock.internal.ClassExtensionHelper.getControl(ClassExtensionHelper.java:66)
  at org.easymock.EasyMock.getControl(EasyMock.java:2068)
  at org.easymock.EasyMock.reset(EasyMock.java:1983)
  at com.spmsoftware.recurringschedules.occurrences.generator.OccurrenceGeneratorTest.setUp(OccurrenceGeneratorTest.java:64)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
  at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
  at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
  at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
  at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27)
  at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:74)
  at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:83)
  at org.springframework.test.context.junit4.statements.SpringRepeat.evaluate(SpringRepeat.java:72)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.runChild(SpringJUnit4ClassRunner.java:231)
  at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
  at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
  at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
  at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
  at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
  at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
  at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
  at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:71)
  at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
  at org.springframework.test.context.junit4.SpringJUnit4ClassRunner.run(SpringJUnit4ClassRunner.java:174)
  at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
  at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
  </code></pre>
  
  <p>The exception is thrown only be the reset() method, though...</p>
  
  <p>One interesting thing i found is that the two objects are not of the same instance. This is what i get when debugging:</p>
  
  <p><img src="https://i.stack.imgur.com/DQCdJ.png" alt="enter image description here"></p>
  
  <p>Any ideas on this would be very valuable.
  Thanks</p>