harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r383878 - in /incubator/harmony/enhanced/classlib/trunk/modules/text/src: main/java/java/text/DateFormat.java test/java/org/apache/harmony/tests/java/text/AllTests.java test/java/org/apache/harmony/tests/java/text/DataFormatFieldTest.java
Date Tue, 07 Mar 2006 13:14:05 GMT
Author: tellison
Date: Tue Mar  7 05:14:03 2006
New Revision: 383878

URL: http://svn.apache.org/viewcvs?rev=383878&view=rev
Log:
Fix for HARMONY-178 (java.text.DateFormat$Field's contructor may replace predefined consts
with new value in cache)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/DataFormatFieldTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java?rev=383878&r1=383877&r2=383878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DateFormat.java
Tue Mar  7 05:14:03 2006
@@ -15,7 +15,6 @@
 
 package java.text;
 
-
 import java.io.InvalidObjectException;
 import java.util.Calendar;
 import java.util.Date;
@@ -327,8 +326,9 @@
 	}
 
 	/**
-	 * Answers a <code>DateFormat</code> instance for the formatting and parsing
-	 * of both dates and times in the manner appropriate to the default Locale.
+	 * Answers a <code>DateFormat</code> instance for the formatting and
+	 * parsing of both dates and times in the manner appropriate to the default
+	 * Locale.
 	 * 
 	 * @param dateStyle
 	 *            one of SHORT, MEDIUM, LONG, FULL, or DEFAULT
@@ -633,7 +633,8 @@
 		protected Field(String fieldName, int calendarField) {
 			super(fieldName);
 			this.calendarField = calendarField;
-			if (calendarField != -1)
+			if (calendarField != -1
+					&& table.get(new Integer(calendarField)) == null)
 				table.put(new Integer(calendarField), this);
 		}
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java?rev=383878&r1=383877&r2=383878&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/AllTests.java
Tue Mar  7 05:14:03 2006
@@ -35,6 +35,7 @@
 		suite.addTestSuite(BreakIteratorTest.class);
 		suite.addTestSuite(MessageFormatTest.class);
 		suite.addTestSuite(ChoiceFormatTest.class);
+		suite.addTestSuite(DataFormatFieldTest.class);
 		//$JUnit-END$
 		return suite;
 	}

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/DataFormatFieldTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/DataFormatFieldTest.java?rev=383878&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/DataFormatFieldTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/org/apache/harmony/tests/java/text/DataFormatFieldTest.java
Tue Mar  7 05:14:03 2006
@@ -0,0 +1,54 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.text;
+
+import java.text.DateFormat;
+import java.util.Calendar;
+
+import junit.framework.TestCase;
+
+public class DataFormatFieldTest extends TestCase{
+
+	public void test_ConstructorLjava_lang_StringLjava_lang_String() {
+		// Regression for HARMONY-178
+		MyField field = new MyField("day of month", Calendar.ERA);
+
+		assertEquals("field has wrong name", "day of month", field.getName());
+		assertEquals("field has wrong Calendar field number", Calendar.ERA,
+				field.getCalendarField());
+
+		DateFormat.Field realField = DateFormat.Field
+				.ofCalendarField(Calendar.ERA);
+		assertSame("Modified calendar field with the same field number",
+				DateFormat.Field.ERA, realField);
+
+		DateFormat.Field realField2 = DateFormat.Field
+				.ofCalendarField(Calendar.DAY_OF_MONTH);
+		assertSame("Modified calendar field with the same field number",
+				DateFormat.Field.DAY_OF_MONTH, realField2);
+	}
+
+	static class MyField extends DateFormat.Field {
+		protected MyField(String fieldName, int calendarField) {
+			super(fieldName, calendarField);
+		}
+
+		protected String getName() {
+			return super.getName();
+		}
+	}
+
+}



Mime
View raw message