Package org.springframework.context.annotation

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


    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.register(A.B.class);
    ctx.refresh();
    assertThat(ctx.containsBean("outer"), is(false));
    assertThat(ctx.containsBean("imported"), is(false));
    assertThat(ctx.containsBean("nested"), is(true));
    assertThat(ctx.containsBean("nestedBean"), is(true));
  }

  @Test
  public void registerOuterConfig_withBeanNameGenerator() {
View Full Code Here


    ctx.register(A.B.class);
    ctx.refresh();
    assertThat(ctx.containsBean("outer"), is(false));
    assertThat(ctx.containsBean("imported"), is(false));
    assertThat(ctx.containsBean("nested"), is(true));
    assertThat(ctx.containsBean("nestedBean"), is(true));
  }

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

public class ImportResourceTests {

  @Test
  public void testImportXml() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlConfig.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 testImportXml() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlConfig.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-6310
View Full Code Here

  @Ignore // TODO: SPR-6310
  @Test
  public void testImportXmlWithRelativePath() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithRelativePathConfig.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

  @Ignore // TODO: SPR-6310
  @Test
  public void testImportXmlWithRelativePath() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithRelativePathConfig.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-6310
View Full Code Here

  @Ignore // TODO: SPR-6310
  @Test
  public void testImportXmlByConvention() {
    ApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlByConventionConfig.class);
    assertTrue("context does not contain xml-declared bean", ctx.containsBean("xmlDeclaredBean"));
  }

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

  }

  @Test
  public void testImportXmlIsInheritedFromSuperclassDeclarations() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(FirstLevelSubConfig.class);
    assertTrue(ctx.containsBean("xmlDeclaredBean"));
  }

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

  }

  @Test
  public void testImportXmlIsMergedFromSuperclassDeclarations() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SecondLevelSubConfig.class);
    assertTrue("failed to pick up second-level-declared XML bean", ctx.containsBean("secondLevelXmlDeclaredBean"));
    assertTrue("failed to pick up parent-declared XML bean", ctx.containsBean("xmlDeclaredBean"));
  }

  @Test
  public void testImportXmlWithNamespaceConfig() {
View Full Code Here

  @Test
  public void testImportXmlIsMergedFromSuperclassDeclarations() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(SecondLevelSubConfig.class);
    assertTrue("failed to pick up second-level-declared XML bean", ctx.containsBean("secondLevelXmlDeclaredBean"));
    assertTrue("failed to pick up parent-declared XML bean", ctx.containsBean("xmlDeclaredBean"));
  }

  @Test
  public void testImportXmlWithNamespaceConfig() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext(ImportXmlWithAopNamespaceConfig.class);
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.