axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hemap...@apache.org
Subject svn commit: r109465 - in webservices/axis/trunk/java/dev/scratch/prototype2: . src/test-resources/soap src/test/org/apache/axis/om
Date Thu, 02 Dec 2004 07:26:42 GMT
Author: hemapani
Date: Wed Dec  1 23:26:41 2004
New Revision: 109465

URL: http://svn.apache.org/viewcvs?view=rev&rev=109465
Log:
add a test case to compare OM with the DOM, exclude it as it break the build
Added:
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/soap/security2-soap.xml
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/CompareOMWithDOMTest.java
Modified:
   webservices/axis/trunk/java/dev/scratch/prototype2/project.xml
   webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestUtils.java

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/project.xml
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/project.xml?view=diff&rev=109465&p1=webservices/axis/trunk/java/dev/scratch/prototype2/project.xml&r1=109464&p2=webservices/axis/trunk/java/dev/scratch/prototype2/project.xml&r2=109465
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/project.xml	(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/project.xml	Wed Dec  1 23:26:41 2004
@@ -79,6 +79,7 @@
         <exclude>**/*Abstract*.java</exclude>
 	    <exclude>**/*Util*.java</exclude>
         <exclude>**/*SOAPEnvelopeAnotherTest.java</exclude>
+        <exclude>**/*CompareOMWithDOMTest.java</exclude>
       </excludes>
       <includes>
         <include>**/*Test.java</include>

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/soap/security2-soap.xml
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/soap/security2-soap.xml?view=auto&rev=109465
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test-resources/soap/security2-soap.xml
Wed Dec  1 23:26:41 2004
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<S:Envelope xmlns:S="http://www.w3.org/2001/12/soap-envelope"
+            xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 
+            xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext" 
+            xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
+   <S:Header>
+      <m:path xmlns:m="http://schemas.xmlsoap.org/rp">
+         <m:action>http://fabrikam123.com/getQuote</m:action>
+         <m:to>http://fabrikam123.com/stocks</m:to>
+         <m:from>mailto:johnsmith@fabrikam123.com</m:from>
+         <m:id>uuid:84b9f5d0-33fb-4a81-b02b-5b760641c1d6</m:id>
+      </m:path>
+      <wsse:Security> 
+         <wsse:BinarySecurityToken 
+                     ValueType="wsse:X509v3"
+                     EncodingType="wsse:Base64Binary"  
+                     Id="X509Token">
+                  MIIEZzCCA9CgAwIBAgIQEmtJZc0rqrKh5i...
+         </wsse:BinarySecurityToken>
+         <ds:Signature>
+            <ds:SignedInfo>
+               <ds:CanonicalizationMethod Algorithm=
+                     "http://www.w3.org/2001/10/xml-exc-c14n#"/>
+               <ds:SignatureMethod Algorithm=
+                     "http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
+               <ds:Reference>
+                  <ds:Transforms>
+                     <ds:Transform Algorithm=
+                           "http://...#RoutingTransform"/>
+                     <ds:Transform Algorithm=
+                           "http://www.w3.org/2001/10/xml-exc-c14n#"/>
+                  </ds:Transforms>
+                  <ds:DigestMethod Algorithm=
+                       "http://www.w3.org/2000/09/xmldsig#sha1"/>
+                  <ds:DigestValue>EULddytSo1...</ds:DigestValue>
+               </ds:Reference>
+            </ds:SignedInfo>
+            <ds:SignatureValue>
+              BL8jdfToEb1l/vXcMZNNjPOV...
+            </ds:SignatureValue>
+            <ds:KeyInfo>
+                <wsse:SecurityTokenReference>
+                    <wsse:Reference URI="#X509Token"/>
+                </wsse:SecurityTokenReference>
+            </ds:KeyInfo>
+         </ds:Signature>
+      </wsse:Security>
+   </S:Header>
+   <S:Body>
+      <tru:StockSymbol xmlns:tru="http://fabrikam123.com/payloads">
+        QQQ
+      </tru:StockSymbol>
+   </S:Body>
+</S:Envelope>
\ No newline at end of file

Added: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/CompareOMWithDOMTest.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/CompareOMWithDOMTest.java?view=auto&rev=109465
==============================================================================
--- (empty file)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/CompareOMWithDOMTest.java
Wed Dec  1 23:26:41 2004
@@ -0,0 +1,57 @@
+/*
+ * Copyright 2003,2004 The Apache Software Foundation.
+ * 
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.axis.om;
+
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import junit.framework.TestCase;
+
+import org.apache.axis.AbstractTestCase;
+import org.w3c.dom.Document;
+
+/**
+ * @version $Rev: $ $Date: $
+ */
+
+public class CompareOMWithDOMTest extends AbstractTestCase{
+    /**
+     * @param testName
+     */
+    public CompareOMWithDOMTest(String testName) {
+        super(testName);
+    }
+    
+    public void testSecuritySample2() throws OMException, Exception{
+        File dir = new File(testResourceDir,"soap");
+        File[] files = dir.listFiles();
+        if(files != null){
+            for(int i = 0;i<files.length;i++){
+                if(files[i].isFile() && files[i].getName().endsWith(".xml")){
+                    OMEnvelope soapEnvelope = OMTestUtils.getOMBuilder(files[i].getAbsolutePath()).getOMEnvelope();
+                    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+                    dbf.setNamespaceAware(true);
+                    DocumentBuilder builder = dbf.newDocumentBuilder();
+                    Document doc = builder.parse(files[i].getAbsolutePath());
+                    OMTestUtils.compare(doc.getDocumentElement(),soapEnvelope);
+                }
+            }
+        
+        }
+    }
+}

Modified: webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestUtils.java
Url: http://svn.apache.org/viewcvs/webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestUtils.java?view=diff&rev=109465&p1=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestUtils.java&r1=109464&p2=webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestUtils.java&r2=109465
==============================================================================
--- webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestUtils.java
(original)
+++ webservices/axis/trunk/java/dev/scratch/prototype2/src/test/org/apache/axis/om/OMTestUtils.java
Wed Dec  1 23:26:41 2004
@@ -24,6 +24,9 @@
 
 import org.apache.axis.impl.llom.wrapper.OMXPPWrapper;
 import org.apache.axis.impl.llom.wrapper.OMXPPWrapper;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 import org.xmlpull.v1.XmlPullParser;
 import org.xmlpull.v1.XmlPullParserFactory;
 
@@ -56,6 +59,37 @@
             }    
         }
     
-    } 
+    }
+    
+    public static void compare(Element ele,OMElement omele) throws Exception{
+        if(ele == null && omele == null){
+            return;
+        }else if(ele != null && omele != null){
+            System.out.println("@@@ ele = " +ele +" = " + "omele = "+ omele);
+            
+            System.out.println(ele.getLocalName() +" = " + omele.getLocalName());
+            System.out.println(ele.getNamespaceURI()+" = " + omele.getNamespace().getValue());
+            TestCase.assertTrue(ele.getLocalName().equals(omele.getLocalName()));
+            TestCase.assertTrue(ele.getNamespaceURI().equals(omele.getNamespace().getValue()));
+            
+            Iterator it = omele.getChildren();
+            
+            NodeList list = ele.getChildNodes();
+            for(int i = 0;i<list.getLength();i++){
+                Node node = list.item(i);
+                if(node.getNodeType() == Node.ELEMENT_NODE){
+                    TestCase.assertTrue(it.hasNext());
+                    OMNode tempOmNode = (OMNode)it.next();
+                    while(tempOmNode.getType() != OMNode.ELEMENT_NODE){
+                        TestCase.assertTrue(it.hasNext());
+                        tempOmNode = (OMNode)it.next();
+                    }
+                    compare((Element)node,(OMElement)tempOmNode);
+                }
+            }
+        }else{
+               throw new Exception("One is null");
+        }
+    }
 
 }

Mime
View raw message