Commit aecb63db authored by Bill Lynch's avatar Bill Lynch Committed by bill

New tests


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@339 b35dd754-fafc-0310-a699-88a17e54d16e
parent ed583d1f
......@@ -13,6 +13,7 @@ package org.jivesoftware.util;
import junit.framework.TestCase;
import java.io.ByteArrayInputStream;
import java.util.Iterator;
public class XMLPropertiesTest extends TestCase {
......@@ -24,4 +25,28 @@ public class XMLPropertiesTest extends TestCase {
props = new XMLProperties(new ByteArrayInputStream(xml.getBytes()));
assertEquals(props.getAttribute("foo","bar"), "test123");
}
public void testGetProperty() throws Exception {
XMLProperties props = new XMLProperties(
"./resources/org/jivesoftware/util/XMLProperties.test01.xml");
assertEquals("123", props.getProperty("foo.bar"));
assertEquals("456", props.getProperty("foo.bar.baz"));
assertNull(props.getProperty("foo"));
assertNull(props.getProperty("nothing.something"));
}
public void testGetChildPropertiesIterator() throws Exception {
XMLProperties props = new XMLProperties(
"./resources/org/jivesoftware/util/XMLProperties.test02.xml");
String[] names = {"a","b","c","d"};
String[] values = {"1","2","3","4"};
String[] children = props.getChildrenProperties("foo.bar");
for (int i=0; i<children.length; i++) {
String prop = children[i];
assertEquals(names[i], prop);
String value = props.getProperty("foo.bar." + prop);
assertEquals(values[i], value);
i++;
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment