You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by sm...@apache.org on 2006/05/16 12:15:53 UTC
svn commit: r406890 [1/2] - in
/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text:
DateFormatSymbolsTest.java DecimalFormatSymbolsTest.java
SimpleDateFormatTest.java
Author: smishura
Date: Tue May 16 03:15:51 2006
New Revision: 406890
URL: http://svn.apache.org/viewcvs?rev=406890&view=rev
Log:
Reformatting code to 4 space indent
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/SimpleDateFormatTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java?rev=406890&r1=406889&r2=406890&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DateFormatSymbolsTest.java Tue May 16 03:15:51 2006
@@ -20,321 +20,321 @@
public class DateFormatSymbolsTest extends junit.framework.TestCase {
- private DateFormatSymbols dfs;
+ private DateFormatSymbols dfs;
- /**
- * @tests java.text.DateFormatSymbols#DateFormatSymbols()
- */
- public void test_Constructor() {
- // Test for method java.text.DateFormatSymbols()
- // Used in tests
- try {
- new DateFormatSymbols();
- } catch (Exception e) {
- fail("Constructor failed.");
- }
- }
-
- /**
- * @tests java.text.DateFormatSymbols#DateFormatSymbols(java.util.Locale)
- */
- public void test_ConstructorLjava_util_Locale() {
- // Test for method java.text.DateFormatSymbols(java.util.Locale)
- try {
- new DateFormatSymbols(new Locale("en", "us"));
- } catch (Exception e) {
- fail("Constructor failed.");
- }
- }
-
- /**
- * @tests java.text.DateFormatSymbols#clone()
- */
- public void test_clone() {
- // Test for method java.lang.Object java.text.DateFormatSymbols.clone()
- DateFormatSymbols symbols = new DateFormatSymbols();
- DateFormatSymbols clone = (DateFormatSymbols) symbols.clone();
- assertTrue("Not equal", symbols.equals(clone));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() {
- // Test for method boolean
- // java.text.DateFormatSymbols.equals(java.lang.Object)
- assertTrue("Equal object returned true", dfs.equals(dfs.clone()));
- dfs.setLocalPatternChars("KKKKKKKKK");
- assertTrue("Un-Equal objects returned false", !dfs
- .equals(new DateFormatSymbols()));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getAmPmStrings()
- */
- public void test_getAmPmStrings() {
- // Test for method java.lang.String []
- // java.text.DateFormatSymbols.getAmPmStrings()
- String[] retVal = dfs.getAmPmStrings();
- String[] val = { "AM", "PM" };
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Array values do not match", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getEras()
- */
- public void test_getEras() {
- // Test for method java.lang.String []
- // java.text.DateFormatSymbols.getEras()
- String[] retVal = dfs.getEras();
- String[] val = { "BC", "AD" };
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Array values do not match", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getLocalPatternChars()
- */
- public void test_getLocalPatternChars() {
- // Test for method java.lang.String
- // java.text.DateFormatSymbols.getLocalPatternChars()
- String retVal = dfs.getLocalPatternChars();
-
- String val = "GyMdkHmsSEDFwWahKzZ";
-
- assertTrue("Returned incorrect pattern string", retVal.equals(val));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getMonths()
- */
- public void test_getMonths() {
- // Test for method java.lang.String []
- // java.text.DateFormatSymbols.getMonths()
- String[] retVal = dfs.getMonths();
- String[] val = { "January", "February", "March", "April", "May",
- "June", "July", "August", "September", "October", "November",
- "December", "" };
- if (retVal.length != val.length)
- fail("Returned wrong array: " + retVal.length);
- for (int i = 0; i < val.length; i++)
- assertTrue("Array values do not match", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getShortMonths()
- */
- public void test_getShortMonths() {
- // Test for method java.lang.String []
- // java.text.DateFormatSymbols.getShortMonths()
- String[] retVal = dfs.getShortMonths();
- String[] val = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
- "Aug", "Sep", "Oct", "Nov", "Dec", "" };
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Array values do not match", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getShortWeekdays()
- */
- public void test_getShortWeekdays() {
- // Test for method java.lang.String []
- // java.text.DateFormatSymbols.getShortWeekdays()
- String[] retVal = dfs.getShortWeekdays();
- String[] val = { "", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Array values do not match", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getWeekdays()
- */
- public void test_getWeekdays() {
- // Test for method java.lang.String []
- // java.text.DateFormatSymbols.getWeekdays()
- String[] retVal = dfs.getWeekdays();
- String[] val = { "", "Sunday", "Monday", "Tuesday", "Wednesday",
- "Thursday", "Friday", "Saturday" };
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Array values do not match", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#getZoneStrings()
- */
- public void test_getZoneStrings() {
- // Test for method java.lang.String [][]
- // java.text.DateFormatSymbols.getZoneStrings()
- String[][] val = { { "XX" }, { "YY" } };
- dfs.setZoneStrings(val);
- String[][] retVal = dfs.getZoneStrings();
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings", Arrays
- .equals(retVal[i], val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#hashCode()
- */
- public void test_hashCode() {
- // Test for method int java.text.DateFormatSymbols.hashCode()
- int hc1 = hashCode();
- int hc2 = hashCode();
- assertTrue("hashCode() returned negative number", hc1 >= 0);
- assertTrue("hashCode() returned inconsistent number", hc1 == hc2);
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setAmPmStrings(java.lang.String[])
- */
- public void test_setAmPmStrings$Ljava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setAmPmStrings(java.lang.String [])
- String[] val = { "XX", "YY" };
- dfs.setAmPmStrings(val);
- String[] retVal = dfs.getAmPmStrings();
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setEras(java.lang.String[])
- */
- public void test_setEras$Ljava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setEras(java.lang.String [])
- String[] val = { "XX", "YY" };
- dfs.setEras(val);
- String[] retVal = dfs.getEras();
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setLocalPatternChars(java.lang.String)
- */
- public void test_setLocalPatternCharsLjava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setLocalPatternChars(java.lang.String)
- dfs.setLocalPatternChars("GyMZZkHmsSEHHFwWahKz");
- String retVal = dfs.getLocalPatternChars();
- String val = "GyMZZkHmsSEHHFwWahKz";
- assertTrue("Returned incorrect pattern string", retVal.equals(val));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setMonths(java.lang.String[])
- */
- public void test_setMonths$Ljava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setMonths(java.lang.String [])
- String[] val = { "XX", "YY" };
- dfs.setMonths(val);
- String[] retVal = dfs.getMonths();
- assertTrue("Return is identical", retVal != dfs.getMonths());
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setShortMonths(java.lang.String[])
- */
- public void test_setShortMonths$Ljava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setShortMonths(java.lang.String [])
- String[] val = { "XX", "YY" };
- dfs.setShortMonths(val);
- String[] retVal = dfs.getShortMonths();
- assertTrue("Return is identical", retVal != dfs.getShortMonths());
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setShortWeekdays(java.lang.String[])
- */
- public void test_setShortWeekdays$Ljava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setShortWeekdays(java.lang.String [])
- String[] val = { "XX", "YY" };
- dfs.setShortWeekdays(val);
- String[] retVal = dfs.getShortWeekdays();
- assertTrue("Return is identical", retVal != dfs.getShortWeekdays());
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setWeekdays(java.lang.String[])
- */
- public void test_setWeekdays$Ljava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setWeekdays(java.lang.String [])
- String[] val = { "XX", "YY" };
- dfs.setWeekdays(val);
- String[] retVal = dfs.getWeekdays();
- assertTrue("Return is identical", retVal != dfs.getWeekdays());
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings", retVal[i].equals(val[i]));
- }
-
- /**
- * @tests java.text.DateFormatSymbols#setZoneStrings(java.lang.String[][])
- */
- public void test_setZoneStrings$$Ljava_lang_String() {
- // Test for method void
- // java.text.DateFormatSymbols.setZoneStrings(java.lang.String [][])
- String[][] val = { { "XX" }, { "YY" } };
- dfs.setZoneStrings(val);
- String[][] retVal = dfs.getZoneStrings();
- assertTrue("get returns identical", retVal != dfs.getZoneStrings());
- assertTrue("get[0] returns identical", retVal[0] != dfs
- .getZoneStrings()[0]);
- assertTrue("get returned identical", retVal != val);
- if (retVal.length != val.length)
- fail("Returned wrong array");
- for (int i = 0; i < val.length; i++)
- assertTrue("Failed to set strings: " + retVal[i], Arrays.equals(
- retVal[i], val[i]));
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- dfs = new DateFormatSymbols(new Locale("en", "us"));
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
+ /**
+ * @tests java.text.DateFormatSymbols#DateFormatSymbols()
+ */
+ public void test_Constructor() {
+ // Test for method java.text.DateFormatSymbols()
+ // Used in tests
+ try {
+ new DateFormatSymbols();
+ } catch (Exception e) {
+ fail("Constructor failed.");
+ }
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#DateFormatSymbols(java.util.Locale)
+ */
+ public void test_ConstructorLjava_util_Locale() {
+ // Test for method java.text.DateFormatSymbols(java.util.Locale)
+ try {
+ new DateFormatSymbols(new Locale("en", "us"));
+ } catch (Exception e) {
+ fail("Constructor failed.");
+ }
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#clone()
+ */
+ public void test_clone() {
+ // Test for method java.lang.Object java.text.DateFormatSymbols.clone()
+ DateFormatSymbols symbols = new DateFormatSymbols();
+ DateFormatSymbols clone = (DateFormatSymbols) symbols.clone();
+ assertTrue("Not equal", symbols.equals(clone));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#equals(java.lang.Object)
+ */
+ public void test_equalsLjava_lang_Object() {
+ // Test for method boolean
+ // java.text.DateFormatSymbols.equals(java.lang.Object)
+ assertTrue("Equal object returned true", dfs.equals(dfs.clone()));
+ dfs.setLocalPatternChars("KKKKKKKKK");
+ assertTrue("Un-Equal objects returned false", !dfs
+ .equals(new DateFormatSymbols()));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getAmPmStrings()
+ */
+ public void test_getAmPmStrings() {
+ // Test for method java.lang.String []
+ // java.text.DateFormatSymbols.getAmPmStrings()
+ String[] retVal = dfs.getAmPmStrings();
+ String[] val = { "AM", "PM" };
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Array values do not match", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getEras()
+ */
+ public void test_getEras() {
+ // Test for method java.lang.String []
+ // java.text.DateFormatSymbols.getEras()
+ String[] retVal = dfs.getEras();
+ String[] val = { "BC", "AD" };
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Array values do not match", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getLocalPatternChars()
+ */
+ public void test_getLocalPatternChars() {
+ // Test for method java.lang.String
+ // java.text.DateFormatSymbols.getLocalPatternChars()
+ String retVal = dfs.getLocalPatternChars();
+
+ String val = "GyMdkHmsSEDFwWahKzZ";
+
+ assertTrue("Returned incorrect pattern string", retVal.equals(val));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getMonths()
+ */
+ public void test_getMonths() {
+ // Test for method java.lang.String []
+ // java.text.DateFormatSymbols.getMonths()
+ String[] retVal = dfs.getMonths();
+ String[] val = { "January", "February", "March", "April", "May",
+ "June", "July", "August", "September", "October", "November",
+ "December", "" };
+ if (retVal.length != val.length)
+ fail("Returned wrong array: " + retVal.length);
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Array values do not match", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getShortMonths()
+ */
+ public void test_getShortMonths() {
+ // Test for method java.lang.String []
+ // java.text.DateFormatSymbols.getShortMonths()
+ String[] retVal = dfs.getShortMonths();
+ String[] val = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
+ "Aug", "Sep", "Oct", "Nov", "Dec", "" };
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Array values do not match", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getShortWeekdays()
+ */
+ public void test_getShortWeekdays() {
+ // Test for method java.lang.String []
+ // java.text.DateFormatSymbols.getShortWeekdays()
+ String[] retVal = dfs.getShortWeekdays();
+ String[] val = { "", "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Array values do not match", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getWeekdays()
+ */
+ public void test_getWeekdays() {
+ // Test for method java.lang.String []
+ // java.text.DateFormatSymbols.getWeekdays()
+ String[] retVal = dfs.getWeekdays();
+ String[] val = { "", "Sunday", "Monday", "Tuesday", "Wednesday",
+ "Thursday", "Friday", "Saturday" };
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Array values do not match", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#getZoneStrings()
+ */
+ public void test_getZoneStrings() {
+ // Test for method java.lang.String [][]
+ // java.text.DateFormatSymbols.getZoneStrings()
+ String[][] val = { { "XX" }, { "YY" } };
+ dfs.setZoneStrings(val);
+ String[][] retVal = dfs.getZoneStrings();
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings", Arrays
+ .equals(retVal[i], val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#hashCode()
+ */
+ public void test_hashCode() {
+ // Test for method int java.text.DateFormatSymbols.hashCode()
+ int hc1 = hashCode();
+ int hc2 = hashCode();
+ assertTrue("hashCode() returned negative number", hc1 >= 0);
+ assertTrue("hashCode() returned inconsistent number", hc1 == hc2);
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setAmPmStrings(java.lang.String[])
+ */
+ public void test_setAmPmStrings$Ljava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setAmPmStrings(java.lang.String [])
+ String[] val = { "XX", "YY" };
+ dfs.setAmPmStrings(val);
+ String[] retVal = dfs.getAmPmStrings();
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setEras(java.lang.String[])
+ */
+ public void test_setEras$Ljava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setEras(java.lang.String [])
+ String[] val = { "XX", "YY" };
+ dfs.setEras(val);
+ String[] retVal = dfs.getEras();
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setLocalPatternChars(java.lang.String)
+ */
+ public void test_setLocalPatternCharsLjava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setLocalPatternChars(java.lang.String)
+ dfs.setLocalPatternChars("GyMZZkHmsSEHHFwWahKz");
+ String retVal = dfs.getLocalPatternChars();
+ String val = "GyMZZkHmsSEHHFwWahKz";
+ assertTrue("Returned incorrect pattern string", retVal.equals(val));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setMonths(java.lang.String[])
+ */
+ public void test_setMonths$Ljava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setMonths(java.lang.String [])
+ String[] val = { "XX", "YY" };
+ dfs.setMonths(val);
+ String[] retVal = dfs.getMonths();
+ assertTrue("Return is identical", retVal != dfs.getMonths());
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setShortMonths(java.lang.String[])
+ */
+ public void test_setShortMonths$Ljava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setShortMonths(java.lang.String [])
+ String[] val = { "XX", "YY" };
+ dfs.setShortMonths(val);
+ String[] retVal = dfs.getShortMonths();
+ assertTrue("Return is identical", retVal != dfs.getShortMonths());
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setShortWeekdays(java.lang.String[])
+ */
+ public void test_setShortWeekdays$Ljava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setShortWeekdays(java.lang.String [])
+ String[] val = { "XX", "YY" };
+ dfs.setShortWeekdays(val);
+ String[] retVal = dfs.getShortWeekdays();
+ assertTrue("Return is identical", retVal != dfs.getShortWeekdays());
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setWeekdays(java.lang.String[])
+ */
+ public void test_setWeekdays$Ljava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setWeekdays(java.lang.String [])
+ String[] val = { "XX", "YY" };
+ dfs.setWeekdays(val);
+ String[] retVal = dfs.getWeekdays();
+ assertTrue("Return is identical", retVal != dfs.getWeekdays());
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings", retVal[i].equals(val[i]));
+ }
+
+ /**
+ * @tests java.text.DateFormatSymbols#setZoneStrings(java.lang.String[][])
+ */
+ public void test_setZoneStrings$$Ljava_lang_String() {
+ // Test for method void
+ // java.text.DateFormatSymbols.setZoneStrings(java.lang.String [][])
+ String[][] val = { { "XX" }, { "YY" } };
+ dfs.setZoneStrings(val);
+ String[][] retVal = dfs.getZoneStrings();
+ assertTrue("get returns identical", retVal != dfs.getZoneStrings());
+ assertTrue("get[0] returns identical", retVal[0] != dfs
+ .getZoneStrings()[0]);
+ assertTrue("get returned identical", retVal != val);
+ if (retVal.length != val.length)
+ fail("Returned wrong array");
+ for (int i = 0; i < val.length; i++)
+ assertTrue("Failed to set strings: " + retVal[i], Arrays.equals(
+ retVal[i], val[i]));
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection. This method
+ * is called before a test is executed.
+ */
+ protected void setUp() {
+ dfs = new DateFormatSymbols(new Locale("en", "us"));
+ }
+
+ /**
+ * Tears down the fixture, for example, close a network connection. This
+ * method is called after a test is executed.
+ */
+ protected void tearDown() {
+ }
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java?rev=406890&r1=406889&r2=406890&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/text/tests/java/text/DecimalFormatSymbolsTest.java Tue May 16 03:15:51 2006
@@ -29,385 +29,382 @@
public class DecimalFormatSymbolsTest extends TestCase {
- DecimalFormatSymbols dfs;
+ DecimalFormatSymbols dfs;
- DecimalFormatSymbols dfsUS;
+ DecimalFormatSymbols dfsUS;
- /**
- * @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols()
- */
- public void test_Constructor() {
- // Test for method java.text.DecimalFormatSymbols()
- // Used in tests
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols(java.util.Locale)
- */
- public void test_ConstructorLjava_util_Locale() {
- DecimalFormatSymbols dfs = new DecimalFormatSymbols(new Locale("en",
- "us"));
- assertEquals("Returned incorrect symbols", '%', dfs.getPercent());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#equals(java.lang.Object)
- */
- public void test_equalsLjava_lang_Object() {
- assertTrue("Equal objects returned false", dfs.equals(dfs.clone()));
- dfs.setDigit('B');
- assertTrue("Un-Equal objects returned true", !dfs
- .equals(new DecimalFormatSymbols()));
-
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getCurrency()
- */
- public void test_getCurrency() {
- Currency currency = Currency.getInstance("USD");
- assertTrue("Returned incorrect currency",
- dfsUS.getCurrency() == currency);
-
- Currency currK = Currency.getInstance("KRW");
- Currency currX = Currency.getInstance("XXX");
- Currency currE = Currency.getInstance("EUR");
- //Currency currF = Currency.getInstance("FRF");
-
- DecimalFormatSymbols dfs1 = new DecimalFormatSymbols(new Locale("ko",
- "KR"));
- assertTrue("Test1: Returned incorrect currency",
- dfs1.getCurrency() == currK);
- assertEquals("Test1: Returned incorrect currencySymbol", "\uffe6", dfs1
- .getCurrencySymbol());
- assertEquals("Test1: Returned incorrect intlCurrencySymbol", "KRW", dfs1
- .getInternationalCurrencySymbol());
-
- dfs1 = new DecimalFormatSymbols(new Locale("", "KR"));
- assertTrue("Test2: Returned incorrect currency",
- dfs1.getCurrency() == currK);
- assertEquals("Test2: Returned incorrect currencySymbol", "KRW", dfs1
- .getCurrencySymbol());
- assertEquals("Test2: Returned incorrect intlCurrencySymbol", "KRW", dfs1
- .getInternationalCurrencySymbol());
-
- dfs1 = new DecimalFormatSymbols(new Locale("ko", ""));
- assertTrue("Test3: Returned incorrect currency",
- dfs1.getCurrency() == currX);
- assertEquals("Test3: Returned incorrect currencySymbol", "\u00a4", dfs1
- .getCurrencySymbol());
- assertEquals("Test3: Returned incorrect intlCurrencySymbol", "XXX", dfs1
- .getInternationalCurrencySymbol());
-
- dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR"));
- assertTrue("Test4: Returned incorrect currency",
- dfs1.getCurrency() == currE);
- assertEquals("Test4: Returned incorrect currencySymbol", "\u20ac", dfs1
- .getCurrencySymbol());
- assertEquals("Test4: Returned incorrect intlCurrencySymbol", "EUR", dfs1
- .getInternationalCurrencySymbol());
-
- // RI fails these tests since it doesn't have the PREEURO variant
- // dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR","PREEURO"));
- // assertTrue("Test5: Returned incorrect currency", dfs1.getCurrency()
- // == currF);
- // assertTrue("Test5: Returned incorrect currencySymbol",
- // dfs1.getCurrencySymbol().equals("F"));
- // assertTrue("Test5: Returned incorrect intlCurrencySymbol",
- // dfs1.getInternationalCurrencySymbol().equals("FRF"));
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getCurrencySymbol()
- */
- public void test_getCurrencySymbol() {
- assertEquals("Returned incorrect currencySymbol", "$", dfsUS
- .getCurrencySymbol());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getDecimalSeparator()
- */
- public void test_getDecimalSeparator() {
- dfs.setDecimalSeparator('*');
- assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs
- .getDecimalSeparator());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getDigit()
- */
- public void test_getDigit() {
- dfs.setDigit('*');
- assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getGroupingSeparator()
- */
- public void test_getGroupingSeparator() {
- dfs.setGroupingSeparator('*');
- assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs
- .getGroupingSeparator());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getInfinity()
- */
- public void test_getInfinity() {
- dfs.setInfinity("&");
- assertTrue("Returned incorrect Infinity symbol",
- dfs.getInfinity() == "&");
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getInternationalCurrencySymbol()
- */
- public void test_getInternationalCurrencySymbol() {
- assertEquals("Returned incorrect InternationalCurrencySymbol", "USD", dfsUS
- .getInternationalCurrencySymbol());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getMinusSign()
- */
- public void test_getMinusSign() {
- dfs.setMinusSign('&');
- assertEquals("Returned incorrect MinusSign symbol",
- '&', dfs.getMinusSign());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getNaN()
- */
- public void test_getNaN() {
- dfs.setNaN("NAN!!");
- assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN()
- );
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getPatternSeparator()
- */
- public void test_getPatternSeparator() {
- dfs.setPatternSeparator('X');
- assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs
- .getPatternSeparator());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getPercent()
- */
- public void test_getPercent() {
- dfs.setPercent('*');
- assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getPerMill()
- */
- public void test_getPerMill() {
- dfs.setPerMill('#');
- assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#getZeroDigit()
- */
- public void test_getZeroDigit() {
- dfs.setZeroDigit('*');
- assertEquals("Returned incorrect ZeroDigit symbol",
- '*', dfs.getZeroDigit());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setCurrency(java.util.Currency)
- */
- public void test_setCurrencyLjava_util_Currency() {
- Locale locale = Locale.CANADA;
- DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
- .getCurrencyInstance(locale)).getDecimalFormatSymbols();
-
- try {
- dfs.setCurrency(null);
- fail("Expected NullPointerException");
- } catch (NullPointerException e) {
- }
-
- Currency currency = Currency.getInstance("JPY");
- dfs.setCurrency(currency);
-
- assertTrue("Returned incorrect currency", currency == dfs.getCurrency());
- assertTrue("Returned incorrect currency symbol", currency.getSymbol(
- locale).equals(dfs.getCurrencySymbol()));
- assertTrue("Returned incorrect international currency symbol", currency
- .getCurrencyCode().equals(dfs.getInternationalCurrencySymbol()));
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setDecimalSeparator(char)
- */
- public void test_setDecimalSeparatorC() {
- dfs.setDecimalSeparator('*');
- assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs
- .getDecimalSeparator());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setDigit(char)
- */
- public void test_setDigitC() {
- dfs.setDigit('*');
- assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setGroupingSeparator(char)
- */
- public void test_setGroupingSeparatorC() {
- dfs.setGroupingSeparator('*');
- assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs
- .getGroupingSeparator());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setInfinity(java.lang.String)
- */
- public void test_setInfinityLjava_lang_String() {
- dfs.setInfinity("&");
- assertTrue("Returned incorrect Infinity symbol",
- dfs.getInfinity() == "&");
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setInternationalCurrencySymbol(java.lang.String)
- */
- public void test_setInternationalCurrencySymbolLjava_lang_String() {
- Locale locale = Locale.CANADA;
- DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
- .getCurrencyInstance(locale)).getDecimalFormatSymbols();
- Currency currency = Currency.getInstance("JPY");
- dfs.setInternationalCurrencySymbol(currency.getCurrencyCode());
-
- assertTrue("Test1: Returned incorrect currency", currency == dfs
- .getCurrency());
- assertTrue("Test1: Returned incorrect currency symbol", currency
- .getSymbol(locale).equals(dfs.getCurrencySymbol()));
- assertTrue("Test1: Returned incorrect international currency symbol",
- currency.getCurrencyCode().equals(
- dfs.getInternationalCurrencySymbol()));
-
- String symbol = dfs.getCurrencySymbol();
- dfs.setInternationalCurrencySymbol("bogus");
- assertNull("Test2: Returned incorrect currency",
- dfs.getCurrency());
- assertTrue("Test2: Returned incorrect currency symbol", dfs
- .getCurrencySymbol().equals(symbol));
- assertEquals("Test2: Returned incorrect international currency symbol",
- "bogus", dfs.getInternationalCurrencySymbol());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setMinusSign(char)
- */
- public void test_setMinusSignC() {
- dfs.setMinusSign('&');
- assertEquals("Returned incorrect MinusSign symbol",
- '&', dfs.getMinusSign());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setNaN(java.lang.String)
- */
- public void test_setNaNLjava_lang_String() {
- dfs.setNaN("NAN!!");
- assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN()
- );
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setPatternSeparator(char)
- */
- public void test_setPatternSeparatorC() {
- dfs.setPatternSeparator('X');
- assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs
- .getPatternSeparator());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setPercent(char)
- */
- public void test_setPercentC() {
- dfs.setPercent('*');
- assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setPerMill(char)
- */
- public void test_setPerMillC() {
- dfs.setPerMill('#');
- assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill());
- }
-
- /**
- * @tests java.text.DecimalFormatSymbols#setZeroDigit(char)
- */
- public void test_setZeroDigitC() {
- dfs.setZeroDigit('*');
- assertEquals("Set incorrect ZeroDigit symbol", '*', dfs.getZeroDigit());
- }
-
- /**
- * Sets up the fixture, for example, open a network connection. This method
- * is called before a test is executed.
- */
- protected void setUp() {
- dfs = new DecimalFormatSymbols();
- dfsUS = new DecimalFormatSymbols(new Locale("en", "us"));
- }
-
- /**
- * Tears down the fixture, for example, close a network connection. This
- * method is called after a test is executed.
- */
- protected void tearDown() {
- }
-
- // Test serialization mechanism of DecimalFormatSymbols
- public void test_serialization() throws Exception {
- DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRANCE);
- Currency currency = symbols.getCurrency();
- assertNotNull(currency);
-
- // serialize
- ByteArrayOutputStream byteOStream = new ByteArrayOutputStream();
- ObjectOutputStream objectOStream = new ObjectOutputStream(byteOStream);
- objectOStream.writeObject(symbols);
-
- // and deserialize
- ObjectInputStream objectIStream = new ObjectInputStream(
- new ByteArrayInputStream(byteOStream.toByteArray()));
- DecimalFormatSymbols symbolsD = (DecimalFormatSymbols) objectIStream
- .readObject();
-
- // The associated currency will not persist
- currency = symbolsD.getCurrency();
- assertNotNull(currency);
- }
-
- // Use RI to write DecimalFormatSymbols out, use Harmony to read
- // DecimalFormatSymbols in. The read symbol will be equal with those
- // instantiated inside Harmony.
-
- // This assertion will not come into existence the other way around. This is
- // probably caused by different serialization mechanism used by RI and
- // Harmony.
- public void test_RIHarmony_compatible() throws Exception {
- ObjectInputStream i = null;
- try {
- DecimalFormatSymbols symbols = new DecimalFormatSymbols(
- Locale.FRANCE);
+ /**
+ * @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols()
+ */
+ public void test_Constructor() {
+ // Test for method java.text.DecimalFormatSymbols()
+ // Used in tests
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#DecimalFormatSymbols(java.util.Locale)
+ */
+ public void test_ConstructorLjava_util_Locale() {
+ DecimalFormatSymbols dfs = new DecimalFormatSymbols(new Locale("en",
+ "us"));
+ assertEquals("Returned incorrect symbols", '%', dfs.getPercent());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#equals(java.lang.Object)
+ */
+ public void test_equalsLjava_lang_Object() {
+ assertTrue("Equal objects returned false", dfs.equals(dfs.clone()));
+ dfs.setDigit('B');
+ assertTrue("Un-Equal objects returned true", !dfs
+ .equals(new DecimalFormatSymbols()));
+
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getCurrency()
+ */
+ public void test_getCurrency() {
+ Currency currency = Currency.getInstance("USD");
+ assertTrue("Returned incorrect currency",
+ dfsUS.getCurrency() == currency);
+
+ Currency currK = Currency.getInstance("KRW");
+ Currency currX = Currency.getInstance("XXX");
+ Currency currE = Currency.getInstance("EUR");
+ // Currency currF = Currency.getInstance("FRF");
+
+ DecimalFormatSymbols dfs1 = new DecimalFormatSymbols(new Locale("ko",
+ "KR"));
+ assertTrue("Test1: Returned incorrect currency",
+ dfs1.getCurrency() == currK);
+ assertEquals("Test1: Returned incorrect currencySymbol", "\uffe6", dfs1
+ .getCurrencySymbol());
+ assertEquals("Test1: Returned incorrect intlCurrencySymbol", "KRW",
+ dfs1.getInternationalCurrencySymbol());
+
+ dfs1 = new DecimalFormatSymbols(new Locale("", "KR"));
+ assertTrue("Test2: Returned incorrect currency",
+ dfs1.getCurrency() == currK);
+ assertEquals("Test2: Returned incorrect currencySymbol", "KRW", dfs1
+ .getCurrencySymbol());
+ assertEquals("Test2: Returned incorrect intlCurrencySymbol", "KRW",
+ dfs1.getInternationalCurrencySymbol());
+
+ dfs1 = new DecimalFormatSymbols(new Locale("ko", ""));
+ assertTrue("Test3: Returned incorrect currency",
+ dfs1.getCurrency() == currX);
+ assertEquals("Test3: Returned incorrect currencySymbol", "\u00a4", dfs1
+ .getCurrencySymbol());
+ assertEquals("Test3: Returned incorrect intlCurrencySymbol", "XXX",
+ dfs1.getInternationalCurrencySymbol());
+
+ dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR"));
+ assertTrue("Test4: Returned incorrect currency",
+ dfs1.getCurrency() == currE);
+ assertEquals("Test4: Returned incorrect currencySymbol", "\u20ac", dfs1
+ .getCurrencySymbol());
+ assertEquals("Test4: Returned incorrect intlCurrencySymbol", "EUR",
+ dfs1.getInternationalCurrencySymbol());
+
+ // RI fails these tests since it doesn't have the PREEURO variant
+ // dfs1 = new DecimalFormatSymbols(new Locale("fr", "FR","PREEURO"));
+ // assertTrue("Test5: Returned incorrect currency", dfs1.getCurrency()
+ // == currF);
+ // assertTrue("Test5: Returned incorrect currencySymbol",
+ // dfs1.getCurrencySymbol().equals("F"));
+ // assertTrue("Test5: Returned incorrect intlCurrencySymbol",
+ // dfs1.getInternationalCurrencySymbol().equals("FRF"));
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getCurrencySymbol()
+ */
+ public void test_getCurrencySymbol() {
+ assertEquals("Returned incorrect currencySymbol", "$", dfsUS
+ .getCurrencySymbol());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getDecimalSeparator()
+ */
+ public void test_getDecimalSeparator() {
+ dfs.setDecimalSeparator('*');
+ assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs
+ .getDecimalSeparator());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getDigit()
+ */
+ public void test_getDigit() {
+ dfs.setDigit('*');
+ assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getGroupingSeparator()
+ */
+ public void test_getGroupingSeparator() {
+ dfs.setGroupingSeparator('*');
+ assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs
+ .getGroupingSeparator());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getInfinity()
+ */
+ public void test_getInfinity() {
+ dfs.setInfinity("&");
+ assertTrue("Returned incorrect Infinity symbol",
+ dfs.getInfinity() == "&");
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getInternationalCurrencySymbol()
+ */
+ public void test_getInternationalCurrencySymbol() {
+ assertEquals("Returned incorrect InternationalCurrencySymbol", "USD",
+ dfsUS.getInternationalCurrencySymbol());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getMinusSign()
+ */
+ public void test_getMinusSign() {
+ dfs.setMinusSign('&');
+ assertEquals("Returned incorrect MinusSign symbol", '&', dfs
+ .getMinusSign());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getNaN()
+ */
+ public void test_getNaN() {
+ dfs.setNaN("NAN!!");
+ assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getPatternSeparator()
+ */
+ public void test_getPatternSeparator() {
+ dfs.setPatternSeparator('X');
+ assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs
+ .getPatternSeparator());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getPercent()
+ */
+ public void test_getPercent() {
+ dfs.setPercent('*');
+ assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getPerMill()
+ */
+ public void test_getPerMill() {
+ dfs.setPerMill('#');
+ assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#getZeroDigit()
+ */
+ public void test_getZeroDigit() {
+ dfs.setZeroDigit('*');
+ assertEquals("Returned incorrect ZeroDigit symbol", '*', dfs
+ .getZeroDigit());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setCurrency(java.util.Currency)
+ */
+ public void test_setCurrencyLjava_util_Currency() {
+ Locale locale = Locale.CANADA;
+ DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
+ .getCurrencyInstance(locale)).getDecimalFormatSymbols();
+
+ try {
+ dfs.setCurrency(null);
+ fail("Expected NullPointerException");
+ } catch (NullPointerException e) {
+ }
+
+ Currency currency = Currency.getInstance("JPY");
+ dfs.setCurrency(currency);
+
+ assertTrue("Returned incorrect currency", currency == dfs.getCurrency());
+ assertTrue("Returned incorrect currency symbol", currency.getSymbol(
+ locale).equals(dfs.getCurrencySymbol()));
+ assertTrue("Returned incorrect international currency symbol", currency
+ .getCurrencyCode().equals(dfs.getInternationalCurrencySymbol()));
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setDecimalSeparator(char)
+ */
+ public void test_setDecimalSeparatorC() {
+ dfs.setDecimalSeparator('*');
+ assertEquals("Returned incorrect DecimalSeparator symbol", '*', dfs
+ .getDecimalSeparator());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setDigit(char)
+ */
+ public void test_setDigitC() {
+ dfs.setDigit('*');
+ assertEquals("Returned incorrect Digit symbol", '*', dfs.getDigit());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setGroupingSeparator(char)
+ */
+ public void test_setGroupingSeparatorC() {
+ dfs.setGroupingSeparator('*');
+ assertEquals("Returned incorrect GroupingSeparator symbol", '*', dfs
+ .getGroupingSeparator());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setInfinity(java.lang.String)
+ */
+ public void test_setInfinityLjava_lang_String() {
+ dfs.setInfinity("&");
+ assertTrue("Returned incorrect Infinity symbol",
+ dfs.getInfinity() == "&");
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setInternationalCurrencySymbol(java.lang.String)
+ */
+ public void test_setInternationalCurrencySymbolLjava_lang_String() {
+ Locale locale = Locale.CANADA;
+ DecimalFormatSymbols dfs = ((DecimalFormat) NumberFormat
+ .getCurrencyInstance(locale)).getDecimalFormatSymbols();
+ Currency currency = Currency.getInstance("JPY");
+ dfs.setInternationalCurrencySymbol(currency.getCurrencyCode());
+
+ assertTrue("Test1: Returned incorrect currency", currency == dfs
+ .getCurrency());
+ assertTrue("Test1: Returned incorrect currency symbol", currency
+ .getSymbol(locale).equals(dfs.getCurrencySymbol()));
+ assertTrue("Test1: Returned incorrect international currency symbol",
+ currency.getCurrencyCode().equals(
+ dfs.getInternationalCurrencySymbol()));
+
+ String symbol = dfs.getCurrencySymbol();
+ dfs.setInternationalCurrencySymbol("bogus");
+ assertNull("Test2: Returned incorrect currency", dfs.getCurrency());
+ assertTrue("Test2: Returned incorrect currency symbol", dfs
+ .getCurrencySymbol().equals(symbol));
+ assertEquals("Test2: Returned incorrect international currency symbol",
+ "bogus", dfs.getInternationalCurrencySymbol());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setMinusSign(char)
+ */
+ public void test_setMinusSignC() {
+ dfs.setMinusSign('&');
+ assertEquals("Returned incorrect MinusSign symbol", '&', dfs
+ .getMinusSign());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setNaN(java.lang.String)
+ */
+ public void test_setNaNLjava_lang_String() {
+ dfs.setNaN("NAN!!");
+ assertEquals("Returned incorrect nan symbol", "NAN!!", dfs.getNaN());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setPatternSeparator(char)
+ */
+ public void test_setPatternSeparatorC() {
+ dfs.setPatternSeparator('X');
+ assertEquals("Returned incorrect PatternSeparator symbol", 'X', dfs
+ .getPatternSeparator());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setPercent(char)
+ */
+ public void test_setPercentC() {
+ dfs.setPercent('*');
+ assertEquals("Returned incorrect Percent symbol", '*', dfs.getPercent());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setPerMill(char)
+ */
+ public void test_setPerMillC() {
+ dfs.setPerMill('#');
+ assertEquals("Returned incorrect PerMill symbol", '#', dfs.getPerMill());
+ }
+
+ /**
+ * @tests java.text.DecimalFormatSymbols#setZeroDigit(char)
+ */
+ public void test_setZeroDigitC() {
+ dfs.setZeroDigit('*');
+ assertEquals("Set incorrect ZeroDigit symbol", '*', dfs.getZeroDigit());
+ }
+
+ /**
+ * Sets up the fixture, for example, open a network connection. This method
+ * is called before a test is executed.
+ */
+ protected void setUp() {
+ dfs = new DecimalFormatSymbols();
+ dfsUS = new DecimalFormatSymbols(new Locale("en", "us"));
+ }
+
+ /**
+ * Tears down the fixture, for example, close a network connection. This
+ * method is called after a test is executed.
+ */
+ protected void tearDown() {
+ }
+
+ // Test serialization mechanism of DecimalFormatSymbols
+ public void test_serialization() throws Exception {
+ DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.FRANCE);
+ Currency currency = symbols.getCurrency();
+ assertNotNull(currency);
+
+ // serialize
+ ByteArrayOutputStream byteOStream = new ByteArrayOutputStream();
+ ObjectOutputStream objectOStream = new ObjectOutputStream(byteOStream);
+ objectOStream.writeObject(symbols);
+
+ // and deserialize
+ ObjectInputStream objectIStream = new ObjectInputStream(
+ new ByteArrayInputStream(byteOStream.toByteArray()));
+ DecimalFormatSymbols symbolsD = (DecimalFormatSymbols) objectIStream
+ .readObject();
+
+ // The associated currency will not persist
+ currency = symbolsD.getCurrency();
+ assertNotNull(currency);
+ }
+
+ // Use RI to write DecimalFormatSymbols out, use Harmony to read
+ // DecimalFormatSymbols in. The read symbol will be equal with those
+ // instantiated inside Harmony.
+
+ // This assertion will not come into existence the other way around. This is
+ // probably caused by different serialization mechanism used by RI and
+ // Harmony.
+ public void test_RIHarmony_compatible() throws Exception {
+ ObjectInputStream i = null;
+ try {
+ DecimalFormatSymbols symbols = new DecimalFormatSymbols(
+ Locale.FRANCE);
i = new ObjectInputStream(
getClass()
.getClassLoader()
@@ -415,15 +412,15 @@
"/serialization/java/text/DecimalFormatSymbols.ser"));
DecimalFormatSymbols symbolsD = (DecimalFormatSymbols) i
.readObject();
- assertEquals(symbols, symbolsD);
- } finally {
- try {
- if (i != null) {
- i.close();
- }
- } catch (Exception e) {
- // ignore
- }
- }
- }
+ assertEquals(symbols, symbolsD);
+ } finally {
+ try {
+ if (i != null) {
+ i.close();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ }
}