harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r465152 - in /incubator/harmony/enhanced/classlib/trunk/modules/beans/src: main/java/java/beans/Encoder.java test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
Date Wed, 18 Oct 2006 06:00:23 GMT
Author: mloenko
Date: Tue Oct 17 23:00:21 2006
New Revision: 465152

URL: http://svn.apache.org/viewvc?view=rev&rev=465152
Log:
applied patch from HARMONY-1304
[classlib][bean] compatibility: no NPE on Harmony for Encoder().setPersistenceDelegate(Void.TYPE,
null)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
    incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java?view=diff&rev=465152&r1=465151&r2=465152
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/Encoder.java
Tue Oct 17 23:00:21 2006
@@ -69,6 +69,9 @@
 
     public void setPersistenceDelegate(Class<?> type,
             PersistenceDelegate persistenceDelegate) {
+        if (type == null || persistenceDelegate == null) {
+            throw new NullPointerException();
+        }
         persistenceDelegates.put(type, persistenceDelegate);
     }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java?view=diff&rev=465152&r1=465151&r2=465152
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/EncoderTest.java
Tue Oct 17 23:00:21 2006
@@ -265,7 +265,7 @@
     }
 
     public void testWriteExpression_Null() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
         try {
             enc.writeExpression(null);
             fail();
@@ -279,10 +279,10 @@
     }
 
     public void testWriteStatement_Null() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
         try {
             enc.writeStatement(null);
-            fail();
+            fail("NPE expected");
         } catch (NullPointerException e) {
             // expected
         }
@@ -360,33 +360,33 @@
     }
 
     public void testGetPersistenceDelegate_Null() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
         PersistenceDelegate pd = enc.getPersistenceDelegate(null);
         assertNotNull(pd);
     }
 
     public void testGetPersistenceDelegate_ArrayClass() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
         PersistenceDelegate pd = enc.getPersistenceDelegate(int[].class);
         assertFalse(pd instanceof DefaultPersistenceDelegate);
     }
 
     public void testGetPersistenceDelegate_ProxyClass() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
         enc.getPersistenceDelegate(Proxy.getProxyClass(ClassLoader
                 .getSystemClassLoader(), new Class[] { List.class }));
     }
 
     public void testGetPersistenceDelegate_BeanInfo() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
         PersistenceDelegate pd = enc
                 .getPersistenceDelegate(MockFooLiYang.class);
         assertTrue(pd instanceof VerbosePD);
     }
 
     public void testGetPersistenceDelegate_Default() {
-        MockEncoder enc = new MockEncoder();
-        MockEncoder enc2 = new MockEncoder();
+        Encoder enc = new Encoder();
+        Encoder enc2 = new Encoder();
 
         PersistenceDelegate pd1 = enc.getPersistenceDelegate(SampleBean.class);
         assertTrue(pd1 instanceof DefaultPersistenceDelegate);
@@ -403,44 +403,45 @@
     }
 
     public void testSetPersistenceDelegate_Null() {
-        MockEncoder enc = new MockEncoder();
+        // Regression for HARMONY-1304
+        Encoder enc = new Encoder();
         PersistenceDelegate pd = enc.getPersistenceDelegate(EncoderTest.class);
 
         try {
             enc.setPersistenceDelegate(null, pd);
-            fail();
+            fail("NPE expected");
         } catch (NullPointerException e) {
             // expected
         }
 
         try {
             enc.setPersistenceDelegate(EncoderTest.class, null);
-            fail();
+            fail("NPE expected");
         } catch (NullPointerException e) {
             // expected
         }
     }
 
     public void testSetPersistenceDelegate() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
         PersistenceDelegate pd = enc.getPersistenceDelegate(EncoderTest.class);
         assertTrue(pd instanceof DefaultPersistenceDelegate);
 
         enc.setPersistenceDelegate(EncoderTest.class, new VerbosePD());
         assertTrue(enc.getPersistenceDelegate(EncoderTest.class) instanceof VerbosePD);
 
-        MockEncoder enc2 = new MockEncoder();
+        Encoder enc2 = new Encoder();
         assertTrue(enc2.getPersistenceDelegate(EncoderTest.class) instanceof VerbosePD);
     }
 
     public void testGet_NullParam() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
 
         assertNull(enc.get(null));
     }
 
     public void testGet_String() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
 
         String str = "string";
         assertSame(str, enc.get(str));
@@ -462,7 +463,7 @@
     }
 
     public void testRemove_Null() {
-        MockEncoder enc = new MockEncoder();
+        Encoder enc = new Encoder();
 
         assertNull(enc.remove(null));
     }



Mime
View raw message