私のコントローラーにクリーンな単体テストを提供しようとしています。この Controller には依存関係として Service があり、この Serviceh には依存関係として Datasource があります。
テストは次のようになります。
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration
public class ContentActionWebServiceControllerTest {
  @Autowired
  private WebApplicationContext wac;
  private MockMvc mockMvc;
  @Autowired
  private MyService myService;
  @Test
  public void getRequestActionList() throws Exception {
    when(...)
    perform(...);
    verify(...);
  }
  @Configuration
  @ImportResource("...")
  static class MyTestConfiguration {
    @Bean
    public MyService myService() {
      return Mockito.mock(MyService.class);
    }
  }
}
そして MyService は次のようなものです
@Service
public class MyService {
  @Autowired
  private MyDataSource myDatasource;
  ...
}
MyService は Autowired プロパティ MyDataSource であるため、MyService の @Autowired アノテーションを満たす MyDataSource タイプが見つからないため、コンテキストは初期化されません。しかし、なぜこの注釈を解決しようとするのでしょうか? これはモックですか?