cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andreasm...@apache.org
Subject svn commit: r472511 - in /incubator/cxf/trunk: rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/ rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/ systests/src/test/java/org/apache/cxf/systest/ws/rm/
Date Wed, 08 Nov 2006 15:01:24 GMT
Author: andreasmyth
Date: Wed Nov  8 07:01:23 2006
New Revision: 472511

URL: http://svn.apache.org/viewvc?view=rev&rev=472511
Log:
[JIRA CXF-140] Using a DOM parser to verify contents of inbound and outbound messages in the
RM system test
instead of SSAJ API as workaround for JDK bug 6467808.
Piggybacked acknowledgements on partial responses.

Modified:
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConstants.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java
    incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
    incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/DestinationSequence.java
Wed Nov  8 07:01:23 2006
@@ -180,7 +180,7 @@
     boolean canPiggybackAckOnPartialResponse() {
         // TODO: should also check if we allow breaking the WI Profile rule by which no headers
         // can be included in a HTTP response
-        return getAcksTo().getAddress().getValue().equals(RMConstants.WSA_ANONYMOUS_ADDRESS);
+        return getAcksTo().getAddress().getValue().equals(RMConstants.getAnonympusAddress());
     }
        
     /**

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConstants.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConstants.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConstants.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMConstants.java Wed Nov
 8 07:01:23 2006
@@ -31,43 +31,43 @@
  */
 public final class RMConstants {
    
-    public static final String WSRM_NAMESPACE_NAME = 
+    private static final String WSRM_NAMESPACE_NAME = 
         "http://schemas.xmlsoap.org/ws/2005/02/rm";
     
-    public static final String WSRMP_NAMESPACE_NAME = 
+    private static final String WSRMP_NAMESPACE_NAME = 
         "http://schemas.xmlsoap.org/ws/2005/02/rm/policy";
     
-    public static final String WSA_NAMESPACE_NAME = 
+    private static final String WSA_NAMESPACE_NAME = 
         "http://schemas.xmlsoap.org/ws/2004/08/addressing";
     
-    public static final String WSRM_NAMESPACE_PREFIX = "wsrm";
+    private static final String WSRM_NAMESPACE_PREFIX = "wsrm";
     
-    public static final String WSRM_WSDL_NAMESPACE_NAME = 
+    private static final String WSRM_WSDL_NAMESPACE_NAME = 
         WSRM_NAMESPACE_NAME + "/wsdl";
     
   
-    public static final String WSRM_SEQUENCE_NAME =
+    private static final String WSRM_SEQUENCE_NAME =
         "Sequence";
     
-    public static final QName WSRM_SEQUENCE_QNAME =
+    private static final QName WSRM_SEQUENCE_QNAME =
         new QName(WSRM_NAMESPACE_NAME, WSRM_SEQUENCE_NAME);
     
-    public static final String WSRM_SEQUENCE_ACK_NAME =
+    private static final String WSRM_SEQUENCE_ACK_NAME =
         "SequenceAcknowledgement";
     
-    public static final QName WSRM_SEQUENCE_ACK_QNAME =
+    private static final QName WSRM_SEQUENCE_ACK_QNAME =
         new QName(WSRM_NAMESPACE_NAME, WSRM_SEQUENCE_ACK_NAME);
     
-    public static final String WSRM_ACK_REQUESTED_NAME =
+    private static final String WSRM_ACK_REQUESTED_NAME =
         "AckRequested";
     
-    public static final QName WSRM_ACK_REQUESTED_QNAME =
+    private static final QName WSRM_ACK_REQUESTED_QNAME =
         new QName(WSRM_NAMESPACE_NAME, WSRM_ACK_REQUESTED_NAME);
     
-    public static final String WSA_ANONYMOUS_ADDRESS = 
+    private static final String WSA_ANONYMOUS_ADDRESS = 
         WSA_NAMESPACE_NAME + "/anonymous";
     
-    public static final String WSA_NONE_ADDRESS =
+    private static final String WSA_NONE_ADDRESS =
         WSA_NAMESPACE_NAME + "/none";
       
     /**
@@ -133,6 +133,58 @@
     
     public static Set<QName> getHeaders() {
         return HEADERS;
+    }
+    
+    public static String getNamespace() {
+        return WSRM_NAMESPACE_NAME; 
+    }
+        
+    public static String getPolicyNamespace() {
+        return WSRMP_NAMESPACE_NAME;
+    }
+    
+    public static String getAddressingNamespace() {
+        return WSA_NAMESPACE_NAME;        
+    }
+    
+    public static String getNamespacePrefix() {
+        return WSRM_NAMESPACE_PREFIX;
+    }
+    
+    public static  String getWsdlNamespace() {
+        return WSRM_WSDL_NAMESPACE_NAME;
+    }    
+  
+    public static String getSequenceName() {
+        return WSRM_SEQUENCE_NAME;
+    }
+    
+    public static QName getSequenceQName() {
+        return WSRM_SEQUENCE_QNAME;
+    }
+    
+    public static String getSequenceAckName() {
+        return WSRM_SEQUENCE_ACK_NAME;
+    }
+    
+    public static QName getSequenceAckQName() {
+        return WSRM_SEQUENCE_ACK_QNAME;
+    }
+    
+    public static String getAckRequestedName() {
+        return WSRM_ACK_REQUESTED_NAME;
+    }
+    
+    public static QName getAckRequestedQName() {
+        return WSRM_ACK_REQUESTED_QNAME;
+    }
+    
+    public static String getAnonympusAddress() {
+        return WSA_ANONYMOUS_ADDRESS; 
+    }
+    
+    public static String getNoneAddress() {
+        return WSA_NONE_ADDRESS;
     }
     
     public static QName getCreateSequenceOperationName() {

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMEndpoint.java Wed Nov
 8 07:01:23 2006
@@ -46,13 +46,13 @@
 public class RMEndpoint {
     
     private static final QName SERVICE_NAME = 
-        new QName(RMConstants.WSRM_NAMESPACE_NAME, "SequenceAbstractService");
+        new QName(RMConstants.getNamespace(), "SequenceAbstractService");
     private static final QName INTERFACE_NAME = 
-         new QName(RMConstants.WSRM_NAMESPACE_NAME, "SequenceAbstractPortType");
+         new QName(RMConstants.getNamespace(), "SequenceAbstractPortType");
     private static final QName BINDING_NAME = 
-        new QName(RMConstants.WSRM_NAMESPACE_NAME, "SequenceAbstractSoapBinding");
+        new QName(RMConstants.getNamespace(), "SequenceAbstractSoapBinding");
     private static final QName PORT_NAME = 
-        new QName(RMConstants.WSRM_NAMESPACE_NAME, "SequenceAbstractSoapPort");
+        new QName(RMConstants.getNamespace(), "SequenceAbstractSoapPort");
         
     private final RMManager manager;
     private final Endpoint applicationEndpoint;

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMInInterceptor.java Wed
Nov  8 07:01:23 2006
@@ -113,13 +113,15 @@
         
         // for application AND out of band messages
 
+        Destination destination = getManager().getDestination(message);
+        
         if (null != rmps) {            
             
             processAcknowledgments(rmps);
 
             processAcknowledgmentRequests(rmps);  
             
-            processSequence(rmps, maps);
+            processSequence(destination, rmps, maps);
             
             processDeliveryAssurance(rmps);
         }
@@ -133,8 +135,15 @@
         
     }
     
-    void processSequence(RMProperties rmps, AddressingProperties maps) {
-        
+    void processSequence(Destination destination, RMProperties rmps, AddressingProperties
maps) 
+        throws SequenceFault {
+        SequenceType s = rmps.getSequence();
+        if (null == s) {
+            return;
+        }  
+
+        destination.acknowledge(s, 
+            null == maps.getReplyTo() ? null : maps.getReplyTo().getAddress().getValue());
     }
     
     void processDeliveryAssurance(RMProperties rmps) {

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/RMManager.java Wed Nov
 8 07:01:23 2006
@@ -144,7 +144,7 @@
                 } else {
                     acksTo = VersionTransformer.convert(maps.getReplyTo());
                     // for oneways
-                    if (RMConstants.WSA_NONE_ADDRESS.equals(acksTo.getAddress().getValue()))
{
+                    if (RMConstants.getNoneAddress().equals(acksTo.getAddress().getValue()))
{
                         acksTo = RMUtils.createAnonymousReference2004();
                     }
                 }

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java (original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/Servant.java Wed Nov 
8 07:01:23 2006
@@ -142,6 +142,11 @@
             createResponse.setAccept(accept);
         }
         
+        DestinationSequence seq = new DestinationSequence(createResponse.getIdentifier(),
+                                                          create.getAcksTo(), destination);
+        seq.setCorrelationID(maps.getMessageID().getValue());
+        destination.addSequence(seq);
+        
         LOG.fine("Returning createResponse: " + createResponse);
         return createResponse;
     }

Modified: incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptor.java
Wed Nov  8 07:01:23 2006
@@ -182,15 +182,15 @@
             // add WSRM namespace declaration to header, instead of
             // repeating in each individual child node
             header.setAttributeNS("http://www.w3.org/2000/xmlns/",
-                                  "xmlns:" + RMConstants.WSRM_NAMESPACE_PREFIX,
-                                 RMConstants.WSRM_NAMESPACE_NAME);
+                                  "xmlns:" + RMConstants.getNamespacePrefix(),
+                                 RMConstants.getNamespace());
             Marshaller marshaller = getJAXBContext().createMarshaller();
             marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
            
             SequenceType seq = rmps.getSequence();
             if (null != seq) {
                 encodeProperty(seq, 
-                               RMConstants.WSRM_SEQUENCE_QNAME, 
+                               RMConstants.getSequenceQName(), 
                                SequenceType.class, 
                                header,
                                marshaller);
@@ -199,7 +199,7 @@
             if (null != acks) {
                 for (SequenceAcknowledgement ack : acks) {
                     encodeProperty(ack, 
-                                   RMConstants.WSRM_SEQUENCE_ACK_QNAME, 
+                                   RMConstants.getSequenceAckQName(), 
                                    SequenceAcknowledgement.class, 
                                    header,
                                    marshaller);
@@ -209,7 +209,7 @@
             if (null != requested) {
                 for (AckRequestedType ar : requested) {
                     encodeProperty(ar, 
-                                   RMConstants.WSRM_ACK_REQUESTED_QNAME, 
+                                   RMConstants.getAckRequestedQName(), 
                                    AckRequestedType.class, 
                                    header,
                                    marshaller);
@@ -260,20 +260,20 @@
                     Element headerElement = (Element)headerElements.item(i);
                     String headerURI = headerElement.getNamespaceURI();
                     String localName = headerElement.getLocalName();
-                    if (RMConstants.WSRM_NAMESPACE_NAME.equals(headerURI)) {
+                    if (RMConstants.getNamespace().equals(headerURI)) {
                         LOG.log(Level.INFO, "decoding RM header {0}", localName);
-                        if (RMConstants.WSRM_SEQUENCE_NAME.equals(localName)) {
+                        if (RMConstants.getSequenceName().equals(localName)) {
                             SequenceType s = decodeProperty(SequenceType.class,
                                                             headerElement,
                                                             unmarshaller);
                             
                             rmps.setSequence(s);
-                        } else if (RMConstants.WSRM_SEQUENCE_ACK_NAME.equals(localName))
{
+                        } else if (RMConstants.getSequenceAckName().equals(localName)) {
                             SequenceAcknowledgement ack = decodeProperty(SequenceAcknowledgement.class,
                                                             headerElement,
                                                             unmarshaller);
                             acks.add(ack);                            
-                        } else if (RMConstants.WSRM_ACK_REQUESTED_NAME.equals(localName))
{
+                        } else if (RMConstants.getAckRequestedName().equals(localName)) {
                             AckRequestedType ar = decodeProperty(AckRequestedType.class,
                                                             headerElement,
                                                             unmarshaller);
@@ -355,11 +355,11 @@
      */
     private static void discardRMHeaders(Element header) throws SOAPException {
         NodeList headerElements =
-            header.getElementsByTagNameNS(RMConstants.WSRM_NAMESPACE_NAME, "*");
+            header.getElementsByTagNameNS(RMConstants.getNamespace(), "*");
         
         for (int i = 0; i < headerElements.getLength(); i++) {
             Node headerElement = headerElements.item(i);
-            if (RMConstants.WSRM_NAMESPACE_NAME.equals(headerElement.getNamespaceURI()))
{
+            if (RMConstants.getNamespace().equals(headerElement.getNamespaceURI())) {
                 header.removeChild(headerElement);
             }
 

Modified: incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
(original)
+++ incubator/cxf/trunk/rt/ws/rm/src/test/java/org/apache/cxf/ws/rm/soap/RMSoapInterceptorTest.java
Wed Nov  8 07:01:23 2006
@@ -74,11 +74,11 @@
         RMSoapInterceptor codec = new RMSoapInterceptor();
         Set<QName> headers = codec.getUnderstoodHeaders();
         assertTrue("expected Sequence header", 
-                   headers.contains(RMConstants.WSRM_SEQUENCE_QNAME));
+                   headers.contains(RMConstants.getSequenceQName()));
         assertTrue("expected SequenceAcknowledgment header", 
-                   headers.contains(RMConstants.WSRM_SEQUENCE_ACK_QNAME));
+                   headers.contains(RMConstants.getSequenceAckQName()));
         assertTrue("expected AckRequested header", 
-                   headers.contains(RMConstants.WSRM_ACK_REQUESTED_QNAME));
+                   headers.contains(RMConstants.getAckRequestedQName()));
     }
     
     public void testHandleMessage() throws NoSuchMethodException {
@@ -152,7 +152,7 @@
         RMProperties rmps = RMContextUtils.retrieveRMProperties(message, true);     
         rmps.setSequence(s1);        
         codec.encode(message);
-        verifyHeaders(message, new String[] {RMConstants.WSRM_SEQUENCE_NAME});
+        verifyHeaders(message, new String[] {RMConstants.getSequenceName()});
 
         // one acknowledgment header
 
@@ -162,7 +162,7 @@
         acks.add(ack1);
         rmps.setAcks(acks);        
         codec.encode(message);
-        verifyHeaders(message, new String[] {RMConstants.WSRM_SEQUENCE_ACK_NAME});
+        verifyHeaders(message, new String[] {RMConstants.getSequenceAckName()});
 
         // two acknowledgment headers
 
@@ -171,8 +171,8 @@
         acks.add(ack2);
         rmps.setAcks(acks);
         codec.encode(message);
-        verifyHeaders(message, new String[] {RMConstants.WSRM_SEQUENCE_ACK_NAME, 
-                                             RMConstants.WSRM_SEQUENCE_ACK_NAME});
+        verifyHeaders(message, new String[] {RMConstants.getSequenceAckName(), 
+                                             RMConstants.getSequenceAckName()});
 
         // one ack requested header
 
@@ -182,7 +182,7 @@
         requested.add(ar1);
         rmps.setAcksRequested(requested);
         codec.encode(message);
-        verifyHeaders(message, new String[] {RMConstants.WSRM_ACK_REQUESTED_NAME});
+        verifyHeaders(message, new String[] {RMConstants.getAckRequestedName()});
 
         // two ack requested headers
 
@@ -191,8 +191,8 @@
         requested.add(ar2);
         rmps.setAcksRequested(requested);
         codec.encode(message);
-        verifyHeaders(message, new String[] {RMConstants.WSRM_ACK_REQUESTED_NAME, 
-                                             RMConstants.WSRM_ACK_REQUESTED_NAME});
+        verifyHeaders(message, new String[] {RMConstants.getAckRequestedName(), 
+                                             RMConstants.getAckRequestedName()});
     }
 
     public void testDecodeSequence() throws XMLStreamException {
@@ -302,11 +302,11 @@
                 Element headerElement = (Element)headerElements.item(i);
                 String namespace = headerElement.getNamespaceURI();
                 String localName = headerElement.getLocalName();
-                if (RMConstants.WSRM_NAMESPACE_NAME.equals(namespace)
+                if (RMConstants.getNamespace().equals(namespace)
                     && localName.equals(name)) {
                     found = true;
                     break;
-                } else if (RMConstants.WSA_NAMESPACE_NAME.equals(namespace)
+                } else if (RMConstants.getAddressingNamespace().equals(namespace)
                     && localName.equals(name)) {
                     found = true;
                     break;
@@ -322,8 +322,8 @@
             Element headerElement = (Element)headerElements.item(i);  
             String namespace = headerElement.getNamespaceURI();
             String localName = headerElement.getLocalName();
-            assertTrue(RMConstants.WSRM_NAMESPACE_NAME.equals(namespace) 
-                || RMConstants.WSA_NAMESPACE_NAME.equals(namespace));
+            assertTrue(RMConstants.getNamespace().equals(namespace) 
+                || RMConstants.getAddressingNamespace().equals(namespace));
             boolean found = false;
             for (String name : names) {
                 if (localName.equals(name)) {

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/InMessageRecorder.java
Wed Nov  8 07:01:23 2006
@@ -24,9 +24,6 @@
 import java.util.ArrayList;
 import java.util.List;
 
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPMessage;
-
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Message;
@@ -35,10 +32,10 @@
 
 public class InMessageRecorder extends AbstractPhaseInterceptor<Message> {
 
-    private List<SOAPMessage> inbound;
+    private List<byte[]> inbound;
 
     public InMessageRecorder() {
-        inbound = new ArrayList<SOAPMessage>();
+        inbound = new ArrayList<byte[]>();
         setPhase(Phase.RECEIVE);
     }
 
@@ -54,18 +51,15 @@
             IOUtils.copy(is, bos);
             is.close();
             bos.close();
-            MessageFactory mf = MessageFactory.newInstance();
+            inbound.add(bos.toByteArray());
             ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-            SOAPMessage sm = mf.createMessage(null, bis);
-            inbound.add(sm);
-            bis = new ByteArrayInputStream(bos.toByteArray());
             message.setContent(InputStream.class, bis);
         } catch (Exception ex) {
             ex.printStackTrace();
         }
     }
 
-    protected List<SOAPMessage> getInboundMessages() {
+    protected List<byte[]> getInboundMessages() {
         return inbound;
     } 
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/MessageFlow.java
Wed Nov  8 07:01:23 2006
@@ -19,17 +19,17 @@
 
 package org.apache.cxf.systest.ws.rm;
 
-import java.io.ByteArrayOutputStream;
-import java.util.Iterator;
+import java.io.ByteArrayInputStream;
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.xml.namespace.QName;
-import javax.xml.soap.Name;
-import javax.xml.soap.SOAPElement;
-import javax.xml.soap.SOAPEnvelope;
-import javax.xml.soap.SOAPHeader;
-import javax.xml.soap.SOAPHeaderElement;
-import javax.xml.soap.SOAPMessage;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
 
 import junit.framework.Assert;
 
@@ -39,21 +39,34 @@
 
 public class MessageFlow extends Assert {
     
-    private List<SOAPMessage> outboundMessages;
-    private List<SOAPMessage> inboundMessages;
-    
-    
-    public MessageFlow(List<SOAPMessage> o, List<SOAPMessage> i) {
-        outboundMessages = o;
-        inboundMessages = i;
-    }
-    
-    public List<SOAPMessage> getOutboundMessages() {
-        return outboundMessages;
-    }
-    
-    public List<SOAPMessage> getInboundMessages() {
-        return inboundMessages;
+    private List<byte[]> inStreams;
+    private List<byte[]> outStreams;
+    private List<Document> outboundMessages;
+    private List<Document> inboundMessages;
+    
+    
+    public MessageFlow(List<byte[]> out, List<byte[]> in) throws Exception {
+        inStreams = in;
+        outStreams = out;
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        DocumentBuilder parser = factory.newDocumentBuilder();
+        inboundMessages = new ArrayList<Document>();
+        for (int i = 0; i < inStreams.size(); i++) {
+            byte[] bytes = inStreams.get(i);
+            String str = new String(bytes);
+            ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+            Document document = parser.parse(is);
+            inboundMessages.add(document);
+        }
+        outboundMessages = new ArrayList<Document>();
+        for (int i = 0; i < outStreams.size(); i++) {
+            byte[] bytes = outStreams.get(i);
+            String str = new String(bytes);
+            ByteArrayInputStream is = new ByteArrayInputStream(bytes);
+            Document document = parser.parse(is);
+            outboundMessages.add(document);
+        }
     }
     
     public void verifyActions(String[] expectedActions, boolean outbound) throws Exception
{
@@ -141,25 +154,25 @@
 
         if (exact) {
             for (int i = 0; i < expectedMessageNumbers.length; i++) {
-                SOAPElement se = outbound ? getSequence(outboundMessages.get(i))
+                Element e = outbound ? getSequence(outboundMessages.get(i))
                     : getSequence(inboundMessages.get(i));
                 if (null == expectedMessageNumbers[i]) {
                     assertNull((outbound ? "Outbound" : "Inbound") + " message " + i
-                        + " contains unexpected message number ", se);
+                        + " contains unexpected message number ", e);
                 } else {
                     assertEquals((outbound ? "Outbound" : "Inbound") + " message " + i
                         + " does not contain expected message number "
                                  + expectedMessageNumbers[i], expectedMessageNumbers[i],

-                                 getMessageNumber(se));
+                                 getMessageNumber(e));
                 }
             }
         } else {
             boolean[] matches = new boolean[expectedMessageNumbers.length];
             for (int i = 0; i < actualMessageCount; i++) {
                 String messageNumber = null;
-                SOAPElement se = outbound ? getSequence(outboundMessages.get(i))
+                Element e = outbound ? getSequence(outboundMessages.get(i))
                     : getSequence(inboundMessages.get(i));
-                messageNumber = null == se ? null : getMessageNumber(se);
+                messageNumber = null == e ? null : getMessageNumber(e);
                 for (int j = 0; j < expectedMessageNumbers.length; j++) {
                     if (messageNumber == null) {
                         if (expectedMessageNumbers[j] == null && !matches[j]) {
@@ -200,9 +213,9 @@
         
         for (int i = 0; i < expectedLastMessages.length; i++) { 
             boolean lastMessage;
-            SOAPElement se = outbound ? getSequence(outboundMessages.get(i))
+            Element e = outbound ? getSequence(outboundMessages.get(i))
                 : getSequence(inboundMessages.get(i));
-            lastMessage = null == se ? false : getLastMessage(se);
+            lastMessage = null == e ? false : getLastMessage(e);
             assertEquals("Outbound message " + i 
                          + (expectedLastMessages[i] ? " does not contain expected last message
element."
                              : " contains last message element."),
@@ -249,16 +262,14 @@
             assertTrue("unexpected number of acks: " + ackCount,
                        expectedAcks <= ackCount);
         }
-        
-        
     }
 
 
     public void verifyAckRequestedOutbound(boolean outbound) throws Exception {
         boolean found = false;
-        List<SOAPMessage> messages = outbound ? outboundMessages : inboundMessages;
-        for (SOAPMessage m : messages) {
-            SOAPElement se = getAckRequested(m);
+        List<Document> messages = outbound ? outboundMessages : inboundMessages;
+        for (Document d : messages) {
+            Element se = getAckRequested(d);
             if (se != null) {
                 found = true;
                 break;
@@ -267,83 +278,74 @@
         assertTrue("expected AckRequested", found);
     }
    
-    protected String getAction(SOAPMessage msg) throws Exception {
-        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
-        SOAPHeader header = env.getHeader();
-        Iterator headerElements = header.examineAllHeaderElements();
-        while (headerElements.hasNext()) {
-            SOAPHeaderElement headerElement = (SOAPHeaderElement)headerElements.next();
-            Name headerName = headerElement.getElementName();
-            String localName = headerName.getLocalName();
-            if ((headerName.getURI().equals(org.apache.cxf.ws.addressing.Names.WSA_NAMESPACE_NAME)

-                || headerName.getURI().equals(org.apache.cxf.ws.addressing.VersionTransformer
-                                              .Names200408.WSA_NAMESPACE_NAME))
-                && localName.equals(org.apache.cxf.ws.addressing.Names.WSA_ACTION_NAME))
{
-                return headerElement.getTextContent();
-            }
+    protected String getAction(Document document) throws Exception {
+        Element e = getHeaderElement(document, RMConstants.getAddressingNamespace(), "Action");
+        if (null != e) {
+            return getText(e);
         }
         return null;
     }
 
-    protected SOAPElement getSequence(SOAPMessage msg) throws Exception {
-        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
-        SOAPHeader header = env.getHeader();
-        Iterator headerElements = header.examineAllHeaderElements();
-        while (headerElements.hasNext()) {
-            SOAPHeaderElement headerElement = (SOAPHeaderElement)headerElements.next();
-            Name headerName = headerElement.getElementName();
-            String localName = headerName.getLocalName();
-            if (headerName.getURI().equals(RMConstants.WSRM_NAMESPACE_NAME)
-                && localName.equals(RMConstants.WSRM_SEQUENCE_NAME)) {
-                return headerElement;
+    protected Element getSequence(Document document) throws Exception {
+        return getRMHeaderElement(document, RMConstants.getSequenceName());
+    }
+
+    public String getMessageNumber(Element elem) throws Exception {
+        for (Node nd = elem.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
+            if (Node.ELEMENT_NODE == nd.getNodeType() && "MessageNumber".equals(nd.getLocalName()))
{
+                return getText(nd);
             }
         }
-        return null;
+        return null;    
     }
 
-    public String getMessageNumber(SOAPElement elem) throws Exception {
-        SOAPElement se = (SOAPElement)elem.getChildElements(
-                                                            new QName(RMConstants.WSRM_NAMESPACE_NAME,
-                                                                      "MessageNumber")).next();
-        return se.getTextContent();
-    }
-
-    private boolean getLastMessage(SOAPElement elem) throws Exception {
-        return elem.getChildElements(new QName(RMConstants.WSRM_NAMESPACE_NAME, "LastMessage")).hasNext();
-    }
-
-    protected SOAPElement getAcknowledgment(SOAPMessage msg) throws Exception {
-        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
-        SOAPHeader header = env.getHeader();
-        Iterator headerElements = header.examineAllHeaderElements();
-        while (headerElements.hasNext()) {
-            SOAPHeaderElement headerElement = (SOAPHeaderElement)headerElements.next();
-            Name headerName = headerElement.getElementName();
-            String localName = headerName.getLocalName();
-            if (headerName.getURI().equals(RMConstants.WSRM_NAMESPACE_NAME)
-                && localName.equals(RMConstants.WSRM_SEQUENCE_ACK_NAME)) {
-                return (SOAPElement)header.getChildElements().next();
+    private boolean getLastMessage(Element element) throws Exception {
+        for (Node nd = element.getFirstChild(); nd != null; nd = nd.getNextSibling()) { 
+            if (Node.ELEMENT_NODE == nd.getNodeType() && "LastMessage".equals(nd.getLocalName()))
{
+                return true;
             }
-        }
-        return null;
+        } 
+        return false;
+    }
+
+    protected Element getAcknowledgment(Document document) throws Exception {
+        return getRMHeaderElement(document, RMConstants.getSequenceAckName());
     }
     
-    private SOAPElement getAckRequested(SOAPMessage msg) throws Exception {
-        SOAPEnvelope env = msg.getSOAPPart().getEnvelope();
-        SOAPHeader header = env.getHeader();
-        Iterator headerElements = header.examineAllHeaderElements();
-        while (headerElements.hasNext()) {
-            SOAPHeaderElement headerElement = (SOAPHeaderElement)headerElements.next();
-            Name headerName = headerElement.getElementName();
-            String localName = headerName.getLocalName();
-            if (headerName.getURI().equals(RMConstants.WSRM_NAMESPACE_NAME)
-                && localName.equals(RMConstants.WSRM_ACK_REQUESTED_NAME)) {
-                return (SOAPElement)header.getChildElements().next();
+    private Element getAckRequested(Document document) throws Exception {
+        return getRMHeaderElement(document, RMConstants.getAckRequestedName());
+    }
+
+    private Element getRMHeaderElement(Document document, String name) throws Exception {
+        return getHeaderElement(document, RMConstants.getNamespace(),  name);
+    }
+
+    private Element getHeaderElement(Document document, String namespace, String localName)
+        throws Exception {
+        Element envelopeElement = document.getDocumentElement();
+        Element headerElement = null;
+        for (Node nd = envelopeElement.getFirstChild(); nd != null; nd = nd.getNextSibling())
{
+            if (Node.ELEMENT_NODE == nd.getNodeType() && "Header".equals(nd.getLocalName()))
{
+                headerElement = (Element)nd;
+                break;
+            }
+        }
+        for (Node nd = headerElement.getFirstChild(); nd != null; nd = nd.getNextSibling())
{ 
+            if (Node.ELEMENT_NODE != nd.getNodeType()) {
+                continue;
+            } 
+            Element element = (Element)nd;
+            String ns = element.getNamespaceURI();
+            String ln = element.getLocalName();
+            if (namespace.equals(ns)
+                && localName.equals(ln)) {
+                return element;
             }
         }
         return null;
     }
     
+    
     public void verifyMessages(int nExpected, boolean outbound) {
         verifyMessages(nExpected, outbound, true);
     }
@@ -406,27 +408,35 @@
                      nExpected, npr);
     }
     
-    public boolean isPartialResponse(SOAPMessage msg) throws Exception {
-        // return null == getAction(ctx) && emptyBody(msg);
+    public boolean isPartialResponse(Document d) throws Exception {
         return false;
     }
     
-    public boolean emptyBody(SOAPMessage msg) throws Exception {
-        return !msg.getSOAPPart().getEnvelope().getBody().hasChildNodes();
+    public boolean emptyBody(Document d) throws Exception {
+        Element envelopeElement = d.getDocumentElement();
+        Element bodyElement = null;
+        for (Node nd = envelopeElement.getFirstChild(); nd != null; nd = nd.getNextSibling())
{
+            if (Node.ELEMENT_NODE == nd.getNodeType() && "Body".equals(nd.getLocalName()))
{
+                bodyElement = (Element)nd;
+                break;
+            }
+        }
+        if (null != bodyElement && bodyElement.hasChildNodes()) {
+            return false;
+        }
+        return true;
     }
-    
+   
+   
     private String outboundDump() {
         StringBuffer buf = new StringBuffer();
         try {
             buf.append(System.getProperty("line.separator"));
-            for (int i = 0; i < outboundMessages.size(); i++) {
-                SOAPMessage sm = outboundMessages.get(i);
+            for (int i = 0; i < outStreams.size(); i++) {
                 buf.append("[");
                 buf.append(i);
                 buf.append("] : ");
-                ByteArrayOutputStream bos = new ByteArrayOutputStream();
-                sm.writeTo(bos);
-                buf.append(bos.toString());
+                buf.append(new String(outStreams.get(i)));
                 buf.append(System.getProperty("line.separator"));
             }
         } catch (Exception ex) {
@@ -434,6 +444,19 @@
         }
         
         return buf.toString();
+    }
+
+    private String getText(Node node) {
+        for (Node nd = node.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
+            if (Node.TEXT_NODE == nd.getNodeType()) {
+                return nd.getNodeValue();
+            }
+        }
+        return null;
+    }
+
+    protected QName getNodeName(Node nd) {
+        return new QName(nd.getNamespaceURI(), nd.getLocalName());
     }
     
 }

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/OutMessageRecorder.java
Wed Nov  8 07:01:23 2006
@@ -19,7 +19,6 @@
 
 package org.apache.cxf.systest.ws.rm;
 
-import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
@@ -28,12 +27,9 @@
 import java.util.List;
 import java.util.Set;
 
-import javax.xml.soap.MessageFactory;
-import javax.xml.soap.SOAPMessage;
 
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.StaxOutInterceptor;
-//import org.apache.cxf.io.AbstractCachedOutputStream;
 import org.apache.cxf.message.Message;
 import org.apache.cxf.phase.AbstractPhaseInterceptor;
 import org.apache.cxf.phase.Phase;
@@ -44,12 +40,11 @@
  */
 public class OutMessageRecorder extends AbstractPhaseInterceptor {
     
-    private List<SOAPMessage> outbound;
+    private List<byte[]> outbound;
     private Set<String> before = Collections.singleton(StaxOutInterceptor.class.getName());
 
     public OutMessageRecorder() {
-        outbound = new ArrayList<SOAPMessage>();
-        //setPhase(Phase.POST_STREAM);
+        outbound = new ArrayList<byte[]>();
         setPhase(Phase.PRE_PROTOCOL);
     }
     
@@ -60,20 +55,6 @@
         }
         ForkOutputStream fos = new ForkOutputStream(os);
         message.setContent(OutputStream.class, fos);
-
-        /*
-        if (os instanceof AbstractCachedOutputStream) {
-            try {
-                String s = ((AbstractCachedOutputStream)os).toString();
-                MessageFactory mf = MessageFactory.newInstance();
-                ByteArrayInputStream bis = new ByteArrayInputStream(s.getBytes()); 
-                SOAPMessage sm = mf.createMessage(null, bis);
-                outbound.add(sm);
-            } catch (Exception ex) {
-                ex.printStackTrace();
-            }
-        }
-        */
     }
    
     @Override
@@ -81,7 +62,8 @@
         return before;
     }
 
-    protected List<SOAPMessage> getOutboundMessages() {
+
+    protected List<byte[]> getOutboundMessages() {
         return outbound;
     } 
 
@@ -91,7 +73,7 @@
     class ForkOutputStream extends OutputStream {
 
         final OutputStream original;
-        final ByteArrayOutputStream bos;
+        ByteArrayOutputStream bos;
     
         public ForkOutputStream(OutputStream o) {
             original = o;
@@ -101,15 +83,8 @@
         @Override
         public void close() throws IOException {
             bos.close();
-            try {
-                MessageFactory mf = MessageFactory.newInstance();
-                ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
-                SOAPMessage sm = mf.createMessage(null, bis);
-                outbound.add(sm);
-            } catch (Exception ex) {
-                ex.printStackTrace();
-            } 
             original.close();
+            outbound.add(bos.toByteArray());
         }
 
         @Override

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java?view=diff&rev=472511&r1=472510&r2=472511
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
(original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/rm/SequenceTest.java
Wed Nov  8 07:01:23 2006
@@ -51,7 +51,8 @@
     private Bus greeterBus;
     private Greeter greeter;
     private String currentCfgResource;
-    private MessageFlow mf;
+    private OutMessageRecorder outRecorder;
+    private InMessageRecorder inRecorder;
 
     private boolean doTestOnewayAnonymousAcks = true;
 
@@ -108,10 +109,12 @@
 
         // three application messages plus createSequence
 
+        MessageFlow mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages());
+
         mf.verifyMessages(4, true);
         String[] expectedActions = new String[] {RMConstants.getCreateSequenceAction(), GREETMEONEWAY_ACTION,
                                                  GREETMEONEWAY_ACTION, GREETMEONEWAY_ACTION};
-        expectedActions = new String[] {RMConstants.getCreateSequenceAction(), "", "", ""};
+        expectedActions = new String[] {RMConstants.getCreateSequenceAction(), null, null,
null};
         mf.verifyActions(expectedActions, true);
         mf.verifyMessageNumbers(new String[] {null, "1", "2", "3"}, true);
 
@@ -121,7 +124,7 @@
         expectedActions = new String[] {RMConstants.getCreateSequenceResponseAction(), null,
null, null};
         mf.verifyActions(expectedActions, false);
         mf.verifyMessageNumbers(new String[] {null, null, null, null}, false);
-        mf.verifyAcknowledgements(new boolean[] {false, false, false, false}, false);
+        mf.verifyAcknowledgements(new boolean[] {false, true, true, true}, false);
     }
 
     // --- test utilities ---
@@ -132,10 +135,10 @@
         greeterBus = bf.createBus(cfgResource);
         bf.setDefaultBus(greeterBus);
 
-        OutMessageRecorder outRecorder = new OutMessageRecorder();
+        outRecorder = new OutMessageRecorder();
         greeterBus.getOutInterceptors().add(new JaxwsInterceptorRemover());
         greeterBus.getOutInterceptors().add(outRecorder);
-        InMessageRecorder inRecorder = new InMessageRecorder();
+        inRecorder = new InMessageRecorder();
         greeterBus.getInInterceptors().add(inRecorder);
         currentCfgResource = cfgResource;
 
@@ -144,7 +147,6 @@
         GreeterService service = new GreeterService();
         greeter = service.getGreeterPort();
  
-        mf = new MessageFlow(outRecorder.getOutboundMessages(), inRecorder.getInboundMessages());
         
         
     }



Mime
View raw message