Package org.springframework.context

Examples of org.springframework.context.ConfigurableApplicationContext


        return loaded || orig.loadBeansOfType(type, listener);
    }

    public boolean hasConfiguredPropertyValue(String beanName, String propertyName, String searchValue) {
        if (context.containsBean(beanName) && !passThroughs.contains(beanName)) {
            ConfigurableApplicationContext ctxt = (ConfigurableApplicationContext)context;
            BeanDefinition def = ctxt.getBeanFactory().getBeanDefinition(beanName);
            if (!ctxt.getBeanFactory().isSingleton(beanName) || def.isAbstract()) {
                return false;
            }
            Collection<?> ids = null;
            PropertyValue pv = def.getPropertyValues().getPropertyValue(propertyName);
           
View Full Code Here


  @Test
  public void testProjectionDataProperties() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app.run(new String[] {
        "--spring.yarn.internal.ContainerClusterApplication.projectionDataAny=1",
        "--spring.yarn.internal.ContainerClusterApplication.projectionDataHosts.host1=1",
        "--spring.yarn.internal.ContainerClusterApplication.projectionDataRacks.rack1=1",
        "--spring.yarn.internal.ContainerClusterApplication.projectionDataHosts.host2=2",
        "--spring.yarn.internal.ContainerClusterApplication.projectionDataRacks.rack2=2" });
    OperationProperties properties = context.getBean(OperationProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getProjectionDataAny(), is(1));
    assertThat(properties.getProjectionDataHosts().get("host1"), is(1));
    assertThat(properties.getProjectionDataHosts().get("host2"), is(2));
    assertThat(properties.getProjectionDataRacks().get("rack1"), is(1));
    assertThat(properties.getProjectionDataRacks().get("rack2"), is(2));
    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnBatchPropertiesTests" });
    SpringYarnBatchProperties properties = context.getBean(SpringYarnBatchProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.isEnabled(), is(true));
    assertThat(properties.getName(), is("nameFoo1"));

    assertThat(properties.getJobs(), notNullValue());
    assertThat(properties.getJobs().size(), is(1));
    assertThat(properties.getJobProperties("jobsName1"), notNullValue());

    JobProperties jobProperties = properties.getJobProperties("jobsName1");
    assertThat(jobProperties.isEnabled(), is(true));
    assertThat(jobProperties.isFailNext(), is(true));
    assertThat(jobProperties.isFailRestart(), is(true));
    assertThat(jobProperties.isNext(), is(true));
    assertThat(jobProperties.isRestart(), is(true));
    assertThat(jobProperties.getParameters(), notNullValue());
    assertThat(jobProperties.getParameters().size(), is(2));
    assertThat((String)jobProperties.getParameters().get("job1key1"), is("job1val1"));
    assertThat((String)jobProperties.getParameters().get("job1key2"), is("job1val2"));
    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnClientLaunchContextPropertiesTests" });
    SpringYarnClientLaunchContextProperties properties = context.getBean(SpringYarnClientLaunchContextProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getArchiveFile(), is("archiveFileFoo"));

    Map<String, String> arguments = properties.getArguments();
    assertThat(arguments, notNullValue());
    assertThat(arguments.size(), is(2));
    assertThat(arguments.get("argumentsKeyFoo1"), is("argumentsValFoo1"));
    assertThat(arguments.get("argumentsKeyFoo2"), is("argumentsValFoo2"));

    List<String> argumentsList = properties.getArgumentsList();
    assertThat(argumentsList, notNullValue());
    assertThat(argumentsList.size(), is(2));
    assertThat(argumentsList, contains("argumentsListFoo1", "argumentsListFoo2"));

    List<String> classpath = properties.getContainerAppClasspath();
    assertThat(classpath, notNullValue());
    assertThat(classpath.size(), is(2));
    assertThat(classpath.get(0), is("classpath1Foo"));
    assertThat(classpath.get(1), is("classpath2Foo"));

    assertThat(properties.getRunnerClass(), is("runnerClassFoo"));

    List<String> options = properties.getOptions();
    assertThat(options, notNullValue());
    assertThat(options.size(), is(2));
    assertThat(options.get(0), is("options1Foo"));
    assertThat(options.get(1), is("options2Foo"));

    assertThat(properties.isUseYarnAppClasspath(), is(true));
    assertThat(properties.isUseMapreduceAppClasspath(), is(true));
    assertThat(properties.isIncludeBaseDirectory(), is(false));
    assertThat(properties.isIncludeLocalSystemEnv(), is(true));
    assertThat(properties.getPathSeparator(), is(":"));

    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnPropertiesTests" });
    SpringYarnProperties properties = context.getBean(SpringYarnProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getApplicationDir(), is("applicationDirFoo"));
    assertThat(properties.getApplicationBaseDir(), is("applicationBaseDirFoo"));
    assertThat(properties.getApplicationVersion(), is("applicationVersionFoo"));
    assertThat(properties.getAppName(), is("appNameFoo"));
    assertThat(properties.getAppType(), is("appTypeFoo"));
    assertThat(properties.getStagingDir(), is("stagingDirFoo"));
    assertThat(properties.getSiteYarnAppClasspath(), is("siteYarnAppClasspathFoo"));
    assertThat(properties.getSiteMapreduceAppClasspath(), is("siteMapreduceAppClasspathFoo"));
    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnClientLocalizerPropertiesTests" });
    SpringYarnClientLocalizerProperties properties = context.getBean(SpringYarnClientLocalizerProperties.class);
    assertThat(properties, notNullValue());

    List<String> pattern = properties.getPatterns();
    assertThat(pattern, notNullValue());
    assertThat(pattern.size(), is(2));
    assertThat(pattern.get(0), is("patterns1Foo"));
    assertThat(pattern.get(1), is("patterns2Foo"));

    List<String> names = properties.getPropertiesNames();
    assertThat(names, notNullValue());
    assertThat(names.size(), is(2));
    assertThat(names.get(0), is("name1Foo"));
    assertThat(names.get(1), is("name2Foo"));

    List<String> suffixes = properties.getPropertiesSuffixes();
    assertThat(suffixes, notNullValue());
    assertThat(suffixes.size(), is(2));
    assertThat(suffixes.get(0), is("suffix1Foo"));
    assertThat(suffixes.get(1), is("suffix2Foo"));

    assertThat(properties.getZipPattern(), is("zipPatternFoo"));

    context.close();
  }
View Full Code Here

    p.put("spring.yarn.client.localizer.rawFileContents." + SpringYarnBootUtils.escapeConfigKey("application.properties"), new byte[3]);
    builder.properties(p);

    SpringApplication app = builder.application();
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app.run(new String[0]);
    SpringYarnClientLocalizerProperties properties = context.getBean(SpringYarnClientLocalizerProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getRawFileContents(), notNullValue());
    assertThat(properties.getRawFileContents().size(), is(3));
    assertThat(properties.getRawFileContents().get(SpringYarnBootUtils.escapeConfigKey("file1")).length, is(1));
    assertThat(properties.getRawFileContents().get(SpringYarnBootUtils.escapeConfigKey("file2")).length, is(2));
View Full Code Here

  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnAppmasterLaunchContextPropertiesTests" });
    SpringYarnAppmasterLaunchContextProperties properties = context.getBean(SpringYarnAppmasterLaunchContextProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getArchiveFile(), is("archiveFileFoo"));

    Map<String, String> arguments = properties.getArguments();
    assertThat(arguments, notNullValue());
    assertThat(arguments.size(), is(2));
    assertThat(arguments.get("argumentsKeyFoo1"), is("argumentsValFoo1"));
    assertThat(arguments.get("argumentsKeyFoo2"), is("argumentsValFoo2"));

    List<String> argumentsList = properties.getArgumentsList();
    assertThat(argumentsList, notNullValue());
    assertThat(argumentsList.size(), is(2));
    assertThat(argumentsList, contains("argumentsListFoo1", "argumentsListFoo2"));

    List<String> classpath = properties.getContainerAppClasspath();
    assertThat(classpath, notNullValue());
    assertThat(classpath.size(), is(2));
    assertThat(classpath.get(0), is("classpath1Foo"));
    assertThat(classpath.get(1), is("classpath2Foo"));

    assertThat(properties.getRunnerClass(), is("runnerClassFoo"));

    List<String> options = properties.getOptions();
    assertThat(options, notNullValue());
    assertThat(options.size(), is(2));
    assertThat(options.get(0), is("options1Foo"));
    assertThat(options.get(1), is("options2Foo"));

    assertThat(properties.isLocality(), is(true));
    assertThat(properties.isUseYarnAppClasspath(), is(true));
    assertThat(properties.isUseMapreduceAppClasspath(), is(true));
    assertThat(properties.isIncludeBaseDirectory(), is(false));
    assertThat(properties.isIncludeLocalSystemEnv(), is(true));
    assertThat(properties.getPathSeparator(), is(":"));

    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnContainerPropertiesTests" });
    SpringYarnContainerProperties properties = context.getBean(SpringYarnContainerProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.isKeepContextAlive(), is(false));
    assertThat(properties.getContainerClass(), is("containerClassFoo"));

    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnAppmasterResourcePropertiesTests" });
    SpringYarnAppmasterResourceProperties properties = context.getBean(SpringYarnAppmasterResourceProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getPriority(), is(234));
    assertThat(properties.getMemory(), is("memoryFoo"));
    assertThat(properties.getVirtualCores(), is(123));
    context.close();
  }
View Full Code Here

TOP

Related Classes of org.springframework.context.ConfigurableApplicationContext

Copyright © 2018 www.massapicom. 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.