harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r415773 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans: ./ src/main/java/org/apache/harmony/beans/ src/test/java-internal/org/apache/harmony/beans/
Date Tue, 20 Jun 2006 19:11:06 GMT
Author: hindessm
Date: Tue Jun 20 12:11:05 2006
New Revision: 415773

URL: http://svn.apache.org/viewvc?rev=415773&view=rev
Log:
Applied patch from "[#HARMONY-627] [classlib] [beans] enabling more tests for java.beans".

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/ClassPersistenceDelegateTest.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/StringPersistenceDelegateTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml?rev=415773&r1=415772&r2=415773&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/build.xml Tue Jun 20 12:11:05
2006
@@ -147,9 +147,6 @@
 
                 <fileset dir="${hy.beans.src.test.internal}">
                     <include name="**/*Test.java"/>
-                	<!-- Excluded pending investigation -->
-                	<exclude name="org/apache/harmony/beans/ClassPersistenceDelegateTest.java"
/>
-                    <exclude name="org/apache/harmony/beans/StringPersistenceDelegateTest.java"
/>
                 </fileset>
             </batchtest>
         </junit>

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java?rev=415773&r1=415772&r2=415773&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_ClassPersistenceDelegate.java
Tue Jun 20 12:11:05 2006
@@ -33,7 +33,7 @@
  */
 
 public class java_lang_ClassPersistenceDelegate extends PersistenceDelegate {
-    
+
     protected Expression instantiate(Object oldInstance, Encoder out) {
         Class value = (Class) oldInstance;
         Field fld = null;
@@ -59,26 +59,33 @@
                 fld = Boolean.class.getField(TYPE);
             }
         } catch (NoSuchFieldException e) {
-            // impossible situation for valid java.lang classes 
-            // implementation with version >= 1.1 
+            // impossible situation for valid java.lang classes
+            // implementation with version >= 1.1
         }
         if (fld != null) {
-            // we have primitive type 
+            // we have primitive type
             result = new Expression(oldInstance, fld, "get",
-                    new Object[] {null});
+                                    new Object[] {null});
         } else {
             result = new Expression(oldInstance, Class.class, "forName",
-                new Object[] { new String(value.getName()) });
+                    new Object[] { new String(value.getName()) });
         }
         return result;
     }
-    
-    protected void initialize(
-            Class type, Object oldInstance, Object newInstance, Encoder out) {
-    }
-    
-    // Added for testing purposes
+
+    protected void initialize(Class type, Object oldInstance,
+                              Object newInstance, Encoder out) {}
+
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
+        if (oldInstance instanceof Class && newInstance instanceof Class) {
+            Class c1 = (Class) oldInstance;
+            Class c2 = (Class) newInstance;
+
+            if (c1.getName().equals(c2.getName())) {
+                return true;
+            }
+            return false;
+        }
         return super.mutatesTo(oldInstance, newInstance);
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java?rev=415773&r1=415772&r2=415773&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/org/apache/harmony/beans/java_lang_StringPersistenceDelegate.java
Tue Jun 20 12:11:05 2006
@@ -30,19 +30,21 @@
  */
 
 public class java_lang_StringPersistenceDelegate extends PersistenceDelegate {
-    
+
     protected Expression instantiate(Object oldInstance, Encoder out) {
         String value = (String) oldInstance;
+
         return new Expression(oldInstance, String.class, "new",
-                new Object[] { new String(value) });
+                              new Object[] {new String(value)});
     }
-    
-    protected void initialize(
-            Class type, Object oldInstance, Object newInstance, Encoder out) {
-    }
-    
-    // Added for testing purposes
+
+    protected void initialize(Class type, Object oldInstance,
+                              Object newInstance, Encoder out) {}
+
     protected boolean mutatesTo(Object oldInstance, Object newInstance) {
+        if (oldInstance instanceof String && newInstance instanceof String) {
+            return newInstance.equals(oldInstance);
+        }
         return super.mutatesTo(oldInstance, newInstance);
     }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/ClassPersistenceDelegateTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/ClassPersistenceDelegateTest.java?rev=415773&r1=415772&r2=415773&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/ClassPersistenceDelegateTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/ClassPersistenceDelegateTest.java
Tue Jun 20 12:11:05 2006
@@ -1,11 +1,11 @@
 /* Copyright 2005 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.
@@ -25,47 +25,52 @@
  */
 public class ClassPersistenceDelegateTest extends TestCase {
 
-	private java_lang_ClassPersistenceDelegate pd = null;
+    private java_lang_ClassPersistenceDelegate pd = null;
 
-	protected void setUp() throws Exception {
-		super.setUp();
-		pd = new java_lang_ClassPersistenceDelegate();
-	}
-
-	public void testMutates() {
-		assertFalse(pd.mutatesTo(Class.class, null));
-		assertFalse(pd.mutatesTo(null, null));
-		assertFalse(pd.mutatesTo(Class.class, String.class));
-		assertTrue(pd.mutatesTo(String.class, String.class));
-	}
-
-	public void testInitialize() {
-		pd.initialize(null, null, null, null);
-	}
-
-	public void testInstantiate_Normal() throws Exception {
-		Expression exp = pd.instantiate(Integer.class, new Encoder());
-		assertSame(Integer.class, exp.getValue());
-		assertTrue(exp.getTarget() instanceof Class);
-		assertEquals("forName", exp.getMethodName());
-		assertEquals(1, exp.getArguments().length);
-		assertEquals("java.lang.Integer", exp.getArguments()[0]);
-	}
-
-	public void testInstantiate_Class() throws Exception {
-		Expression exp = pd.instantiate(Class.class, new Encoder());
-		assertSame(Class.class, exp.getValue());
-		assertTrue(exp.getTarget() instanceof Class);
-		assertEquals("forName", exp.getMethodName());
-		assertEquals(1, exp.getArguments().length);
-		assertEquals("java.lang.Class", exp.getArguments()[0]);
-	}
-
-	public void testInstantiate_String() throws Exception {
-		Expression exp = pd.instantiate(String.class, new Encoder());
-		assertSame(String.class, exp.getValue());
-		assertSame("", exp.getTarget());
-		assertEquals("getClass", exp.getMethodName());
-		assertEquals(0, exp.getArguments().length);
-	}
+    protected void setUp() throws Exception {
+        super.setUp();
+        pd = new java_lang_ClassPersistenceDelegate();
+    }
+
+    public void testMutates() {
+        assertFalse(pd.mutatesTo(Class.class, null));
+        assertFalse(pd.mutatesTo(null, null));
+        assertFalse(pd.mutatesTo(Class.class, String.class));
+        assertTrue(pd.mutatesTo(String.class, String.class));
+    }
+
+    public void testInitialize() {
+        pd.initialize(null, null, null, null);
+    }
+
+    public void testInstantiate_Normal() throws Exception {
+        Expression exp = pd.instantiate(Integer.class, new Encoder());
+
+        assertSame(Integer.class, exp.getValue());
+        assertTrue(exp.getTarget() instanceof Class);
+        assertEquals("forName", exp.getMethodName());
+        assertEquals(1, exp.getArguments().length);
+        assertEquals("java.lang.Integer", exp.getArguments()[0]);
+    }
+
+    public void testInstantiate_Primitive() throws Exception {
+        Expression exp = pd.instantiate(Integer.TYPE, new Encoder());
+
+        assertSame(Integer.TYPE, exp.getValue());
+        assertTrue(exp.getTarget() instanceof java.lang.reflect.Field);
+        assertEquals("get", exp.getMethodName());
+        assertEquals(1, exp.getArguments().length);
+        assertNull(exp.getArguments()[0]);
+    }
+
+
+    public void testInstantiate_Class() throws Exception {
+        Expression exp = pd.instantiate(Class.class, new Encoder());
+
+        assertSame(Class.class, exp.getValue());
+        assertTrue(exp.getTarget() instanceof Class);
+        assertEquals("forName", exp.getMethodName());
+        assertEquals(1, exp.getArguments().length);
+        assertEquals("java.lang.Class", exp.getArguments()[0]);
+    }
 }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/StringPersistenceDelegateTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/StringPersistenceDelegateTest.java?rev=415773&r1=415772&r2=415773&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/StringPersistenceDelegateTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java-internal/org/apache/harmony/beans/StringPersistenceDelegateTest.java
Tue Jun 20 12:11:05 2006
@@ -1,11 +1,11 @@
 /* Copyright 2005 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.
@@ -25,30 +25,31 @@
  */
 public class StringPersistenceDelegateTest extends TestCase {
 
-	private java_lang_StringPersistenceDelegate pd = null;
+    private java_lang_StringPersistenceDelegate pd = null;
 
-	protected void setUp() throws Exception {
-		super.setUp();
-		pd = new java_lang_StringPersistenceDelegate();
-	}
-
-	public void testMutates() {
-		assertFalse(pd.mutatesTo("", null));
-		assertFalse(pd.mutatesTo(null, null));
-		assertFalse(pd.mutatesTo("str1", "str2"));
-		assertTrue(pd.mutatesTo("str1", "str2"));
-	}
-
-	public void testInitialize() {
-		pd.initialize(null, null, null, null);
-	}
-
-	public void testInstantiate_Normal() throws Exception {
-		Expression exp = pd.instantiate("str", new Encoder());
-		assertSame("str", exp.getValue());
-		assertSame(String.class, exp.getTarget());
-		assertEquals("new", exp.getMethodName());
-		assertEquals(1, exp.getArguments().length);
-		assertEquals("str", exp.getArguments()[0]);
-	}
+    protected void setUp() throws Exception {
+        super.setUp();
+        pd = new java_lang_StringPersistenceDelegate();
+    }
+
+    public void testMutates() {
+        assertFalse(pd.mutatesTo("", null));
+        assertFalse(pd.mutatesTo(null, null));
+        assertFalse(pd.mutatesTo("str1", "str2"));
+        assertTrue(pd.mutatesTo("str1", "str1"));
+    }
+
+    public void testInitialize() {
+        pd.initialize(null, null, null, null);
+    }
+
+    public void testInstantiate_Normal() throws Exception {
+        Expression exp = pd.instantiate("str", new Encoder());
+
+        assertSame("str", exp.getValue());
+        assertSame(String.class, exp.getTarget());
+        assertEquals("new", exp.getMethodName());
+        assertEquals(1, exp.getArguments().length);
+        assertEquals("str", exp.getArguments()[0]);
+    }
 }



Mime
View raw message