You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by "Richard Liang (JIRA)" <ji...@apache.org> on 2006/02/24 03:10:38 UTC
[jira] Updated: (HARMONY-96) Two new methods need to be implemented
by java.nio.charset.Charset
[ http://issues.apache.org/jira/browse/HARMONY-96?page=all ]
Richard Liang updated HARMONY-96:
---------------------------------
Attachment: charset_patch.txt
Here is the test cases:
/*
* Test method defaultCharset()
*/
public void testDefaultCharset_Normal(){
String charsetName = null;
String defaultCharsetName = null;
Properties oldProps = (Properties)System.getProperties().clone();
try{
charsetName = "UTF-8"; //$NON-NLS-1$
System.setProperty("file.encoding",charsetName);//$NON-NLS-1$
defaultCharsetName = Charset.defaultCharset().name();
assertEquals(charsetName,defaultCharsetName);
charsetName = "ISO-8859-1"; //$NON-NLS-1$
System.setProperty("file.encoding",charsetName);//$NON-NLS-1$
defaultCharsetName = Charset.defaultCharset().name();
assertEquals(charsetName,defaultCharsetName);
}finally{
System.setProperties(oldProps);
}
}
/*
* Test method defaultCharset()
*/
public void testDefaultCharset_Unsupported(){
String charsetName = null;
String defaultCharsetName = null;
Properties oldProps = (Properties)System.getProperties().clone();
try{
charsetName = "IMPOSSIBLE-8"; //$NON-NLS-1$
System.setProperty("file.encoding",charsetName);//$NON-NLS-1$
defaultCharsetName = Charset.defaultCharset().name();
assertEquals("UTF-8",defaultCharsetName);
}finally{
System.setProperties(oldProps);
}
}
/*
* Test method defaultCharset()
*/
public void testDefaultCharset_Null(){
Properties currentProps = System.getProperties();
Properties oldProps = (Properties)currentProps.clone();
try{
currentProps.remove("file.encoding");//$NON-NLS-1$
Charset.defaultCharset().name();
fail("Should throw illegal IllegalArgumentException");//$NON-NLS-1$
}catch(IllegalArgumentException e){
// expected
}finally{
System.setProperties(oldProps);
}
}
/*
* Test method defaultCharset()
*/
public void testDefaultCharset_IllegalCharsetName(){
String charsetName = null;
Properties oldProps = (Properties)System.getProperties().clone();
try{
charsetName = "IMP~~OSSIBLE-8"; //$NON-NLS-1$
System.setProperty("file.encoding",charsetName);//$NON-NLS-1$
Charset.defaultCharset().name();
fail("Should throw IllegalCharsetNameException");//$NON-NLS-1$
}catch(IllegalCharsetNameException e){
// expected
}finally{
System.setProperties(oldProps);
}
}
> Two new methods need to be implemented by java.nio.charset.Charset
> ------------------------------------------------------------------
>
> Key: HARMONY-96
> URL: http://issues.apache.org/jira/browse/HARMONY-96
> Project: Harmony
> Type: Improvement
> Components: Classlib
> Reporter: Richard Liang
> Attachments: charset_patch.txt
>
> There are two new methods added since Java 5.0
> 1. public static Charset defaultCharset()
> 2. public final int compareTo(Charset that)
> I'd like to implement the two methods and attach my code soon :-)
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira