Package org.springframework.context.annotation

Examples of org.springframework.context.annotation.AnnotationConfigApplicationContext.containsBean()


  }

  @Test
  public void testImportXmlWithOtherConfigurationClass() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithConfigurationClass.class);
    assertTrue("did not contain java-declared bean", ctx.containsBean("javaDeclaredBean"));
    assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
    TestBean tb = ctx.getBean("javaDeclaredBean", TestBean.class);
    assertEquals("myName", tb.getName());
  }
View Full Code Here


  @Test
  public void testImportXmlWithOtherConfigurationClass() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithConfigurationClass.class);
    assertTrue("did not contain java-declared bean", ctx.containsBean("javaDeclaredBean"));
    assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
    TestBean tb = ctx.getBean("javaDeclaredBean", TestBean.class);
    assertEquals("myName", tb.getName());
  }

  @Ignore // TODO: SPR-6327
View Full Code Here

  @Ignore // TODO: SPR-6327
  @Test
  public void testImportDifferentResourceTypes() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SubResourceConfig.class);
    assertTrue(ctx.containsBean("propertiesDeclaredBean"));
    assertTrue(ctx.containsBean("xmlDeclaredBean"));
  }

  @Test
  public void importWithPlaceholder() throws Exception {
View Full Code Here

  @Ignore // TODO: SPR-6327
  @Test
  public void testImportDifferentResourceTypes() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SubResourceConfig.class);
    assertTrue(ctx.containsBean("propertiesDeclaredBean"));
    assertTrue(ctx.containsBean("xmlDeclaredBean"));
  }

  @Test
  public void importWithPlaceholder() throws Exception {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
View Full Code Here

    PropertySource<?> propertySource = new MapPropertySource("test",
        Collections.<String, Object> singletonMap("test", "springframework"));
    ctx.getEnvironment().getPropertySources().addFirst(propertySource);
    ctx.register(ImportXmlConfig.class);
    ctx.refresh();
    assertTrue("did not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
  }

  @Test
  public void testImportXmlWithAutowiredConfig() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlAutowiredConfig.class);
View Full Code Here

  }

  @Test
  public void testImportNonXmlResource() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportNonXmlResourceConfig.class);
    assertTrue(ctx.containsBean("propertiesDeclaredBean"));
  }


  @Configuration
  @ImportResource("classpath:org/springframework/context/annotation/configuration/ImportXmlConfig-context.xml")
View Full Code Here

public class AnyNestedConditionTests {

  @Test
  public void neither() throws Exception {
    AnnotationConfigApplicationContext context = load(OnPropertyAorBCondition.class);
    assertThat(context.containsBean("myBean"), equalTo(false));
    context.close();
  }

  @Test
  public void propertyA() throws Exception {
View Full Code Here

  }

  @Test
  public void propertyA() throws Exception {
    AnnotationConfigApplicationContext context = load(Config.class, "a:a");
    assertThat(context.containsBean("myBean"), equalTo(true));
    context.close();
  }

  @Test
  public void propertyB() throws Exception {
View Full Code Here

  }

  @Test
  public void propertyB() throws Exception {
    AnnotationConfigApplicationContext context = load(Config.class, "b:b");
    assertThat(context.containsBean("myBean"), equalTo(true));
    context.close();
  }

  @Test
  public void both() throws Exception {
View Full Code Here

  }

  @Test
  public void both() throws Exception {
    AnnotationConfigApplicationContext context = load(Config.class, "a:a", "b:b");
    assertThat(context.containsBean("myBean"), equalTo(true));
    context.close();
  }

  private AnnotationConfigApplicationContext load(Class<?> config, String... env) {
    AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.