axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From az...@apache.org
Subject svn commit: r448893 - in /webservices/axis2/trunk/java/modules/security/test/org/apache/rampart: AsymmetricBindingBuilderTest.java MessageBuilderTestBase.java TransportBindingBuilderTest.java
Date Fri, 22 Sep 2006 11:32:20 GMT
Author: azeez
Date: Fri Sep 22 04:32:19 2006
New Revision: 448893

URL: http://svn.apache.org/viewvc?view=rev&rev=448893
Log:
Updated testcases


Modified:
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
    webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java?view=diff&rev=448893&r1=448892&r2=448893
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
(original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/AsymmetricBindingBuilderTest.java
Fri Sep 22 04:32:19 2006
@@ -38,7 +38,7 @@
             
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
-            
+
             ArrayList list = new ArrayList();
             
             list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java?view=diff&rev=448893&r1=448892&r2=448893
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
(original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/MessageBuilderTestBase.java
Fri Sep 22 04:32:19 2006
@@ -16,6 +16,7 @@
 
 package org.apache.rampart;
 
+import junit.framework.TestCase;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -33,15 +34,10 @@
 import javax.xml.stream.XMLInputFactory;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
-
 import java.io.FileInputStream;
-import java.util.ArrayList;
 import java.util.Iterator;
 
-import junit.framework.TestCase;
-
 /**
- *
  * @author Ruchith Fernando (ruchith.fernando@gmail.com)
  */
 public class MessageBuilderTestBase extends TestCase {
@@ -63,38 +59,40 @@
         MessageContext ctx = new MessageContext();
         ctx.setAxisService(new AxisService("TestService"));
         ctx.setAxisOperation(new OutInAxisOperation(new QName("http://rampart.org", "test")));
-        
-        XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new
FileInputStream("test-resources/policy/soapmessage.xml"));
+
+        XMLStreamReader reader =
+                XMLInputFactory.newInstance().
+                        createXMLStreamReader(new FileInputStream("test-resources/policy/soapmessage.xml"));
         ctx.setEnvelope(new StAXSOAPModelBuilder(reader, null).getSOAPEnvelope());
         return ctx;
     }
-    
+
     protected Policy loadPolicy(String xmlPath) throws Exception {
         StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
         return PolicyEngine.getPolicy(builder.getDocumentElement());
     }
-    
+
     protected void verifySecHeader(Iterator qnameList, SOAPEnvelope env) {
-        Iterator secHeaderChildren = env.getHeader().getFirstChildWithName(
-                new QName(WSConstants.WSSE_NS, 
-                        WSConstants.WSSE_LN)).getChildElements();
-        
+        Iterator secHeaderChildren =
+                env.getHeader().
+                        getFirstChildWithName(new QName(WSConstants.WSSE_NS,
+                                                        WSConstants.WSSE_LN)).getChildElements();
+
         while (secHeaderChildren.hasNext()) {
-            OMElement  element = (OMElement ) secHeaderChildren.next();
-            if(qnameList.hasNext()) {
-                if(!element.getQName().equals(qnameList.next())) {
+            OMElement element = (OMElement) secHeaderChildren.next();
+            if (qnameList.hasNext()) {
+                if (!element.getQName().equals(qnameList.next())) {
                     fail("Incorrect Element" + element);
-                } 
+                }
             } else {
                 fail("Extra child in the security header: " + element.toString());
             }
         }
-        
-        if(qnameList.hasNext()) {
+
+        if (qnameList.hasNext()) {
             fail("Incorrect number of children in the security header: " +
-                    "next expected element"
-                    + ((QName) qnameList.next()).toString());
+                 "next expected element" + qnameList.next().toString());
         }
     }
-    
+
 }

Modified: webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java?view=diff&rev=448893&r1=448892&r2=448893
==============================================================================
--- webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java
(original)
+++ webservices/axis2/trunk/java/modules/security/test/org/apache/rampart/TransportBindingBuilderTest.java
Fri Sep 22 04:32:19 2006
@@ -18,41 +18,62 @@
 
 import org.apache.axis2.context.MessageContext;
 import org.apache.neethi.Policy;
+import org.apache.ws.security.WSConstants;
+import org.apache.ws.security.conversation.ConversationConstants;
+
+import javax.xml.namespace.QName;
+import java.util.ArrayList;
+import java.util.List;
 
 public class TransportBindingBuilderTest extends MessageBuilderTestBase {
 
     public void testTransportBinding() {
         try {
             MessageContext ctx = getMsgCtx();
-            
+
             String policyXml = "test-resources/policy/rampart-transport-binding.xml";
             Policy policy = this.loadPolicy(policyXml);
-            
+
             ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
-            
+
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
-            
+
             System.out.println(ctx.getEnvelope());
+
+            List list = new ArrayList();
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.WSSE_NS, WSConstants.USERNAME_TOKEN_LN));
+            list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
+
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
         }
     }
-    
+
     public void testTransportBindingNoBST() {
         try {
             MessageContext ctx = getMsgCtx();
-            
+
             String policyXml = "test-resources/policy/rampart-transport-binding-no-bst.xml";
             Policy policy = this.loadPolicy(policyXml);
-            
+
             ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
-            
+
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
-            
+
             System.out.println(ctx.getEnvelope());
+
+            List list = new ArrayList();
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.WSSE_NS, WSConstants.USERNAME_TOKEN_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
+
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -62,17 +83,25 @@
     public void testTransportBindingWithDK() {
         try {
             MessageContext ctx = getMsgCtx();
-            
+
             String policyXml = "test-resources/policy/rampart-transport-binding-dk.xml";
             Policy policy = this.loadPolicy(policyXml);
-            
+
             ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
-            
+
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
-            
+
             System.out.println(ctx.getEnvelope());
-            
+
+            List list = new ArrayList();
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            list.add(new QName(WSConstants.WSSE_NS, WSConstants.USERNAME_TOKEN_LN));
+            list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
+            list.add(new QName(ConversationConstants.WSC_NS_05_02,
+                               ConversationConstants.DERIVED_KEY_TOKEN_LN));
+            list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
@@ -83,23 +112,25 @@
         try {
             MessageContext ctx = getMsgCtx();
             ctx.setServerSide(true);
-            
+
             String policyXml = "test-resources/policy/rampart-transport-binding-dk.xml";
             Policy policy = this.loadPolicy(policyXml);
-            
+
             ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
-            
+
             MessageBuilder builder = new MessageBuilder();
             builder.build(ctx);
-            
+
             System.out.println(ctx.getEnvelope());
-            
+
+            List list = new ArrayList();
+            list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
+            this.verifySecHeader(list.iterator(), ctx.getEnvelope());
         } catch (Exception e) {
             e.printStackTrace();
             fail(e.getMessage());
         }
     }
 
-    
-    
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org


Mime
View raw message