Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestWebdavConfigurationBuilder.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestWebdavConfigurationBuilder.java?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestWebdavConfigurationBuilder.java (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/TestWebdavConfigurationBuilder.java Sat Oct 24 15:09:58 2009 @@ -17,32 +17,34 @@ package org.apache.commons.configuration2; import java.io.File; +import java.io.FileReader; import java.io.IOException; +import java.io.OutputStreamWriter; import java.io.Reader; -import java.io.FileReader; import java.io.Writer; -import java.io.OutputStreamWriter; import java.util.Collection; -import java.util.Set; import java.util.HashMap; import java.util.Map; +import java.util.Set; import junit.framework.TestCase; import org.apache.commons.configuration2.beanutils.BeanHelper; -import org.apache.commons.configuration2.reloading.FileChangedReloadingStrategy; -import org.apache.commons.configuration2.tree.DefaultConfigurationNode; -import org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine; +import org.apache.commons.configuration2.combined.CombinedConfiguration; +import org.apache.commons.configuration2.combined.DynamicCombinedConfiguration; import org.apache.commons.configuration2.event.ConfigurationEvent; import org.apache.commons.configuration2.event.ConfigurationListener; +import org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine; import org.apache.commons.configuration2.fs.FileOptionsProvider; import org.apache.commons.configuration2.fs.FileSystem; import org.apache.commons.configuration2.fs.VFSFileSystem; +import org.apache.commons.configuration2.reloading.FileChangedReloadingStrategy; +import org.apache.commons.configuration2.tree.DefaultConfigurationNode; +import org.apache.commons.vfs.FileName; import org.apache.commons.vfs.FileObject; import org.apache.commons.vfs.FileSystemManager; -import org.apache.commons.vfs.VFS; -import org.apache.commons.vfs.FileName; import org.apache.commons.vfs.FileSystemOptions; +import org.apache.commons.vfs.VFS; /** * Test class for DefaultConfigurationBuilder. @@ -137,6 +139,7 @@ factory.clearErrorListeners(); // avoid exception messages } + @Override protected void tearDown() throws Exception { FileSystem.resetDefaultFileSystem();
Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/beanutils/TestConfigurationDynaBean.java Sat Oct 24 15:09:58 2009 @@ -21,15 +21,16 @@ import java.util.HashMap; import java.util.List; +import junit.framework.AssertionFailedError; +import junit.framework.TestCase; +import junitx.framework.ObjectAssert; + import org.apache.commons.beanutils.DynaProperty; import org.apache.commons.configuration2.Configuration; import org.apache.commons.configuration2.MapConfiguration; +import org.apache.commons.configuration2.expr.def.DefaultExpressionEngine; import org.apache.commons.configuration2.flat.BaseConfiguration; -import junit.framework.AssertionFailedError; -import junit.framework.TestCase; -import junitx.framework.ObjectAssert; - /** * <p>Test Case for the <code>ConfigurationDynaBean</code> implementation class. * These tests were based on the ones in <code>BasicDynaBeanTestCase</code> @@ -98,6 +99,7 @@ /** * Set up instance variables required by this test case. */ + @Override public void setUp() throws Exception { Configuration configuration = createConfiguration(); @@ -144,7 +146,11 @@ */ protected Configuration createConfiguration() { - return new BaseConfiguration(); + BaseConfiguration config = new BaseConfiguration(); + DefaultExpressionEngine expr = new DefaultExpressionEngine(); + expr.setPropertyDelimiter("/"); + config.setExpressionEngine(expr); + return config; } /** Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/FlatConfigurationMockImpl.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/FlatConfigurationMockImpl.java?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/FlatConfigurationMockImpl.java (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/FlatConfigurationMockImpl.java Sat Oct 24 15:09:58 2009 @@ -65,26 +65,27 @@ @Override public void clearPropertyDirect(String key) { - TestFlatNodes.assertEquals("Wrong property key", NAME, key); + Assert.assertEquals("Wrong property key", NAME, key); clearProperty = true; } @Override public void setProperty(String key, Object value) { - TestFlatNodes.assertFalse("Add operation expected", expectAdd); - TestFlatNodes.assertEquals("Wrong property key", NAME, key); + Assert.assertFalse("Add operation expected", expectAdd); + Assert.assertEquals("Wrong property key", NAME, key); property = value; } @Override protected void addPropertyDirect(String key, Object value) { - TestFlatNodes.assertTrue("Set operation expected", expectAdd); - TestFlatNodes.assertEquals("Wrong property key", NAME, key); + Assert.assertTrue("Set operation expected", expectAdd); + Assert.assertEquals("Wrong property key", NAME, key); property = value; } + @Override public boolean containsKey(String key) { return false; @@ -96,6 +97,7 @@ * * @return the keys stored in this configuration */ + @Override public Iterator<String> getKeys() { return keyList.iterator(); @@ -121,6 +123,7 @@ * exist, this call must match the current element of this list. Otherwise * the test property is returned. */ + @Override public Object getProperty(String key) { if (getPropertyInvocations != null) @@ -167,6 +170,7 @@ return getMaxIndexInvocations.remove(0).checkAndReturn(key); } + @Override public boolean isEmpty() { return false; Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestAbstractFlatConfiguration.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestAbstractFlatConfiguration.java?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestAbstractFlatConfiguration.java (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestAbstractFlatConfiguration.java Sat Oct 24 15:09:58 2009 @@ -152,9 +152,7 @@ */ public void testGetNodeHandler() { - FlatNodeHandler handler = (FlatNodeHandler) config.getNodeHandler(); - assertSame("Handler not associated with configuration", config, handler - .getConfiguration()); + assertNotNull("No node handler", config.getNodeHandler()); } /** @@ -210,7 +208,6 @@ checkNodeStructure(config.getRootNode()); FlatConfigurationMockImpl copy = (FlatConfigurationMockImpl) config.clone(); FlatNodeHandler handler = (FlatNodeHandler) copy.getNodeHandler(); - assertSame("Wrong config for node handler", copy, handler.getConfiguration()); assertNotSame("Node handler not copied", handler, config.getNodeHandler()); prepareGetRootNode(copy, 2); FlatNode root = copy.getRootNode(); Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodeHandler.java Sat Oct 24 15:09:58 2009 @@ -67,7 +67,7 @@ internalUpdate = handler.isInternalUpdate(); } }); - handler = new FlatNodeHandler(config); + handler = new FlatNodeHandler(); } /** @@ -88,7 +88,7 @@ */ private FlatNode setUpTestNode() { - FlatRootNode root = new FlatRootNode(); + FlatRootNode root = new FlatRootNode(config); for (String c : CHILD_NAMES) { root.addChild(c); @@ -109,14 +109,6 @@ } /** - * Tests whether the correct configuration is returned by the handler. - */ - public void testGetConfiguration() - { - assertSame("Configuration not set", config, handler.getConfiguration()); - } - - /** * Tests querying the child nodes of a node. */ public void testGetChildren() @@ -198,7 +190,7 @@ FlatNode child = handler.addChild(node, NAME); assertEquals("Wrong name of child", NAME, child.getName()); assertTrue("Config not empty", config.isEmpty()); - child.setValue(config, TestFlatNodes.VALUE); + child.setValue(TestFlatNodes.VALUE); assertEquals("Value not added", TestFlatNodes.VALUE, config.getProperty(NAME)); checkUpdate(false); } Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodes.java URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodes.java?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodes.java (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/java/org/apache/commons/configuration2/flat/TestFlatNodes.java Sat Oct 24 15:09:58 2009 @@ -16,13 +16,23 @@ */ package org.apache.commons.configuration2.flat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.List; -import junit.framework.TestCase; - +import org.apache.commons.configuration2.Configuration; import org.apache.commons.configuration2.ConfigurationRuntimeException; +import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.Test; /** * Test class for the FlatNode classes. @@ -31,7 +41,7 @@ * Configuration team</a> * @version $Id$ */ -public class TestFlatNodes extends TestCase +public class TestFlatNodes { /** Constant for the name of the test node. */ private static final String NAME = "testFlatNode"; @@ -39,23 +49,45 @@ /** Constant for a test value. */ static final Object VALUE = 42; + /** A mock object for the owning configuration. */ + private Configuration config; + /** The parent node. */ private FlatRootNode parent; /** The node to be tested. */ private FlatLeafNode node; - @Override - protected void setUp() throws Exception + @Before + public void setUp() throws Exception { - super.setUp(); - parent = new FlatRootNode(); + config = EasyMock.createMock(Configuration.class); + parent = new FlatRootNode(config); node = (FlatLeafNode) parent.addChild(NAME); } /** + * Tests whether the root node returns the correct configuration. + */ + @Test + public void testGetConfigurationRoot() + { + assertEquals("Wrong configuration", config, parent.getConfiguration()); + } + + /** + * Tests whether the leaf node returns the correct configuration. + */ + @Test + public void testGetConfigurationLeaf() + { + assertEquals("Wrong configuration", config, node.getConfiguration()); + } + + /** * Tests querying the name of a leaf node. */ + @Test public void testGetNameLeaf() { assertEquals("Wrong node name", NAME, node.getName()); @@ -64,6 +96,7 @@ /** * Tests querying the parent node. */ + @Test public void testGetParent() { assertSame("Wrong parent node", parent, node.getParent()); @@ -73,6 +106,7 @@ * Tests querying a leaf node's children. A leaf node has no children, so * result should always be an empty list. */ + @Test public void testGetChildrenLeaf() { assertTrue("Children not empty", node.getChildren().isEmpty()); @@ -82,6 +116,7 @@ * Tests querying a leaf's child nodes with a specific name. Because a leaf * node cannot have any children result should always be an empty list. */ + @Test public void testGetChildrenNameLeaf() { assertTrue("Named children not empty", node.getChildren("test") @@ -92,6 +127,7 @@ * Tests querying the number of children of a leaf node. Result should * always be 0. */ + @Test public void testGetChildrenCountLeaf() { assertEquals("Wrong number of total children", 0, node @@ -104,6 +140,7 @@ * Tests the getChild() method on a leaf. Because leafs have no children, * this method will always throw an exception. */ + @Test public void testGetChildLeaf() { for (int i = 0; i < 10; i++) @@ -124,6 +161,7 @@ * Tests querying the index of a child node if this node is the only child * with this name. */ + @Test public void testGetValueIndexLeafSingle() { assertEquals("Wrong index for single child node", @@ -133,6 +171,7 @@ /** * Tests querying the indices of child nodes. */ + @Test public void testGetValueIndexLeafMulti() { FlatNode c1 = parent.addChild(NAME); @@ -146,92 +185,109 @@ /** * Tests querying a simple value. */ + @Test public void testGetValueSimple() { - BaseConfiguration conf = new BaseConfiguration(); - conf.setProperty(NAME, VALUE); - assertEquals("Wrong property value", VALUE, node.getValue(conf)); + EasyMock.expect(config.getProperty(NAME)).andReturn(VALUE); + EasyMock.replay(config); + assertEquals("Wrong property value", VALUE, node.getValue()); + EasyMock.verify(config); } /** * Tests the getValue() method when the value is a collection, but no index * is specified. In this case the whole collection should be returned. */ + @Test public void testGetValueCollectionNoIndex() { - BaseConfiguration config = new BaseConfiguration(); Collection<Object> values = new ArrayList<Object>(); values.add(VALUE); - config.addPropertyDirect(NAME, values); - assertSame("Wrong value collection", values, node.getValue(config)); + EasyMock.expect(config.getProperty(NAME)).andReturn(values); + EasyMock.replay(config); + assertSame("Wrong value collection", values, node.getValue()); + EasyMock.verify(config); } /** * Tests the getValue() method when multiple values are involved. */ + @Test public void testGetValueCollection() { - BaseConfiguration config = new BaseConfiguration(); Collection<Object> values = new ArrayList<Object>(); values.add(VALUE); values.add(2); - config.setProperty(NAME, values); + EasyMock.expect(config.getProperty(NAME)).andReturn(values).times(2); + EasyMock.replay(config); FlatNode c2 = parent.addChild(NAME); - assertEquals("Wrong value index 1", VALUE, node.getValue(config)); - assertEquals("Wrong value index 2", 2, c2.getValue(config)); + assertEquals("Wrong value index 1", VALUE, node.getValue()); + assertEquals("Wrong value index 2", 2, c2.getValue()); + EasyMock.verify(config); } /** * Tests the getValue() method when multiple values are involved, but the * index is out of range. In this case null should be returned. */ + @Test public void testGetValueCollectionInvalidIndex() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, VALUE); - config.addProperty(NAME, 2); + Collection<Object> values = new ArrayList<Object>(); + values.add(VALUE); + values.add(2); + EasyMock.expect(config.getProperty(NAME)).andReturn(values); + EasyMock.replay(config); parent.addChild(NAME); FlatNode c2 = parent.addChild(NAME); - assertNull("Found value for invalid index", c2.getValue(config)); + assertNull("Found value for invalid index", c2.getValue()); + EasyMock.verify(config); } /** * Tests the setValue() method for a new value. */ + @Test public void testSetValueNew() { - BaseConfiguration config = new BaseConfiguration(); - node.setValue(config, VALUE); - assertEquals("Value was not set", VALUE, config.getProperty(NAME)); + config.addProperty(NAME, VALUE); + EasyMock.replay(config); + node.setValue(VALUE); + EasyMock.verify(config); } /** * Tests the setValue() method for an existing value. */ + @Test public void testSetValueExisting() { - BaseConfiguration config = new BaseConfiguration(); - // remove node, so that there is only a single child with this name - parent.removeChild(config, node); - FlatNode child = parent.addChild(NAME, true); - child.setValue(config, VALUE); - assertEquals("Value was not set", VALUE, config.getProperty(NAME)); + final String property = NAME + "_new"; + config.setProperty(property, VALUE); + EasyMock.replay(config); + FlatNode child = parent.addChild(property, true); + child.setValue(VALUE); + EasyMock.verify(config); } /** * Tests setting a value for a property with multiple values. */ + @Test public void testSetValueCollection() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, 1); - config.addProperty(NAME, 2); + Collection<Object> values = new ArrayList<Object>(); + values.add(1); + values.add(2); + Collection<Object> newValues = new ArrayList<Object>(); + newValues.add(1); + newValues.add(VALUE); + EasyMock.expect(config.getProperty(NAME)).andReturn(values); + config.setProperty(NAME, newValues); + EasyMock.replay(config); FlatNode child = parent.addChild(NAME, true); - child.setValue(config, VALUE); - List<?> values = config.getList(NAME); - assertEquals("Wrong number of values", 2, values.size()); - assertEquals("Wrong value 1", 1, values.get(0)); - assertEquals("Wrong value 2", VALUE, values.get(1)); + child.setValue(VALUE); + EasyMock.verify(config); } /** @@ -239,18 +295,18 @@ * value index is involved. This case should not happen normally. No * modification should be performed. */ + @Test public void testSetValueCollectionInvalidIndex() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, VALUE); - config.addProperty(NAME, 2); + Collection<Object> values = new ArrayList<Object>(); + values.add(VALUE); + values.add(2); + EasyMock.expect(config.getProperty(NAME)).andReturn(values); + EasyMock.replay(config); parent.addChild(NAME, true); FlatNode child = parent.addChild(NAME, true); - child.setValue(config, "new"); - List<?> values = config.getList(NAME); - assertEquals("Wrong number of values", 2, values.size()); - assertEquals("Wrong value 0", VALUE, values.get(0)); - assertEquals("Wrong value 1", 2, values.get(1)); + child.setValue("new"); + EasyMock.verify(config); } /** @@ -258,91 +314,98 @@ * configuration does not return a collection. This should normally not * happen. In this case no modification should be performed. */ + @Test public void testSetValueCollectionInvalidValue() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, VALUE); + EasyMock.expect(config.getProperty(NAME)).andReturn(VALUE); + EasyMock.replay(config); FlatNode child = parent.addChild(NAME, true); - child.setValue(config, "new"); - assertEquals("Value was changed", VALUE, config.getProperty(NAME)); + child.setValue("new"); + EasyMock.verify(config); } /** * Tests calling setValue() twice. The first time, the value should be * added. The second time it should be overridden. */ + @Test public void testSetValueNewAndExisting() { - BaseConfiguration config = new BaseConfiguration(); - config.setProperty(NAME, 1); - node.setValue(config, VALUE); - List<?> values = config.getList(NAME); - assertEquals("Value was not added", 2, values.size()); - assertEquals("Wrong value", VALUE, values.get(1)); - node.setValue(config, "new"); - assertEquals("Value was not changed", "new", config.getProperty(NAME)); + config.addProperty(NAME, VALUE); + config.setProperty(NAME, "new"); + EasyMock.replay(config); + node.setValue(VALUE); + node.setValue("new"); + EasyMock.verify(config); } /** * Tests removing a child node. The associated configuration should also be * updated, */ + @Test public void testRemoveChild() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, VALUE); - parent.removeChild(config, node); - assertFalse("Property not removed", config.containsKey(NAME)); + config.clearProperty(NAME); + EasyMock.replay(config); + parent.removeChild(node); + EasyMock.verify(config); } /** * Tests removing a child node for a property with multiple values. */ + @Test public void testRemoveChildCollection() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, new Object[] { - 1, 2, 3 - }); + List<Object> values = Arrays.asList(new Object[] { 1, 2, 3 }); + List<Object> newValues = new ArrayList<Object>(values); + newValues.remove(1); + EasyMock.expect(config.getProperty(NAME)).andReturn(values); + config.setProperty(NAME, newValues); + EasyMock.replay(config); FlatNode n2 = parent.addChild(NAME, true); parent.addChild(NAME, true); - parent.removeChild(config, n2); - List<?> values = config.getList(NAME); - assertEquals("Wrong number of values", 2, values.size()); - assertEquals("Wrong value 1", 1, values.get(0)); - assertEquals("Wrong value 2", 3, values.get(1)); + parent.removeChild(n2); + EasyMock.verify(config); } /** * Tests the behavior of removeChild() if after the operation only a single * collection element remains. */ + @Test public void testRemoveChildCollectionSingleElement() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, VALUE); - config.addProperty(NAME, 2); + List<Object> values = new ArrayList<Object>(); + values.add(VALUE); + values.add(2); + List<Object> newValues = new ArrayList<Object>(); + newValues.add(VALUE); + EasyMock.expect(config.getProperty(NAME)).andReturn(values); + config.setProperty(NAME, newValues); + EasyMock.replay(config); FlatNode n2 = parent.addChild(NAME, true); - parent.removeChild(config, n2); - assertEquals("Wrong value", VALUE, config.getProperty(NAME)); + parent.removeChild(n2); + EasyMock.verify(config); } /** * Tests removeChild() if the child has an invalid index. This should * normally not happen. In this case no modification should be performed. */ + @Test public void testRemoveChildCollectionInvalidIndex() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, VALUE); - config.addProperty(NAME, 2); + List<Object> values = new ArrayList<Object>(); + values.add(VALUE); + values.add(2); + EasyMock.expect(config.getProperty(NAME)).andReturn(values); + EasyMock.replay(config); parent.addChild(NAME, true); FlatNode n2 = parent.addChild(NAME, true); - parent.removeChild(config, n2); - List<?> values = config.getList(NAME); - assertEquals("Wrong number of values", 2, values.size()); - assertEquals("Wrong value 1", VALUE, values.get(0)); - assertEquals("Wrong value 2", 2, values.get(1)); + parent.removeChild(n2); + EasyMock.verify(config); } /** @@ -350,57 +413,46 @@ * configuration does not return a collection. This should normally not * happen. In this case no modification should be performed. */ - public void testRemoveChildeCollectionInvalidValue() + @Test + public void testRemoveChildCollectionInvalidValue() { - BaseConfiguration config = new BaseConfiguration(); - config.addProperty(NAME, VALUE); + EasyMock.expect(config.getProperty(NAME)).andReturn(VALUE); + EasyMock.replay(config); FlatNode n2 = parent.addChild(NAME, true); - parent.removeChild(config, n2); - assertEquals("Wrong value", VALUE, config.getProperty(NAME)); + parent.removeChild(n2); + EasyMock.verify(config); } /** * Tries to remove a child node that does not belong to the parent. This * should cause an exception. */ + @Test(expected = ConfigurationRuntimeException.class) public void testRemoveChildWrongParent() { FlatLeafNode child = new FlatLeafNode(null, "test", true); - BaseConfiguration config = new BaseConfiguration(); - try - { - parent.removeChild(config, child); - fail("Could remove non existing child!"); - } - catch (ConfigurationRuntimeException crex) - { - // ok - } + parent.removeChild(child); } /** * Tries to remove a null child node. This should cause an exception. */ + @Test(expected = ConfigurationRuntimeException.class) public void testRemoveChildNull() { - try - { - parent.removeChild(new BaseConfiguration(), null); - fail("Could remove null child!"); - } - catch (ConfigurationRuntimeException crex) - { - // ok - } + parent.removeChild(null); } /** * Tests corner cases when adding and removing child nodes. */ + @Test public void testAddAndRemoveChild() { final int count = 5; BaseConfiguration config = new BaseConfiguration(); + parent = new FlatRootNode(config); + node = (FlatLeafNode) parent.addChild(NAME); List<FlatNode> nodes = new ArrayList<FlatNode>(count); nodes.add(node); for (int i = 0; i < count; i++) @@ -414,18 +466,18 @@ for (int i = 0; i < count; i++) { assertEquals("Wrong value", Integer.valueOf(i), nodes.get(i) - .getValue(config)); + .getValue()); } for (int j = count - 1; j > 0; j--) { - parent.removeChild(config, nodes.get(j)); + parent.removeChild(nodes.get(j)); List<FlatNode> remainingChildren = parent.getChildren(NAME); assertEquals("Wrong children", nodes.subList(0, j), remainingChildren); } assertEquals("Wrong remaining value", Integer.valueOf(0), config .getProperty(NAME)); - parent.removeChild(config, nodes.get(0)); + parent.removeChild(nodes.get(0)); assertFalse("Property still found", config.containsKey(NAME)); assertEquals("Wrong number of children", 0, parent .getChildrenCount(NAME)); @@ -434,39 +486,25 @@ /** * Tests adding a child node to a leaf. This should cause an exception. */ + @Test(expected = ConfigurationRuntimeException.class) public void testAddChildLeaf() { - try - { - node.addChild(NAME); - fail("Could add a child to a leaf node!"); - } - catch (ConfigurationRuntimeException crex) - { - // ok - } + node.addChild(NAME); } /** * Tests removing a child from a leaf. This should cause an exception. */ + @Test(expected = ConfigurationRuntimeException.class) public void testRemoveChildLeaf() { - BaseConfiguration config = new BaseConfiguration(); - try - { - node.removeChild(config, parent); - fail("Could remove child from a leaf!"); - } - catch (ConfigurationRuntimeException crex) - { - // ok - } + node.removeChild(parent); } /** * Tests the getChildren() method of a root node. */ + @Test public void testGetChildren() { FlatNode c1 = parent.addChild("child1"); @@ -481,6 +519,7 @@ /** * Tests querying child nodes by their name. */ + @Test public void testGetChildrenName() { FlatNode c1 = parent.addChild("child1"); @@ -497,6 +536,7 @@ /** * Tests querying child nodes with a non existing name. */ + @Test public void testGetChildrenNameUnknown() { List<FlatNode> children = parent.getChildren("unknownName"); @@ -506,6 +546,7 @@ /** * Tests accessing child nodes by its index. */ + @Test public void testGetChild() { FlatNode c1 = parent.addChild("child1"); @@ -518,6 +559,7 @@ /** * Tests querying the number of child nodes. */ + @Test public void testGetChildrenCount() { parent.addChild("child1"); @@ -531,6 +573,7 @@ /** * Tests querying the total number of child nodes. */ + @Test public void testGetChildrenCountTotal() { parent.addChild("child1"); @@ -542,6 +585,7 @@ /** * Tests querying the number of non existing children. */ + @Test public void testGetChildrenCountUnknown() { assertEquals("Found unknown children", 0, parent @@ -551,6 +595,7 @@ /** * Tests querying the name of the root node. The answer should be null. */ + @Test public void testGetNameRoot() { assertNull("Wrong root name", parent.getName()); @@ -560,6 +605,7 @@ * Tests querying the parent of the root node. Of course, this node has no * parent. */ + @Test public void testGetParentRoot() { assertNull("Root node has a parent", parent.getParent()); @@ -569,6 +615,7 @@ * Tests querying the root node for its value index. This index is * undefined. */ + @Test public void testGetValueIndexRoot() { assertEquals("Wrong root value index", FlatNode.INDEX_UNDEFINED, parent @@ -578,27 +625,19 @@ /** * Tests querying the value from the root node. The root never has a value. */ + @Test public void testGetValueRoot() { - BaseConfiguration config = new BaseConfiguration(); - assertNull("Wrong value of root node", parent.getValue(config)); + assertNull("Wrong value of root node", parent.getValue()); } /** * Tests setting the value of the root node. This should cause an exception * because the root node does not support a value. */ + @Test(expected = ConfigurationRuntimeException.class) public void testSetValueRoot() { - BaseConfiguration config = new BaseConfiguration(); - try - { - parent.setValue(config, VALUE); - fail("Could set value of root node!"); - } - catch (ConfigurationRuntimeException crex) - { - // ok - } + parent.setValue(VALUE); } } Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testComplexInitialization.xml Sat Oct 24 15:09:58 2009 @@ -3,8 +3,8 @@ <configuration> <header> <result delimiterParsingDisabled="true"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> - <expressionEngine config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> + <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <combiner> <override> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testConfigurationProvider.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testConfigurationProvider.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testConfigurationProvider.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testConfigurationProvider.xml Sat Oct 24 15:09:58 2009 @@ -3,7 +3,7 @@ <configuration> <header> <result delimiterParsingDisabled="true"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> </result> <providers> <provider config-tag="test" Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testDigesterConfigurationSysProps.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testDigesterConfigurationSysProps.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testDigesterConfigurationSysProps.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testDigesterConfigurationSysProps.xml Sat Oct 24 15:09:58 2009 @@ -4,5 +4,5 @@ --> <configuration> <system/> - <properties fileName="${config.file}"/> + <properties fileName="${config..file}"/> </configuration> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExpression.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExpression.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExpression.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExpression.xml Sat Oct 24 15:09:58 2009 @@ -3,11 +3,11 @@ <configuration> <header> <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger" - config-class="org.apache.commons.configuration2.DynamicCombinedConfiguration" + config-class="org.apache.commons.configuration2.combined.DynamicCombinedConfiguration" keyPattern="$${sys:Id}"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.MergeCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.MergeCombiner"/> <expressionEngine - config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <lookups> <lookup config-prefix="expr" Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExtendedClass.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExtendedClass.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExtendedClass.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testExtendedClass.xml Sat Oct 24 15:09:58 2009 @@ -4,7 +4,7 @@ <header> <result delimiterParsingDisabled="true" config-class="org.apache.commons.configuration2.TestDefaultConfigurationBuilder$ExtendedCombinedConfiguration"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> </result> <combiner> <override> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileReloadConfigurationBuilder.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileReloadConfigurationBuilder.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileReloadConfigurationBuilder.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileReloadConfigurationBuilder.xml Sat Oct 24 15:09:58 2009 @@ -3,11 +3,11 @@ <configuration> <header> <result delimiterParsingDisabled="true" forceReloadCheck="true" - config-class="org.apache.commons.configuration2.DynamicCombinedConfiguration" + config-class="org.apache.commons.configuration2.combined.DynamicCombinedConfiguration" keyPattern="$${sys:Id}"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.MergeCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.MergeCombiner"/> <expressionEngine - config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <fileSystem config-class="org.apache.commons.configuration2.fs.VFSFileSystem"/> <providers> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileSystem.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileSystem.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileSystem.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testFileSystem.xml Sat Oct 24 15:09:58 2009 @@ -3,8 +3,8 @@ <configuration> <header> <result delimiterParsingDisabled="true"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> - <expressionEngine config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> + <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <fileSystem config-class="org.apache.commons.configuration2.fs.VFSFileSystem"/> <providers> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testGlobalLookup.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testGlobalLookup.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testGlobalLookup.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testGlobalLookup.xml Sat Oct 24 15:09:58 2009 @@ -3,8 +3,8 @@ <configuration> <header> <result delimiterParsingDisabled="true"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> - <expressionEngine config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> + <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <lookups> <lookup config-prefix="test" Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder.xml Sat Oct 24 15:09:58 2009 @@ -3,11 +3,11 @@ <configuration> <header> <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger" - config-class="org.apache.commons.configuration2.DynamicCombinedConfiguration" + config-class="org.apache.commons.configuration2.combined.DynamicCombinedConfiguration" keyPattern="$${sys:Id}"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.MergeCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.MergeCombiner"/> <expressionEngine - config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <providers> <provider config-tag="multifile" Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder2.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder2.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder2.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder2.xml Sat Oct 24 15:09:58 2009 @@ -3,11 +3,11 @@ <configuration> <header> <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger" - config-class="org.apache.commons.configuration2.DynamicCombinedConfiguration" + config-class="org.apache.commons.configuration2.combined.DynamicCombinedConfiguration" keyPattern="$${sys:Id}"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.MergeCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.MergeCombiner"/> <expressionEngine - config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <entity-resolver catalogFiles="catalog.xml"/> <providers> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder3.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder3.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder3.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testMultiTenentConfigurationBuilder3.xml Sat Oct 24 15:09:58 2009 @@ -3,11 +3,11 @@ <configuration> <header> <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger" - config-class="org.apache.commons.configuration2.DynamicCombinedConfiguration" + config-class="org.apache.commons.configuration2.combined.DynamicCombinedConfiguration" keyPattern="$${sys:Id}"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.MergeCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.MergeCombiner"/> <expressionEngine - config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <entity-resolver catalogFiles="catalog.xml"/> <providers> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testSystemProperties.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testSystemProperties.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testSystemProperties.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testSystemProperties.xml Sat Oct 24 15:09:58 2009 @@ -3,8 +3,8 @@ <configuration systemProperties="test.properties.xml"> <header> <result delimiterParsingDisabled="true"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> - <expressionEngine config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> + <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> </header> <system/> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testVFSMultiTenentConfigurationBuilder1.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testVFSMultiTenentConfigurationBuilder1.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testVFSMultiTenentConfigurationBuilder1.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testVFSMultiTenentConfigurationBuilder1.xml Sat Oct 24 15:09:58 2009 @@ -3,11 +3,11 @@ <configuration> <header> <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger" - config-class="org.apache.commons.configuration2.DynamicCombinedConfiguration" + config-class="org.apache.commons.configuration2.combined.DynamicCombinedConfiguration" keyPattern="$${sys:Id}"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.MergeCombiner"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.MergeCombiner"/> <expressionEngine - config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <fileSystem config-class="org.apache.commons.configuration2.fs.VFSFileSystem"/> <entity-resolver catalogFiles="catalog.xml"/> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation.xml Sat Oct 24 15:09:58 2009 @@ -3,8 +3,8 @@ <configuration> <header> <result delimiterParsingDisabled="true"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> - <expressionEngine config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> + <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <entity-resolver catalogFiles="catalog.xml"/> </header> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation2.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation2.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation2.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation2.xml Sat Oct 24 15:09:58 2009 @@ -3,8 +3,8 @@ <configuration> <header> <result delimiterParsingDisabled="true"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.OverrideCombiner"/> - <expressionEngine config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.OverrideCombiner"/> + <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <entity-resolver catalogFiles="file://${sys:user.dir}/target/test-classes/catalog2.xml"/> </header> Modified: commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation3.xml URL: http://svn.apache.org/viewvc/commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation3.xml?rev=829384&r1=829383&r2=829384&view=diff ============================================================================== --- commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation3.xml (original) +++ commons/proper/configuration/branches/configuration2_experimental/src/test/resources/testValidation3.xml Sat Oct 24 15:09:58 2009 @@ -3,10 +3,10 @@ <configuration> <header> <result delimiterParsingDisabled="true" forceReloadCheck="true" loggerName="TestLogger" - config-class="org.apache.commons.configuration2.DynamicCombinedConfiguration" + config-class="org.apache.commons.configuration2.combined.DynamicCombinedConfiguration" keyPattern="$${sys:Id}"> - <nodeCombiner config-class="org.apache.commons.configuration2.tree.MergeCombiner"/> - <expressionEngine config-class="org.apache.commons.configuration2.tree.xpath.XPathExpressionEngine"/> + <nodeCombiner config-class="org.apache.commons.configuration2.combined.MergeCombiner"/> + <expressionEngine config-class="org.apache.commons.configuration2.expr.xpath.XPathExpressionEngine"/> </result> <providers> <provider config-tag="multifile"