示例#1
0
  @Test
  public void testMacros2() throws IOException {
    Props p = new Props();
    p.setValue("key1", "**${key${key3}}**");
    p.setValue("key3", "2");
    p.setValue("key2", "++++");

    assertEquals("**++++**", p.getValue("key1"));
  }
示例#2
0
  @Test
  public void testMacroNotExist() {
    Props p = new Props();
    p.setValue("mac1", "value1");
    p.setValue("key1", "${mac1}");
    p.setValue("key2", "${mac2}");

    assertEquals("value1", p.getValue("mac1"));
    assertEquals("value1", p.getValue("key1"));
    assertEquals("${mac2}", p.getValue("key2"));
  }
示例#3
0
  @Test
  public void testAdd() {
    Props p = new Props();
    p.setValue("key1", "val${key2}");

    assertEquals("val${key2}", p.getValue("key1"));
    assertNull(p.getValue("key1${key2}"));

    p.setValue("key2", "hurrey\tme!");

    assertEquals("valhurrey\tme!", p.getValue("key1"));
  }
示例#4
0
  @Test
  public void testMacroNotExistIgnoreMissing() {
    Props p = new Props();
    p.setIgnoreMissingMacros(true);
    p.setValue("mac1", "value1");
    p.setValue("key1", "${mac1}");
    p.setValue("key2", "${mac2}");

    assertEquals("value1", p.getValue("mac1"));
    assertEquals("value1", p.getValue("key1"));
    assertNull(p.getValue("key2"));
  }