ws-wss4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cohei...@apache.org
Subject svn commit: r782049 [1/2] - /webservices/wss4j/trunk/test/wssec/
Date Fri, 05 Jun 2009 15:24:12 GMT
Author: coheigea
Date: Fri Jun  5 15:24:11 2009
New Revision: 782049

URL: http://svn.apache.org/viewvc?rev=782049&view=rev
Log:
Refactored the unit tests so that they get the Document to process from SOAPUtil
 - This has the advantage of confining the Axis dependencies to a single class
 - Also, it's easier to plug in different SAAJ implementations for testing purposes.

Modified:
    webservices/wss4j/trunk/test/wssec/SOAPUtil.java
    webservices/wss4j/trunk/test/wssec/SignatureConfirmationTest.java
    webservices/wss4j/trunk/test/wssec/SignatureKeyValueTest.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityCertError.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityKerberosTokenProfile.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew10.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew11.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew12.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew13.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew14.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew15.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew16.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew17.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew18.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew3.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew5.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew6.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew7.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew8.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNew9.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNewDK.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSCT.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNewSOAP12.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNewST1.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNewST2.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityNewST3.java
    webservices/wss4j/trunk/test/wssec/TestWSSecuritySignatureParts.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityTimestamp.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityUTDK.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityUTSignature.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityUserProcessor.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityWSS178.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityWSS40.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityWSS60.java
    webservices/wss4j/trunk/test/wssec/TestWSSecurityWSS86.java

Modified: webservices/wss4j/trunk/test/wssec/SOAPUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/SOAPUtil.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/SOAPUtil.java (original)
+++ webservices/wss4j/trunk/test/wssec/SOAPUtil.java Fri Jun  5 15:24:11 2009
@@ -21,18 +21,47 @@
 
 import javax.xml.soap.MessageFactory;
 import javax.xml.soap.SOAPMessage;
+
+import org.apache.axis.Message;
+import org.apache.axis.MessageContext;
+import org.apache.axis.client.AxisClient;
+import org.apache.axis.configuration.NullProvider;
+
 import java.io.ByteArrayInputStream;
+import java.io.InputStream;
 
 public class SOAPUtil {
-
+    
     /**
-     * Convert an xml String to a Document
+     * Convert an SOAP Envelope as a String to a org.w3c.dom.Document. The way this
+     * is done is delegated to one of the other methods in this class.
      */
     public static org.w3c.dom.Document toSOAPPart(String xml) throws Exception {
+        // return toSOAPPartSAAJ(xml);
+        return toSOAPPartAxis(xml);
+    }
+
+    /**
+     * Convert an xml String to a Document using the SAAJ API
+     */
+    public static org.w3c.dom.Document toSOAPPartSAAJ(String xml) throws Exception {
         ByteArrayInputStream in = new ByteArrayInputStream(xml.getBytes());
         MessageFactory factory = MessageFactory.newInstance();
         SOAPMessage soapMessage = factory.createMessage(null, in);
         return soapMessage.getSOAPPart();
     }
-
+    
+    /**
+     * Convert an xml String to a Document using Axis
+     */
+    public static org.w3c.dom.Document toSOAPPartAxis(String xml) throws Exception {
+        AxisClient tmpEngine = new AxisClient(new NullProvider());
+        MessageContext msgContext = new MessageContext(tmpEngine);
+        InputStream in = new ByteArrayInputStream(xml.getBytes());
+        Message msg = new Message(in);
+        msg.setMessageContext(msgContext);
+        org.apache.axis.message.SOAPEnvelope soapEnvelope = msg.getSOAPEnvelope();
+        return soapEnvelope.getAsDocument();
+    }
+    
 }

Modified: webservices/wss4j/trunk/test/wssec/SignatureConfirmationTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/SignatureConfirmationTest.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/SignatureConfirmationTest.java (original)
+++ webservices/wss4j/trunk/test/wssec/SignatureConfirmationTest.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -42,9 +37,7 @@
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.List;
 import java.util.Vector;
 
@@ -71,8 +64,6 @@
         +   "</SOAP-ENV:Body>" 
         + "</SOAP-ENV:Envelope>";
 
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
 
@@ -94,30 +85,6 @@
         return new TestSuite(SignatureConfirmationTest.class);
     }
 
-    /**
-     * Setup method
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
-
     
     /**
      * Test to see that a signature is saved correctly on the outbound request.
@@ -134,7 +101,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.SIGN));
-        final Document doc = unsignedEnvelope.getAsDocument();
+        final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.SIGN, doc, reqData, actions, true
@@ -170,7 +137,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.SIGN));
-        final Document doc = unsignedEnvelope.getAsDocument();
+        final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.SIGN, doc, reqData, actions, true
@@ -204,7 +171,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.SIGN));
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.SIGN, doc, reqData, actions, true
@@ -227,7 +194,7 @@
         //
         List results = verify(doc);
         actions.clear();
-        doc = unsignedEnvelope.getAsDocument();
+        doc = SOAPUtil.toSOAPPart(SOAPMSG);
         msgContext = (java.util.Map)reqData.getMsgContext();
         WSHandlerResult handlerResult = new WSHandlerResult(null, results);
         List receivedResults = new Vector();
@@ -262,7 +229,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.SIGN));
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.SIGN, doc, reqData, actions, true
@@ -279,7 +246,7 @@
         //
         List results = verify(doc);
         actions.clear();
-        doc = unsignedEnvelope.getAsDocument();
+        doc = SOAPUtil.toSOAPPart(SOAPMSG);
         msgContext = (java.util.Map)reqData.getMsgContext();
         WSHandlerResult handlerResult = new WSHandlerResult(null, results);
         List receivedResults = new Vector();

Modified: webservices/wss4j/trunk/test/wssec/SignatureKeyValueTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/SignatureKeyValueTest.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/SignatureKeyValueTest.java (original)
+++ webservices/wss4j/trunk/test/wssec/SignatureKeyValueTest.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.PublicKeyCallback;
@@ -41,9 +36,7 @@
 import org.apache.ws.security.util.WSSecurityUtil;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.List;
 
 import javax.security.auth.callback.Callback;
@@ -73,8 +66,6 @@
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
     private java.security.KeyStore keyStore = null;
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -98,39 +89,13 @@
     }
 
     /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
-
-    /**
      * Successful RSAKeyValue test.
      */
     public void testRSAKeyValue() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
         builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);
@@ -165,7 +130,7 @@
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss86", "security");
         builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = 
@@ -195,7 +160,7 @@
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40DSA", "security");
         builder.setKeyIdentifierType(WSConstants.KEY_VALUE);
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityCertError.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityCertError.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityCertError.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityCertError.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.components.crypto.CryptoFactory;
 import org.apache.ws.security.message.WSSecEncrypt;
@@ -34,8 +29,6 @@
 import org.apache.ws.security.message.WSSecHeader;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
 
 /**
  * This class tests for error messages that apply to certificates, e.g. when a bad
@@ -55,8 +48,6 @@
         +   "</SOAP-ENV:Body>" 
         + "</SOAP-ENV:Envelope>";
     
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -78,31 +69,6 @@
         return new TestSuite(TestWSSecurityNew3.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
 
     /**
      * Test for when a bad certificate is used for Signature
@@ -110,7 +76,7 @@
     public void testX509Signature() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("bob", "security");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         try {
@@ -128,7 +94,7 @@
     public void testEncryption() throws Exception {
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("alice");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         try {

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef.java Fri Jun  5 15:24:11 2009
@@ -19,9 +19,7 @@
 
 package wssec;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.List;
 import java.util.Vector;
 
@@ -33,11 +31,6 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -82,8 +75,6 @@
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurityDataRef constructor <p/>
@@ -105,32 +96,6 @@
     }
 
     /**
-     * Setup method <p/>
-     * 
-     * @throws Exception
-     *             Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception
-     *             if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
-
-    /**
      * Test that check for correct WSDataRef object from ReferenceList Processor 
      * 
      * 
@@ -138,13 +103,11 @@
      *             Thrown when there is an error in encryption or decryption
      */
     public void testDataRefReferenceListProcessor() throws Exception {
-      
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-        Document doc = unsignedEnvelope.getAsDocument();
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         LOG.info("Before Encryption Triple DES....");

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityDataRef1.java Fri Jun  5 15:24:11 2009
@@ -19,9 +19,7 @@
 
 package wssec;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.List;
 import java.util.Vector;
 
@@ -33,11 +31,6 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -82,8 +75,6 @@
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurityDataRef constructor <p/>
@@ -104,31 +95,6 @@
         return new TestSuite( TestWSSecurityDataRef1.class);
     }
 
-    /**
-     * Setup method <p/>
-     * 
-     * @throws Exception
-     *             Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception
-     *             if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
 
     /**
      * Test that check for correct WSDataRef object from EncryptedKey Processor 
@@ -138,13 +104,11 @@
      *             Thrown when there is an error in encryption or decryption
      */
     public void testDataRefEncryptedKeyProcessor() throws Exception {
-      
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-        Document doc = unsignedEnvelope.getAsDocument();
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         LOG.info("Before Encryption Triple DES....");

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityEncryptionParts.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.SOAPConstants;
@@ -47,9 +42,7 @@
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.xml.namespace.QName;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.List;
 import java.util.Vector;
 
@@ -71,8 +64,6 @@
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurity constructor
@@ -94,42 +85,16 @@
         return new TestSuite(TestWSSecurityEncryptionParts.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
 
     /**
      * Test encrypting a custom SOAP header
      */
     public void testSOAPHeader() throws Exception {
-        SOAPEnvelope unencryptedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        Document doc = unencryptedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         
@@ -175,12 +140,11 @@
      * Test encrypting a custom SOAP header using wsse11:EncryptedHeader
      */
     public void testSOAPEncryptedHeader() throws Exception {
-        SOAPEnvelope unencryptedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        Document doc = unencryptedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         
@@ -210,12 +174,11 @@
      * Test encrypting a custom SOAP header with a bad localname
      */
     public void testBadLocalname() throws Exception {
-        SOAPEnvelope unencryptedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        Document doc = unencryptedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -242,12 +205,11 @@
      * Test encrypting a custom SOAP header with a bad namespace
      */
     public void testBadNamespace() throws Exception {
-        SOAPEnvelope unencryptedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        Document doc = unencryptedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -274,15 +236,13 @@
      * Test signing a custom SOAP header and the SOAP body
      */
     public void testSOAPHeaderAndBody() throws Exception {
-        SOAPEnvelope unencryptedEnvelope = message.getSOAPEnvelope();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         SOAPConstants soapConstants = 
-            WSSecurityUtil.getSOAPConstants(unencryptedEnvelope.getAsDOM());
+            WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
         WSSecEncrypt encrypt = new WSSecEncrypt();
         encrypt.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         encrypt.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
-        Document doc = unencryptedEnvelope.getAsDocument();
-
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         
@@ -347,7 +307,6 @@
             // expected
         }
     }
-    
 
     /**
      * Verifies the soap envelope

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityFaultCodes.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.ws.security.WSConstants;
 import org.apache.ws.security.WSSecurityException;
 import org.apache.ws.security.WSPasswordCallback;
@@ -47,9 +42,7 @@
 import javax.security.auth.callback.UnsupportedCallbackException;
 import javax.xml.namespace.QName;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 /**
  * WS-Security Test Case for fault codes. The SOAP Message Security specification 1.1 defines
@@ -71,8 +64,6 @@
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -94,32 +85,6 @@
         return new TestSuite(TestWSSecurityFaultCodes.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
-
     
     /**
      * Test for the wsse:FailedCheck faultcode. This will fail due to a bad password in
@@ -129,7 +94,7 @@
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
@@ -185,7 +150,7 @@
         WSSecTimestamp builder = new WSSecTimestamp();
         builder.setTimeToLive(-1);
         
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         Document timestampedDoc = builder.build(doc, secHeader);
@@ -211,7 +176,7 @@
         builder.addNonce();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         Document timestampedDoc = builder.build(doc, secHeader);
@@ -237,7 +202,7 @@
         builder.addNonce();
         builder.setUserInfo(null, "security");
         
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         builder.build(doc, secHeader);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityGetPassword.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSPasswordCallback;
@@ -37,9 +32,7 @@
 import org.apache.ws.security.handler.WSHandlerConstants;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -65,9 +58,6 @@
         +   "</SOAP-ENV:Body>" 
         + "</SOAP-ENV:Envelope>";
 
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
-
     /**
      * TestWSSecurity constructor
      * <p/>
@@ -88,31 +78,6 @@
         return new TestSuite(TestWSSecurityGetPassword.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
 
     /**
      * A unit test for {@link WSHandler#getPassword(String, int, String, String, RequestData)},
@@ -160,7 +125,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.UT));
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.UT, 
@@ -201,7 +166,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.UT));
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.UT, 

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityKerberosTokenProfile.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityKerberosTokenProfile.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityKerberosTokenProfile.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityKerberosTokenProfile.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSEncryptionPart;
@@ -46,9 +41,7 @@
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.Vector;
 
 /**
@@ -75,8 +68,6 @@
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurity constructor
@@ -98,38 +89,12 @@
         return new TestSuite(TestWSSecurityKerberosTokenProfile.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
 
     /**
      * A unit test for creating BinarySecurityTokens
      */
     public void testCreateBinarySecurityToken() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSConfig.getNewInstance();
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -157,8 +122,7 @@
      * A test for signing a Kerberos BST
      */
     public void testSignBST() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSConfig.getNewInstance();
 
         WSSecHeader secHeader = new WSSecHeader();
@@ -196,8 +160,7 @@
      * A test for signing a Kerberos BST as well as a Timestamp
      */
     public void testSignBSTTimestamp() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSConfig.getNewInstance();
 
         WSSecHeader secHeader = new WSSecHeader();

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSSecurityEngine;
@@ -37,9 +32,6 @@
 import org.apache.ws.security.message.WSSecHeader;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
 
 /**
  * WS-Security Test Case
@@ -64,8 +56,6 @@
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -87,31 +77,6 @@
         return new TestSuite(TestWSSecurityNew.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
 
     /**
      * The test uses the ThumbprintSHA1 key identifier type.
@@ -124,7 +89,7 @@
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         LOG.info("Before Signing IS....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);
@@ -149,7 +114,7 @@
     public void testDoubleX509SignatureIS() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew10.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew10.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew10.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew10.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -44,9 +39,7 @@
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 /**
  * TestCase10 for testing HMAC_SHA1 in wss4j. Based on TestCase9.
@@ -71,8 +64,6 @@
         + "</SOAP-ENV:Envelope>";
 
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurity constructor <p/>
@@ -94,31 +85,6 @@
         return new TestSuite(TestWSSecurityNew10.class);
     }
 
-    /**
-     * Setup method <p/>
-     * 
-     * @throws Exception
-     *             Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception
-     *             if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
 
     /**
      * Test that encrypts and signs a WS-Security envelope, then performs
@@ -129,13 +95,10 @@
      *             decryption, or verification
      */
     public void testEMBED_SECURITY_TOKEN_REF() throws Exception {
-
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt wsEncrypt = new WSSecEncrypt();
-
         // Get the message as document
         LOG.info("Before Encryption....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew11.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew11.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew11.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew11.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.SOAPConstants;
@@ -41,8 +36,7 @@
 import org.apache.ws.security.message.WSSecTimestamp;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
+import java.util.List;
 import java.util.Vector;
 
 /**
@@ -68,8 +62,6 @@
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -91,31 +83,6 @@
         return new TestSuite(TestWSSecurityNew11.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
 
     /**
      * Test that signs and verifies a WS-Security envelope.
@@ -129,13 +96,14 @@
     public void testX509SignatureDirectSTR() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
-        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
-        Vector parts = new Vector();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
+        List parts = new Vector();
         
-        /*
-         * Set up to sign body and use STRTransform to sign
-         * the signature token (e.g. X.509 certificate)
-         */
+        //
+        // Set up to sign body and use STRTransform to sign
+        // the signature token (e.g. X.509 certificate)
+        //
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 soapConstants.getBodyQName().getLocalPart(),
@@ -153,7 +121,6 @@
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
 
         LOG.info("Before Signing STR DirectReference....");
-        Document doc = unsignedEnvelope.getAsDocument();
 
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -178,17 +145,17 @@
     public void testWSS96() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
-        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
-        Vector parts = new Vector();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
+        List parts = new Vector();
         
-        Document doc = unsignedEnvelope.getAsDocument();
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         
-        /*
-         * Set up to sign body and use STRTransform to sign
-         * the signature token (e.g. X.509 certificate)
-         */
+        //
+        // Set up to sign body and use STRTransform to sign
+        // the signature token (e.g. X.509 certificate)
+        //
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 soapConstants.getBodyQName().getLocalPart(),
@@ -236,13 +203,15 @@
     public void testX509SignatureISSTR() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
-        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
-        Vector parts = new Vector();
         
-        /*
-         * Set up to sign body and use STRTransform to sign
-         * the signature token (e.g. X.509 certificate)
-         */
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
+        List parts = new Vector();
+        
+        //
+        // Set up to sign body and use STRTransform to sign
+        // the signature token (e.g. X.509 certificate)
+        //
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 soapConstants.getBodyQName().getLocalPart(),    // define the body
@@ -260,7 +229,6 @@
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
 
         LOG.info("Before Signing STR IS....");
-        Document doc = unsignedEnvelope.getAsDocument();
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -289,13 +257,14 @@
     public void testX509SignatureSKISTR() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("wss40", "security");
-        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(unsignedEnvelope.getAsDOM());
-        Vector parts = new Vector();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
+        SOAPConstants soapConstants = WSSecurityUtil.getSOAPConstants(doc.getDocumentElement());
+        List parts = new Vector();
         
-        /*
-         * Set up to sign body and use STRTransform to sign
-         * the signature token (e.g. X.509 certificate)
-         */
+        //
+        // Set up to sign body and use STRTransform to sign
+        // the signature token (e.g. X.509 certificate)
+        //
         WSEncryptionPart encP =
             new WSEncryptionPart(
                 soapConstants.getBodyQName().getLocalPart(),    // define the body
@@ -313,7 +282,6 @@
         builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
 
         LOG.info("Before Signing STR SKI....");
-        Document doc = unsignedEnvelope.getAsDocument();
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew12.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew12.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew12.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew12.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSSecurityEngine;
@@ -39,9 +34,6 @@
 
 import org.apache.xml.security.signature.XMLSignature;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
 
 /**
  * WS-Security Test Case
@@ -67,8 +59,6 @@
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -90,31 +80,6 @@
         return new TestSuite(TestWSSecurityNew12.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
 
     /**
      * Test that signs and verifies a WS-Security envelope using SubjectKeyIdentifier.
@@ -131,7 +96,7 @@
         builder.setSignatureAlgorithm(XMLSignature.ALGO_ID_SIGNATURE_DSA);
         
         LOG.info("Before SigningDSA_SKIDirect....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -164,7 +129,7 @@
         builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
         
         LOG.info("Before SigningDSA_Autodetect....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -197,7 +162,7 @@
         builder.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
         
         LOG.info("Before SigningRSA_Autodetect....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew13.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew13.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew13.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew13.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSPasswordCallback;
@@ -43,9 +38,7 @@
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 
 /**
@@ -70,8 +63,6 @@
         + "</SOAP-ENV:Envelope>";
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -93,32 +84,6 @@
         return new TestSuite(TestWSSecurityNew13.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
-
  
     /**
      * Test the specific signing method that use UsernameToken values
@@ -127,7 +92,7 @@
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     public void testUsernameTokenSigning() throws Exception {
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -168,7 +133,7 @@
      * @throws java.lang.Exception Thrown when there is any problem in signing or verification
      */
     public void testUsernameTokenSigningDigest() throws Exception {
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
 
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew14.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew14.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew14.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew14.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSSConfig;
@@ -42,9 +37,7 @@
 import org.apache.ws.security.message.WSSecHeader;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
@@ -77,8 +70,6 @@
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
     private byte[] keyData;
     private SecretKey key;
 
@@ -109,29 +100,12 @@
      * @throws java.lang.Exception Thrown when there is a problem in setup
      */
     protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-        
         KeyGenerator keyGen = KeyGenerator.getInstance("AES");
         keyGen.init(128);
         key = keyGen.generateKey();
         keyData = key.getEncoded();
     }
 
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
 
     /**
      * Test that signs and verifies a WS-Security envelope.
@@ -146,7 +120,7 @@
         builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
         // builder.setUserInfo("john", "keypass");
         LOG.info("Before Signing ThumbprintSHA1....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -174,8 +148,8 @@
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
         // builder.setUserInfo("john", "keypass");
-        builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);        
-        Document doc = unsignedEnvelope.getAsDocument();
+        builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -198,7 +172,7 @@
         builder.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
         
         LOG.info("Before Encrypting ThumbprintSHA1....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
@@ -228,7 +202,7 @@
         builder.setKeyIdentifierType(WSConstants.ENCRYPTED_KEY_SHA1_IDENTIFIER);
      
         LOG.info("Before Encrypting EncryptedKeySHA1....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
@@ -259,7 +233,7 @@
         builder.setEncryptSymmKey(false);
         
         LOG.info("Before Encrypting EncryptedKeySHA1....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
@@ -290,7 +264,7 @@
         builder.setEncryptSymmKey(false);
         
         LOG.info("Before Encrypting EncryptedKeySHA1....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         Document encryptedDoc = builder.build(doc, crypto, secHeader);
@@ -329,7 +303,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.ENCR));
-        final Document doc = unsignedEnvelope.getAsDocument();
+        final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.ENCR, 

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew15.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew15.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew15.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew15.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.SOAPConstants;
@@ -45,9 +40,7 @@
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import java.util.Vector;
 
@@ -84,8 +77,6 @@
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurity constructor <p/>
@@ -106,31 +97,6 @@
         return new TestSuite(TestWSSecurityNew15.class);
     }
 
-    /**
-     * Setup method <p/>
-     * 
-     * @throws Exception
-     *             Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception
-     *             if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
 
     /**
      * Test that encrypt and decrypt a WS-Security envelope.
@@ -142,12 +108,11 @@
      *             Thrown when there is any problem in signing or verification
      */
     public void testEncryptionDecryptionRSA15() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         LOG.info("Before Encryption Triple DES....");

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew16.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew16.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew16.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew16.java Fri Jun  5 15:24:11 2009
@@ -19,9 +19,7 @@
 
 package wssec;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
@@ -32,11 +30,6 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -74,8 +67,6 @@
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurity constructor
@@ -97,31 +88,6 @@
         return new TestSuite(TestWSSecurityNew16.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
 
     /**
      * Test that first signs, then encrypts a WS-Security envelope.
@@ -131,10 +97,8 @@
      *                   decryption, or verification
      */
     public void testEncryptedKeySignature() throws Exception {
-        
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         LOG.info("Before Sign/Encryption....");
-        Document doc = unsignedEnvelope.getAsDocument();
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew17.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew17.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew17.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew17.java Fri Jun  5 15:24:11 2009
@@ -19,9 +19,7 @@
 
 package wssec;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import javax.crypto.KeyGenerator;
 import javax.crypto.SecretKey;
@@ -34,11 +32,6 @@
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -78,8 +71,6 @@
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private Message message;
     private byte[] keyData;
 
     /**
@@ -109,10 +100,6 @@
      * @throws Exception Thrown when there is a problem in setup
      */
     protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-        
         KeyGenerator keyGen = KeyGenerator.getInstance("AES");
         keyGen.init(128);
         SecretKey key = keyGen.generateKey();
@@ -120,25 +107,10 @@
     }
 
     /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
-    
-    /**
      * Test signing a message body using a symmetric key with EncryptedKeySHA1
      */
     public void testSymmetricSignatureSHA1() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -166,8 +138,7 @@
      * EncryptedKey
      */
     public void testSymmetricSignatureDR() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -205,10 +176,8 @@
      *                   decryption, or verification
      */
     public void testEncryptedKeySignature() throws Exception {
-        
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         LOG.info("Before Sign/Encryption....");
-        Document doc = unsignedEnvelope.getAsDocument();
         
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
@@ -263,8 +232,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(WSConstants.SIGN));
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
-        final Document doc = unsignedEnvelope.getAsDocument();
+        final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             WSConstants.SIGN, 

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew18.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew18.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew18.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew18.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSSConfig;
@@ -40,9 +35,6 @@
 import org.apache.ws.security.message.WSSecHeader;
 import org.w3c.dom.Document;
 
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-
 
 /**
  * WS-Security Test Case
@@ -67,8 +59,6 @@
     
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance();
-    private MessageContext msgContext;
-    private SOAPEnvelope unsignedEnvelope;
 
     /**
      * TestWSSecurity constructor
@@ -90,31 +80,6 @@
         return new TestSuite(TestWSSecurityNew18.class);
     }
 
-    /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws java.lang.Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        unsignedEnvelope = getSOAPEnvelope();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws java.lang.Exception if there is any problem constructing the soap envelope
-     */
-    protected SOAPEnvelope getSOAPEnvelope() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg.getSOAPEnvelope();
-    }
 
     /**
      * Sign using a different digest algorithm (SHA-256).
@@ -129,7 +94,7 @@
         builder.setSignatureAlgorithm("http://www.w3.org/2001/04/xmldsig-more#rsa-sha256");
         builder.setDigestAlgo("http://www.w3.org/2001/04/xmlenc#sha256");
         LOG.info("Before Signing IS....");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);
@@ -154,7 +119,7 @@
     public void testDoubleX509SignatureIS() throws Exception {
         WSSecSignature builder = new WSSecSignature();
         builder.setUserInfo("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         Document signedDoc = builder.build(doc, crypto, secHeader);
@@ -220,7 +185,7 @@
         
         final java.util.Vector actions = new java.util.Vector();
         actions.add(new Integer(action));
-        final Document doc = unsignedEnvelope.getAsDocument();
+        final Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         MyHandler handler = new MyHandler();
         handler.send(
             action, 

Modified: webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java?rev=782049&r1=782048&r2=782049&view=diff
==============================================================================
--- webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java (original)
+++ webservices/wss4j/trunk/test/wssec/TestWSSecurityNew2.java Fri Jun  5 15:24:11 2009
@@ -22,11 +22,6 @@
 import junit.framework.Test;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
-import org.apache.axis.Message;
-import org.apache.axis.MessageContext;
-import org.apache.axis.client.AxisClient;
-import org.apache.axis.configuration.NullProvider;
-import org.apache.axis.message.SOAPEnvelope;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.ws.security.WSConstants;
@@ -44,9 +39,7 @@
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.callback.UnsupportedCallbackException;
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
-import java.io.InputStream;
 
 import java.util.Vector;
 
@@ -76,8 +69,6 @@
 
     private WSSecurityEngine secEngine = new WSSecurityEngine();
     private Crypto crypto = CryptoFactory.getInstance("wss40.properties");
-    private MessageContext msgContext;
-    private Message message;
 
     /**
      * TestWSSecurity constructor
@@ -100,32 +91,6 @@
     }
 
     /**
-     * Setup method
-     * <p/>
-     * 
-     * @throws Exception Thrown when there is a problem in setup
-     */
-    protected void setUp() throws Exception {
-        AxisClient tmpEngine = new AxisClient(new NullProvider());
-        msgContext = new MessageContext(tmpEngine);
-        message = getSOAPMessage();
-    }
-
-    /**
-     * Constructs a soap envelope
-     * <p/>
-     * 
-     * @return soap envelope
-     * @throws Exception if there is any problem constructing the soap envelope
-     */
-    protected Message getSOAPMessage() throws Exception {
-        InputStream in = new ByteArrayInputStream(SOAPMSG.getBytes());
-        Message msg = new Message(in);
-        msg.setMessageContext(msgContext);
-        return msg;
-    }
-
-    /**
      * Test that encrypt and decrypt a WS-Security envelope.
      * This test uses the RSA_15 algorithm to transport (wrap) the symmetric
      * key.
@@ -134,12 +99,11 @@
      * @throws Exception Thrown when there is any problem in signing or verification
      */
     public void testEncryptionDecryptionRSA15() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.BST_DIRECT_REFERENCE);
         builder.setSymmetricEncAlgorithm(WSConstants.TRIPLE_DES);
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);
         LOG.info("Before Encryption Triple DES....");
@@ -161,7 +125,6 @@
          * This tests if several runs of different algorithms on same builder/cipher 
          * setup are ok.
          */
-        message = getSOAPMessage(); // create fresh message environment
         builder.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
         builder.setSymmetricEncAlgorithm(WSConstants.AES_128);
         Vector parts = new Vector();
@@ -169,8 +132,7 @@
             new WSEncryptionPart("testMethod", "uri:LogTestService2", "Element");
         parts.add(encP);
         builder.setParts(parts);
-        unsignedEnvelope = message.getSOAPEnvelope();
-        doc = unsignedEnvelope.getAsDocument();
+        doc = SOAPUtil.toSOAPPart(SOAPMSG);
         secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         LOG.info("Before Encryption AES 128/RSA-15....");
@@ -201,12 +163,11 @@
      * @throws Exception Thrown when there is any problem in signing or verification
      */
      public void testEncryptionDecryptionOAEP() throws Exception {
-        SOAPEnvelope unsignedEnvelope = message.getSOAPEnvelope();
         WSSecEncrypt builder = new WSSecEncrypt();
         builder.setUserInfo("wss40");
         builder.setKeyIdentifierType(WSConstants.X509_KEY_IDENTIFIER);
         builder.setKeyEnc(WSConstants.KEYTRANSPORT_RSAOEP);
-        Document doc = unsignedEnvelope.getAsDocument();
+        Document doc = SOAPUtil.toSOAPPart(SOAPMSG);
         WSSecHeader secHeader = new WSSecHeader();
         secHeader.insertSecurityHeader(doc);        
         LOG.info("Before Encryption Triple DES/RSA-OAEP....");



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


Mime
View raw message