Package org.springframework.context

Examples of org.springframework.context.ConfigurableApplicationContext


  @Test
  public void testAllPropertiesSet() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnAppmasterPropertiesTests" });
    SpringYarnAppmasterProperties properties = context.getBean(SpringYarnAppmasterProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getAppmasterClass(), is("appmasterClassFoo"));
    assertThat(properties.getContainerCount(), is(123));
    assertThat(properties.isKeepContextAlive(), is(false));
    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=SpringYarnClientPropertiesTests" });
    SpringYarnClientProperties properties = context.getBean(SpringYarnClientProperties.class);
    assertThat(properties, notNullValue());

    List<String> files = properties.getFiles();
    assertThat(files, notNullValue());
    assertThat(files.size(), is(2));
    assertThat(files.get(0), is("files1Foo"));
    assertThat(files.get(1), is("files2Foo"));

    assertThat(properties.getPriority(), is(234));
    assertThat(properties.getQueue(), is("queueFoo"));

    assertThat(properties.getClientClass(), is("clientClassFoo"));

    assertThat(properties.getStartup().getAction(), is("submit"));

    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet1() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringHadoopPropertiesTests1" });
    SpringHadoopProperties properties = context.getBean(SpringHadoopProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getFsUri(), is("fsUriFoo"));
    assertThat(properties.getResourceManagerAddress(), is("resourceManagerAddressFoo:321"));
    assertThat(properties.getResourceManagerSchedulerAddress(), is("resourceManagerSchedulerAddressFoo:123"));
    assertThat(properties.getResourceManagerHost(), is("resourceManagerAddressFoo"));
    assertThat(properties.getResourceManagerPort(), is(321));
    assertThat(properties.getResourceManagerSchedulerPort(), is(123));
    assertThat(properties.getResources(), notNullValue());
    assertThat(properties.getResources().size(), is(2));
    assertThat(properties.getResources().get(0), is("file:/fake-resource-1.xml"));
    assertThat(properties.getResources().get(1), is("classpath:/fake-resource-2.xml"));
    context.close();
  }
View Full Code Here

  @Test
  public void testAllPropertiesSet2() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringHadoopPropertiesTests2" });
    SpringHadoopProperties properties = context.getBean(SpringHadoopProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getFsUri(), is("fsUriFoo"));
    assertThat(properties.getResourceManagerAddress(), is("resourceManagerHostFoo:321"));
    assertThat(properties.getResourceManagerSchedulerAddress(), is("resourceManagerHostFoo:123"));
    assertThat(properties.getResourceManagerHost(), is("resourceManagerHostFoo"));
    assertThat(properties.getResourceManagerPort(), is(321));
    assertThat(properties.getResourceManagerSchedulerPort(), is(123));
    assertThat(properties.getResources(), nullValue());
    context.close();
  }
View Full Code Here

  @Test
  public void testHadoopConfig() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringHadoopPropertiesTests3" });
    SpringHadoopProperties properties = context.getBean(SpringHadoopProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getConfig(), notNullValue());
    assertThat(properties.getConfig().get("key1"), is("value1"));
    assertThat(properties.getConfig().get("key2"), is("value2"));
    context.close();
  }
View Full Code Here

  @Test
  public void testSecurityProperties() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringHadoopSecurityPropertiesTests" });
    SpringHadoopProperties properties = context.getBean(SpringHadoopProperties.class);
    assertThat(properties, notNullValue());
    assertThat(properties.getSecurity(), notNullValue());
    assertThat(properties.getSecurity().getAuthMethod(), is(SecurityAuthMethod.KERBEROS));
    assertThat(properties.getSecurity().getUserPrincipal(), is("userPrincipalFoo"));
    assertThat(properties.getSecurity().getUserKeytab(), is("userKeytabFoo"));
    assertThat(properties.getSecurity().getNamenodePrincipal(), is("hdfs/foo@LOCALDOMAIN"));
    assertThat(properties.getSecurity().getRmManagerPrincipal(), is("yarn/foo@LOCALDOMAIN"));
    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=SpringYarnAppmasterContainerClusterPropertiesTests1" });
    SpringYarnAppmasterProperties properties = context.getBean(SpringYarnAppmasterProperties.class);
    assertThat(properties, notNullValue());

    assertThat(properties.getContainercluster().getClusters().size(), is(2));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionType(), is("any"));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionAny(), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().size(), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().get("host1"), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().get("host2"), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().size(), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().get("rack1"), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().get("rack2"), is(2));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource(), notNullValue());
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getPriority(), is(234));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getMemory(), is("memoryFoo"));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getVirtualCores(), is(123));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getLaunchcontext(), notNullValue());
    SpringYarnAppmasterLaunchContextProperties properties1 = properties.getContainercluster().getClusters().get("cluster1").getLaunchcontext();
    assertThat(properties1, notNullValue());
    assertThat(properties1.getArchiveFile(), is("archiveFileFoo"));
    Map<String, String> arguments = properties1.getArguments();
    assertThat(arguments, notNullValue());
    assertThat(arguments.size(), is(2));
    assertThat(arguments.get("argumentsKeyFoo1"), is("argumentsValFoo1"));
    assertThat(arguments.get("argumentsKeyFoo2"), is("argumentsValFoo2"));

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

    List<String> classpath = properties1.getContainerAppClasspath();
    assertThat(classpath, notNullValue());
    assertThat(classpath.size(), is(2));
    assertThat(classpath.get(0), is("classpath1Foo"));
    assertThat(classpath.get(1), is("classpath2Foo"));
    assertThat(properties1.getRunnerClass(), is("runnerClassFoo"));
    List<String> options = properties1.getOptions();
    assertThat(options, notNullValue());
    assertThat(options.size(), is(2));
    assertThat(options.get(0), is("options1Foo"));
    assertThat(options.get(1), is("options2Foo"));
    assertThat(properties1.isLocality(), is(true));
    assertThat(properties1.isUseYarnAppClasspath(), is(false));
    assertThat(properties1.isIncludeBaseDirectory(), is(false));
    assertThat(properties1.isIncludeLocalSystemEnv(), is(true));
    assertThat(properties1.getPathSeparator(), is(":"));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getLocalizer(), notNullValue());
    SpringYarnAppmasterLocalizerProperties properties2 = properties.getContainercluster().getClusters().get("cluster1").getLocalizer();
    assertThat(properties2, notNullValue());
    List<String> pattern = properties2.getPatterns();
    assertThat(pattern, notNullValue());
    assertThat(pattern.size(), is(2));
    assertThat(pattern.get(0), is("patterns1Foo"));
    assertThat(pattern.get(1), is("patterns2Foo"));
    List<String> names = properties2.getPropertiesNames();
    assertThat(names, notNullValue());
    assertThat(names.size(), is(2));
    assertThat(names.get(0), is("name1Foo"));
    assertThat(names.get(1), is("name2Foo"));
    List<String> suffixes = properties2.getPropertiesSuffixes();
    assertThat(suffixes, notNullValue());
    assertThat(suffixes.size(), is(2));
    assertThat(suffixes.get(0), is("suffix1Foo"));
    assertThat(suffixes.get(1), is("suffix2Foo"));
    assertThat(properties2.getZipPattern(), is("zipPatternFoo"));

    assertThat(properties.getContainercluster().getClusters().get("cluster2").getResource(), notNullValue());
    assertThat(properties.getContainercluster().getClusters().get("cluster2").getLaunchcontext(), nullValue());
    assertThat(properties.getContainercluster().getClusters().get("cluster2").getLocalizer(), nullValue());
    assertThat(properties.getContainercluster().getClusters().get("cluster2").getResource().getPriority(), is(2344));
    assertThat(properties.getContainercluster().getClusters().get("cluster2").getResource().getMemory(), is("memoryFooo"));
    assertThat(properties.getContainercluster().getClusters().get("cluster2").getResource().getVirtualCores(), is(1233));
    context.close();
  }
View Full Code Here

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

    assertThat(properties.getContainercluster().getClusters().size(), is(1));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionType(), is("any"));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionAny(), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().size(), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().get("host1"), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().get("host2"), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().size(), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().get("rack1"), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().get("rack2"), is(2));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource(), notNullValue());
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getPriority(), is(234));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getMemory(), is("memoryFoo"));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getVirtualCores(), is(123));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getLaunchcontext(), notNullValue());
    SpringYarnAppmasterLaunchContextProperties properties1 = properties.getContainercluster().getClusters().get("cluster1").getLaunchcontext();
    assertThat(properties1, notNullValue());
    assertThat(properties1.getArchiveFile(), is("archiveFileFoo"));
    Map<String, String> arguments = properties1.getArguments();
    assertThat(arguments, notNullValue());
    assertThat(arguments.size(), is(2));
    assertThat(arguments.get("argumentsKeyFoo1"), is("argumentsValFoo1"));
    assertThat(arguments.get("argumentsKeyFoo2"), is("argumentsValFoo2"));
    List<String> classpath = properties1.getContainerAppClasspath();
    assertThat(classpath, notNullValue());
    assertThat(classpath.size(), is(2));
    assertThat(classpath.get(0), is("classpath1Foo"));
    assertThat(classpath.get(1), is("classpath2Foo"));
    assertThat(properties1.getRunnerClass(), is("runnerClassFoo"));
    List<String> options = properties1.getOptions();
    assertThat(options, notNullValue());
    assertThat(options.size(), is(2));
    assertThat(options.get(0), is("options1Foo"));
    assertThat(options.get(1), is("options2Foo"));
    assertThat(properties1.isLocality(), is(true));
    assertThat(properties1.isUseYarnAppClasspath(), is(false));
    assertThat(properties1.isIncludeBaseDirectory(), is(false));
    assertThat(properties1.isIncludeLocalSystemEnv(), is(true));
    assertThat(properties1.getPathSeparator(), is(":"));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getLocalizer(), notNullValue());
    SpringYarnAppmasterLocalizerProperties properties2 = properties.getContainercluster().getClusters().get("cluster1").getLocalizer();
    assertThat(properties2, notNullValue());
    List<String> pattern = properties2.getPatterns();
    assertThat(pattern, notNullValue());
    assertThat(pattern.size(), is(2));
    assertThat(pattern.get(0), is("patterns1Foo"));
    assertThat(pattern.get(1), is("patterns2Foo"));
    List<String> names = properties2.getPropertiesNames();
    assertThat(names, notNullValue());
    assertThat(names.size(), is(2));
    assertThat(names.get(0), is("name1Foo"));
    assertThat(names.get(1), is("name2Foo"));
    List<String> suffixes = properties2.getPropertiesSuffixes();
    assertThat(suffixes, notNullValue());
    assertThat(suffixes.size(), is(2));
    assertThat(suffixes.get(0), is("suffix1Foo"));
    assertThat(suffixes.get(1), is("suffix2Foo"));
    assertThat(properties2.getZipPattern(), is("zipPatternFoo"));

    context.close();
  }
View Full Code Here

  @Test
  public void testAllMultiYaml() {
    SpringApplication app = new SpringApplication(TestConfiguration.class);
    app.setWebEnvironment(false);
    ConfigurableApplicationContext context = app
        .run(new String[] { "--spring.config.name=SpringYarnAppmasterContainerClusterPropertiesTests2",
            "--spring.config.location=classpath:/SpringYarnAppmasterContainerClusterPropertiesTests2-2.yml"});
    SpringYarnAppmasterProperties properties = context.getBean(SpringYarnAppmasterProperties.class);
    assertThat(properties, notNullValue());

    assertThat(properties.getContainercluster().getClusters().size(), is(2));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionType(), is("any"));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionAny(), is(1));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().size(), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().get("host1"), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionHosts().get("host2"), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().size(), is(2));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().get("rack1"), is(1));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getProjectionRacks().get("rack2"), is(2));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource(), notNullValue());
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getPriority(), is(234));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getMemory(), is("memoryFoo"));
    assertThat(properties.getContainercluster().getClusters().get("cluster1").getResource().getVirtualCores(), is(123));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getLaunchcontext(), notNullValue());
    SpringYarnAppmasterLaunchContextProperties properties1 = properties.getContainercluster().getClusters().get("cluster1").getLaunchcontext();
    assertThat(properties1, notNullValue());
    assertThat(properties1.getArchiveFile(), is("archiveFileFoo"));
    Map<String, String> arguments = properties1.getArguments();
    assertThat(arguments, notNullValue());
    assertThat(arguments.size(), is(2));
    assertThat(arguments.get("argumentsKeyFoo1"), is("argumentsValFoo1"));
    assertThat(arguments.get("argumentsKeyFoo2"), is("argumentsValFoo2"));
    List<String> classpath = properties1.getContainerAppClasspath();
    assertThat(classpath, notNullValue());
    assertThat(classpath.size(), is(2));
    assertThat(classpath.get(0), is("classpath1Foo"));
    assertThat(classpath.get(1), is("classpath2Foo"));
    assertThat(properties1.getRunnerClass(), is("runnerClassFoo"));
    List<String> options = properties1.getOptions();
    assertThat(options, notNullValue());
    assertThat(options.size(), is(2));
    assertThat(options.get(0), is("options1Foo"));
    assertThat(options.get(1), is("options2Foo"));
    assertThat(properties1.isLocality(), is(true));
    assertThat(properties1.isUseYarnAppClasspath(), is(false));
    assertThat(properties1.isIncludeBaseDirectory(), is(false));
    assertThat(properties1.isIncludeLocalSystemEnv(), is(true));
    assertThat(properties1.getPathSeparator(), is(":"));

    assertThat(properties.getContainercluster().getClusters().get("cluster1").getLocalizer(), notNullValue());
    SpringYarnAppmasterLocalizerProperties properties2 = properties.getContainercluster().getClusters().get("cluster1").getLocalizer();
    assertThat(properties2, notNullValue());
    List<String> pattern = properties2.getPatterns();
    assertThat(pattern, notNullValue());
    assertThat(pattern.size(), is(2));
    assertThat(pattern.get(0), is("patterns1Foo"));
    assertThat(pattern.get(1), is("patterns2Foo"));
    List<String> names = properties2.getPropertiesNames();
    assertThat(names, notNullValue());
    assertThat(names.size(), is(2));
    assertThat(names.get(0), is("name1Foo"));
    assertThat(names.get(1), is("name2Foo"));
    List<String> suffixes = properties2.getPropertiesSuffixes();
    assertThat(suffixes, notNullValue());
    assertThat(suffixes.size(), is(2));
    assertThat(suffixes.get(0), is("suffix1Foo"));
    assertThat(suffixes.get(1), is("suffix2Foo"));
    assertThat(properties2.getZipPattern(), is("zipPatternFoo"));

    assertThat(properties.getContainercluster().getClusters().get("cluster2").getProjectionType(), is("any"));
    assertThat(properties.getContainercluster().getClusters().get("cluster2").getProjectionAny(), 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=SpringYarnAppmasterLocalizerPropertiesTests" });
    SpringYarnAppmasterLocalizerProperties properties = context.getBean(SpringYarnAppmasterLocalizerProperties.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

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.