title: Force Jersey to read mocks from JerseyTest
body: <p>I want to test a Resourse with JerseyTest. I have created the following test:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(locations = "classpath:testApplicationContext.xml")
  public class ResourceTest extends JerseyTest
  {
      @Configuration
      public static class Config
      {
          @Bean
          public AObject aObject()
          {
              return mock(AObject.class);
          }
      }
  
      @Autowired
      public AObject _aObject;
  
      @Test
      public void testResource()
      {
          // configouring mock _aObject
  
          Response response = target("path");
          Assert.assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
      }
  
  
      @Override
      protected Application configure()
      {
          return new ResourceConfig(Resource.class).property("contextConfigLocation", "classpath:testApplicationContext.xml");
      }
  }
  </code></pre>
  
  <p>My Resource also has an AObject reference with <code>@Autowired</code> annotation.</p>
  
  <p>My problem is that my <code>JerseyTest</code> and the <code>Resource</code> (that is configured by the test) have different instances for the Mock object. In the console I see that the <code>testApplicationContext.xml</code> is loaded twice, once for the test and one for the Resource.</p>
  
  <p>How can I force jersey to use the same mock?</p>