Package org.apache.commons.configuration

Examples of org.apache.commons.configuration.PropertiesConfiguration


   * @throws Exception
   */
  protected ClusterSpec getClusterSpec() throws Exception {
    ClusterSpec clusterSpec = null;
    if (pid != null || fileName != null) {
      PropertiesConfiguration properties = getConfiguration(pid, fileName);
      clusterSpec = new ClusterSpec(properties);
    } else {
      clusterSpec = new ClusterSpec();
    }

View Full Code Here


    privateKeyFile.deleteOnExit();
    Files.write(("-----BEGIN RSA PRIVATE KEY-----\n" +
      "DUMMY FILE\n" +
      "-----END RSA PRIVATE KEY-----").getBytes(), privateKeyFile);

    Configuration conf = new PropertiesConfiguration();
    conf.setProperty("whirr.private-key-file", privateKeyFile.getAbsolutePath());

    ClusterSpec.withNoDefaults(conf);
  }
View Full Code Here

  @Test(expected = ConfigurationException.class)
  public void testEncryptedPrivateKey()
    throws JSchException, IOException, ConfigurationException {
    File privateKey = KeyPair.generateTemporaryFiles("dummy").get("private");

    Configuration conf = new PropertiesConfiguration();
    conf.setProperty("whirr.private-key-file", privateKey.getAbsolutePath());

    ClusterSpec.withNoDefaults(conf);
  }
View Full Code Here

    ClusterSpec.withNoDefaults(conf);
  }

  @Test(expected = ConfigurationException.class)
  public void testMissingPrivateKey() throws ConfigurationException {
    Configuration conf = new PropertiesConfiguration();
    conf.setProperty("whirr.private-key-file", "/dummy/path/that/does/not/exists");

    ClusterSpec.withNoDefaults(conf);
  }
View Full Code Here

  @Test(expected = ConfigurationException.class)
  public void testMissingPublicKey() throws JSchException, IOException, ConfigurationException {
    File privateKey = KeyPair.generateTemporaryFiles().get("private");

    Configuration conf = new PropertiesConfiguration();
    conf.setProperty("whirr.private-key-file", privateKey.getAbsolutePath());
    conf.setProperty("whirr.public-key-file", "/dummy/path/that/does/not/exists");

    ClusterSpec.withNoDefaults(conf);
  }
View Full Code Here

    File publicKey = File.createTempFile("public", "key");
    publicKey.deleteOnExit();
    Files.write("ssh-rsa BROKEN PUBLIC KEY".getBytes(), publicKey);

    Configuration conf = new PropertiesConfiguration();
    conf.setProperty("whirr.private-key-file", privateKey.getAbsolutePath());
    conf.setProperty("whirr.public-key-file", publicKey.getAbsolutePath());

    ClusterSpec.withNoDefaults(conf);
  }
View Full Code Here

  @Test(expected = ConfigurationException.class)
  public void testNotSameKeyPair() throws JSchException, IOException, ConfigurationException {
    Map<String, File> first = KeyPair.generateTemporaryFiles();
    Map<String, File> second = KeyPair.generateTemporaryFiles();

    Configuration conf = new PropertiesConfiguration();
    conf.setProperty("whirr.private-key-file", first.get("private").getAbsolutePath());
    conf.setProperty("whirr.public-key-file", second.get("public").getAbsolutePath());

    ClusterSpec.withNoDefaults(conf);
  }
View Full Code Here

    ClusterSpec.withNoDefaults(conf);
  }

  @Test(expected = IllegalArgumentException.class)
  public void testMissingCommaInInstanceTemplates() throws Exception {
    Configuration conf = new PropertiesConfiguration();
    conf.setProperty(ClusterSpec.Property.INSTANCE_TEMPLATES.getConfigName(),
      "1 a+b 2 c+d"); // missing comma
    ClusterSpec.withTemporaryKeys(conf);
  }
View Full Code Here

      .roles("a b").build();
  }

  @Test(expected = IllegalArgumentException.class)
  public void testIllegalArgumentExceptionOnInstancesTemplates() throws Exception {
    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,3 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.instance-templates-max-percent-failures", "60 % hadoop-datanode+hadoop-tasktracker");
    ClusterSpec expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    List<InstanceTemplate> templates = expectedClusterSpec.getInstanceTemplates();
    InstanceTemplate t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    InstanceTemplate t2 = templates.get(1);
View Full Code Here

    assertThat(t2.getMinNumberOfInstances(), is(2));
  }

  @Test(expected = NumberFormatException.class)
  public void testNumberFormatExceptionOnInstancesTemplates() throws Exception {
    Configuration conf = new PropertiesConfiguration();
    conf.addProperty("whirr.instance-templates", "1 hadoop-namenode+hadoop-jobtracker,3 hadoop-datanode+hadoop-tasktracker");
    conf.addProperty("whirr.instance-templates-max-percent-failures", "60% hadoop-datanode+hadoop-tasktracker");
    ClusterSpec expectedClusterSpec = ClusterSpec.withNoDefaults(conf);
    List<InstanceTemplate> templates = expectedClusterSpec.getInstanceTemplates();
    InstanceTemplate t1 = templates.get(0);
    assertThat(t1.getMinNumberOfInstances(), is(1));
    InstanceTemplate t2 = templates.get(1);
View Full Code Here

TOP

Related Classes of org.apache.commons.configuration.PropertiesConfiguration

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.