You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by aj...@apache.org on 2006/04/06 11:58:46 UTC

svn commit: r391953 - /webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java

Author: ajith
Date: Thu Apr  6 02:58:44 2006
New Revision: 391953

URL: http://svn.apache.org/viewcvs?rev=391953&view=rev
Log:
Added two more test cases to test the functionality of the ADBXMLStreamReader

Modified:
    webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java

Modified: webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java?rev=391953&r1=391952&r2=391953&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java (original)
+++ webservices/axis2/trunk/java/modules/adb/test/org/apache/axis2/databinding/utils/reader/ADBXMLStreamReaderTest.java Thu Apr  6 02:58:44 2006
@@ -126,6 +126,64 @@
         }
     }
 
+    /**
+     * complex array scenario with nulls in between
+     */
+    public void testComplexObjectArrayScenarioWithNulls() {
+        try {
+            String expectedXML = "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
+                    "<AdditionalDependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</AdditionalDependent>" +
+                    "<AdditionalDependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</AdditionalDependent>" +
+                    "<AdditionalDependent>" +
+                    "<Name>FooTwo</Name>" +
+                    "<Age>25</Age>" +
+                    "<Sex>Male</Sex>" +
+                    "</AdditionalDependent>" +
+                    "<AdditionalDependent xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" +
+                    "</AdditionalDependent>" +
+                    "<Bar>Some More Text</Bar><" +
+                    "/ns1:TestComplexStringArrayScenario>";
+
+            ArrayList propertyList = new ArrayList();
+
+            ADBBean[] adbBeans = new ADBBean[4];
+            for (int i = 0; i < 4; i++) {
+                adbBeans[i] = new DummyADBBean();
+            }
+
+            adbBeans[3] = null;
+
+            for (int i = 0; i < adbBeans.length; i++) {
+                propertyList.add(new QName("AdditionalDependent"));
+                propertyList.add(adbBeans[i]);
+
+            }
+
+            propertyList.add("Bar");
+            propertyList.add("Some More Text");
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(new QName("http://testComplexStringArrayScenario.org", "TestComplexStringArrayScenario", "ns1"), propertyList.toArray(), null);
+            String actualXML = getStringXML(pullParser);
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        } catch (Exception e) {
+            fail("Error has occurred " + e);
+        }
+    }
 
     /**
      * Empty array
@@ -336,7 +394,7 @@
     /**
      * Test a simple array
      */
-    public void testComplexStringArrayScenario() {
+    public void testSimpleStringArrayScenario() {
         try {
             String expectedXML = "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
                     "<StringInfo>Some Text 0</StringInfo>" +
@@ -374,6 +432,51 @@
 
 
     }
+
+    /**
+     * Test a simple array with null's inbetween
+     */
+    public void testSimpleStringArrayScenarioWithNulls() {
+        try {
+            String expectedXML = "<ns1:TestComplexStringArrayScenario xmlns:ns1=\"http://testComplexStringArrayScenario.org\">" +
+                    "<StringInfo>Some Text 0</StringInfo>" +
+                    "<StringInfo xsi:nil=\"true\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"/>" +
+                    "<StringInfo>Some Text 2</StringInfo>" +
+                    "<StringInfo>Some Text 3</StringInfo>" +
+                    "</ns1:TestComplexStringArrayScenario>";
+
+            ArrayList propertyList = new ArrayList();
+
+            String[] stringArray = new String[4];
+            for (int i = 0; i < 4; i++) {
+                stringArray[i] = "Some Text " + i;
+            }
+            stringArray[1] =null;
+
+            propertyList.add("StringInfo");
+            propertyList.add(stringArray);
+
+            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
+                    new QName("http://testComplexStringArrayScenario.org",
+                            "TestComplexStringArrayScenario", "ns1"),
+                    propertyList.toArray(), null);
+            String actualXML = getStringXML(pullParser);
+
+
+            assertXMLEqual(newDocument(expectedXML), newDocument(actualXML));
+        } catch (ParserConfigurationException e) {
+            fail("Error has occurred " + e);
+        } catch (SAXException e) {
+            fail("Error has occurred " + e);
+        } catch (IOException e) {
+            fail("Error has occurred " + e);
+        }catch (XMLStreamException e) {
+            fail("Error has occurred " + e);
+        }
+
+
+    }
+
 
     /**
      * test the mixed content