コード例 #1
0
  @Before
  public void setUp() throws IOException {
    final URL conf = getClass().getResource("/wrapper.conf");

    config = new File(testIndex.getDirectory("configs"), "wrapper.conf");

    config.delete();

    copyFile(new File(conf.getFile()), config);

    jswConfig = new JSWConfig(config);
    jswConfig.load();
  }
コード例 #2
0
  /**
   * Verify that calling write, multiple times, will not append overridden properties multiple
   * times.
   *
   * @throws IOException unexpected
   */
  @Test
  public void subsequentSavesProducesSameFile() throws IOException {
    jswConfig.setProperty("wrapper.java.classpath.2", "foo/*");
    jswConfig.save();

    // copy written configuration file so we can compare
    final File saved = new File(testIndex.getDirectory("configs"), "wrapper-1.conf");
    copyFile(config, saved);

    // save again
    jswConfig.save();

    // and check that the last save and previous saved are equal
    assertThat(config, FileMatchers.matchSha1(saved));

    // check that original property is written
    assertThat(
        config, contains("wrapper.java.mainclass=org.tanukisoftware.wrapper.WrapperSimpleApp"));
    // check that overridden property is written
    assertThat(config, contains("wrapper.java.classpath.2=foo/*"));
  }