Exemple #1
0
  @Test
  public void testNestedProfiles() throws IOException {
    Props p = new Props();
    p.load(readDataFile("test-profiles.props"));

    assertEquals("hello", p.getBaseValue("key1"));
    assertEquals("hello", p.getValue("key1"));
    assertEquals("Hi!", p.getValue("key1", "one"));
    assertEquals("Hola!", p.getValue("key1", "one.two"));
    assertEquals("world", p.getValue("key2", "one.two"));
    assertNull(p.getValue("key2", "one"));
    assertEquals("Grazias", p.getValue("key3", "one.two"));
    assertEquals("Grazias", p.getValue("key3", "one"));

    Properties prop = new Properties();
    p.extractProps(prop);
    assertEquals(3, prop.size());
    assertEquals("hello", prop.getProperty("key1"));

    prop.clear();
    p.extractProps(prop, "one");
    assertEquals(3 + 1, prop.size());
    assertEquals("Hi!", prop.getProperty("key1"));
    assertEquals("Grazias", prop.getProperty("key3"));

    prop.clear();
    p.extractProps(prop, "one.two");
    assertEquals(3 + 2, prop.size());
    assertEquals("Hola!", prop.getProperty("key1"));
    assertEquals("world", prop.getProperty("key2"));
    assertEquals("Grazias", prop.getProperty("key3"));
  }
Exemple #2
0
  @Test
  public void testActiveProfiles() throws IOException {
    Props p = loadProps("test-actp.props");

    assertEquals("hello", p.getBaseValue("key1"));
    assertEquals("Hola!", p.getValue("key1"));
    assertEquals("world", p.getValue("key2"));

    assertEquals(1, p.getActiveProfiles().length);
    assertEquals("one.two", p.getActiveProfiles()[0]);
  }