You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avalon.apache.org by Anton Tagunov <at...@mail.cnt.ru> on 2003/04/26 15:08:05 UTC
[PATCH] DefaultConfiguration [BUG 19345] Autocreated DefaultConfiguration nodes do not get inserted into parent - attempt 2 :-)
Oops, forgot how to send patches propelly :-))
diff -ur src.orig/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java
--- src.orig/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java 2003-02-27 19:25:02.000000000 +0300
+++ src/java/org/apache/avalon/framework/configuration/DefaultConfiguration.java 2003-04-26 16:25:38.000000000 +0400
@@ -307,7 +307,10 @@
if( createNew )
{
- return new DefaultConfiguration( name, "-" );
+ final DefaultConfiguration child =
+ new DefaultConfiguration( name, "-" );
+ addChild( child );
+ return child;
}
else
{
diff -ur src.orig/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationBuilderTestCase.java src/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationBuilderTestCase.java
--- src.orig/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationBuilderTestCase.java 2003-02-27 19:25:02.000000000 +0300
+++ src/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationBuilderTestCase.java 2003-04-26 16:38:16.000000000 +0400
@@ -144,7 +144,8 @@
fail( "Auto-created child nodes should not have a value" );
} catch ( ConfigurationException e )
{}
- assertEquals( "Turning auto-node-creation off failed", null, conf.getChild( "nonexistent", false )
+ assertEquals( "Turning auto-node-creation off failed", null,
+ conf.getChild( "another-nonexistent", false )
);
assertEquals( "Standard getChild() lookup failed", "elements-b", conf.getChild( "elements-b", false ).getName() );
assertEquals( "Boolean value surrounded by whitespace failed", true, conf.getChild("elements-c").getValueAsBoolean( false ) );
@@ -229,7 +230,8 @@
fail( "Auto-created child nodes should not have a value" );
} catch ( ConfigurationException e )
{}
- assertEquals( "Turning auto-node-creation off failed", null, conf.getChild( "nonexistent", false )
+ assertEquals( "Turning auto-node-creation off failed", null,
+ conf.getChild( "another-nonexistent", false )
);
assertEquals( "Standard getChild() lookup failed", "b:elements-b", conf.getChild( "b:elements-b", false ).getName() );
assertEquals( "Boolean value surrounded by whitespace failed", true, conf.getChild("elements-c").getValueAsBoolean( false ) );
@@ -292,7 +294,8 @@
fail( "Auto-created child nodes should not have a value" );
} catch ( ConfigurationException e )
{}
- assertEquals( "Turning auto-node-creation off failed", null, conf.getChild( "nonexistent", false )
+ assertEquals( "Turning auto-node-creation off failed", null,
+ conf.getChild( "another-nonexistent", false )
);
assertEquals( "Standard getChild() lookup failed", "elements-b", conf.getChild( "elements-b", false ).getName() );
assertEquals( "Boolean value surrounded by whitespace failed", true, conf.getChild("elements-c").getValueAsBoolean( false ) );
diff -ur src.orig/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationTestCase.java src/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationTestCase.java
--- src.orig/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationTestCase.java 2003-02-27 19:25:00.000000000 +0300
+++ src/test/org/apache/avalon/framework/configuration/test/DefaultConfigurationTestCase.java 2003-04-26 16:40:38.000000000 +0400
@@ -59,6 +59,7 @@
* Test the basic public methods of DefaultConfiguration.
*
* @author <a href="mailto:rantene@hotmail.com">Ran Tene</a>
+ * @author <a href="mailto:tagunov@motor.ru">Anton Tagunov</a>
*/
public final class DefaultConfigurationTestCase extends TestCase
{
@@ -151,6 +152,15 @@
m_configuration.removeChild( child );
assertEquals( null, m_configuration.getChild( childName, false ) );
}
+
+ public void testAutocreateChild()
+ {
+ final String name = "params";
+ final Configuration c1 = m_configuration.getChild( name );
+ final Configuration c2 = m_configuration.getChild( name );
+ assertTrue( "Autocreated child should have been saved",
+ c1 == c2 );
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@avalon.apache.org
For additional commands, e-mail: dev-help@avalon.apache.org