CharacterEncoding renamed to CharEncoding
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/lang/trunk@137955 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
dd2a1841fc
commit
59d5f2f523
|
@ -35,9 +35,9 @@ import java.io.UnsupportedEncodingException;
|
|||
* names </a>
|
||||
* @author Apache Software Foundation
|
||||
* @since 2.1
|
||||
* @version $Id: CharacterEncoding.java,v 1.2 2004/08/26 18:54:04 ggregory Exp $
|
||||
* @version $Id: CharEncoding.java,v 1.1 2004/10/02 01:46:29 bayard Exp $
|
||||
*/
|
||||
public class CharacterEncoding {
|
||||
public class CharEncoding {
|
||||
|
||||
/**
|
||||
* <p>
|
|
@ -22,48 +22,48 @@ import junit.framework.TestSuite;
|
|||
import junit.textui.TestRunner;
|
||||
|
||||
/**
|
||||
* Tests CharacterEncoding.
|
||||
* Tests CharEncoding.
|
||||
*
|
||||
* @see CharacterEncoding
|
||||
* @see CharEncoding
|
||||
* @author Gary D. Gregory
|
||||
* @version $Id: CharacterEncodingTest.java,v 1.1 2004/08/03 17:17:08 ggregory Exp $
|
||||
* @version $Id: CharEncodingTest.java,v 1.1 2004/10/02 01:46:30 bayard Exp $
|
||||
*/
|
||||
public class CharacterEncodingTest extends TestCase {
|
||||
public class CharEncodingTest extends TestCase {
|
||||
|
||||
public static void main(String[] args) {
|
||||
TestRunner.run(suite());
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite(CharacterEncodingTest.class);
|
||||
suite.setName("CharacterEncoding Tests");
|
||||
TestSuite suite = new TestSuite(CharEncodingTest.class);
|
||||
suite.setName("CharEncoding Tests");
|
||||
return suite;
|
||||
}
|
||||
|
||||
private void assertSupportedEncoding(String name) {
|
||||
assertTrue("Encoding should be supported: " + name, CharacterEncoding.isSupported(name));
|
||||
assertTrue("Encoding should be supported: " + name, CharEncoding.isSupported(name));
|
||||
}
|
||||
|
||||
public void testMustBeSupportedJava1_3_1() {
|
||||
if (SystemUtils.isJavaVersionAtLeast(1.3f)) {
|
||||
this.assertSupportedEncoding(CharacterEncoding.ISO_8859_1);
|
||||
this.assertSupportedEncoding(CharacterEncoding.US_ASCII);
|
||||
this.assertSupportedEncoding(CharacterEncoding.UTF_16);
|
||||
this.assertSupportedEncoding(CharacterEncoding.UTF_16BE);
|
||||
this.assertSupportedEncoding(CharacterEncoding.UTF_16LE);
|
||||
this.assertSupportedEncoding(CharacterEncoding.UTF_8);
|
||||
this.assertSupportedEncoding(CharEncoding.ISO_8859_1);
|
||||
this.assertSupportedEncoding(CharEncoding.US_ASCII);
|
||||
this.assertSupportedEncoding(CharEncoding.UTF_16);
|
||||
this.assertSupportedEncoding(CharEncoding.UTF_16BE);
|
||||
this.assertSupportedEncoding(CharEncoding.UTF_16LE);
|
||||
this.assertSupportedEncoding(CharEncoding.UTF_8);
|
||||
} else {
|
||||
this.warn("Java 1.3 tests not run since the current version is " + SystemUtils.JAVA_VERSION);
|
||||
}
|
||||
}
|
||||
|
||||
public void testNotSupported() {
|
||||
assertFalse(CharacterEncoding.isSupported(null));
|
||||
assertFalse(CharacterEncoding.isSupported(""));
|
||||
assertFalse(CharacterEncoding.isSupported(" "));
|
||||
assertFalse(CharacterEncoding.isSupported("\t\r\n"));
|
||||
assertFalse(CharacterEncoding.isSupported("DOESNOTEXIST"));
|
||||
assertFalse(CharacterEncoding.isSupported("this is not a valid encoding name"));
|
||||
assertFalse(CharEncoding.isSupported(null));
|
||||
assertFalse(CharEncoding.isSupported(""));
|
||||
assertFalse(CharEncoding.isSupported(" "));
|
||||
assertFalse(CharEncoding.isSupported("\t\r\n"));
|
||||
assertFalse(CharEncoding.isSupported("DOESNOTEXIST"));
|
||||
assertFalse(CharEncoding.isSupported("this is not a valid encoding name"));
|
||||
}
|
||||
|
||||
public void testWorksOnJava1_1_8() {
|
||||
|
@ -72,9 +72,9 @@ public class CharacterEncodingTest extends TestCase {
|
|||
// The Javadoc do not specify which encodings are required.
|
||||
//
|
||||
if (SystemUtils.isJavaVersionAtLeast(1.1f)) {
|
||||
this.assertSupportedEncoding(CharacterEncoding.ISO_8859_1);
|
||||
this.assertSupportedEncoding(CharacterEncoding.US_ASCII);
|
||||
this.assertSupportedEncoding(CharacterEncoding.UTF_8);
|
||||
this.assertSupportedEncoding(CharEncoding.ISO_8859_1);
|
||||
this.assertSupportedEncoding(CharEncoding.US_ASCII);
|
||||
this.assertSupportedEncoding(CharEncoding.UTF_8);
|
||||
} else {
|
||||
this.warn("Java 1.1 tests not run since the current version is " + SystemUtils.JAVA_VERSION);
|
||||
}
|
||||
|
@ -86,9 +86,9 @@ public class CharacterEncodingTest extends TestCase {
|
|||
// The Javadoc do not specify which encodings are required.
|
||||
//
|
||||
if (SystemUtils.isJavaVersionAtLeast(1.2f)) {
|
||||
this.assertSupportedEncoding(CharacterEncoding.ISO_8859_1);
|
||||
this.assertSupportedEncoding(CharacterEncoding.US_ASCII);
|
||||
this.assertSupportedEncoding(CharacterEncoding.UTF_8);
|
||||
this.assertSupportedEncoding(CharEncoding.ISO_8859_1);
|
||||
this.assertSupportedEncoding(CharEncoding.US_ASCII);
|
||||
this.assertSupportedEncoding(CharEncoding.UTF_8);
|
||||
} else {
|
||||
this.warn("Java 1.2 tests not run since the current version is " + SystemUtils.JAVA_VERSION);
|
||||
}
|
||||
|
@ -97,4 +97,4 @@ public class CharacterEncodingTest extends TestCase {
|
|||
void warn(String msg) {
|
||||
System.err.println(msg);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ import junit.textui.TestRunner;
|
|||
* @author Stephen Colebourne
|
||||
* @author <a href="mailto:ridesmet@users.sourceforge.net">Ringo De Smet</a>
|
||||
* @author Matthew Hawthorne
|
||||
* @version $Id: LangTestSuite.java,v 1.28 2004/09/05 00:56:31 bayard Exp $
|
||||
* @version $Id: LangTestSuite.java,v 1.29 2004/10/02 01:46:30 bayard Exp $
|
||||
*/
|
||||
public class LangTestSuite extends TestCase {
|
||||
|
||||
|
@ -54,6 +54,7 @@ public class LangTestSuite extends TestCase {
|
|||
suite.addTest(ArrayUtilsAddTest.suite());
|
||||
suite.addTest(BitFieldTest.suite());
|
||||
suite.addTest(BooleanUtilsTest.suite());
|
||||
suite.addTest(CharEncodingTest.suite());
|
||||
suite.addTest(CharRangeTest.suite());
|
||||
suite.addTest(CharSetTest.suite());
|
||||
suite.addTest(CharSetUtilsTest.suite());
|
||||
|
|
|
@ -44,9 +44,9 @@ limitations under the License.
|
|||
<p>CharRange and CharSet are both used internally by CharSetUtils, and will probaby rarely be used. </p>
|
||||
</subsection>
|
||||
|
||||
<subsection name="JVM interaction - SystemUtils, CharacterEncoding">
|
||||
<subsection name="JVM interaction - SystemUtils, CharEncoding">
|
||||
<p>SystemUtils is a simple little class which makes it easy to find out information about which platform you are on. For some, this is a necessary evil. It was never something I expected to use myself until I was trying to ensure that Commons Lang itself compiled under JDK 1.2. Having pushed out a few JDK 1.3 bits that had slipped in (Collections.EMPTY_MAP is a classic offender), I then found that one of the Unit Tests was dying mysteriously under JDK 1.2, but ran fine under JDK 1.3. There was no obvious solution and I needed to move onwards, so the simple solution was to wrap that particular test in a 'if(SystemUtils.isJavaVersionAtLeast(1.3f)) {', make a note and move on. </p>
|
||||
<p>The CharacterEncoding class is also used to interact with the Java environment and may be used to see which character encodings are supported in a particular environment. </p>
|
||||
<p>The CharEncoding class is also used to interact with the Java environment and may be used to see which character encodings are supported in a particular environment. </p>
|
||||
</subsection>
|
||||
|
||||
<subsection name="Serialization - SerializationUtils, SerializationException">
|
||||
|
|
Loading…
Reference in New Issue