cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dsosno...@apache.org
Subject svn commit: r1137112 [7/7] - in /cxf/trunk: rt/ws/rm/ rt/ws/rm/src/main/build-resources/ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/feature/ rt/ws/rm/src/main/java/org/apache/cxf/ws/rm/persistence/ rt/ws/rm...
Date Sat, 18 Jun 2011 01:51:04 GMT
Modified: cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java?rev=1137112&r1=1137111&r2=1137112&view=diff
==============================================================================
--- cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java
(original)
+++ cxf/trunk/systests/ws-specs/src/test/java/org/apache/cxf/systest/ws/util/MessageFlow.java
Sat Jun 18 01:51:01 2011
@@ -28,28 +28,34 @@ import javax.xml.namespace.QName;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 import junit.framework.Assert;
 
 import org.apache.cxf.staxutils.StaxUtils;
+import org.apache.cxf.ws.addressing.Names;
 import org.apache.cxf.ws.rm.RMConstants;
 
-
-
 public class MessageFlow extends Assert {
     
+    private final String addressingNamespace;
+    private final String rmNamespace;
     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 {
+    public MessageFlow(List<byte[]> out, List<byte[]> in, String addrns, String
rmns) throws Exception {
+        addressingNamespace = addrns;
+        rmNamespace = rmns;
         inboundMessages = new ArrayList<Document>();
         outboundMessages = new ArrayList<Document>();
         reset(out, in);
     }
     
+    public MessageFlow(List<byte[]> out, List<byte[]> in) throws Exception {
+        this(out, in, Names.WSA_NAMESPACE_NAME, null);
+    }
+    
     public void clear() throws Exception {
         inStreams.clear();
         outStreams.clear();
@@ -80,12 +86,17 @@ public class MessageFlow extends Assert 
         }
     }
     
+    public Document getMessage(int i, boolean outbound) {
+        return outbound ? outboundMessages.get(i) : inboundMessages.get(i);
+    }
+    
     public void verifyActions(String[] expectedActions, boolean outbound) throws Exception
{
 
         assertEquals(expectedActions.length, outbound ? outboundMessages.size() : inboundMessages.size());
 
         for (int i = 0; i < expectedActions.length; i++) {
-            String action = outbound ? getAction(outboundMessages.get(i)) : getAction(inboundMessages.get(i));
+            Document doc = outbound ? outboundMessages.get(i) : inboundMessages.get(i);
+            String action = getAction(doc);
             if (null == expectedActions[i]) {
                 assertNull((outbound ? "Outbound " : "Inbound") + " message " + i
                            + " has unexpected action: " + action, action);
@@ -184,8 +195,8 @@ public class MessageFlow extends Assert 
 
         if (exact) {
             for (int i = 0; i < expectedMessageNumbers.length; i++) {
-                Element e = outbound ? getSequence(outboundMessages.get(i))
-                    : getSequence(inboundMessages.get(i));
+                Document doc = outbound ? outboundMessages.get(i) : inboundMessages.get(i);
+                Element e = getSequence(doc);
                 if (null == expectedMessageNumbers[i]) {
                     assertNull((outbound ? "Outbound" : "Inbound") + " message " + i
                         + " contains unexpected message number ", e);
@@ -310,7 +321,7 @@ public class MessageFlow extends Assert 
     
     public void verifySequenceFault(QName code, boolean outbound, int index) throws Exception
{
         Document d = outbound ? outboundMessages.get(index) : inboundMessages.get(index);
-        assert null != getRMHeaderElement(d, RMConstants.getSequenceFaultName());
+        assert null != getRMHeaderElement(d, RMConstants.SEQUENCE_FAULT_NAME);
     }
     
     public void verifyHeader(QName name, boolean outbound, int index) throws Exception {
@@ -328,7 +339,7 @@ public class MessageFlow extends Assert 
     }
    
     protected String getAction(Document document) throws Exception {
-        Element e = getHeaderElement(document, RMConstants.getAddressingNamespace(), "Action");
+        Element e = getHeaderElement(document, addressingNamespace, "Action");
         if (null != e) {
             return getText(e);
         }
@@ -336,7 +347,7 @@ public class MessageFlow extends Assert 
     }
 
     protected Element getSequence(Document document) throws Exception {
-        return getRMHeaderElement(document, RMConstants.getSequenceName());
+        return getRMHeaderElement(document, RMConstants.SEQUENCE_NAME);
     }
 
     public String getMessageNumber(Element elem) throws Exception {
@@ -358,15 +369,15 @@ public class MessageFlow extends Assert 
     }
 
     protected Element getAcknowledgment(Document document) throws Exception {
-        return getRMHeaderElement(document, RMConstants.getSequenceAckName());
+        return getRMHeaderElement(document, RMConstants.SEQUENCE_ACK_NAME);
     }
     
     private Element getAckRequested(Document document) throws Exception {
-        return getRMHeaderElement(document, RMConstants.getAckRequestedName());
+        return getRMHeaderElement(document, RMConstants.ACK_REQUESTED_NAME);
     }
 
     private Element getRMHeaderElement(Document document, String name) throws Exception {
-        return getHeaderElement(document, RMConstants.getNamespace(),  name);
+        return getHeaderElement(document, rmNamespace, name);
     }
 
     private Element getHeaderElement(Document document, String namespace, String localName)
@@ -427,7 +438,7 @@ public class MessageFlow extends Assert 
         long currentUpper = 0;
         // get the final ack range
         for (Document doc : inboundMessages) {
-            Element e = getRMHeaderElement(doc, RMConstants.getSequenceAckName());
+            Element e = getRMHeaderElement(doc, RMConstants.SEQUENCE_ACK_NAME);
             // let the newer messages take precedence over the older messages in getting
the final range
             if (null != e) {
                 e = getNamedElement(e, "AcknowledgementRange");
@@ -445,7 +456,7 @@ public class MessageFlow extends Assert 
     
 
     // note that this method picks the first match and returns
-    private Element getNamedElement(Element element, String lcname) throws Exception {
+    public static Element getNamedElement(Element element, String lcname) throws Exception
{
         for (Node nd = element.getFirstChild(); nd != null; nd = nd.getNextSibling()) { 
             if (Node.ELEMENT_NODE == nd.getNodeType() && lcname.equals(nd.getLocalName()))
{
                 return (Element)nd;
@@ -453,29 +464,6 @@ public class MessageFlow extends Assert 
         } 
         return null;
     }
-
-    public void verifyCreateSequenceAction(int index, String expiration, boolean outbound)
throws Exception {
-        Document d = outbound ? outboundMessages.get(index) : inboundMessages.get(index);
-
-        String expires = getCreateSequenceExpires(d);
-
-        assertEquals("Unexpected expires-value", expiration, expires);
-    }
-    
-    private String getCreateSequenceExpires(Document document) throws Exception {
-        Element envelopeElement = document.getDocumentElement();
-        QName qname = RMConstants.getCreateSequenceOperationName(); 
-        NodeList nodes = 
-            envelopeElement.getElementsByTagNameNS(qname.getNamespaceURI(), qname.getLocalPart());
-        
-        if (nodes.getLength() == 1) {
-            Element element = getNamedElement((Element)nodes.item(0), "Expires");
-            if (element != null) {
-                return getText(element);
-            }
-        }
-        return null;
-    }
     
     public void purgePartialResponses() throws Exception {
         for (int i = inboundMessages.size() - 1; i >= 0; i--) {
@@ -552,7 +540,7 @@ public class MessageFlow extends Assert 
         return buf.toString();
     }
     
-    private String getText(Node node) {
+    public static String getText(Node node) {
         for (Node nd = node.getFirstChild(); nd != null; nd = nd.getNextSibling()) {
             if (Node.TEXT_NODE == nd.getNodeType()) {
                 return nd.getNodeValue();



Mime
View raw message