You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by ch...@apache.org on 2005/10/24 04:43:18 UTC

svn commit: r327928 - in /webservices/axis2/trunk/java/modules: codegen/src/org/apache/axis2/databinding/utils/ codegen/test/org/apache/axis2/databinding/utils/ security/src/org/apache/axis2/security/

Author: chinthaka
Date: Sun Oct 23 19:43:07 2005
New Revision: 327928

URL: http://svn.apache.org/viewcvs?rev=327928&view=rev
Log:
Adding one more test case with a complex scenario. Yet to be finished. 

Modified:
    webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java
    webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java
    webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java

Modified: webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java?rev=327928&r1=327927&r2=327928&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/src/org/apache/axis2/databinding/utils/ADBPullParser.java Sun Oct 23 19:43:07 2005
@@ -116,7 +116,7 @@
      * @param properties - this should contain all the stuff that stax events should be generated.
      *                   Lets take an example of a bean.
      *                   <pre>
-     *                                                                                                                                                                                                           <Person>
+     *                       <Person>
      *                                                                                                                                                                                                                  <DependentOne>
      *                                                                                                                                                                                                                      <Name>FooTwo</Name>
      *                                                                                                                                                                                                                      <Age>25</Age>
@@ -248,6 +248,7 @@
             // this is the end of this element
             currentIndex++;
             isEndElementFinished = true;
+            removeDeclaredNamespaces();
             return XMLStreamConstants.END_ELEMENT;
         } else {
 
@@ -301,6 +302,16 @@
 
     }
 
+    private void removeDeclaredNamespaces() {
+        if(declaredNamespaces != null){
+        Iterator declaredNamespacesURIIter = declaredNamespaces.keySet().iterator();
+        while (declaredNamespacesURIIter.hasNext()) {
+            String s = (String) declaredNamespacesURIIter.next();
+            namespaceMap.remove(s);
+        }
+        }
+    }
+
     private XMLStreamReader getPullParser(Object object, QName qname) {
         if (object instanceof ADBBean) {
             ADBBean adbBean = (ADBBean) object;
@@ -498,20 +509,6 @@
         return (attributes != null && attributesList.size() >= i * 2);
     }
 
-// -------- un-implemented methods ----------
-
-    public void require(int i, String string, String string1) throws XMLStreamException {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
-    }
-
-    public int nextTag() throws XMLStreamException {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
-    }
-
-    public void close() throws XMLStreamException {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
-    }
-
     public String getNamespaceURI(String prefixParam) {
         if (accessingChildPullParser) return childPullParser.getNamespaceURI(prefixParam);
         if ("".equals(prefixParam) || prefixParam == null) return null;
@@ -528,23 +525,6 @@
         return null;
     }
 
-    public boolean isStartElement() {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
-    }
-
-    public boolean isEndElement() {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
-    }
-
-    public boolean isCharacters() {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
-    }
-
-    public boolean isWhiteSpace() {
-        throw new UnsupportedOperationException("Yet to be implemented !!");
-    }
-
-
     public String getNamespacePrefix(int index) {
         /* We are holding namespaces in a HashMap and there is no direct way to retrieve a prefix
          by its index. So I need to call toArray and then get the index. Since this method will be
@@ -555,7 +535,7 @@
         */
         if (accessingChildPullParser) return childPullParser.getNamespacePrefix(index);
         if (declaredNamespaces != null && declaredNamespaces.size() >= index) {
-            if (tempDeclaredNamespacePrefixesArray == null || tempDeclaredNamespacePrefixesArray.size() != declaredNamespaces.size()) {
+            if (tempDeclaredNamespacePrefixesArray == null || (tempDeclaredNamespacePrefixesArray.size() != declaredNamespaces.size())) {
                 tempDeclaredNamespacePrefixesArray = new ArrayList();
                 Iterator iterator = declaredNamespaces.values().iterator();
                 while (iterator.hasNext()) {
@@ -578,7 +558,7 @@
         */
         if (accessingChildPullParser) return childPullParser.getNamespaceURI(index);
         if (declaredNamespaces != null && declaredNamespaces.size() >= index) {
-            if (tempDeclaredNamespacesArray == null || tempDeclaredNamespacesArray.size() != declaredNamespaces.size()) {
+            if (tempDeclaredNamespacesArray == null || (tempDeclaredNamespacesArray.size() != declaredNamespaces.size())) {
                 tempDeclaredNamespacesArray = new ArrayList();
                 Iterator iterator = declaredNamespaces.keySet().iterator();
                 while (iterator.hasNext()) {
@@ -589,6 +569,36 @@
             return (String) tempDeclaredNamespacesArray.get(index);
         }
         return null;
+    }
+
+// -------- un-implemented methods ----------
+
+    public void require(int i, String string, String string1) throws XMLStreamException {
+        throw new UnsupportedOperationException("Yet to be implemented !!");
+    }
+
+    public int nextTag() throws XMLStreamException {
+        throw new UnsupportedOperationException("Yet to be implemented !!");
+    }
+
+    public void close() throws XMLStreamException {
+        throw new UnsupportedOperationException("Yet to be implemented !!");
+    }
+
+    public boolean isStartElement() {
+        throw new UnsupportedOperationException("Yet to be implemented !!");
+    }
+
+    public boolean isEndElement() {
+        throw new UnsupportedOperationException("Yet to be implemented !!");
+    }
+
+    public boolean isCharacters() {
+        throw new UnsupportedOperationException("Yet to be implemented !!");
+    }
+
+    public boolean isWhiteSpace() {
+        throw new UnsupportedOperationException("Yet to be implemented !!");
     }
 
     public NamespaceContext getNamespaceContext() {

Modified: webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java?rev=327928&r1=327927&r2=327928&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java (original)
+++ webservices/axis2/trunk/java/modules/codegen/test/org/apache/axis2/databinding/utils/ADBPullParserTest.java Sun Oct 23 19:43:07 2005
@@ -508,6 +508,110 @@
         }
     }
 
+    public void testComplexScenarioOne() {
+        /*
+           <apache:Project xmlns:axis2="http://ws.apache.org/namespaces/axis2" xmlns:apache="http://www.apache.org/" xmlns:myAttr="mailto:myAttributes@axis2.org" myAttr:name="Apache Axis2">
+    <CurrentRelease>0.92</CurrentRelease>
+    <axis2:Module axis2:name="xml">
+        <Description>This is the XML object model for Axis2</Description>
+        <Dependencies myAttr:number="2">
+            <JarName>stax-api.jar</JarName>
+            <JarName>stax-impl.jar</JarName>
+        </Dependencies>
+    </axis2:Module>
+    <axis2:Module axis2:name="core">
+        <Description myAttr:number="3">This will handle the main logics of the system</Description>
+        <Dependencies>
+            <JarName>axis2-xml.jar</JarName>
+            <JarName>axis2-wsdl.jar</JarName>
+            <JarName>commons-logging.jar</JarName>
+        </Dependencies>
+    </axis2:Module>
+</apache:Project>
+
+        */
+        final OMFactory fac = OMAbstractFactory.getOMFactory();
+        final OMNamespace axis2NS = fac.createOMNamespace("http://ws.apache.org/namespaces/axis2", "axis2");
+
+
+        class Dependencies implements ADBBean {
+
+            String[] dependencies;
+
+            public Dependencies(String[] dependencies) {
+                this.dependencies = dependencies;
+            }
+
+            public XMLStreamReader getPullParser(QName adbBeanQName) {
+                if (adbBeanQName == null) {
+                    adbBeanQName = new QName("http://ws.apache.org/namespaces/axis2", "Dependencies", "axis2");
+                }
+
+                ArrayList properties = new ArrayList();
+                properties.add("JarName");
+                properties.add(dependencies);
+
+                Object[] attrubutes = new Object[2];
+                attrubutes[0] = new QName("mailto:myAttributes@axis2.org", "number", "myAttr");
+                attrubutes[1] = new String(dependencies.length + "");
+
+                return ADBPullParser.createPullParser(adbBeanQName, properties.toArray(), attrubutes);
+            }
+        }
+
+        class Module implements ADBBean {
+
+            String projectName;
+            String description;
+            Dependencies dependencyBean;
+
+            public Module(String projectName, String description, Dependencies dependencyBean) {
+                this.projectName = projectName;
+                this.description = description;
+                this.dependencyBean = dependencyBean;
+            }
+
+            public XMLStreamReader getPullParser(QName adbBeanQName) {
+                if (adbBeanQName == null) {
+                    adbBeanQName = new QName("http://ws.apache.org/namespaces/axis2", "Module", "axis2");
+                }
+
+                ArrayList properties = new ArrayList();
+                properties.add("Description");
+                properties.add(description);
+                properties.add(new QName("Dependencies"));
+                properties.add(dependencyBean);
+
+                Object[] attrubutes = new Object[2];
+                attrubutes[0] = new QName("http://ws.apache.org/namespaces/axis2", "name", "axis2");
+                attrubutes[1] = projectName;
+
+                return ADBPullParser.createPullParser(adbBeanQName, properties.toArray(), attrubutes);
+            }
+        }
+
+
+        ArrayList propertyList = new ArrayList();
+        propertyList.add("CurrentRelease");
+        propertyList.add("0.92");
+
+        Dependencies xmlModuleDeps = new Dependencies(new String[] {"stax-api.jar", "stax-impl.jar"});
+        Module xmlModule = new Module("xml", "This is the XML object model for Axis2", xmlModuleDeps );
+        propertyList.add(new QName("http://ws.apache.org/namespaces/axis2", "Module", "axis2"));
+        propertyList.add(xmlModule);
+
+        Dependencies coreModuleDeps = new Dependencies(new String[] {"axis2-xml.jar", "axis2-wsdl.jar", "commons-logging.jar"});
+        Module coreModule = new Module("core", "This will handle the main logics of the system", coreModuleDeps );
+        propertyList.add(new QName("http://ws.apache.org/namespaces/axis2", "Module", "axis2"));
+        propertyList.add(coreModule);
+
+        Object[]  attributes = new Object[]{ new QName("mailto:myAttributes@axis2.org", "name", "myAttr"), "Apache Axis2"};
+
+        XMLStreamReader pullParser = ADBPullParser.createPullParser(new QName("http://www.apache.org/", "Project", "apache"), propertyList.toArray(), attributes);
+        System.out.println(getStringXML(pullParser));
+
+    }
+
     private String getStringXML(XMLStreamReader reader) {
         OMElement omelement = new StAXOMBuilder(reader).getDocumentElement();
         return omelement.toString();

Modified: webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java?rev=327928&r1=327927&r2=327928&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java (original)
+++ webservices/axis2/trunk/java/modules/security/src/org/apache/axis2/security/WSDoAllReceiver.java Sun Oct 23 19:43:07 2005
@@ -51,7 +51,7 @@
 public class WSDoAllReceiver extends WSDoAllHandler {
 
     protected static Log log = LogFactory.getLog(WSDoAllReceiver.class.getName());
-    
+
     
     public WSDoAllReceiver() {
     	super();