Author: sebb
Date: Sat Mar 14 21:33:48 2009
New Revision: 754531
URL: http://svn.apache.org/viewvc?rev=754531&view=rev
Log:
Remove deprecated methods
Modified:
commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
Modified:
commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java?rev=754531&r1=754530&r2=754531&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
(original)
+++ commons/proper/lang/trunk/src/java/org/apache/commons/lang/StringUtils.java
Sat Mar 14 21:33:48 2009
@@ -93,7 +93,7 @@
*
* <p>A side effect of the <code>null</code> handling is that a
* <code>NullPointerException</code> should be considered a bug in
- * <code>StringUtils</code> (except for deprecated methods).</p>
+ * <code>StringUtils</code>.</p>
*
* <p>Methods in this class give sample code to explain their operation.
* The symbol <code>*</code> is used to indicate any input including
<code>null</code>.</p>
@@ -121,6 +121,7 @@
* @since 1.0
* @version $Id$
*/
+//@Immutable
public class StringUtils {
// Performance testing notes (JDK 1.4, Jul03, scolebourne)
// Whitespace:
@@ -262,29 +263,6 @@
/**
* <p>Removes control characters (char <= 32) from both
* ends of this String, handling <code>null</code> by returning
- * an empty String ("").</p>
- *
- * <pre>
- * StringUtils.clean(null) = ""
- * StringUtils.clean("") = ""
- * StringUtils.clean("abc") = "abc"
- * StringUtils.clean(" abc ") = "abc"
- * StringUtils.clean(" ") = ""
- * </pre>
- *
- * @see java.lang.String#trim()
- * @param str the String to clean, may be null
- * @return the trimmed text, never <code>null</code>
- * @deprecated Use the clearer named {...@link #trimToEmpty(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String clean(String str) {
- return str == null ? EMPTY : str.trim();
- }
-
- /**
- * <p>Removes control characters (char <= 32) from both
- * ends of this String, handling <code>null</code> by returning
* <code>null</code>.</p>
*
* <p>The String is trimmed using {...@link String#trim()}.
@@ -2034,61 +2012,6 @@
// Nested extraction
//-----------------------------------------------------------------------
- /**
- * <p>Gets the String that is nested in between two instances of the
- * same String.</p>
- *
- * <p>A <code>null</code> input String returns <code>null</code>.
- * A <code>null</code> tag returns <code>null</code>.</p>
- *
- * <pre>
- * StringUtils.getNestedString(null, *) = null
- * StringUtils.getNestedString("", "") = ""
- * StringUtils.getNestedString("", "tag") = null
- * StringUtils.getNestedString("tagabctag", null) = null
- * StringUtils.getNestedString("tagabctag", "") = ""
- * StringUtils.getNestedString("tagabctag", "tag") = "abc"
- * </pre>
- *
- * @param str the String containing nested-string, may be null
- * @param tag the String before and after nested-string, may be null
- * @return the nested String, <code>null</code> if no match
- * @deprecated Use the better named {...@link #substringBetween(String,
String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getNestedString(String str, String tag) {
- return substringBetween(str, tag, tag);
- }
-
- /**
- * <p>Gets the String that is nested in between two Strings.
- * Only the first match is returned.</p>
- *
- * <p>A <code>null</code> input String returns <code>null</code>.
- * A <code>null</code> open/close returns <code>null</code> (no match).
- * An empty ("") open/close returns an empty string.</p>
- *
- * <pre>
- * StringUtils.getNestedString(null, *, *) = null
- * StringUtils.getNestedString("", "", "") = ""
- * StringUtils.getNestedString("", "", "tag") = null
- * StringUtils.getNestedString("", "tag", "tag") = null
- * StringUtils.getNestedString("yabcz", null, null) = null
- * StringUtils.getNestedString("yabcz", "", "") = ""
- * StringUtils.getNestedString("yabcz", "y", "z") = "abc"
- * StringUtils.getNestedString("yabczyabcz", "y", "z") = "abc"
- * </pre>
- *
- * @param str the String containing nested-string, may be null
- * @param open the String before nested-string, may be null
- * @param close the String after nested-string, may be null
- * @return the nested String, <code>null</code> if no match
- * @deprecated Use the better named {...@link #substringBetween(String,
String, String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getNestedString(String str, String open, String
close) {
- return substringBetween(str, open, close);
- }
// Splitting
//-----------------------------------------------------------------------
@@ -2797,28 +2720,6 @@
// Joining
//-----------------------------------------------------------------------
/**
- * <p>Concatenates elements of an array into a single String.
- * Null objects or empty strings within the array are represented by
- * empty strings.</p>
- *
- * <pre>
- * StringUtils.concatenate(null) = null
- * StringUtils.concatenate([]) = ""
- * StringUtils.concatenate([null]) = ""
- * StringUtils.concatenate(["a", "b", "c"]) = "abc"
- * StringUtils.concatenate([null, "", "a"]) = "a"
- * </pre>
- *
- * @param array the array of values to concatenate, may be null
- * @return the concatenated String, <code>null</code> if null array input
- * @deprecated Use the better named {...@link #join(Object[])} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String concatenate(Object[] array) {
- return join(array, null);
- }
-
- /**
* <p>Joins the elements of the provided array into a single String
* containing the provided list of elements.</p>
*
@@ -3145,39 +3046,6 @@
// Delete
//-----------------------------------------------------------------------
/**
- * <p>Deletes all 'space' characters from a String as defined by
- * {...@link Character#isSpace(char)}.</p>
- *
- * <p>This is the only StringUtils method that uses the
- * <code>isSpace</code> definition. You are advised to use
- * {...@link #deleteWhitespace(String)} instead as whitespace is much
- * better localized.</p>
- *
- * <pre>
- * StringUtils.deleteSpaces(null) = null
- * StringUtils.deleteSpaces("") = ""
- * StringUtils.deleteSpaces("abc") = "abc"
- * StringUtils.deleteSpaces(" \t abc \n ") = "abc"
- * StringUtils.deleteSpaces("ab c") = "abc"
- * StringUtils.deleteSpaces("a\nb\tc ") = "abc"
- * </pre>
- *
- * <p>Spaces are defined as <code>{' ', '\t', '\r', '\n', '\b'}</code>
- * in line with the deprecated <code>isSpace</code> method.</p>
- *
- * @param str the String to delete spaces from, may be null
- * @return the String without 'spaces', <code>null</code> if null String
input
- * @deprecated Use the better localized {...@link
#deleteWhitespace(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String deleteSpaces(String str) {
- if (str == null) {
- return null;
- }
- return CharSetUtils.delete(str, " \t\r\n\b");
- }
-
- /**
* <p>Deletes all whitespaces from a String as defined by
* {...@link Character#isWhitespace(char)}.</p>
*
@@ -3891,39 +3759,6 @@
/**
* <p>Overlays part of a String with another String.</p>
*
- * <pre>
- * StringUtils.overlayString(null, *, *, *) =
NullPointerException
- * StringUtils.overlayString(*, null, *, *) =
NullPointerException
- * StringUtils.overlayString("", "abc", 0, 0) = "abc"
- * StringUtils.overlayString("abcdef", null, 2, 4) = "abef"
- * StringUtils.overlayString("abcdef", "", 2, 4) = "abef"
- * StringUtils.overlayString("abcdef", "zzzz", 2, 4) = "abzzzzef"
- * StringUtils.overlayString("abcdef", "zzzz", 4, 2) = "abcdzzzzcdef"
- * StringUtils.overlayString("abcdef", "zzzz", -1, 4) =
IndexOutOfBoundsException
- * StringUtils.overlayString("abcdef", "zzzz", 2, 8) =
IndexOutOfBoundsException
- * </pre>
- *
- * @param text the String to do overlaying in, may be null
- * @param overlay the String to overlay, may be null
- * @param start the position to start overlaying at, must be valid
- * @param end the position to stop overlaying before, must be valid
- * @return overlayed String, <code>null</code> if null String input
- * @throws NullPointerException if text or overlay is null
- * @throws IndexOutOfBoundsException if either position is invalid
- * @deprecated Use better named {...@link #overlay(String, String, int,
int)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String overlayString(String text, String overlay, int start,
int end) {
- return new StringBuffer(start + overlay.length() + text.length() - end
+ 1)
- .append(text.substring(0, start))
- .append(overlay)
- .append(text.substring(end))
- .toString();
- }
-
- /**
- * <p>Overlays part of a String with another String.</p>
- *
* <p>A <code>null</code> string input returns <code>null</code>.
* A negative index is treated as zero.
* An index greater than the string length is treated as the string length.
@@ -4071,103 +3906,6 @@
return str;
}
- /**
- * <p>Remove any "\n" if and only if it is at the end
- * of the supplied String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @return String without chomped ending
- * @throws NullPointerException if str is <code>null</code>
- * @deprecated Use {...@link #chomp(String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String chompLast(String str) {
- return chompLast(str, "\n");
- }
-
- /**
- * <p>Remove a value if and only if the String ends with that value.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String without chomped ending
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {...@link #chomp(String,String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String chompLast(String str, String sep) {
- if (str.length() == 0) {
- return str;
- }
- String sub = str.substring(str.length() - sep.length());
- if (sep.equals(sub)) {
- return str.substring(0, str.length() - sep.length());
- }
- return str;
- }
-
- /**
- * <p>Remove everything and return the last value of a supplied String, and
- * everything after it from a String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String chomped
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {...@link #substringAfterLast(String, String)} instead
- * (although this doesn't include the separator)
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getChomp(String str, String sep) {
- int idx = str.lastIndexOf(sep);
- if (idx == str.length() - sep.length()) {
- return sep;
- } else if (idx != -1) {
- return str.substring(idx);
- } else {
- return EMPTY;
- }
- }
-
- /**
- * <p>Remove the first value of a supplied String, and everything before it
- * from a String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String without chomped beginning
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {...@link #substringAfter(String,String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String prechomp(String str, String sep) {
- int idx = str.indexOf(sep);
- if (idx == -1) {
- return str;
- }
- return str.substring(idx + sep.length());
- }
-
- /**
- * <p>Remove and return everything before the first value of a
- * supplied String from another String.</p>
- *
- * @param str the String to chomp from, must not be null
- * @param sep the String to chomp, must not be null
- * @return String prechomped
- * @throws NullPointerException if str or sep is <code>null</code>
- * @deprecated Use {...@link #substringBefore(String,String)} instead
- * (although this doesn't include the separator).
- * Method will be removed in Commons Lang 3.0.
- */
- public static String getPrechomp(String str, String sep) {
- int idx = str.indexOf(sep);
- if (idx == -1) {
- return EMPTY;
- }
- return str.substring(0, idx + sep.length());
- }
-
// Chopping
//-----------------------------------------------------------------------
/**
@@ -4212,53 +3950,8 @@
return ret;
}
- /**
- * <p>Removes <code>\n</code> from end of a String if it's there.
- * If a <code>\r</code> precedes it, then remove that too.</p>
- *
- * @param str the String to chop a newline from, must not be null
- * @return String without newline
- * @throws NullPointerException if str is <code>null</code>
- * @deprecated Use {...@link #chomp(String)} instead.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String chopNewline(String str) {
- int lastIdx = str.length() - 1;
- if (lastIdx <= 0) {
- return EMPTY;
- }
- char last = str.charAt(lastIdx);
- if (last == CharUtils.LF) {
- if (str.charAt(lastIdx - 1) == CharUtils.CR) {
- lastIdx--;
- }
- } else {
- lastIdx++;
- }
- return str.substring(0, lastIdx);
- }
-
// Conversion
//-----------------------------------------------------------------------
- /**
- * <p>Escapes any values it finds into their String form.</p>
- *
- * <p>So a tab becomes the characters <code>'\\'</code> and
- * <code>'t'</code>.</p>
- *
- * <p>As of Lang 2.0, this calls {...@link
StringEscapeUtils#escapeJava(String)}
- * behind the scenes.
- * </p>
- * @see StringEscapeUtils#escapeJava(java.lang.String)
- * @param str String to escape values in
- * @return String with escaped values
- * @throws NullPointerException if str is <code>null</code>
- * @deprecated Use {...@link StringEscapeUtils#escapeJava(String)}
- * This method will be removed in Commons Lang 3.0
- */
- public static String escape(String str) {
- return StringEscapeUtils.escapeJava(str);
- }
// Padding
//-----------------------------------------------------------------------
@@ -4836,19 +4529,6 @@
}
/**
- * <p>Capitalizes a String changing the first letter to title case as
- * per {...@link Character#toTitleCase(char)}. No other letters are
changed.</p>
- *
- * @param str the String to capitalize, may be null
- * @return the capitalized String, <code>null</code> if null String input
- * @deprecated Use the standardly named {...@link #capitalize(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String capitalise(String str) {
- return capitalize(str);
- }
-
- /**
* <p>Uncapitalizes a String changing the first letter to title case as
* per {...@link Character#toLowerCase(char)}. No other letters are
changed.</p>
*
@@ -4880,19 +4560,6 @@
}
/**
- * <p>Uncapitalizes a String changing the first letter to title case as
- * per {...@link Character#toLowerCase(char)}. No other letters are
changed.</p>
- *
- * @param str the String to uncapitalize, may be null
- * @return the uncapitalized String, <code>null</code> if null String input
- * @deprecated Use the standardly named {...@link #uncapitalize(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String uncapitalise(String str) {
- return uncapitalize(str);
- }
-
- /**
* <p>Swaps the case of a String changing upper and title case to
* lower case, and lower case to upper case.</p>
*
@@ -4941,22 +4608,6 @@
return buffer.toString();
}
- /**
- * <p>Capitalizes all the whitespace separated words in a String.
- * Only the first letter of each word is changed.</p>
- *
- * <p>Whitespace is defined by {...@link Character#isWhitespace(char)}.
- * A <code>null</code> input String returns <code>null</code>.</p>
- *
- * @param str the String to capitalize, may be null
- * @return capitalized String, <code>null</code> if null String input
- * @deprecated Use the relocated {...@link WordUtils#capitalize(String)}.
- * Method will be removed in Commons Lang 3.0.
- */
- public static String capitaliseAllWords(String str) {
- return WordUtils.capitalize(str);
- }
-
// Count matches
//-----------------------------------------------------------------------
/**
@@ -5382,42 +5033,6 @@
return join(strs, separatorChar);
}
- /**
- * <p>Reverses a String that is delimited by a specific character.</p>
- *
- * <p>The Strings between the delimiters are not reversed.
- * Thus java.lang.String becomes String.lang.java (if the delimiter
- * is <code>"."</code>).</p>
- *
- * <pre>
- * StringUtils.reverseDelimitedString(null, *) = null
- * StringUtils.reverseDelimitedString("",*) = ""
- * StringUtils.reverseDelimitedString("a.b.c", null) = "a.b.c"
- * StringUtils.reverseDelimitedString("a.b.c", ".") = "c.b.a"
- * </pre>
- *
- * @param str the String to reverse, may be null
- * @param separatorChars the separator characters to use, null treated as
whitespace
- * @return the reversed String, <code>null</code> if null String input
- * @deprecated Use {...@link #reverseDelimited(String, char)} instead.
- * This method is broken as the join doesn't know which char to use.
- * Method will be removed in Commons Lang 3.0.
- *
- */
- public static String reverseDelimitedString(String str, String
separatorChars) {
- if (str == null) {
- return null;
- }
- // could implement manually, but simple way is to reuse other,
- // probably slower, methods.
- String[] strs = split(str, separatorChars);
- ArrayUtils.reverse(strs);
- if (separatorChars == null) {
- return join(strs, ' ');
- }
- return join(strs, separatorChars);
- }
-
// Abbreviating
//-----------------------------------------------------------------------
/**
Modified:
commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
URL:
http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java?rev=754531&r1=754530&r2=754531&view=diff
==============================================================================
---
commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
(original)
+++
commons/proper/lang/trunk/src/test/org/apache/commons/lang/StringUtilsTest.java
Sat Mar 14 21:33:48 2009
@@ -134,27 +134,12 @@
assertEquals(null, StringUtils.lowerCase(null));
assertEquals(null, StringUtils.lowerCase(null, Locale.ENGLISH));
assertEquals(null, StringUtils.capitalize(null));
- assertEquals(null, StringUtils.uncapitalise(null));
assertEquals(null, StringUtils.uncapitalize(null));
- assertEquals("capitalise(String) failed",
- FOO_CAP, StringUtils.capitalise(FOO_UNCAP) );
- assertEquals("capitalise(empty-string) failed",
- "", StringUtils.capitalise("") );
- assertEquals("capitalise(single-char-string) failed",
- "X", StringUtils.capitalise("x") );
- assertEquals("capitalize(String) failed",
- FOO_CAP, StringUtils.capitalize(FOO_UNCAP) );
assertEquals("capitalize(empty-string) failed",
"", StringUtils.capitalize("") );
assertEquals("capitalize(single-char-string) failed",
"X", StringUtils.capitalize("x") );
- assertEquals("uncapitalise(String) failed",
- FOO_UNCAP, StringUtils.uncapitalise(FOO_CAP) );
- assertEquals("uncapitalise(empty-string) failed",
- "", StringUtils.uncapitalise("") );
- assertEquals("uncapitalise(single-char-string) failed",
- "x", StringUtils.uncapitalise("X") );
assertEquals("uncapitalize(String) failed",
FOO_UNCAP, StringUtils.uncapitalize(FOO_CAP) );
assertEquals("uncapitalize(empty-string) failed",
@@ -163,20 +148,12 @@
"x", StringUtils.uncapitalize("X") );
// reflection type of tests: Sentences.
- assertEquals("uncapitalise(capitalise(String)) failed",
- SENTENCE_UNCAP,
StringUtils.uncapitalise(StringUtils.capitalise(SENTENCE_UNCAP)) );
- assertEquals("capitalise(uncapitalise(String)) failed",
- SENTENCE_CAP,
StringUtils.capitalise(StringUtils.uncapitalise(SENTENCE_CAP)) );
assertEquals("uncapitalize(capitalize(String)) failed",
SENTENCE_UNCAP,
StringUtils.uncapitalize(StringUtils.capitalize(SENTENCE_UNCAP)) );
assertEquals("capitalize(uncapitalize(String)) failed",
SENTENCE_CAP,
StringUtils.capitalize(StringUtils.uncapitalize(SENTENCE_CAP)) );
// reflection type of tests: One word.
- assertEquals("uncapitalise(capitalise(String)) failed",
- FOO_UNCAP,
StringUtils.uncapitalise(StringUtils.capitalise(FOO_UNCAP)) );
- assertEquals("capitalise(uncapitalise(String)) failed",
- FOO_CAP,
StringUtils.capitalise(StringUtils.uncapitalise(FOO_CAP)) );
assertEquals("uncapitalize(capitalize(String)) failed",
FOO_UNCAP,
StringUtils.uncapitalize(StringUtils.capitalize(FOO_UNCAP)) );
assertEquals("capitalize(uncapitalize(String)) failed",
@@ -314,14 +291,6 @@
assertEquals(TEXT_LIST, StringUtils.join(Arrays.asList(ARRAY_LIST),
SEPARATOR));
}
- public void testDeprecatedConcatenate_Objectarray() {
- assertEquals(null, StringUtils.concatenate(null));
- assertEquals("", StringUtils.concatenate(EMPTY_ARRAY_LIST));
- assertEquals("", StringUtils.concatenate(NULL_ARRAY_LIST));
- assertEquals("foo", StringUtils.concatenate(MIXED_ARRAY_LIST));
- assertEquals("foo2", StringUtils.concatenate(MIXED_TYPE_LIST));
- }
-
public void testSplit_String() {
assertEquals(null, StringUtils.split(null));
assertEquals(0, StringUtils.split("").length);
@@ -450,7 +419,7 @@
String stringToSplitOnNulls = "ab de fg" ;
String[] splitOnNullExpectedResults = { "ab", "de", "fg" } ;
- String[] splitOnNullResults = StringUtils.splitByWholeSeparator( "ab
de fg", null ) ;
+ String[] splitOnNullResults = StringUtils.splitByWholeSeparator(
stringToSplitOnNulls, null ) ;
assertEquals( splitOnNullExpectedResults.length,
splitOnNullResults.length ) ;
for ( int i = 0 ; i < splitOnNullExpectedResults.length ; i+= 1 ) {
assertEquals( splitOnNullExpectedResults[i], splitOnNullResults[i]
) ;
@@ -958,13 +927,6 @@
StringUtils.splitByCharacterTypeCamelCase("ASFRules")));
}
- public void testDeprecatedDeleteSpace_String() {
- assertEquals(null, StringUtils.deleteSpaces(null));
- assertEquals("", StringUtils.deleteSpaces(""));
- assertEquals("", StringUtils.deleteSpaces(" \t\t\n\n "));
- assertEquals("test", StringUtils.deleteSpaces("t \t\ne\rs\n\n
\tt"));
- }
-
public void testDeleteWhitespace_String() {
assertEquals(null, StringUtils.deleteWhitespace(null));
assertEquals("", StringUtils.deleteWhitespace(""));
@@ -1153,30 +1115,6 @@
"nopqrstuvwxyzabcdefghijklmNOPQRSTUVWXYZABCDEFGHIJKLM567891234"));
}
- 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));
- assertEquals("abzzzzef", StringUtils.overlayString("abcdef", "zzzz",
2, 4));
- assertEquals("abcdzzzzcdef", StringUtils.overlayString("abcdef",
"zzzz", 4, 2));
- try {
- StringUtils.overlayString(null, "zzzz", 2, 4);
- fail();
- } catch (NullPointerException ex) {}
- try {
- StringUtils.overlayString("abcdef", null, 2, 4);
- fail();
- } catch (NullPointerException ex) {}
- try {
- StringUtils.overlayString("abcdef", "zzzz", -1, 4);
- fail();
- } catch (IndexOutOfBoundsException ex) {}
- try {
- StringUtils.overlayString("abcdef", "zzzz", 2, 8);
- fail();
- } catch (IndexOutOfBoundsException ex) {}
- }
-
public void testOverlay_StringStringIntInt() {
assertEquals(null, StringUtils.overlay(null, null, 2, 4));
assertEquals(null, StringUtils.overlay(null, null, -2, -4));
@@ -1216,36 +1154,6 @@
assertEquals(true, StringUtils.containsOnly(str, new char[] {'a'}));
}
- public void testDeprecatedChompFunctions() {
- assertEquals("chompLast(String) failed",
- FOO_UNCAP, StringUtils.chompLast(FOO_UNCAP + "\n") );
-
- assertEquals("chompLast(\"\") failed",
- "", StringUtils.chompLast("") );
- assertEquals("chompLast(\"test\", \"test\") failed",
- "test", StringUtils.chompLast("test", "tst") );
-
- assertEquals("getChomp(String, String) failed",
- "\n" + FOO_UNCAP, StringUtils.getChomp(FOO_UNCAP + "\n" +
FOO_UNCAP, "\n") );
- assertEquals("getChomp(String, String) failed",
- FOO_CAP, StringUtils.getChomp(FOO_CAP+FOO_CAP, FOO_CAP));
- assertEquals("getChomp(String, String) failed",
- "", StringUtils.getChomp(FOO_UNCAP, FOO_CAP));
-
- assertEquals("prechomp(String, String) failed",
- FOO_UNCAP, StringUtils.prechomp(FOO_UNCAP + "\n" +
FOO_UNCAP, "\n") );
- assertEquals("prechomp(String, String) failed",
- FOO_UNCAP, StringUtils.prechomp(FOO_UNCAP, FOO_CAP));
-
- assertEquals("getPrechomp(String, String) failed",
- FOO_UNCAP + "\n", StringUtils.getPrechomp(FOO_UNCAP +
"\n" + FOO_UNCAP, "\n") );
- assertEquals("getPrechomp(String, String) failed",
- "", StringUtils.getPrechomp(FOO_CAP, FOO_UNCAP));
-
- assertEquals("chopNewline(String, String) failed",
- FOO_UNCAP, StringUtils.chopNewline(FOO_UNCAP + "\r\n") );
- }
-
public void testChop() {
String[][] chopCases = {
@@ -1327,28 +1235,6 @@
"foo ", StringUtils.chomp("foo ", "foo"));
}
- public void testChopNewLine() {
-
- String[][] newLineCases = {
- { FOO_UNCAP + "\r\n", FOO_UNCAP } ,
- { FOO_UNCAP + "\n" , FOO_UNCAP } ,
- { FOO_UNCAP + "\r", FOO_UNCAP + "\r" },
- { FOO_UNCAP, FOO_UNCAP },
- { FOO_UNCAP + "\n" + FOO_UNCAP , FOO_UNCAP + "\n" + FOO_UNCAP },
- { FOO_UNCAP + "\n\n", FOO_UNCAP + "\n"},
- { "\n", "" },
- { "", "" },
- { "\r\n", "" }
- };
-
- for (int i = 0; i < newLineCases.length; i++) {
- String original = newLineCases[i][0];
- String expectedResult = newLineCases[i][1];
- assertEquals("chopNewline(String) failed",
- expectedResult, StringUtils.chopNewline(original));
- }
- }
-
//-----------------------------------------------------------------------
public void testRightPad_StringInt() {
assertEquals(null, StringUtils.rightPad(null, 5));
@@ -1488,15 +1374,6 @@
assertEquals("", StringUtils.reverseDelimited("", '.') );
}
- public void testDeprecatedReverseDelimitedString_StringString() {
- assertEquals(null, StringUtils.reverseDelimitedString(null, null) );
- assertEquals("", StringUtils.reverseDelimitedString("", null) );
- assertEquals("", StringUtils.reverseDelimitedString("", ".") );
- assertEquals("a.b.c", StringUtils.reverseDelimitedString("a.b.c",
null) );
- assertEquals("c b a", StringUtils.reverseDelimitedString("a b c",
null) );
- assertEquals("c.b.a", StringUtils.reverseDelimitedString("a.b.c", ".")
);
- }
-
//-----------------------------------------------------------------------
public void testDefault_String() {
assertEquals("", StringUtils.defaultString(null));
@@ -1518,18 +1395,6 @@
}
//-----------------------------------------------------------------------
- public void testDeprecatedEscapeFunctions_String() {
- assertEquals("", StringUtils.escape("") );
- assertEquals("abc", StringUtils.escape("abc") );
- assertEquals("\\t", StringUtils.escape("\t") );
- assertEquals("\\\\", StringUtils.escape("\\") );
- assertEquals("\\\\\\b\\t\\r", StringUtils.escape("\\\b\t\r") );
- assertEquals("\\u1234", StringUtils.escape("\u1234") );
- assertEquals("\\u0234", StringUtils.escape("\u0234") );
- assertEquals("\\u00FD", StringUtils.escape("\u00fd") );
- }
-
- //-----------------------------------------------------------------------
public void testAbbreviate_StringInt() {
assertEquals(null, StringUtils.abbreviate(null, 10));
assertEquals("", StringUtils.abbreviate("", 10));
@@ -1547,6 +1412,7 @@
assertEquals("", StringUtils.abbreviate("", 4));
try {
+ @SuppressWarnings("unused")
String res = StringUtils.abbreviate("abc", 3);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
@@ -1560,12 +1426,14 @@
assertEquals("", StringUtils.abbreviate("", 2, 10));
try {
+ @SuppressWarnings("unused")
String res = StringUtils.abbreviate("abcdefghij", 0, 3);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {
// empty
}
try {
+ @SuppressWarnings("unused")
String res = StringUtils.abbreviate("abcdefghij", 5, 6);
fail("StringUtils.abbreviate expecting IllegalArgumentException");
} catch (IllegalArgumentException ex) {