Package org.springframework.context.support

Examples of org.springframework.context.support.GenericApplicationContext.containsBean()


    assertTrue(context.containsBean("serviceInvocationCounter"));
    assertTrue(context.containsBean("fooServiceImpl"));
    assertTrue(context.containsBean("stubFooDao"));
    assertTrue(context.containsBean("myNamedComponent"));
    assertTrue(context.containsBean("myNamedDao"));
    assertTrue(context.containsBean("thoreau"));
  }

  public void testSimpleScanWithDefaultFiltersAndNoPostProcessors() {
    GenericApplicationContext context = new GenericApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
View Full Code Here


    GenericApplicationContext context = new GenericApplicationContext();
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
    scanner.setIncludeAnnotationConfig(false);
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(9, beanCount);
    assertTrue(context.containsBean("serviceInvocationCounter"));
    assertTrue(context.containsBean("fooServiceImpl"));
    assertTrue(context.containsBean("stubFooDao"));
    assertTrue(context.containsBean("myNamedComponent"));
    assertTrue(context.containsBean("myNamedDao"));
  }
View Full Code Here

    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(context);
    scanner.setIncludeAnnotationConfig(false);
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(9, beanCount);
    assertTrue(context.containsBean("serviceInvocationCounter"));
    assertTrue(context.containsBean("fooServiceImpl"));
    assertTrue(context.containsBean("stubFooDao"));
    assertTrue(context.containsBean("myNamedComponent"));
    assertTrue(context.containsBean("myNamedDao"));
  }
View Full Code Here

    scanner.setIncludeAnnotationConfig(false);
    int beanCount = scanner.scan(BASE_PACKAGE);
    assertEquals(9, beanCount);
    assertTrue(context.containsBean("serviceInvocationCounter"));
    assertTrue(context.containsBean("fooServiceImpl"));
    assertTrue(context.containsBean("stubFooDao"));
    assertTrue(context.containsBean("myNamedComponent"));
    assertTrue(context.containsBean("myNamedDao"));
  }

  public void testSimpleScanWithDefaultFiltersAndOverridingBean() {
View Full Code Here

  public void annotatedBeanDefinitionReader_inheritsEnvironmentFromEnvironmentCapableBDR() {
    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.setEnvironment(prodEnv);
    new AnnotatedBeanDefinitionReader(ctx).register(Config.class);
    ctx.refresh();
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

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

    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.setEnvironment(prodEnv);
    new AnnotatedBeanDefinitionReader(ctx).register(Config.class);
    ctx.refresh();
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

  @Test
  public void classPathBeanDefinitionScanner_inheritsEnvironmentFromEnvironmentCapableBDR_scanProfileAnnotatedConfigClasses() {
    // it's actually ConfigurationClassPostProcessor's Environment that gets the job done here.
View Full Code Here

    GenericApplicationContext ctx = new GenericApplicationContext();
    ctx.setEnvironment(prodEnv);
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("org.springframework.core.env.scan1");
    ctx.refresh();
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

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

    ctx.setEnvironment(prodEnv);
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("org.springframework.core.env.scan1");
    ctx.refresh();
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

  @Test
  public void classPathBeanDefinitionScanner_inheritsEnvironmentFromEnvironmentCapableBDR_scanProfileAnnotatedComponents() {
    GenericApplicationContext ctx = new GenericApplicationContext();
View Full Code Here

    ctx.setEnvironment(prodEnv);
    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("org.springframework.core.env.scan2");
    ctx.refresh();
    assertThat(scanner.getEnvironment(), is((Environment)ctx.getEnvironment()));
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

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

    ClassPathBeanDefinitionScanner scanner = new ClassPathBeanDefinitionScanner(ctx);
    scanner.scan("org.springframework.core.env.scan2");
    ctx.refresh();
    assertThat(scanner.getEnvironment(), is((Environment)ctx.getEnvironment()));
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

  @Test
  public void genericXmlApplicationContext() {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
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.