commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang/builder ToStringBuilderTest.java
Date Wed, 30 Jun 2004 18:22:22 GMT
ggregory    2004/06/30 11:22:22

  Modified:    lang/src/test/org/apache/commons/lang/builder
                        ToStringBuilderTest.java
  Log:
  PR: http://issues.apache.org/bugzilla/show_bug.cgi?id=27876
  [lang] ReflectionToStringBuilder.toString(null) throws exception by design
  ReflectionToStringBuilder.toString is now null-safe and returns the style's nullText.
  ToStringBuilder constructors are now null-safe. A new ToStringBuilder on a null followed
by a call to toString returns "".
  
  Revision  Changes    Path
  1.14      +10 -35    jakarta-commons/lang/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java
  
  Index: ToStringBuilderTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/builder/ToStringBuilderTest.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ToStringBuilderTest.java	18 Feb 2004 23:00:51 -0000	1.13
  +++ ToStringBuilderTest.java	30 Jun 2004 18:22:22 -0000	1.14
  @@ -62,46 +62,18 @@
       //-----------------------------------------------------------------------
   
       public void testConstructorEx1() {
  -        try {
  -            new ToStringBuilder(null);
  -            
  -        } catch (IllegalArgumentException ex) {
  -            return;
  -        }
  -        fail();
  +        assertEquals("", new ToStringBuilder(null).toString());
       }
   
       public void testConstructorEx2() {
  -        try {
  -            new ToStringBuilder(null, null);
  -            
  -        } catch (IllegalArgumentException ex) {
  -            try {
  -                new ToStringBuilder(base, null);
  -                
  -            } catch (Exception ex2) {
  -                fail();
  -            }
  -            return;
  -        }
  -        fail();
  +        assertEquals("", new ToStringBuilder(null, null).toString());
  +        new ToStringBuilder(this.base, null).toString();
       }
   
       public void testConstructorEx3() {
  -        try {
  -            new ToStringBuilder(null, null, null);
  -            
  -        } catch (IllegalArgumentException ex) {
  -            try {
  -                new ToStringBuilder(base, null, null);
  -                new ToStringBuilder(base, ToStringStyle.DEFAULT_STYLE, null);
  -                
  -            } catch (Exception ex2) {
  -                fail();
  -            }
  -            return;
  -        }
  -        fail();
  +        assertEquals("", new ToStringBuilder(null, null, null).toString());
  +        new ToStringBuilder(this.base, null, null);
  +        new ToStringBuilder(this.base, ToStringStyle.DEFAULT_STYLE, null);
       }
   
       public void testGetSetDefault() {
  @@ -915,4 +887,7 @@
           static final int staticInt2 = 67890;
       }
   
  +    public void testReflectionNull() {
  +        assertEquals("<null>", ReflectionToStringBuilder.toString(null));
  +    }
   }
  
  
  

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