Package org.springframework.context.support

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


  public void propertyPlaceholderEnvironmentProperties() throws Exception {
    MockEnvironment env = new MockEnvironment().withProperty("foo", "spam");
    GenericXmlApplicationContext applicationContext = new GenericXmlApplicationContext();
    applicationContext.setEnvironment(env);
    applicationContext.load(new ClassPathResource("contextNamespaceHandlerTests-simple.xml", getClass()));
    applicationContext.refresh();
    Map<String, PlaceholderConfigurerSupport> beans = applicationContext
        .getBeansOfType(PlaceholderConfigurerSupport.class);
    assertFalse("No PropertyPlaceholderConfigurer found", beans.isEmpty());
    String s = (String) applicationContext.getBean("string");
    assertEquals("No properties replaced", "spam", s);
View Full Code Here


  @Test
  public void configuredThroughNamespace() {
    GenericXmlApplicationContext context = new GenericXmlApplicationContext();
    context.load(new ClassPathResource("taskNamespaceTests.xml", getClass()));
    context.refresh();
    ITestBean testBean = context.getBean("target", ITestBean.class);
    testBean.test();
    testBean.await(3000);
    Thread asyncThread = testBean.getThread();
    assertTrue(asyncThread.getName().startsWith("testExecutor"));
View Full Code Here

  public void genericXmlApplicationContext() {
    GenericXmlApplicationContext ctx = new GenericXmlApplicationContext();
    assertHasStandardEnvironment(ctx);
    ctx.setEnvironment(prodEnv);
    ctx.load(XML_PATH);
    ctx.refresh();

    assertHasEnvironment(ctx, prodEnv);
    assertEnvironmentBeanRegistered(ctx);
    assertEnvironmentAwareInvoked(ctx, prodEnv);
    assertThat(ctx.containsBean(DEV_BEAN_NAME), is(false));
View Full Code Here

  public void componentScanRespectsProfileAnnotation() {
    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();
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 },
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

    context.getEnvironment().getSystemProperties().put("username", username);
    context.getEnvironment().getSystemProperties().put("password", password);

    context.load("classpath:META-INF/spring/integration/*-context.xml");
    context.registerShutdownHook();
    context.refresh();

    context.registerShutdownHook();

    if (LOGGER.isInfoEnabled()) {
      LOGGER.info("\n========================================================="
View Full Code Here

      environment.getSystemProperties().put("secretKey", secretKey);
    }

    context.load("classpath:META-INF/spring/integration/*-context.xml");
    context.registerShutdownHook();
    context.refresh();

    final EmailService emailService = context.getBean(EmailService.class);

    emailService.send(fromEmailAddress, toEmailAddress, subject, body);

View Full Code Here

      }
    }

    context.load("classpath:META-INF/spring/integration/*-context.xml");
    context.registerShutdownHook();
    context.refresh();

    final JavaMailSender ms = context.getBean(JavaMailSender.class);
    final String toEmailAddressToUse = toEmailAddress;
    final MimeMessagePreparator preparator = new MimeMessagePreparator() {

View Full Code Here

      }
    }

    context.load("classpath:META-INF/spring/integration/*-context.xml");
    context.registerShutdownHook();
    context.refresh();

    final CustomerService service = context.getBean(CustomerService.class);

    final Resource resource = context.getResource("classpath:data/customers.xml");
    final InputStream is = resource.getInputStream();
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.