commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebo...@apache.org
Subject cvs commit: jakarta-commons/configuration/xdocs changes.xml
Date Fri, 03 Sep 2004 16:36:21 GMT
ebourg      2004/09/03 09:36:21

  Modified:    configuration/src/java/org/apache/commons/configuration
                        XMLConfiguration.java
               configuration/src/test/org/apache/commons/configuration
                        TestXMLConfiguration.java
               configuration/xdocs changes.xml
  Log:
  Fixed Bug 30839 (ClassCastException in XMLConfiguration)
  
  Revision  Changes    Path
  1.11      +4 -4      jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java
  
  Index: XMLConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/XMLConfiguration.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- XMLConfiguration.java	14 Aug 2004 11:32:06 -0000	1.10
  +++ XMLConfiguration.java	3 Sep 2004 16:36:20 -0000	1.11
  @@ -374,7 +374,7 @@
           }
   
           if (attName == null) {
  -            CharacterData data = document.createTextNode((String) value);
  +            CharacterData data = document.createTextNode(String.valueOf(value));
               element.appendChild(data);
           } else {
               element.setAttribute(attName, (String) value);
  @@ -427,10 +427,10 @@
           Element child = document.createElement(nodes[nodes.length - 1]);
           parent.appendChild(child);
           if (attName == null) {
  -            CharacterData data = document.createTextNode((String) value);
  +            CharacterData data = document.createTextNode(String.valueOf(value));
               child.appendChild(data);
           } else {
  -            child.setAttribute(attName, (String) value);
  +            child.setAttribute(attName, String.valueOf(value));
           }
       }
   
  
  
  
  1.9       +37 -24    jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java
  
  Index: TestXMLConfiguration.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/TestXMLConfiguration.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestXMLConfiguration.java	16 Aug 2004 22:16:31 -0000	1.8
  +++ TestXMLConfiguration.java	3 Sep 2004 16:36:21 -0000	1.9
  @@ -44,7 +44,7 @@
           conf = new XMLConfiguration(new File(testProperties));
       }
   
  -    public void testGetProperty() throws Exception
  +    public void testGetProperty()
       {
           assertEquals("value", conf.getProperty("element"));
       }
  @@ -66,7 +66,7 @@
           conf.clearProperty(key);
           assertNull(key, conf.getProperty(key));
           assertNull(key, conf.getXmlProperty(key));
  -        
  +
           // test single element
           conf.load();
           key = "clear.element";
  @@ -83,21 +83,21 @@
           key = "clear.element2[@id]";
           assertNotNull(key, conf.getProperty(key));
           assertNotNull(key, conf.getXmlProperty(key));
  -        
  +
           // test non-text/cdata element
           conf.load();
           key = "clear.comment";
           conf.clearProperty(key);
           assertNull(key, conf.getProperty(key));
           assertNull(key, conf.getXmlProperty(key));
  -        
  +
           // test cdata element
           conf.load();
           key = "clear.cdata";
           conf.clearProperty(key);
           assertNull(key, conf.getProperty(key));
           assertNull(key, conf.getXmlProperty(key));
  -        
  +
           // test multiple sibling elements
           conf.load();
           key = "clear.list.item";
  @@ -107,7 +107,7 @@
           key = "clear.list.item[@id]";
           assertNotNull(key, conf.getProperty(key));
           assertNotNull(key, conf.getXmlProperty(key));
  -        
  +
           // test multiple, disjoined elements
           conf.load();
           key = "list.item";
  @@ -120,7 +120,7 @@
           // test non-leaf element
           Object property = conf.getXmlProperty("clear");
           assertNull(property);
  -        
  +
           // test non-existent element
           property = conf.getXmlProperty("e");
           assertNull(property);
  @@ -128,29 +128,29 @@
           // test non-existent element
           property = conf.getXmlProperty("element3[@n]");
           assertNull(property);
  -        
  +
           // test single element
           property = conf.getXmlProperty("element");
           assertNotNull(property);
           assertTrue(property instanceof String);
           assertEquals("value", property);
  -        
  +
           // test single attribute
           property = conf.getXmlProperty("element3[@name]");
           assertNotNull(property);
           assertTrue(property instanceof String);
           assertEquals("foo", property);
  -        
  +
           // test non-text/cdata element
           property = conf.getXmlProperty("test.comment");
           assertNull(property);
  -        
  +
           // test cdata element
           property = conf.getXmlProperty("test.cdata");
           assertNotNull(property);
           assertTrue(property instanceof String);
           assertEquals("<cdata value>", property);
  -        
  +
           // test multiple sibling elements
           property = conf.getXmlProperty("list.sublist.item");
           assertNotNull(property);
  @@ -159,7 +159,7 @@
           assertEquals(2, list.size());
           assertEquals("five", list.get(0));
           assertEquals("six", list.get(1));
  -        
  +
           // test multiple, disjoined elements
           property = conf.getXmlProperty("list.item");
           assertNotNull(property);
  @@ -180,8 +180,8 @@
           assertEquals("one", list.get(0));
           assertEquals("three", list.get(1));
       }
  -    
  -    public void testGetAttribute() throws Exception
  +
  +    public void testGetAttribute()
       {
           assertEquals("element3[@name]", "foo", conf.getProperty("element3[@name]"));
       }
  @@ -205,7 +205,7 @@
           key = "clear.element2";
           assertNotNull(key, conf.getProperty(key));
           assertNotNull(key, conf.getXmlProperty(key));
  -        
  +
           // test multiple, disjoined attributes
           conf.load();
           key = "clear.list.item[@id]";
  @@ -217,7 +217,7 @@
           assertNotNull(key, conf.getXmlProperty(key));
       }
   
  -    public void testSetAttribute() throws Exception
  +    public void testSetAttribute()
       {
           // replace an existing attribute
           conf.setProperty("element3[@name]", "bar");
  @@ -228,7 +228,7 @@
           assertEquals("foo[@bar]", "value", conf.getProperty("foo[@bar]"));
       }
   
  -    public void testAddAttribute() throws Exception
  +    public void testAddAttribute()
       {
           conf.addProperty("element3[@name]", "bar");
   
  @@ -239,7 +239,13 @@
           assertEquals("list size", 2, list.size());
       }
   
  -    public void testAddVectorAttribute() throws Exception
  +    public void testAddObjectAttribute()
  +    {
  +        conf.addProperty("test.boolean[@value]", Boolean.TRUE);
  +        assertTrue("test.boolean[@value]", conf.getBoolean("test.boolean[@value]"));
  +    }
  +
  +    public void testAddVectorAttribute()
       {
           conf.addProperty("element3[@name]", "bar");
   
  @@ -250,7 +256,7 @@
           assertEquals("vector size", 2, vector.size());
       }
   
  -    public void testAddList() throws Exception
  +    public void testAddList()
       {
           conf.addProperty("test.array", "value1");
           conf.addProperty("test.array", "value2");
  @@ -262,7 +268,7 @@
           assertEquals("list size", 2, list.size());
       }
   
  -    public void testAddVector() throws Exception
  +    public void testAddVector()
       {
           conf.addProperty("test.array", "value1");
           conf.addProperty("test.array", "value2");
  @@ -274,12 +280,12 @@
           assertEquals("vector size", 2, vector.size());
       }
   
  -    public void testGetComplexProperty() throws Exception
  +    public void testGetComplexProperty()
       {
           assertEquals("I'm complex!", conf.getProperty("element2.subelement.subsubelement"));
       }
   
  -    public void testSettingFileNames() throws Exception
  +    public void testSettingFileNames()
       {
           conf = new XMLConfiguration();
           conf.setFileName(testProperties);
  @@ -325,6 +331,13 @@
           config.addProperty("test.string", "hello");
   
           assertEquals("'test.string'", "hello", config.getString("test.string"));
  +    }
  +
  +    public void testAddObjectProperty()
  +    {
  +        // add a non string property
  +        conf.addProperty("test.boolean", Boolean.TRUE);
  +        assertTrue("'test.boolean'", conf.getBoolean("test.boolean"));
       }
   
       public void testSave() throws Exception
  
  
  
  1.38      +3 -0      jakarta-commons/configuration/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- changes.xml	20 Aug 2004 15:49:27 -0000	1.37
  +++ changes.xml	3 Sep 2004 16:36:21 -0000	1.38
  @@ -7,6 +7,9 @@
   
     <body>
       <release version="1.0-rc2" date="in CVS">
  +      <action dev="ebourg" type="fix" issue="30839">
  +        Fixed a ClassCastException when adding a non String property to an XMLConfiguration.
  +      </action>
         <action dev="ebourg" type="fix" issue="30655" due-to="Oliver Heger">
           Fixed the handling of attribute properties by HierarchicalConfigurationConverter.
         </action>
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message