harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r812318 - /harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
Date Tue, 08 Sep 2009 01:51:55 GMT
Author: regisxu
Date: Tue Sep  8 01:51:54 2009
New Revision: 812318

URL: http://svn.apache.org/viewvc?rev=812318&view=rev
Log:
format code of XMLDecoderTest.java, no functional changes.

Modified:
    harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java

Modified: harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java?rev=812318&r1=812317&r2=812318&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/harmony/beans/tests/java/beans/XMLDecoderTest.java
Tue Sep  8 01:51:54 2009
@@ -22,15 +22,14 @@
 import java.beans.XMLDecoder;
 import java.beans.XMLEncoder;
 import java.io.BufferedInputStream;
+import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
-import java.io.Reader;
 import java.io.InputStream;
 import java.io.InputStreamReader;
-import java.io.BufferedReader;
+import java.lang.reflect.Array;
 import java.util.HashMap;
 import java.util.Vector;
-import java.lang.reflect.Array;
 
 import junit.framework.Test;
 import junit.framework.TestCase;
@@ -54,7 +53,8 @@
         junit.textui.TestRunner.run(XMLDecoderTest.class);
     }
 
-    private InputStream getCodedXML(Class clazz, String xmlFile) throws Exception {
+    private InputStream getCodedXML(Class clazz, String xmlFile)
+            throws Exception {
         InputStream refIn;
 
         String version = System.getProperty("java.version");
@@ -64,16 +64,17 @@
             throw new Error("resource " + xmlFile + " not exist in "
                     + XMLEncoderTest.class.getPackage());
         }
-        BufferedReader br = new BufferedReader(new InputStreamReader(refIn, "UTF-8"));
+        BufferedReader br = new BufferedReader(new InputStreamReader(refIn,
+                "UTF-8"));
         StringBuilder sb = new StringBuilder();
         String line = null;
-        while((line = br.readLine()) != null){
+        while ((line = br.readLine()) != null) {
             sb.append(line + "\n");
         }
         refIn.close();
         String refString = sb.toString();
         refString = refString.replace("${version}", version);
-        if(clazz != null){
+        if (clazz != null) {
             refString = refString.replace("${classname}", clazz.getName());
         }
         return new ByteArrayInputStream(refString.getBytes("UTF-8"));
@@ -103,7 +104,7 @@
         }
 
     }
-    
+
     /*
      * test XMLDecoder constructor with null inputStream argument
      */
@@ -163,13 +164,15 @@
             }
         };
 
-        xmlDecoder = new XMLDecoder(new ByteArrayInputStream(xml123bytes), this, el);
+        xmlDecoder = new XMLDecoder(new ByteArrayInputStream(xml123bytes),
+                this, el);
         assertEquals(el, xmlDecoder.getExceptionListener());
         assertEquals(this, xmlDecoder.getOwner());
     }
 
     /* RI fails on this testcase */
-    /*    public void testConstructor_ClassLoader() {
+    /*
+    public void testConstructor_ClassLoader() {
         XMLDecoder dec;
         final Vector<Exception> exceptions = new Vector<Exception>();
 
@@ -193,8 +196,10 @@
         } catch (ArrayIndexOutOfBoundsException e) {
             // also valid
         }
+
         dec.close();
-        }*/
+    }
+    */
 
     public void testClose() {
         XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
@@ -353,19 +358,22 @@
     }
 
     public void testReadObject_NoChange() throws Exception {
-        XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class, "/xml/MockBean4Codec_NoChange.xml"));
+        XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class,
+                "/xml/MockBean4Codec_NoChange.xml"));
         dec.readObject();
     }
 
     public void testReadObject_BornFriendChange() throws Exception {
-        XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class, "/xml/MockBean4Codec_BornFriendChange.xml"));
+        XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class,
+                "/xml/MockBean4Codec_BornFriendChange.xml"));
         MockBean4Codec b = (MockBean4Codec) dec.readObject();
         assertEquals(888, b.getBornFriend().getZarr()[0]);
         assertEquals(b.getBornFriend(), b.getNill());
     }
 
     public void testReadObject_ManyChanges() throws Exception {
-        XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class, "/xml/MockBean4Codec_ManyChanges.xml"));
+        XMLDecoder dec = new XMLDecoder(getCodedXML(MockBean4Codec.class,
+                "/xml/MockBean4Codec_ManyChanges.xml"));
         MockBean4Codec b = (MockBean4Codec) dec.readObject();
         assertEquals(127, b.getB());
         assertSame(b, b.getBackRef());
@@ -400,66 +408,64 @@
         assertEquals("6", b.getZarrarr()[0][1]);
         assertEquals("6", b.getZarrarr()[0][2]);
     }
+
     public void testReadObject_StaticField() throws Exception {
-        XMLDecoder dec1 = new XMLDecoder(getCodedXML(MockBean4StaticField.class, "/xml/MockBean4StaticField_Original.xml"));
+        XMLDecoder dec1 = new XMLDecoder(getCodedXML(
+                MockBean4StaticField.class,
+                "/xml/MockBean4StaticField_Original.xml"));
         MockBean4StaticField o1 = (MockBean4StaticField) dec1.readObject();
         assertNull(o1);
 
-        XMLDecoder dec2 = new XMLDecoder(getCodedXML(MockBean4StaticField.class, "/xml/MockBean4StaticField.xml"));
+        XMLDecoder dec2 = new XMLDecoder(getCodedXML(
+                MockBean4StaticField.class, "/xml/MockBean4StaticField.xml"));
         MockBean4StaticField o2 = (MockBean4StaticField) dec2.readObject();
         assertNotNull(o2);
-        /*
-        if (!o1.equals(o2)) {
-            System.out
-                    .println("Loading object with static field, original xml: "
-                            + o1.getV());
-            System.out.println("Loading object with static field, field xml: "
-                    + o2.getV());
-        }
-
-        assertEquals(o1, o2);*/
     }
 
     public void testReadObject_Owner() throws Exception {
         MockBean4Owner_Owner o1 = new MockBean4Owner_Owner();
-        XMLDecoder dec1 = new XMLDecoder(getCodedXML(MockBean4Owner_Target.class, "/xml/MockBean4Owner_SetOwner.xml"),
o1);
+        XMLDecoder dec1 = new XMLDecoder(
+                getCodedXML(MockBean4Owner_Target.class,
+                        "/xml/MockBean4Owner_SetOwner.xml"), o1);
         MockBean4Owner_Target t1 = (MockBean4Owner_Target) dec1.readObject();
 
         assertEquals(1, o1.getV());
         assertEquals(o1, t1.getV());
     }
 
-    public void testReadObject_Owner_Specific(){
+    public void testReadObject_Owner_Specific() {
         String expectedValue = "expected value";
         HashMap map = new HashMap();
         map.put("key", expectedValue);
 
-        XMLDecoder decoder = new XMLDecoder(this.getClass().getResourceAsStream(
-                "/xml/MockOwner.xml"), map);
+        XMLDecoder decoder = new XMLDecoder(this.getClass()
+                .getResourceAsStream("/xml/MockOwner.xml"), map);
         String actualValue = (String) decoder.readObject();
-        assertEquals(expectedValue,actualValue);
+        assertEquals(expectedValue, actualValue);
 
         MockOwnerClass mock = new MockOwnerClass();
         expectedValue = "I_Ljava.lang.String";
         decoder = new XMLDecoder(this.getClass().getResourceAsStream(
-        "/xml/MockOwner_Specific.xml"), mock);
+                "/xml/MockOwner_Specific.xml"), mock);
         actualValue = (String) decoder.readObject();
-        assertEquals(expectedValue,actualValue);
+        assertEquals(expectedValue, actualValue);
 
         decoder = new XMLDecoder(this.getClass().getResourceAsStream(
-        "/xml/MockOwner_Ambiguous.xml"), mock);
+                "/xml/MockOwner_Ambiguous.xml"), mock);
         actualValue = (String) decoder.readObject();
         assertNull(actualValue);
 
         decoder = new XMLDecoder(this.getClass().getResourceAsStream(
-        "/xml/MockOwner_Null.xml"), mock);
+                "/xml/MockOwner_Null.xml"), mock);
         actualValue = (String) decoder.readObject();
         assertNull(actualValue);
     }
 
     public void testReadObject_Owner_WithWriteStatement() throws Exception {
         MockBean4Owner_Owner o2 = new MockBean4Owner_Owner();
-        XMLDecoder dec2 = new XMLDecoder(getCodedXML(MockBean4Owner_Target.class, "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml"),
o2);
+        XMLDecoder dec2 = new XMLDecoder(getCodedXML(
+                MockBean4Owner_Target.class,
+                "/xml/MockBean4Owner_SetOwnerWithWriteStatement.xml"), o2);
         MockBean4Owner_Target t2 = (MockBean4Owner_Target) dec2.readObject();
 
         assertEquals(999, o2.getV());
@@ -498,13 +504,13 @@
                 return isCalled;
             }
         }
-        
+
         XMLDecoder xmlDecoder = new XMLDecoder(new ByteArrayInputStream(
                 "<java><string/>".getBytes("UTF-8")));
         MockExceptionListener mockListener = new MockExceptionListener();
         xmlDecoder.setExceptionListener(mockListener);
-        
-        assertFalse(mockListener.isCalled());        
+
+        assertFalse(mockListener.isCalled());
         // Real Parsing should occur in method of ReadObject rather constructor.
         assertNotNull(xmlDecoder.readObject());
         assertTrue(mockListener.isCalled());
@@ -521,12 +527,15 @@
         dec.setExceptionListener(newL);
         assertSame(newL, dec.getExceptionListener());
     }
-    /* RI also failed on the test case
+
+    /* RI also failed on the test case */
+    /*
     public void testSetExceptionListener_CatchException() throws Exception {
         MockExceptionListener l = new MockExceptionListener();
         new XMLDecoder(getCodedXML(null, "/xml/bad_int.xml"), null, l);
         assertTrue(l.size() > 0);
-    }*/
+    }
+    */
 
     public void testSetOwner() {
         XMLDecoder dec = new XMLDecoder(new ByteArrayInputStream(xml123bytes));
@@ -581,7 +590,6 @@
         decode("xml/Test1.xml");
     }
 
-
     /**
      * The test checks the code generation for XML from Test2.xml
      */
@@ -617,7 +625,9 @@
         XMLDecoder d = null;
         try {
             Introspector.setBeanInfoSearchPath(new String[] {});
-            d = new XMLDecoder(getCodedXML(org.apache.harmony.beans.tests.support.SampleBean.class,
"/xml/Test6.xml"));
+            d = new XMLDecoder(getCodedXML(
+                    org.apache.harmony.beans.tests.support.SampleBean.class,
+                    "/xml/Test6.xml"));
             while (true) {
                 d.readObject();
             }
@@ -637,7 +647,6 @@
         decode("xml/Test7.xml");
     }
 
-
     /**
      * Regression test for HARMONY-1890
      */
@@ -654,27 +663,15 @@
         obj = decoder.readObject();
         decoder.close();
         assertTrue("Returned object is not array", obj.getClass().isArray());
-        assertSame("String type expected", String.class,
-                obj.getClass().getComponentType());
+        assertSame("String type expected", String.class, obj.getClass()
+                .getComponentType());
         assertEquals("Size mismatch", 10, Array.getLength(obj));
     }
 
-    /*
-     * The test checks the code generation for XML from MainTest.xml
-     * 
-     * public void testMain() { decode("xml/MainTest.xml"); }
-     */
-
-    /**
-     * 
-     */
     public static Test suite() {
         return new TestSuite(XMLDecoderTest.class);
     }
 
-    /**
-     * 
-     */
     private void decode(String resourceName) throws Exception {
         XMLDecoder d = null;
         try {



Mime
View raw message