Package org.springframework.context.annotation

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


    ctx.register(Config.class);
    ctx.refresh();

    assertEnvironmentAwareInvoked(ctx, prodEnv);
    assertThat("should have prod bean", ctx.containsBean(PROD_BEAN_NAME), is(true));
    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
  }

  @Test
View Full Code Here


    ctx.register(Config.class);
    ctx.refresh();

    assertEnvironmentAwareInvoked(ctx, prodEnv);
    assertThat("should have prod bean", ctx.containsBean(PROD_BEAN_NAME), is(true));
    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
  }

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

    ctx.refresh();

    assertEnvironmentAwareInvoked(ctx, prodEnv);
    assertThat("should have prod bean", ctx.containsBean(PROD_BEAN_NAME), is(true));
    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
  }

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

    derivedDevEnv.setActiveProfiles(DERIVED_DEV_ENV_NAME);
    ctx.setEnvironment(derivedDevEnv);
    ctx.register(DerivedDevConfig.class);
    ctx.refresh();

    assertThat("should have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(true));
    assertThat("should have derived dev bean", ctx.containsBean(DERIVED_DEV_BEAN_NAME), is(true));
    assertThat("should have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(true));
  }

  @Test
View Full Code Here

    ctx.setEnvironment(derivedDevEnv);
    ctx.register(DerivedDevConfig.class);
    ctx.refresh();

    assertThat("should have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(true));
    assertThat("should have derived dev bean", ctx.containsBean(DERIVED_DEV_BEAN_NAME), is(true));
    assertThat("should have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(true));
  }

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

    ctx.register(DerivedDevConfig.class);
    ctx.refresh();

    assertThat("should have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(true));
    assertThat("should have derived dev bean", ctx.containsBean(DERIVED_DEV_BEAN_NAME), is(true));
    assertThat("should have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(true));
  }

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

    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.setEnvironment(devEnv);
    ctx.register(DerivedDevConfig.class);
    ctx.refresh();

    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have derived dev bean", ctx.containsBean(DERIVED_DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
  }

  @Test
View Full Code Here

    ctx.setEnvironment(devEnv);
    ctx.register(DerivedDevConfig.class);
    ctx.refresh();

    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have derived dev bean", ctx.containsBean(DERIVED_DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
  }

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

    ctx.register(DerivedDevConfig.class);
    ctx.refresh();

    assertThat("should not have dev bean", ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat("should not have derived dev bean", ctx.containsBean(DERIVED_DEV_BEAN_NAME), is(false));
    assertThat("should not have transitive bean", ctx.containsBean(TRANSITIVE_BEAN_NAME), is(false));
  }

  @Test
  public void webApplicationContext() {
    GenericWebApplicationContext ctx = new GenericWebApplicationContext(newBeanFactoryWithEnvironmentAwareBean());
View Full Code Here

  @Test
  public void repro() {
    AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
    ctx.scan(getClass().getPackage().getName());
    ctx.refresh();
    assertThat(ctx.containsBean("withNestedAnnotation"), is(true));
  }

}

@Component
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.