harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r767524 - in /harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/ test/java/org/apache/harmony/beans/tests/java/beans/ test/resources/xml/ test/support/java/org/apache/harmony/beans/tests/support/mock/
Date Wed, 22 Apr 2009 13:56:32 GMT
Author: tellison
Date: Wed Apr 22 13:56:31 2009
New Revision: 767524

URL: http://svn.apache.org/viewvc?rev=767524&view=rev
Log:
Apply patch for HARMONY-6160 ([classlib][beans] java.beans.XMLEncoder.writeObject(Object o)
should not change the inner content of the given object)

Added:
    harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockTreeMap.xml 
 (with props)
    harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java
  (with props)
Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLEncoderTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java?rev=767524&r1=767523&r2=767524&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/XMLEncoder.java
Wed Apr 22 13:56:31 2009
@@ -838,7 +838,7 @@
                 break;
             }
             
-            if (obj != null && value.equals(obj)) {
+            if (obj != null && obj.equals(value)) {
                 n++;
 
                 if (n >= DEADLOCK_THRESHOLD) {

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=767524&r1=767523&r2=767524&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
Wed Apr 22 13:56:31 2009
@@ -32,6 +32,8 @@
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.io.StringReader;
+import java.util.Map;
+import java.util.TreeMap;
 
 import junit.framework.TestCase;
 
@@ -44,6 +46,7 @@
 import org.apache.harmony.beans.tests.support.mock.MockBean4Owner_Target;
 import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField;
 import org.apache.harmony.beans.tests.support.mock.MockBean4StaticField_PD;
+import org.apache.harmony.beans.tests.support.mock.MockTreeMapClass;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLReader;
 import org.xml.sax.helpers.XMLReaderFactory;
@@ -300,6 +303,18 @@
 
     }
 
+    public void testWriteObject_MockTreeMap() throws Exception {
+        Map<String, TreeMap<String, String>> innerTreeMap = new MockTreeMapClass();
+        TreeMap resultTreeMap = innerTreeMap.get("outKey");
+        resultTreeMap.put("innerKey", "innerValue");
+
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
+        XMLEncoder xmlEncoder = new XMLEncoder(baos);
+
+        assertCodedXML(innerTreeMap, "/xml/MockTreeMap.xml", baos, xmlEncoder);
+        assertEquals(1, innerTreeMap.size());
+    }
+
     public void testClose() {
         ByteArrayOutputStream out = new ByteArrayOutputStream() {
             boolean closeCalled = false;

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockTreeMap.xml
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockTreeMap.xml?rev=767524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockTreeMap.xml (added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockTreeMap.xml Wed
Apr 22 13:56:31 2009
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?> 
+<!--
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You 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.
+-->
+
+<java version="${version}" class="java.beans.XMLDecoder"> 
+ <object class="${classname}"> 
+  <void method="get"> 
+   <string>outer_key</string> 
+   <void method="put"> 
+    <string>inner_key</string> 
+    <string>value</string> 
+   </void> 
+  </void> 
+ </object> 
+</java>

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/resources/xml/MockTreeMap.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Added: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java?rev=767524&view=auto
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java
(added)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java
Wed Apr 22 13:56:31 2009
@@ -0,0 +1,33 @@
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.beans.tests.support.mock;
+
+import java.util.TreeMap;
+
+public class MockTreeMapClass extends TreeMap {
+
+    @Override
+    public Object get(Object key) {
+        Object result = super.get(key);
+        if (result == null) {
+            result = new TreeMap();
+            put(key, result);
+        }
+        return result;
+    }
+}

Propchange: harmony/enhanced/classlib/trunk/modules/beans/src/test/support/java/org/apache/harmony/beans/tests/support/mock/MockTreeMapClass.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message