commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/lang/src/test/org/apache/commons/lang SerializationUtilsTest.java BooleanUtilsTest.java CharSetUtilsTest.java StringUtilsEqualsIndexOfTest.java SystemUtilsTest.java StringEscapeUtilsTest.java StringUtilsTest.java RandomStringUtilsTest.java ClassUtilsTest.java StringUtilsSubstringTest.java WordWrapUtilsTest.java ArrayUtilsTest.java ObjectUtilsTest.java
Date Wed, 30 Jul 2003 22:21:40 GMT
scolebourne    2003/07/30 15:21:40

  Modified:    lang/src/test/org/apache/commons/lang
                        SerializationUtilsTest.java BooleanUtilsTest.java
                        CharSetUtilsTest.java
                        StringUtilsEqualsIndexOfTest.java
                        SystemUtilsTest.java StringEscapeUtilsTest.java
                        StringUtilsTest.java RandomStringUtilsTest.java
                        ClassUtilsTest.java StringUtilsSubstringTest.java
                        WordWrapUtilsTest.java ArrayUtilsTest.java
                        ObjectUtilsTest.java
  Log:
  Additional tests as suggested by Clover report
  
  Revision  Changes    Path
  1.4       +34 -2     jakarta-commons/lang/src/test/org/apache/commons/lang/SerializationUtilsTest.java
  
  Index: SerializationUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/SerializationUtilsTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SerializationUtilsTest.java	19 Jul 2003 20:22:36 -0000	1.3
  +++ SerializationUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.4
  @@ -57,6 +57,8 @@
   import java.io.ByteArrayOutputStream;
   import java.io.InputStream;
   import java.io.ObjectOutputStream;
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
   import java.util.HashMap;
   
   import junit.framework.Test;
  @@ -105,7 +107,37 @@
       }
   
       //-----------------------------------------------------------------------
  -
  +    public void testConstructor() {
  +        assertNotNull(new SerializationUtils());
  +        Constructor[] cons = SerializationUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(SerializationUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(SerializationUtils.class.getModifiers()));
  +    }
  +    
  +    public void testException() {
  +        SerializationException serEx;
  +        Exception ex = new Exception();
  +        
  +        serEx = new SerializationException();
  +        assertSame(null, serEx.getMessage());
  +        assertSame(null, serEx.getCause());
  +        
  +        serEx = new SerializationException("Message");
  +        assertSame("Message", serEx.getMessage());
  +        assertSame(null, serEx.getCause());
  +        
  +        serEx = new SerializationException(ex);
  +        assertEquals("java.lang.Exception", serEx.getMessage());
  +        assertSame(ex, serEx.getCause());
  +        
  +        serEx = new SerializationException("Message", ex);
  +        assertSame("Message", serEx.getMessage());
  +        assertSame(ex, serEx.getCause());
  +    }
  +    
  +    //-----------------------------------------------------------------------
       public void testSerializeStream() throws Exception {
           ByteArrayOutputStream streamTest = new ByteArrayOutputStream();
           SerializationUtils.serialize(iMap, streamTest);
  
  
  
  1.5       +47 -2     jakarta-commons/lang/src/test/org/apache/commons/lang/BooleanUtilsTest.java
  
  Index: BooleanUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/BooleanUtilsTest.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- BooleanUtilsTest.java	28 Jun 2003 18:16:03 -0000	1.4
  +++ BooleanUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.5
  @@ -53,6 +53,9 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  @@ -90,6 +93,16 @@
       }
   
       //-----------------------------------------------------------------------
  +    public void testConstructor() {
  +        assertNotNull(new BooleanUtils());
  +        Constructor[] cons = BooleanUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(BooleanUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(BooleanUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       public void test_negate_Boolean() {
           assertSame(null, BooleanUtils.negate(null));
           assertSame(Boolean.TRUE, BooleanUtils.negate(Boolean.FALSE));
  @@ -151,6 +164,14 @@
       public void test_toBoolean_Integer_Integer_Integer() {
           Integer six = new Integer(6);
           Integer seven = new Integer(7);
  +
  +        assertEquals(true, BooleanUtils.toBoolean((Integer) null, null, seven));
  +        assertEquals(false, BooleanUtils.toBoolean((Integer) null, six, null));
  +        try {
  +            BooleanUtils.toBoolean(null, six, seven);
  +            fail();
  +        } catch (IllegalArgumentException ex) {}
  +        
           assertEquals(true, BooleanUtils.toBoolean(new Integer(6), six, seven));
           assertEquals(false, BooleanUtils.toBoolean(new Integer(7), six, seven));
           try {
  @@ -170,10 +191,19 @@
           } catch (IllegalArgumentException ex) {}
       }
       
  -    public void test_toBooleanObject_Integer_Integer_Integer() {
  +    public void test_toBooleanObject_Integer_Integer_Integer_Integer() {
           Integer six = new Integer(6);
           Integer seven = new Integer(7);
           Integer eight = new Integer(8);
  +
  +        assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((Integer) null, null, seven,
eight));
  +        assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((Integer) null, six, null,
eight));
  +        assertSame(null, BooleanUtils.toBooleanObject((Integer) null, six, seven, null));
  +        try {
  +            BooleanUtils.toBooleanObject(null, six, seven, eight);
  +            fail();
  +        } catch (IllegalArgumentException ex) {}
  +        
           assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject(new Integer(6), six, seven,
eight));
           assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject(new Integer(7), six, seven,
eight));
           assertEquals(null, BooleanUtils.toBooleanObject(new Integer(8), six, seven, eight));
  @@ -251,6 +281,14 @@
       }
       
       public void test_toBooleanObject_String_String_String_String() {
  +        assertSame(Boolean.TRUE, BooleanUtils.toBooleanObject((String) null, null, "N",
"U"));
  +        assertSame(Boolean.FALSE, BooleanUtils.toBooleanObject((String) null, "Y", null,
"U"));
  +        assertSame(null, BooleanUtils.toBooleanObject((String) null, "Y", "N", null));
  +        try {
  +            BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
  +            fail();
  +        } catch (IllegalArgumentException ex) {}
  +
           assertEquals(Boolean.TRUE, BooleanUtils.toBooleanObject("Y", "Y", "N", "U"));
           assertEquals(Boolean.FALSE, BooleanUtils.toBooleanObject("N", "Y", "N", "U"));
           assertEquals(null, BooleanUtils.toBooleanObject("U", "Y", "N", "U"));
  @@ -280,6 +318,13 @@
       }
   
       public void test_toBoolean_String_String_String() {
  +        assertEquals(true, BooleanUtils.toBoolean((String) null, null, "N"));
  +        assertEquals(false, BooleanUtils.toBoolean((String) null, "Y", null));
  +        try {
  +            BooleanUtils.toBooleanObject((String) null, "Y", "N", "U");
  +            fail();
  +        } catch (IllegalArgumentException ex) {}
  +        
           assertEquals(true, BooleanUtils.toBoolean("Y", "Y", "N"));
           assertEquals(false, BooleanUtils.toBoolean("N", "Y", "N"));
           try {
  
  
  
  1.10      +14 -2     jakarta-commons/lang/src/test/org/apache/commons/lang/CharSetUtilsTest.java
  
  Index: CharSetUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/CharSetUtilsTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- CharSetUtilsTest.java	30 Jul 2003 00:08:38 -0000	1.9
  +++ CharSetUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.10
  @@ -53,6 +53,9 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  @@ -91,7 +94,16 @@
       }
   
       //-----------------------------------------------------------------------
  -
  +    public void testConstructor() {
  +        assertNotNull(new CharSetUtils());
  +        Constructor[] cons = CharSetUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(CharSetUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(CharSetUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       public void testSqueeze() {
           assertEquals(null, CharSetUtils.squeeze(null, (String[]) null));
           assertEquals(null, CharSetUtils.squeeze(null, (String) null));
  
  
  
  1.6       +3 -1      jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java
  
  Index: StringUtilsEqualsIndexOfTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsEqualsIndexOfTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StringUtilsEqualsIndexOfTest.java	26 Jul 2003 14:36:30 -0000	1.5
  +++ StringUtilsEqualsIndexOfTest.java	30 Jul 2003 22:21:39 -0000	1.6
  @@ -315,6 +315,8 @@
       
       //-----------------------------------------------------------------------
       public void testIndexOfAnyButChar() {
  +        assertEquals(-1, StringUtils.indexOfAnyBut(null, (char[]) null));
  +        assertEquals(-1, StringUtils.indexOfAnyBut("", (char[]) null));
           assertEquals(-1, StringUtils.indexOfAnyBut(null, new char[0]));
           assertEquals(-1, StringUtils.indexOfAnyBut("", new char[0]));
           assertEquals(3, StringUtils.indexOfAnyBut("zzabyycdxx", new char[] {'z','a'}));

  
  
  
  1.4       +14 -1     jakarta-commons/lang/src/test/org/apache/commons/lang/SystemUtilsTest.java
  
  Index: SystemUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/SystemUtilsTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SystemUtilsTest.java	21 Jul 2003 22:57:51 -0000	1.3
  +++ SystemUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.4
  @@ -53,6 +53,9 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  @@ -91,6 +94,16 @@
           super.tearDown();
       }
   
  +    //-----------------------------------------------------------------------
  +    public void testConstructor() {
  +        assertNotNull(new SystemUtils());
  +        Constructor[] cons = SystemUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(SystemUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(SystemUtils.class.getModifiers()));
  +    }
  +    
       //-----------------------------------------------------------------------
       // COPIED FROM SystemUtils
       //-----------------------------------------------------------------------
  
  
  
  1.11      +13 -2     jakarta-commons/lang/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java
  
  Index: StringEscapeUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringEscapeUtilsTest.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- StringEscapeUtilsTest.java	30 Jul 2003 00:08:38 -0000	1.10
  +++ StringEscapeUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.11
  @@ -54,6 +54,8 @@
   package org.apache.commons.lang;
   
   import java.io.IOException;
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
   
   import junit.framework.Test;
   import junit.framework.TestCase;
  @@ -85,7 +87,16 @@
       }
   
       //-----------------------------------------------------------------------
  -
  +    public void testConstructor() {
  +        assertNotNull(new StringEscapeUtils());
  +        Constructor[] cons = StringEscapeUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(StringEscapeUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(StringEscapeUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       public void testEscapeJava() throws IOException {
           assertEquals(null, StringEscapeUtils.escapeJava(null));
           try {
  
  
  
  1.40      +24 -2     jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java
  
  Index: StringUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsTest.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- StringUtilsTest.java	25 Jul 2003 22:22:30 -0000	1.39
  +++ StringUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.40
  @@ -53,6 +53,8 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
   import java.util.Arrays;
   import java.util.Iterator;
   
  @@ -146,7 +148,16 @@
       }
   
       //-----------------------------------------------------------------------
  -
  +    public void testConstructor() {
  +        assertNotNull(new StringUtils());
  +        Constructor[] cons = StringUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(StringUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(StringUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       public void testCaseFunctions() {
           assertEquals(null, StringUtils.upperCase(null));
           assertEquals(null, StringUtils.lowerCase(null));
  @@ -221,6 +232,7 @@
       public void testJoin_IteratorChar() {
           assertEquals(null, StringUtils.join((Iterator) null, ','));
           assertEquals(TEXT_LIST_CHAR, StringUtils.join(Arrays.asList(ARRAY_LIST).iterator(),
SEPARATOR_CHAR));
  +        assertEquals("", StringUtils.join(Arrays.asList(NULL_ARRAY_LIST).iterator(), SEPARATOR_CHAR));
           assertEquals("", StringUtils.join(Arrays.asList(EMPTY_ARRAY_LIST).iterator(), SEPARATOR_CHAR));
       }
       
  @@ -452,6 +464,9 @@
           assertEquals("aaa", StringUtils.repeat("a", 3));
           assertEquals("ababab", StringUtils.repeat("ab", 3));
           assertEquals("abcabcabc", StringUtils.repeat("abc", 3));
  +        String str = StringUtils.repeat("a", 10000);  // bigger than pad limit
  +        assertEquals(10000, str.length());
  +        assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
       }
   
       public void testDeprecatedChompFunctions() {
  @@ -509,6 +524,7 @@
               { "foo\n\rfoo", "foo\n\rfoo" },
               { "\n", "" },
               { "\r", "" },
  +            { "a", "a" },
               { "\r\n", "" },
               { "", "" },
               { null, null },
  @@ -589,6 +605,9 @@
           assertEquals("abc", StringUtils.rightPad("abc", 2, ' '));
           assertEquals("abc", StringUtils.rightPad("abc", -1, ' '));
           assertEquals("abcxx", StringUtils.rightPad("abc", 5, 'x'));
  +        String str = StringUtils.rightPad("aaa", 10000, 'a');  // bigger than pad length
  +        assertEquals(10000, str.length());
  +        assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
       }
   
       public void testRightPad_StringIntString() {
  @@ -624,6 +643,9 @@
           assertEquals("  abc", StringUtils.leftPad("abc", 5, ' '));
           assertEquals("xxabc", StringUtils.leftPad("abc", 5, 'x'));
           assertEquals("abc", StringUtils.leftPad("abc", 2, ' '));
  +        String str = StringUtils.leftPad("aaa", 10000, 'a');  // bigger than pad length
  +        assertEquals(10000, str.length());
  +        assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
       }
           
       public void testLeftPad_StringIntString() {
  
  
  
  1.9       +14 -1     jakarta-commons/lang/src/test/org/apache/commons/lang/RandomStringUtilsTest.java
  
  Index: RandomStringUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/RandomStringUtilsTest.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RandomStringUtilsTest.java	20 Jul 2003 15:49:58 -0000	1.8
  +++ RandomStringUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.9
  @@ -53,6 +53,8 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
   import java.util.Random;
   
   import junit.framework.Test;
  @@ -93,6 +95,17 @@
       public void tearDown() {
       }
       
  +    //-----------------------------------------------------------------------
  +    public void testConstructor() {
  +        assertNotNull(new RandomStringUtils());
  +        Constructor[] cons = RandomStringUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(RandomStringUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(RandomStringUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       /**
        * Test the implementation
        */
  
  
  
  1.4       +17 -3     jakarta-commons/lang/src/test/org/apache/commons/lang/ClassUtilsTest.java
  
  Index: ClassUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/ClassUtilsTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ClassUtilsTest.java	23 Mar 2003 21:47:30 -0000	1.3
  +++ ClassUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.4
  @@ -53,6 +53,8 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
   import java.util.ArrayList;
   import java.util.List;
   import java.util.Map;
  @@ -95,6 +97,16 @@
       private static class Inner {
       }
       
  +    //-----------------------------------------------------------------------
  +    public void testConstructor() {
  +        assertNotNull(new ClassUtils());
  +        Constructor[] cons = ClassUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(ClassUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(ClassUtils.class.getModifiers()));
  +    }
  +    
       // -------------------------------------------------------------------------
       public void test_getShortClassName_Object() {
           assertEquals("ClassUtils", ClassUtils.getShortClassName(new ClassUtils(), "<null>"));
  @@ -231,11 +243,13 @@
           assertEquals(0, result.size());
           
           list.add(String.class);
  +        list.add(null);
           list.add(Object.class);
           result = ClassUtils.convertClassesToClassNames(list);
  -        assertEquals(2, result.size());
  +        assertEquals(3, result.size());
           assertEquals("java.lang.String", result.get(0));
  -        assertEquals("java.lang.Object", result.get(1));
  +        assertEquals(null, result.get(1));
  +        assertEquals("java.lang.Object", result.get(2));
   
           list.add(new Object());
           try {
  
  
  
  1.10      +22 -14    jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
  
  Index: StringUtilsSubstringTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- StringUtilsSubstringTest.java	25 Jul 2003 22:22:30 -0000	1.9
  +++ StringUtilsSubstringTest.java	30 Jul 2003 22:21:39 -0000	1.10
  @@ -98,14 +98,33 @@
       //-----------------------------------------------------------------------
   
   
  -    public void testSubstring2() {
  +    public void testSubstring_StringInt() {
  +        assertEquals(null, StringUtils.substring(null, 0));
  +        assertEquals("", StringUtils.substring("", 0));
  +        assertEquals("", StringUtils.substring("", 2));
  +        
           assertEquals("", StringUtils.substring(SENTENCE, 80));
           assertEquals(BAZ, StringUtils.substring(SENTENCE, 8));
           assertEquals(BAZ, StringUtils.substring(SENTENCE, -3));
           assertEquals(SENTENCE, StringUtils.substring(SENTENCE, 0));
  +        assertEquals("abc", StringUtils.substring("abc", -4));
  +        assertEquals("abc", StringUtils.substring("abc", -3));
  +        assertEquals("bc", StringUtils.substring("abc", -2));
  +        assertEquals("c", StringUtils.substring("abc", -1));
  +        assertEquals("abc", StringUtils.substring("abc", 0));
  +        assertEquals("bc", StringUtils.substring("abc", 1));
  +        assertEquals("c", StringUtils.substring("abc", 2));
  +        assertEquals("", StringUtils.substring("abc", 3));
  +        assertEquals("", StringUtils.substring("abc", 4));
       }
       
  -    public void testSubstring3() {
  +    public void testSubstring_StringIntInt() {
  +        assertEquals(null, StringUtils.substring(null, 0, 0));
  +        assertEquals(null, StringUtils.substring(null, 1, 2));
  +        assertEquals("", StringUtils.substring("", 0, 0));
  +        assertEquals("", StringUtils.substring("", 1, 2));
  +        assertEquals("", StringUtils.substring("", -2, -1));
  +        
           assertEquals("", StringUtils.substring(SENTENCE, 8, 6));
           assertEquals(FOO, StringUtils.substring(SENTENCE, 0, 3));
           assertEquals("o", StringUtils.substring(SENTENCE, -9, 3));
  @@ -114,17 +133,6 @@
           assertEquals(SENTENCE, StringUtils.substring(SENTENCE, 0, 80));
           assertEquals("", StringUtils.substring(SENTENCE, 2, 2));
           assertEquals("b",StringUtils.substring("abc", -2, -1));
  -    }
  -    
  -    public void testSubstring4() {
  -        assertEquals("", StringUtils.substring("",0));
  -        assertEquals("", StringUtils.substring("",2));
  -        assertEquals("", StringUtils.substring("",0,0));
  -        assertEquals("", StringUtils.substring("",1,2));
  -        assertEquals("", StringUtils.substring("",-2,-1));
  -        assertEquals(null, StringUtils.substring(null,0));
  -        assertEquals(null, StringUtils.substring(null,0,0));
  -        assertEquals(null, StringUtils.substring(null,1,2));
       }
              
       public void testLeft_String() {
  
  
  
  1.3       +17 -1     jakarta-commons/lang/src/test/org/apache/commons/lang/WordWrapUtilsTest.java
  
  Index: WordWrapUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/WordWrapUtilsTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WordWrapUtilsTest.java	19 Jul 2003 20:22:36 -0000	1.2
  +++ WordWrapUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.3
  @@ -53,6 +53,9 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  @@ -61,6 +64,8 @@
    * Unit tests for the wrap methods of WordWrapUtils.
    * 
    * @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
  + * @author Henri Yandell
  + * @author Stephen Colebourne
    * @version $Id$
    */
   public class WordWrapUtilsTest extends TestCase {
  @@ -75,6 +80,17 @@
           return suite;
       }
   
  +    //-----------------------------------------------------------------------
  +    public void testConstructor() {
  +        assertNotNull(new WordWrapUtils());
  +        Constructor[] cons = WordWrapUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(WordWrapUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(WordWrapUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       /**
        * Wrap text. This is the most general use.
        */
  
  
  
  1.10      +42 -2     jakarta-commons/lang/src/test/org/apache/commons/lang/ArrayUtilsTest.java
  
  Index: ArrayUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/ArrayUtilsTest.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- ArrayUtilsTest.java	12 Jul 2003 10:09:40 -0000	1.9
  +++ ArrayUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.10
  @@ -53,6 +53,8 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
   import java.util.Arrays;
   import java.util.Map;
   
  @@ -95,6 +97,16 @@
       }
   
       //-----------------------------------------------------------------------
  +    public void testConstructor() {
  +        assertNotNull(new ArrayUtils());
  +        Constructor[] cons = ArrayUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(ArrayUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(ArrayUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       public void testToString() {
           assertEquals("{}", ArrayUtils.toString(null));
           assertEquals("{}", ArrayUtils.toString(new Object[0]));
  @@ -195,6 +207,7 @@
       }
   
       public void testCloneBoolean() {
  +        assertEquals(null, ArrayUtils.clone((boolean[]) null));
           boolean[] original = new boolean[] {true, false};
           boolean[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -202,6 +215,7 @@
       }
       
       public void testCloneLong() {
  +        assertEquals(null, ArrayUtils.clone((long[]) null));
           long[] original = new long[] {0L, 1L};
           long[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -209,6 +223,7 @@
       }
       
       public void testCloneInt() {
  +        assertEquals(null, ArrayUtils.clone((int[]) null));
           int[] original = new int[] {5, 8};
           int[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -216,6 +231,7 @@
       }
       
       public void testCloneShort() {
  +        assertEquals(null, ArrayUtils.clone((short[]) null));
           short[] original = new short[] {1, 4};
           short[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -223,6 +239,7 @@
       }
       
       public void testCloneChar() {
  +        assertEquals(null, ArrayUtils.clone((char[]) null));
           char[] original = new char[] {'a', '4'};
           char[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -230,6 +247,7 @@
       }
       
       public void testCloneByte() {
  +        assertEquals(null, ArrayUtils.clone((byte[]) null));
           byte[] original = new byte[] {1, 6};
           byte[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -237,6 +255,7 @@
       }
       
       public void testCloneDouble() {
  +        assertEquals(null, ArrayUtils.clone((double[]) null));
           double[] original = new double[] {2.4d, 5.7d};
           double[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -244,6 +263,7 @@
       }
       
       public void testCloneFloat() {
  +        assertEquals(null, ArrayUtils.clone((float[]) null));
           float[] original = new float[] {2.6f, 6.4f};
           float[] cloned = ArrayUtils.clone(original);
           assertTrue(Arrays.equals(original, cloned));
  @@ -642,6 +662,7 @@
           Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
           assertEquals(-1, ArrayUtils.indexOf(null, null));
           assertEquals(-1, ArrayUtils.indexOf(null, "0"));
  +        assertEquals(-1, ArrayUtils.indexOf(new Object[0], "0"));
           assertEquals(0, ArrayUtils.indexOf(array, "0"));
           assertEquals(1, ArrayUtils.indexOf(array, "1"));
           assertEquals(2, ArrayUtils.indexOf(array, "2"));
  @@ -653,6 +674,7 @@
       public void testIndexOfWithStartIndex() {
           Object[] array = new Object[] { "0", "1", "2", "3", null, "0" };
           assertEquals(-1, ArrayUtils.indexOf(null, null, 2));
  +        assertEquals(-1, ArrayUtils.indexOf(new Object[0], "0", 0));
           assertEquals(-1, ArrayUtils.indexOf(null, "0", 2));
           assertEquals(5, ArrayUtils.indexOf(array, "0", 2));
           assertEquals(-1, ArrayUtils.indexOf(array, "1", 2));
  @@ -685,6 +707,7 @@
           assertEquals(1, ArrayUtils.lastIndexOf(array, "1", 2));
           assertEquals(2, ArrayUtils.lastIndexOf(array, "2", 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, "3", 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, "3", -1));
           assertEquals(4, ArrayUtils.lastIndexOf(array, null, 5));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, null, 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, "notInArray", 5));
  @@ -725,6 +748,7 @@
           assertEquals(-1, ArrayUtils.indexOf(array, 1, 2));
           assertEquals(2, ArrayUtils.indexOf(array, 2, 2));
           assertEquals(3, ArrayUtils.indexOf(array, 3, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, 3, -1));
           assertEquals(-1, ArrayUtils.indexOf(array, 99, 0));
           assertEquals(-1, ArrayUtils.indexOf(array, 0, 6));
       }
  @@ -748,7 +772,8 @@
           assertEquals(1, ArrayUtils.lastIndexOf(array, 1, 2));
           assertEquals(2, ArrayUtils.lastIndexOf(array, 2, 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, 2));
  -        assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, -1));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 99, 4));
           assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 88));
       }
   
  @@ -783,6 +808,7 @@
           assertEquals(-1, ArrayUtils.indexOf(array, 1, 2));
           assertEquals(2, ArrayUtils.indexOf(array, 2, 2));
           assertEquals(3, ArrayUtils.indexOf(array, 3, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, 3, -1));
           assertEquals(-1, ArrayUtils.indexOf(array, 99, 0));
           assertEquals(-1, ArrayUtils.indexOf(array, 0, 6));
       }
  @@ -806,6 +832,7 @@
           assertEquals(1, ArrayUtils.lastIndexOf(array, 1, 2));
           assertEquals(2, ArrayUtils.lastIndexOf(array, 2, 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, 3, -1));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, 99));
           assertEquals(4, ArrayUtils.lastIndexOf(array, 0, 88));
       }
  @@ -841,6 +868,7 @@
           assertEquals(-1, ArrayUtils.indexOf(array, (short) 1, 2));
           assertEquals(2, ArrayUtils.indexOf(array, (short) 2, 2));
           assertEquals(3, ArrayUtils.indexOf(array, (short) 3, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (short) 3, -1));
           assertEquals(-1, ArrayUtils.indexOf(array, (short) 99, 0));
           assertEquals(-1, ArrayUtils.indexOf(array, (short) 0, 6));
       }
  @@ -864,6 +892,7 @@
           assertEquals(1, ArrayUtils.lastIndexOf(array, (short) 1, 2));
           assertEquals(2, ArrayUtils.lastIndexOf(array, (short) 2, 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 3, -1));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (short) 99));
           assertEquals(4, ArrayUtils.lastIndexOf(array, (short) 0, 88));
       }
  @@ -899,6 +928,7 @@
           assertEquals(-1, ArrayUtils.indexOf(array, (byte) 1, 2));
           assertEquals(2, ArrayUtils.indexOf(array, (byte) 2, 2));
           assertEquals(3, ArrayUtils.indexOf(array, (byte) 3, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (byte) 3, -1));
           assertEquals(-1, ArrayUtils.indexOf(array, (byte) 99, 0));
           assertEquals(-1, ArrayUtils.indexOf(array, (byte) 0, 6));
       }
  @@ -922,6 +952,7 @@
           assertEquals(1, ArrayUtils.lastIndexOf(array, (byte) 1, 2));
           assertEquals(2, ArrayUtils.lastIndexOf(array, (byte) 2, 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 3, -1));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (byte) 99));
           assertEquals(4, ArrayUtils.lastIndexOf(array, (byte) 0, 88));
       }
  @@ -946,6 +977,7 @@
           assertEquals(1, ArrayUtils.indexOf(array, (double) 1));
           assertEquals(2, ArrayUtils.indexOf(array, (double) 2));
           assertEquals(3, ArrayUtils.indexOf(array, (double) 3));
  +        assertEquals(3, ArrayUtils.indexOf(array, (double) 3, -1));
           assertEquals(-1, ArrayUtils.indexOf(array, (double) 99));
       }
   
  @@ -980,6 +1012,7 @@
           assertEquals(1, ArrayUtils.lastIndexOf(array, (double) 1, 2));
           assertEquals(2, ArrayUtils.lastIndexOf(array, (double) 2, 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 3, -1));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (double) 99));
           assertEquals(4, ArrayUtils.lastIndexOf(array, (double) 0, 88));
       }
  @@ -1015,6 +1048,7 @@
           assertEquals(-1, ArrayUtils.indexOf(array, (float) 1, 2));
           assertEquals(2, ArrayUtils.indexOf(array, (float) 2, 2));
           assertEquals(3, ArrayUtils.indexOf(array, (float) 3, 2));
  +        assertEquals(3, ArrayUtils.indexOf(array, (float) 3, -1));
           assertEquals(-1, ArrayUtils.indexOf(array, (float) 99, 0));
           assertEquals(-1, ArrayUtils.indexOf(array, (float) 0, 6));
       }
  @@ -1038,6 +1072,7 @@
           assertEquals(1, ArrayUtils.lastIndexOf(array, (float) 1, 2));
           assertEquals(2, ArrayUtils.lastIndexOf(array, (float) 2, 2));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 3, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 3, -1));
           assertEquals(-1, ArrayUtils.lastIndexOf(array, (float) 99));
           assertEquals(4, ArrayUtils.lastIndexOf(array, (float) 0, 88));
       }
  @@ -1070,8 +1105,11 @@
           array = new boolean[] { true, false, true };
           assertEquals(2, ArrayUtils.indexOf(array, true, 1));
           assertEquals(-1, ArrayUtils.indexOf(array, false, 2));
  +        assertEquals(1, ArrayUtils.indexOf(array, false, 0));
  +        assertEquals(1, ArrayUtils.indexOf(array, false, -1));
           array = new boolean[] { true, true };
           assertEquals(-1, ArrayUtils.indexOf(array, false, 0));
  +        assertEquals(-1, ArrayUtils.indexOf(array, false, -1));
       }
   
       public void testLastIndexOfBoolean() {
  @@ -1091,8 +1129,10 @@
           assertEquals(2, ArrayUtils.lastIndexOf(array, true, 2));
           assertEquals(0, ArrayUtils.lastIndexOf(array, true, 1));
           assertEquals(1, ArrayUtils.lastIndexOf(array, false, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, true, -1));
           array = new boolean[] { true, true };
           assertEquals(-1, ArrayUtils.lastIndexOf(array, false, 2));
  +        assertEquals(-1, ArrayUtils.lastIndexOf(array, true, -1));
       }
   
       public void testContainsBoolean() {
  
  
  
  1.8       +14 -2     jakarta-commons/lang/src/test/org/apache/commons/lang/ObjectUtilsTest.java
  
  Index: ObjectUtilsTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/lang/src/test/org/apache/commons/lang/ObjectUtilsTest.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ObjectUtilsTest.java	25 Jul 2003 22:37:59 -0000	1.7
  +++ ObjectUtilsTest.java	30 Jul 2003 22:21:39 -0000	1.8
  @@ -53,6 +53,9 @@
    */
   package org.apache.commons.lang;
   
  +import java.lang.reflect.Constructor;
  +import java.lang.reflect.Modifier;
  +
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  @@ -94,7 +97,16 @@
       }
   
       //-----------------------------------------------------------------------
  -
  +    public void testConstructor() {
  +        assertNotNull(new ObjectUtils());
  +        Constructor[] cons = ObjectUtils.class.getDeclaredConstructors();
  +        assertEquals(1, cons.length);
  +        assertEquals(true, Modifier.isPublic(cons[0].getModifiers()));
  +        assertEquals(true, Modifier.isPublic(ObjectUtils.class.getModifiers()));
  +        assertEquals(false, Modifier.isFinal(ObjectUtils.class.getModifiers()));
  +    }
  +    
  +    //-----------------------------------------------------------------------
       public void testIsNull() {
           Object o = FOO;
           Object dflt = BAR;
  
  
  

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