Package org.springframework.context.support

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


    ctx.refresh();

    assertHasEnvironment(ctx, prodEnv);
    assertEnvironmentBeanRegistered(ctx);
    assertEnvironmentAwareInvoked(ctx, prodEnv);
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

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


    assertHasEnvironment(ctx, prodEnv);
    assertEnvironmentBeanRegistered(ctx);
    assertEnvironmentAwareInvoked(ctx, prodEnv);
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
    assertThat(ctx.containsBean(PROD_BEAN_NAME), is(true));
  }

  @Test
  public void classPathXmlApplicationContext() {
    ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext(XML_PATH);
View Full Code Here

    String xmlLocation = "org/springframework/context/annotation/componentScanRespectsProfileAnnotationTests.xml";
    { // should exclude the profile-annotated bean if active profiles remains unset
      GenericXmlApplicationContext context = new GenericXmlApplicationContext();
      context.load(xmlLocation);
      context.refresh();
      assertThat(context.containsBean(ProfileAnnotatedComponent.BEAN_NAME), is(false));
      context.close();
    }
    { // should include the profile-annotated bean with active profiles set
      GenericXmlApplicationContext context = new GenericXmlApplicationContext();
      context.getEnvironment().setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
View Full Code Here

    { // should include the profile-annotated bean with active profiles set
      GenericXmlApplicationContext context = new GenericXmlApplicationContext();
      context.getEnvironment().setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
      context.load(xmlLocation);
      context.refresh();
      assertThat(context.containsBean(ProfileAnnotatedComponent.BEAN_NAME), is(true));
      context.close();
    }
    { // ensure the same works for AbstractRefreshableApplicationContext impls too
      ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] { xmlLocation },
        false);
View Full Code Here

    { // ensure the same works for AbstractRefreshableApplicationContext impls too
      ConfigurableApplicationContext context = new ClassPathXmlApplicationContext(new String[] { xmlLocation },
        false);
      context.getEnvironment().setActiveProfiles(ProfileAnnotatedComponent.PROFILE_NAME);
      context.refresh();
      assertThat(context.containsBean(ProfileAnnotatedComponent.BEAN_NAME), is(true));
      context.close();
    }
  }

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.