Package org.springframework.context.support

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


  @Test
  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");
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();
View Full Code Here

  @Test
  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);
View Full Code Here

  @Test
  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
View Full Code Here

      context.close();
    }
    { // 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
View Full Code Here

    context.getEnvironment().getSystemProperties().put("host", host);
    context.getEnvironment().getSystemProperties().put("shareAndDir", shareAndDir);
    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();

 
View Full Code Here

      System.out.print("Please enter your secret key: ");
      final String secretKey = scanner.nextLine();
      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);

View Full Code Here

        System.out.println("Invalid choice\n\n");
        System.out.print("Enter you choice: ");
      }
    }

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

    final JavaMailSender ms = context.getBean(JavaMailSender.class);
    final String toEmailAddressToUse = toEmailAddress;
View Full Code Here

        System.out.println("Invalid choice\n\n");
        System.out.print("Enter you choice: ");
      }
    }

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

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

View Full Code Here

        environment.setActiveProfiles("upload-to-s3");
        setupCredentials(environment, scanner);
        setupS3info(environment, scanner);

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

        System.out.print("\nPlease enter the path to the file you want to upload: ");
        filePath = scanner.nextLine();
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.