commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ep...@apache.org
Subject cvs commit: jakarta-commons/configuration/src/test/org/apache/commons/configuration/beanutils TestConfigurationDynaBean.java
Date Mon, 06 Sep 2004 12:52:13 GMT
epugh       2004/09/06 05:52:13

  Modified:    configuration/xdocs changes.xml
               configuration/src/java/org/apache/commons/configuration/beanutils
                        ConfigurationDynaBean.java
               configuration/src/test/org/apache/commons/configuration/beanutils
                        TestConfigurationDynaBean.java
  Log:
  30655 Clarify for ConfigurationDynaBean that the get method should
  throw an illegalArgumentException if there is no property specified.
  
  Revision  Changes    Path
  1.39      +4 -0      jakarta-commons/configuration/xdocs/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/xdocs/changes.xml,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- changes.xml	3 Sep 2004 16:36:21 -0000	1.38
  +++ changes.xml	6 Sep 2004 12:52:12 -0000	1.39
  @@ -7,6 +7,10 @@
   
     <body>
       <release version="1.0-rc2" date="in CVS">
  +      <action dev="epugh" type="fix" issue="30545" due-to="Ricardo Gladwell">
  +        Clarify for ConfigurationDynaBean that the get method should throw an illegalArgumentException
  +        if there is no property specified.
  +      </action>        
         <action dev="ebourg" type="fix" issue="30839">
           Fixed a ClassCastException when adding a non String property to an XMLConfiguration.
         </action>
  
  
  
  1.3       +2 -2      jakarta-commons/configuration/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java
  
  Index: ConfigurationDynaBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/java/org/apache/commons/configuration/beanutils/ConfigurationDynaBean.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ConfigurationDynaBean.java	12 Aug 2004 17:29:53 -0000	1.2
  +++ ConfigurationDynaBean.java	6 Sep 2004 12:52:12 -0000	1.3
  @@ -121,10 +121,10 @@
           if(log.isTraceEnabled()) log.trace("get("+name+")");
           // get configuration property
           Object result = configuration.getProperty(name);
  -        if(result == null && name != null) {
  +        if(result == null) {
               // otherwise attempt to create bean from configuration subset
               Configuration subset = configuration.subset(name);
  -            if(subset != null)
  +            if(!subset.isEmpty())
                   result = new ConfigurationDynaBean(configuration.subset(name));
           }
           if(log.isDebugEnabled()) log.debug(name+"=["+result+"]");
  
  
  
  1.2       +14 -1     jakarta-commons/configuration/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBean.java
  
  Index: TestConfigurationDynaBean.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/configuration/src/test/org/apache/commons/configuration/beanutils/TestConfigurationDynaBean.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestConfigurationDynaBean.java	12 Aug 2004 16:29:38 -0000	1.1
  +++ TestConfigurationDynaBean.java	6 Sep 2004 12:52:12 -0000	1.2
  @@ -797,6 +797,19 @@
           }
           fail("Should have thrown NullPointerException");
       }
  +    /**
  +     * Test the retrieval of a non-existent property.
  +     */
  +    public void testGetNonExistentProperty() {
  +        try {
  +            Object value = bean.get("nonexistProperty");
  +        } catch (IllegalArgumentException e) {
  +        	return;
  +        } catch(Exception e) {
  +            fail("Threw '" + e + "' instead of java.lang.IllegalArgumentException");
  +        }
  +        fail("Get non-existent property failed to throw java.lang.IllegalArgumentException");
  +    }
   
       /**
        * Base for testGetDescriptorXxxxx() series of tests.
  
  
  

---------------------------------------------------------------------
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