commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r534588 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/ test/org/apache/commons/lang/ test/org/apache/commons/lang/math/
Date Wed, 02 May 2007 18:46:08 GMT
Author: bayard
Date: Wed May  2 11:46:07 2007
New Revision: 534588

URL: http://svn.apache.org/viewvc?view=rev&rev=534588
Log:
Adding 'Deprecated' to tests which are testing deprecated methods and moving CharSetUtils
from the deprecated evaluateSet method to a new getInstance(String[]) method. This does mean
that getInstance(null) is no longer going to compile for people - they'll need to cast the
null. 

Modified:
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java
    jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/SystemUtilsTest.java
    jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java (original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSet.java Wed May
 2 11:46:07 2007
@@ -146,6 +146,19 @@
         return new CharSet(setStr);
     }
 
+    /**
+     * <p>Constructs a new CharSet using the set syntax.
+     * Each string is merged in with the set.</p>
+     *
+     * @param set  Strings to merge into the initial set, may be null
+     */
+    public static CharSet getInstance(String[] setStrs) {
+        if (setStrs == null) {
+            return null;
+        }
+        return new CharSet(setStrs); 
+    }
+
     //-----------------------------------------------------------------------
     /**
      * <p>Constructs a new CharSet using the set syntax.</p>

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java (original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/CharSetUtils.java Wed
May  2 11:46:07 2007
@@ -63,7 +63,7 @@
      *
      * @param set  the set, may be null
      * @return a CharSet instance, <code>null</code> if null input
-     * @deprecated Use {@link CharSet#getInstance(String)}.
+     * @deprecated Use {@link CharSet#getInstance(String[])}.
      *             Method will be removed in Commons Lang 3.0.
      */
     public static CharSet evaluateSet(String[] set) {
@@ -120,7 +120,7 @@
         if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
             return str;
         }
-        CharSet chars = evaluateSet(set);
+        CharSet chars = CharSet.getInstance(set);
         StringBuffer buffer = new StringBuffer(str.length());
         char[] chrs = str.toCharArray();
         int sz = chrs.length;
@@ -186,7 +186,7 @@
         if (StringUtils.isEmpty(str) || ArrayUtils.isEmpty(set)) {
             return 0;
         }
-        CharSet chars = evaluateSet(set);
+        CharSet chars = CharSet.getInstance(set);
         int count = 0;
         char[] chrs = str.toCharArray();
         int sz = chrs.length;
@@ -318,7 +318,7 @@
      * @return modified String
      */
     private static String modify(String str, String[] set, boolean expect) {
-        CharSet chars = evaluateSet(set);
+        CharSet chars = CharSet.getInstance(set);
         StringBuffer buffer = new StringBuffer(str.length());
         char[] chrs = str.toCharArray();
         int sz = chrs.length;

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java (original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/CharSetTest.java Wed
May  2 11:46:07 2007
@@ -64,7 +64,7 @@
     
     //-----------------------------------------------------------------------
     public void testGetInstance() {
-        assertSame(CharSet.EMPTY, CharSet.getInstance(null));
+        assertSame(CharSet.EMPTY, CharSet.getInstance( (String) null));
         assertSame(CharSet.EMPTY, CharSet.getInstance(""));
         assertSame(CharSet.ASCII_ALPHA, CharSet.getInstance("a-zA-Z"));
         assertSame(CharSet.ASCII_ALPHA, CharSet.getInstance("A-Za-z"));
@@ -72,7 +72,15 @@
         assertSame(CharSet.ASCII_ALPHA_UPPER, CharSet.getInstance("A-Z"));
         assertSame(CharSet.ASCII_NUMERIC, CharSet.getInstance("0-9"));
     }
-            
+
+    //-----------------------------------------------------------------------
+    public void testGetInstance_Stringarray() {
+        assertEquals(null, CharSet.getInstance((String[]) null));
+        assertEquals("[]", CharSet.getInstance(new String[0]).toString());
+        assertEquals("[]", CharSet.getInstance(new String[] {null}).toString());
+        assertEquals("[a-e]", CharSet.getInstance(new String[] {"a-e"}).toString());
+    }
+    
     //-----------------------------------------------------------------------
     public void testConstructor_String_simple() {
         CharSet set;

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsSubstringTest.java
Wed May  2 11:46:07 2007
@@ -332,7 +332,7 @@
              StringUtils.countMatches("oooooooooooo", "ooo"));
     }
 
-    public void testGetNestedString_StringString() {
+    public void testDeprecatedGetNestedString_StringString() {
         assertEquals(null, StringUtils.getNestedString(null, "tag"));
         assertEquals("", StringUtils.getNestedString("", ""));
         assertEquals(null, StringUtils.getNestedString("", "abc"));
@@ -345,7 +345,7 @@
         assertEquals("bar", StringUtils.getNestedString("\nbar\n", "\n"));
     }
             
-    public void testGetNestedString_StringStringString() {
+    public void testDeprecatedGetNestedString_StringStringString() {
         assertEquals(null, StringUtils.getNestedString(null, "", ""));
         assertEquals("", StringUtils.getNestedString("", "", ""));
         assertEquals("", StringUtils.getNestedString("    ", " ", "  "));

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
Wed May  2 11:46:07 2007
@@ -300,7 +300,7 @@
         assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST), SEPARATOR));
     }
 
-    public void testConcatenate_Objectarray() {
+    public void testDeprecatedConcatenate_Objectarray() {
         assertEquals(null, StringUtils.concatenate(null));
         assertEquals("", StringUtils.concatenate(EMPTY_ARRAY_LIST));
         assertEquals("", StringUtils.concatenate(NULL_ARRAY_LIST));
@@ -847,7 +847,7 @@
         assertEquals(msg, str.substring(2), res[1]);
     }
     
-    public void testDeleteSpace_String() {
+    public void testDeprecatedDeleteSpace_String() {
         assertEquals(null, StringUtils.deleteSpaces(null));
         assertEquals("", StringUtils.deleteSpaces(""));
         assertEquals("", StringUtils.deleteSpaces("    \t\t\n\n   "));
@@ -984,7 +984,7 @@
             "nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM567891234"));
     }
     
-    public void testOverlayString_StringStringIntInt() {
+    public void testDeprecatedOverlayString_StringStringIntInt() {
         assertEquals("overlayString(String, String, int, int) failed",
                      "foo foor baz", StringUtils.overlayString(SENTENCE_UNCAP, FOO_UNCAP,
4, 6) );
         assertEquals("abef", StringUtils.overlayString("abcdef", "", 2, 4));
@@ -1310,7 +1310,7 @@
         assertEquals("", StringUtils.reverseDelimited("", '.') );
     }
 
-    public void testReverseDelimitedString_StringString() {
+    public void testDeprecatedReverseDelimitedString_StringString() {
         assertEquals(null, StringUtils.reverseDelimitedString(null, null) );
         assertEquals("", StringUtils.reverseDelimitedString("", null) );
         assertEquals("", StringUtils.reverseDelimitedString("", ".") );
@@ -1339,7 +1339,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testEscapeFunctions_String() {
+    public void testDeprecatedEscapeFunctions_String() {
         assertEquals("", StringUtils.escape("") );
         assertEquals("abc", StringUtils.escape("abc") );
         assertEquals("\\t", StringUtils.escape("\t") );

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTrimEmptyTest.java
Wed May  2 11:46:07 2007
@@ -87,7 +87,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testClean() {
+    public void testDeprecatedClean() {
         assertEquals(FOO, StringUtils.clean(FOO + "  "));
         assertEquals(FOO, StringUtils.clean(" " + FOO + "  "));
         assertEquals(FOO, StringUtils.clean(" " + FOO));

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/SystemUtilsTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/SystemUtilsTest.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/SystemUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/SystemUtilsTest.java
Wed May  2 11:46:07 2007
@@ -333,7 +333,7 @@
     }
 
     //-----------------------------------------------------------------------
-    public void testJavaVersion() {
+    public void testDeprecatedJavaVersion() {
         assertEquals(SystemUtils.JAVA_VERSION_FLOAT, SystemUtils.getJavaVersion(), 0f);
     }
 

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java?view=diff&rev=534588&r1=534587&r2=534588
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
Wed May  2 11:46:07 2007
@@ -70,7 +70,7 @@
     /**
      * Test for {@link NumberUtils#stringToInt(String)}.
      */
-    public void testStringToIntString() {
+    public void testDeprecatedStringToIntString() {
         assertTrue("stringToInt(String) 1 failed", NumberUtils.stringToInt("12345") == 12345);
         assertTrue("stringToInt(String) 2 failed", NumberUtils.stringToInt("abc") == 0);
         assertTrue("stringToInt(empty) failed", NumberUtils.stringToInt("") == 0);
@@ -90,7 +90,7 @@
     /**
      * Test for {@link NumberUtils#stringToInt(String, int)}.
      */
-    public void testStringToIntStringI() {
+    public void testDeprecatedStringToIntStringI() {
         assertTrue("stringToInt(String,int) 1 failed", NumberUtils.stringToInt("12345", 5)
== 12345);
         assertTrue("stringToInt(String,int) 2 failed", NumberUtils.stringToInt("1234.5",
5) == 5);
     }



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