public void testConstructorAutowiring() {
    ApplicationContext context =
        new ClassPathXmlApplicationContext("explicit/jsr330/service-constructor-dependency.xml");

    MyService service = context.getBean(ServiceWithConstructorDependency.class);

    assertNotNull(
        "Please inject a repository using @Inject on the constructor", service.getRepository());
  }
  public void testFieldAutowiring() {
    ApplicationContext context =
        new ClassPathXmlApplicationContext(
            "explicit/jsr330/services-property-and-field-dependencies.xml");

    MyService service = context.getBean(ServiceWithFieldDependency.class);

    assertNotNull(
        "Please inject a repository into the service using @Inject", service.getRepository());
  }
  public void testNamedDependency() {
    ApplicationContext context =
        new ClassPathXmlApplicationContext("explicit/jsr330/service-named-property-dependency.xml");

    MyService service = context.getBean(ServiceWithNamedDependency.class);

    assertNotNull(
        "Use @Named to select which repository to inject into the service (use 'firstRepository')",
        service.getRepository());
    assertTrue(
        "Please inject firstRepository into the service",
        context.getBean("firstRepository") == service.getRepository());
  }