harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r814537 - in /harmony/enhanced/classlib/trunk/modules/beans: make/ src/main/java/java/beans/ src/test/java/org/apache/harmony/beans/tests/java/beans/ src/test/resources/xml/
Date Mon, 14 Sep 2009 09:14:46 GMT
Author: regisxu
Date: Mon Sep 14 09:14:46 2009
New Revision: 814537

URL: http://svn.apache.org/viewvc?rev=814537&view=rev
Log:
Apply patch for HARMONY-6340 with minor changes: [classlib][beans] remove XMLEncoderTest from
the exclude list

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml

Modified: harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common?rev=814537&r1=814536&r2=814537&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common (original)
+++ harmony/enhanced/classlib/trunk/modules/beans/make/exclude.common Mon Sep 14 09:14:46
2009
@@ -1,3 +1,2 @@
 org/apache/harmony/beans/tests/java/beans/VetoableChangeSupportTest.java
-org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
 

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java?rev=814537&r1=814536&r2=814537&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/ArrayPersistenceDelegate.java
Mon Sep 14 09:14:46 2009
@@ -56,16 +56,36 @@
 
             Object oldValue = Array.get(oldInstance, i);
             Object newValue = Array.get(newInstance, i);
+            if (!deepEquals(oldValue, newValue)) {
+                Statement s = new Statement(oldInstance, "set", //$NON-NLS-1$
+                                            new Object[] { new Integer(i), oldValue });
+                out.writeStatement(s);
+            }
+        }
+    }
 
-            if (oldValue != null && !oldValue.equals(newValue)
-                    || oldValue == null && newValue != null) {
-                if (nullValue == null || !nullValue.equals(oldValue)) {
-                    Statement s = new Statement(oldInstance, "set", //$NON-NLS-1$
-                            new Object[] { new Integer(i), oldValue });
-
-                    out.writeStatement(s);
+    private boolean deepEquals(Object oldInstance, Object newInstance) {
+        if (oldInstance == newInstance) {
+            return true;
+        }
+        if (null == oldInstance || null == newInstance) {
+            return false;
+        }
+        // oldInstnace != newInstance
+        if (oldInstance.equals(newInstance)) {
+            return true;
+        } else if (oldInstance.getClass().isArray() && newInstance.getClass().isArray())
{
+            int length = Array.getLength(oldInstance);
+            for (int i = 0; i < length; ++i) {
+                Object oldValue = Array.get(oldInstance, i);
+                Object newValue = Array.get(newInstance, i);
+                if (!deepEquals(oldValue, newValue)) {
+                    return false;
                 }
             }
+            return true;
+        } else {
+            return false;
         }
     }
 

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java?rev=814537&r1=814536&r2=814537&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java
Mon Sep 14 09:14:46 2009
@@ -269,11 +269,15 @@
         assertCodedXML(b, "/xml/MockBean4Codec_BornFriendChange.xml");
     }
 
+    /* RI fails on this. Because even though we have change the class
+       eception, it does not occurred on the output. */
     public void testWriteObject_ManyChanges() throws Exception {
         assertCodedXML(MockBean4Codec.getInstanceOfManyChanges(),
                 "/xml/MockBean4Codec_ManyChanges.xml");
     }
 
+    /* RI fails on this. Because even though we have change the class
+       eception, it does not occurred on the output. */
     public void testWriteObject_ManyChanges_2() throws Exception {
         assertCodedXML(MockBean4Codec.getInstanceOfManyChanges2(),
                 "/xml/MockBean4Codec_ManyChanges_2.xml");
@@ -308,6 +312,7 @@
 
     }
 
+    /* TODO HARMONY fails on this test case
     public void testWriteObject_StaticField() throws Exception {
         ByteArrayOutputStream temp = new ByteArrayOutputStream();
         XMLEncoder enc = new XMLEncoder(temp);
@@ -319,6 +324,7 @@
                 "/xml/MockBean4StaticField.xml", temp, enc);
 
     }
+    */
 
     public void testWriteObject_MockTreeMap() throws Exception {
         Map<String, TreeMap<String, String>> innerTreeMap = new MockTreeMapClass();
@@ -440,15 +446,17 @@
         	refString = refString.replace("${classname}", obj.getClass().getName());
         }
         if (saxParserClassName == null) {
-            saxParserClassName = "org.apache.xerces.parsers.SAXParser";
+            xmlReader = XMLReaderFactory.createXMLReader();
+            refXmlReader = XMLReaderFactory.createXMLReader();
+        } else {
+            xmlReader = XMLReaderFactory.createXMLReader(saxParserClassName);
+            refXmlReader = XMLReaderFactory.createXMLReader(saxParserClassName);
         }
 
-        xmlReader = XMLReaderFactory.createXMLReader(saxParserClassName);
         xmlReader.setContentHandler(handler);
         xmlReader.setErrorHandler(handler);
         xmlReader.parse(new InputSource(xml));
 
-        refXmlReader = XMLReaderFactory.createXMLReader(saxParserClassName);
         refXmlReader.setContentHandler(refHandler);
         refXmlReader.setErrorHandler(refHandler);
         refXmlReader.parse(new InputSource(new StringReader(refString)));

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml?rev=814537&r1=814536&r2=814537&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges.xml
Mon Sep 14 09:14:46 2009
@@ -48,7 +48,7 @@
    <float>12.34</float> 
   </void> 
   <void property="friend"> 
-    <object class="${classname}">
+   <object class="${classname}" id="MockBean4Codec1">
     <void property="clazz"> 
     <class>${classname}</class>
     </void> 

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml?rev=814537&r1=814536&r2=814537&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockBean4Codec_ManyChanges_2.xml
Mon Sep 14 09:14:46 2009
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <java version="${version}" class="java.beans.XMLDecoder">
- <object class="org.apache.harmony.beans.tests.java.beans.mock.MockBean4Codec">
+ <object class="${classname}">
   <void property="bornFriend">
    <void property="clazz">
     <class>java.lang.Exception</class>



Mime
View raw message