harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ghar...@apache.org
Subject svn commit: r395251 - in /incubator/harmony/enhanced/classlib/trunk/modules/text: make/common/ src/main/java/java/text/ src/test/java/tests/api/java/text/ src/test/resources/serialization/ src/test/resources/serialization/java/ src/test/resources/seria...
Date Wed, 19 Apr 2006 14:33:30 GMT
Author: gharley
Date: Wed Apr 19 07:33:27 2006
New Revision: 395251

URL: http://svn.apache.org/viewcvs?rev=395251&view=rev
Log:
HARMONY-349 : currency field of DecimalFormatSymbols is not deserialized properly

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormatSymbols.ser
  (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/hyproperties.xml
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AllTests.java
    incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml?rev=395251&r1=395250&r2=395251&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/build.xml Wed Apr 19
07:33:27 2006
@@ -45,7 +45,7 @@
 	</target>
 
 	
-	<target name="compile.tests">
+	<target name="compile.tests" depends="copy.test.resources">
 		<echo message="Compiling TEXT tests from ${hy.text.src.test.java}" />
 
 		<mkdir dir="${hy.text.bin.test}" />
@@ -62,7 +62,7 @@
 					<include name="**/*.jar" />
 				</fileset>
 			</bootclasspath>
-                        <classpath location="../../../../build/tests" />
+            <classpath location="${hy.tests.support.bin}" />
 		</javac>
 	</target>
 
@@ -89,7 +89,7 @@
 			<classpath>
 				<pathelement path="${hy.text.bin.test}"/>
 			</classpath>
-            <classpath location="../../../../build/tests" />	
+            <classpath location="${hy.tests.support.bin}" />	
 
 			<formatter type="xml" />
 
@@ -125,5 +125,15 @@
 	<target name="copy.resources">
 		<!-- Nothing for TEXT -->
 	</target>
+	
+	<target name="copy.test.resources">
+		<mkdir dir="${hy.text.bin.test}" />
+        <copy todir="${hy.text.bin.test}" includeemptydirs="false">
+            <fileset dir="${hy.text.src.test.resources}">
+                <exclude name="**/*.java" />
+            </fileset>
+        </copy>
+	</target>	
+	
 </project>
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/hyproperties.xml
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/hyproperties.xml?rev=395251&r1=395250&r2=395251&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/hyproperties.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/make/common/hyproperties.xml Wed
Apr 19 07:33:27 2006
@@ -40,5 +40,8 @@
 
    <tests>
       <reports location="../../build/test_report" />
+      <support>
+          <bin location="../../build/tests" />
+      </support>
    </tests>
 </hy>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java?rev=395251&r1=395250&r2=395251&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/main/java/java/text/DecimalFormatSymbols.java
Wed Apr 19 07:33:27 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 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.
@@ -476,7 +476,8 @@
 			new ObjectStreamField("percent", Character.TYPE),
 			new ObjectStreamField("perMill", Character.TYPE),
 			new ObjectStreamField("serialVersionOnStream", Integer.TYPE),
-			new ObjectStreamField("zeroDigit", Character.TYPE), };
+			new ObjectStreamField("zeroDigit", Character.TYPE),
+			new ObjectStreamField("locale", Locale.class),};
 
 	private void writeObject(ObjectOutputStream stream) throws IOException {
 		ObjectOutputStream.PutField fields = stream.putFields();
@@ -495,6 +496,7 @@
 		fields.put("perMill", getPerMill());
 		fields.put("serialVersionOnStream", 1);
 		fields.put("zeroDigit", getZeroDigit());
+		fields.put("locale", locale);
 		stream.writeFields();
 	}
 
@@ -514,12 +516,19 @@
 		setPercent(fields.get("percent", '%'));
 		setPerMill(fields.get("perMill", '\u2030'));
 		setZeroDigit(fields.get("zeroDigit", '0'));
+		locale = (Locale)fields.get("locale", null);
 		if (fields.get("serialVersionOnStream", 0) == 0) {
 			setMonetaryDecimalSeparator(getDecimalSeparator());
 			setExponential('E');
 		} else {
 			setMonetaryDecimalSeparator(fields.get("monetarySeparator", '.'));
 			setExponential(fields.get("exponential", 'E'));
+			
+		}
+		try {
+			currency = Currency.getInstance(intlCurrencySymbol);
+		} catch (IllegalArgumentException e) {
+			currency = null;
 		}
 	}
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AllTests.java?rev=395251&r1=395250&r2=395251&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/AllTests.java
Wed Apr 19 07:33:27 2006
@@ -1,4 +1,4 @@
-/* Copyright 2005 The Apache Software Foundation or its licensors, as applicable
+/* 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.
@@ -18,10 +18,7 @@
 import junit.framework.Test;
 import junit.framework.TestSuite;
 
-/**
- * TODO Type description
- * 
- */
+
 public class AllTests {
 
 	public static Test suite() {
@@ -40,6 +37,7 @@
 		suite.addTestSuite(CollatorTest.class);
 		suite.addTestSuite(DateFormatFieldTest.class);
 		suite.addTestSuite(DateFormatTest.class);
+		suite.addTestSuite(DecimalFormatSymbolsTest.class);
 		suite.addTestSuite(DateFormatSymbolsTest.class);
 		suite.addTestSuite(FieldPositionTest.class);
 		suite.addTestSuite(MessageFormatFieldTest.class);

Modified: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java?rev=395251&r1=395250&r2=395251&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/java/tests/api/java/text/DecimalFormatSymbolsTest.java
Wed Apr 19 07:33:27 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 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.
@@ -15,6 +15,13 @@
 
 package tests.api.java.text;
 
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.net.URI;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
 import java.text.NumberFormat;
@@ -366,5 +373,59 @@
 	 * 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(
+					new FileInputStream(
+							new File(URI.create(
+									this.getClass().getResource(
+										"/serialization/java/text/DecimalFormatSymbols.ser")
+											.toString()))));
+			DecimalFormatSymbols symbolsD = (DecimalFormatSymbols) i
+					.readObject();
+			assertEquals(symbols, symbolsD);
+		} finally {
+			try {
+				if (i != null) {
+					i.close();
+				}
+			} catch (Exception e) {
+				// ignore
+			}
+		}
 	}
 }

Added: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormatSymbols.ser
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormatSymbols.ser?rev=395251&view=auto
==============================================================================
Binary file - no diff available.

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/text/src/test/resources/serialization/java/text/DecimalFormatSymbols.ser
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message