cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1150739 - in /cxf/trunk/common/common/src: main/java/org/apache/cxf/staxutils/transform/ test/java/org/apache/cxf/staxutils/ test/java/org/apache/cxf/staxutils/transform/
Date Mon, 25 Jul 2011 15:05:59 GMT
Author: sergeyb
Date: Mon Jul 25 15:05:57 2011
New Revision: 1150739

URL: http://svn.apache.org/viewvc?rev=1150739&view=rev
Log:
[CXF-3681] More tests from Andi and a fix for PartialXMLStreamReader issue

Added:
    cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/PartialXMLStreamReaderTest.java
  (with props)
Modified:
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
    cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
    cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/transform/InTransformReaderTest.java

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java?rev=1150739&r1=1150738&r2=1150739&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/DelegatingNamespaceContext.java
Mon Jul 25 15:05:57 2011
@@ -87,7 +87,6 @@ class DelegatingNamespaceContext impleme
         return prefix;
     }
 
-    @SuppressWarnings("unchecked")
     public Iterator getPrefixes(String ns) {
         return nc.getPrefixes(ns);
     }

Modified: cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java?rev=1150739&r1=1150738&r2=1150739&view=diff
==============================================================================
--- cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
(original)
+++ cxf/trunk/common/common/src/main/java/org/apache/cxf/staxutils/transform/InTransformReader.java
Mon Jul 25 15:05:57 2011
@@ -42,6 +42,7 @@ public class InTransformReader extends D
     private int previousDepth = -1;
     private boolean blockOriginalReader = true;
     private DelegatingNamespaceContext namespaceContext;
+    private boolean appendInProgress;
     
     public InTransformReader(XMLStreamReader reader, 
                              Map<String, String> inMap,
@@ -64,7 +65,8 @@ public class InTransformReader extends D
     }
     
     public int next() throws XMLStreamException {
-        if (currentQName != null) {
+        if (currentQName != null && appendInProgress) {
+            appendInProgress = false;
             return XMLStreamConstants.START_ELEMENT;
         } else if (previousDepth != -1 && previousDepth == getDepth() + 1) {
             previousDepth = -1;
@@ -140,6 +142,7 @@ public class InTransformReader extends D
         QName theName = readCurrentElement();
         QName appendQName = inAppendMap.remove(theName);
         if (appendQName != null) {
+            appendInProgress = true;
             previousDepth = getDepth();
             previousQName = theName;
             currentQName = appendQName;

Added: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/PartialXMLStreamReaderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/PartialXMLStreamReaderTest.java?rev=1150739&view=auto
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/PartialXMLStreamReaderTest.java
(added)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/PartialXMLStreamReaderTest.java
Mon Jul 25 15:05:57 2011
@@ -0,0 +1,90 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.staxutils;
+
+import java.io.ByteArrayOutputStream;
+import java.io.StringReader;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.w3c.dom.Document;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PartialXMLStreamReaderTest extends Assert {
+
+    @Test
+    public void testReader() throws Exception {
+        String test = 
+                "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"

+                + "<soap:Header>"
+                + "<ns2:SoapHeaderIn xmlns:ns4=\"http://cxf.apache.org/transform/fault\"
"
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns=\"http://cxf.apache.org/transform/test\">"
+                + "<ns2:OperationalMode>SIMULATION1</ns2:OperationalMode>"
+                + "<ns2:SomeComplexHeaderType>"
+                + "<ns3:CallerCorrelationId>SomeComplexValue</ns3:CallerCorrelationId>"
+                + "</ns2:SomeComplexHeaderType>"
+                + "</ns2:SoapHeaderIn>"
+                + "</soap:Header>"
+                + "<soap:Body>"
+                + "<TransformTestRequest xmlns=\"http://cxf.apache.org/transform/test\"
"
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns4=\"http://cxf.apache.org/transform/fault\" />"
+                + "</soap:Body></soap:Envelope>";
+        
+        XMLStreamReader reader = 
+            StaxUtils.createXMLStreamReader(new StringReader(test));
+        QName bodyTag = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body");
+        PartialXMLStreamReader filteredReader = new PartialXMLStreamReader(reader, bodyTag);
+        
+        Document doc = StaxUtils.read(filteredReader);
+        
+        assertNotNull(doc);
+        
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bos);
+        StaxUtils.copy(doc, writer);
+        writer.flush();
+        String value = bos.toString();
+        
+        System.out.println("value: " + value);
+        
+        assertTrue(("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"
+                + "<soap:Header>"
+                + "<ns2:SoapHeaderIn xmlns=\"http://cxf.apache.org/transform/test\" "
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns4=\"http://cxf.apache.org/transform/fault\">"
+                + "<ns2:OperationalMode>SIMULATION1</ns2:OperationalMode>"
+                + "<ns2:SomeComplexHeaderType>"
+                + "<ns3:CallerCorrelationId>SomeComplexValue</ns3:CallerCorrelationId>"
+                + "</ns2:SomeComplexHeaderType></ns2:SoapHeaderIn></soap:Header>"
+                + "<soap:Body/>"
+                + "</soap:Envelope>").
+                equals(value.trim()));
+        
+    }
+}
+

Propchange: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/PartialXMLStreamReaderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/PartialXMLStreamReaderTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/transform/InTransformReaderTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/transform/InTransformReaderTest.java?rev=1150739&r1=1150738&r2=1150739&view=diff
==============================================================================
--- cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/transform/InTransformReaderTest.java
(original)
+++ cxf/trunk/common/common/src/test/java/org/apache/cxf/staxutils/transform/InTransformReaderTest.java
Mon Jul 25 15:05:57 2011
@@ -21,13 +21,25 @@ package org.apache.cxf.staxutils.transfo
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.InputStream;
+import java.io.StringReader;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
 
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.staxutils.PartialXMLStreamReader;
 import org.apache.cxf.staxutils.StaxUtils;
+
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -63,6 +75,23 @@ public class InTransformReaderTest exten
     }
     
     @Test
+    public void testTransformAndAppend() throws Exception {
+        InputStream is = new ByteArrayInputStream("<test/>".getBytes());
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
+        reader = new InTransformReader(reader, 
+                                       Collections.singletonMap("test", "test2"),
+                                       Collections.singletonMap("test", "wrapper"), 
+                                       false);
+        
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
+        StaxUtils.copy(reader, bos);
+        String value = bos.toString();
+        System.out.println(value);
+        assertTrue("<wrapper><test2/></wrapper>".equals(value));      
 
+    }
+    
+    
+    @Test
     public void testReadWithSameNamespace() throws Exception {
         InputStream is = new ByteArrayInputStream(
                 ("<test xmlns=\"http://bar\" xmlns:ns1=\"http://foo\">" 
@@ -241,4 +270,253 @@ public class InTransformReaderTest exten
                 + "xmlns:ns4=\"http://cxf.apache.org/transform/fault\"/></soap:Body></ps1:TheEnvelope>").
                 equals(value.trim()));
     }
+    
+    @Test
+    public void testReadPartialWithComplexRequestSameNamespace() throws Exception {
+        InputStream is = new ByteArrayInputStream(
+                ("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"

+                + "<soap:Header>"
+                + "<ns2:SoapHeaderIn xmlns:ns4=\"http://cxf.apache.org/transform/fault\"
"
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns=\"http://cxf.apache.org/transform/test\">"
+                + "<ns2:OperationalMode>SIMULATION1</ns2:OperationalMode>"
+                + "<ns2:SomeComplexHeaderType>"
+                + "<ns3:CallerCorrelationId>SomeComplexValue</ns3:CallerCorrelationId>"
+                + "</ns2:SomeComplexHeaderType>"
+                + "</ns2:SoapHeaderIn>"
+                + "</soap:Header>"
+                + "<soap:Body>"
+                + "<TransformTestRequest xmlns=\"http://cxf.apache.org/transform/test\"
"
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns4=\"http://cxf.apache.org/transform/fault\" />"
+                + "</soap:Body></soap:Envelope>").getBytes());
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
+        
+        Map<String, String> inMap = new HashMap<String, String>();
+        inMap.put("{http://cxf.apache.org/transform/header/element}*", 
+                "{http://cxf.apache.org/transform/header/element}*");
+        
+        reader = new InTransformReader(reader, 
+                                       inMap,
+                                       null, false);
+        
+        QName bodyTag = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body");
+        PartialXMLStreamReader filteredReader = new PartialXMLStreamReader(reader, bodyTag);
+        
+        Document doc = StaxUtils.read(filteredReader);
+        
+        assertNotNull(doc);
+        
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bos);
+        StaxUtils.copy(doc, writer);
+        writer.flush();
+
+        String value = bos.toString();
+        
+        Document docTransformed = DOMUtils.readXml(new StringReader(value));
+        Element env = docTransformed.getDocumentElement();
+        assertEquals("http://schemas.xmlsoap.org/soap/envelope/", env.getNamespaceURI());
+        assertEquals("soap", env.getPrefix());
+        
+        Element header = getElement(env, "http://schemas.xmlsoap.org/soap/envelope/", "Header",
"soap");
+        
+        Element customHeader = getElement(header, "http://cxf.apache.org/transform/header",

+                                          "SoapHeaderIn", "ns2");
+        NamedNodeMap map = customHeader.getAttributes();
+        assertEquals(4, map.getLength());
+        validateAttribute(map, "xmlns", "http://cxf.apache.org/transform/test");
+        validateAttribute(map, "xmlns:ns2", "http://cxf.apache.org/transform/header");
+        validateAttribute(map, "xmlns:ns4", "http://cxf.apache.org/transform/fault");
+        validateAttribute(map, "xmlns:ps1", "http://cxf.apache.org/transform/header/element");
+        
+        Element mode = 
+            getElement(customHeader, "http://cxf.apache.org/transform/header", "OperationalMode",
"ns2");
+        assertEquals("SIMULATION1", mode.getTextContent());
+        Element headerType = 
+            getElement(customHeader, "http://cxf.apache.org/transform/header", 
+                       "SomeComplexHeaderType", "ns2");
+        
+        Element correlationId = 
+            getElement(headerType, "http://cxf.apache.org/transform/header/element", 
+                       "CallerCorrelationId", "ps1");
+        assertEquals("SomeComplexValue", correlationId.getTextContent());
+        getElement(env, "http://schemas.xmlsoap.org/soap/envelope/", "Body", "soap");
+    }
+    
+    @Test
+    public void testPartialReadWithComplexRequestMultipleNamespace() throws Exception {
+        InputStream is = new ByteArrayInputStream(
+                ("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"

+                + "<soap:Header>"
+                + "<ns2:SoapHeaderIn xmlns:ns4=\"http://cxf.apache.org/transform/fault\"
"
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns=\"http://cxf.apache.org/transform/test\">"
+                + "<ns2:OperationalMode>SIMULATION1</ns2:OperationalMode>"
+                + "<ns2:SomeComplexHeaderType>"
+                + "<ns3:CallerCorrelationId>SomeComplexValue</ns3:CallerCorrelationId>"
+                + "</ns2:SomeComplexHeaderType>"
+                + "</ns2:SoapHeaderIn>"
+                + "</soap:Header>"
+                + "<soap:Body>"
+                + "<TransformTestRequest xmlns=\"http://cxf.apache.org/transform/test\"
"
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns4=\"http://cxf.apache.org/transform/fault\" />"
+                + "</soap:Body></soap:Envelope>").getBytes());
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
+        
+        Map<String, String> inMap = new HashMap<String, String>();
+        inMap.put("{http://cxf.apache.org/transform/header/element}*", 
+                "{http://cxf.apache.org/transform/header/otherelement}*");
+        inMap.put("{http://cxf.apache.org/transform/test}*", 
+                "{http://cxf.apache.org/transform/othertest}*");
+        
+        reader = new InTransformReader(reader, 
+                                       inMap,
+                                       null, false);
+        
+        QName bodyTag = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body");
+        PartialXMLStreamReader filteredReader = new PartialXMLStreamReader(reader, bodyTag);
+        
+        Document doc = StaxUtils.read(filteredReader);
+        
+        assertNotNull(doc);
+        
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bos);
+        StaxUtils.copy(doc, writer);
+        writer.flush();
+
+        String value = bos.toString();
+        
+        Document docTransformed = DOMUtils.readXml(new StringReader(value));
+        Element env = docTransformed.getDocumentElement();
+        assertEquals("http://schemas.xmlsoap.org/soap/envelope/", env.getNamespaceURI());
+        assertEquals("soap", env.getPrefix());
+        
+        Element header = getElement(env, "http://schemas.xmlsoap.org/soap/envelope/", "Header",
"soap");
+        
+        Element customHeader = getElement(header, "http://cxf.apache.org/transform/header",

+                                          "SoapHeaderIn", "ns2");
+        NamedNodeMap map = customHeader.getAttributes();
+        assertEquals(4, map.getLength());
+        validateAttribute(map, "xmlns:ps2", "http://cxf.apache.org/transform/othertest");
+        validateAttribute(map, "xmlns:ns2", "http://cxf.apache.org/transform/header");
+        validateAttribute(map, "xmlns:ns4", "http://cxf.apache.org/transform/fault");
+        validateAttribute(map, "xmlns:ps1", "http://cxf.apache.org/transform/header/otherelement");
+        
+        Element mode = 
+            getElement(customHeader, "http://cxf.apache.org/transform/header", "OperationalMode",
"ns2");
+        assertEquals("SIMULATION1", mode.getTextContent());
+        Element headerType = 
+            getElement(customHeader, "http://cxf.apache.org/transform/header", 
+                       "SomeComplexHeaderType", "ns2");
+        
+        Element correlationId = 
+            getElement(headerType, "http://cxf.apache.org/transform/header/otherelement",

+                       "CallerCorrelationId", "ps1");
+        assertEquals("SomeComplexValue", correlationId.getTextContent());
+        getElement(env, "http://schemas.xmlsoap.org/soap/envelope/", "Body", "soap");
+        
+    }
+    
+    @Test
+    public void testPartialReadWithComplexTransformationNamespace() throws Exception {
+        InputStream is = new ByteArrayInputStream(
+                ("<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">"

+                + "<soap:Header>"
+                + "<ns2:SoapHeaderIn xmlns:ns4=\"http://cxf.apache.org/transform/fault\"
"
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns=\"http://cxf.apache.org/transform/test\">"
+                + "<ns2:OperationalMode>SIMULATION1</ns2:OperationalMode>"
+                + "<ns2:SomeComplexHeaderType>"
+                + "<ns3:CallerCorrelationId>SomeComplexValue</ns3:CallerCorrelationId>"
+                + "</ns2:SomeComplexHeaderType>"
+                + "</ns2:SoapHeaderIn>"
+                + "</soap:Header>"
+                + "<soap:Body>"
+                + "<TransformTestRequest xmlns=\"http://cxf.apache.org/transform/test\"
"
+                + "xmlns:ns2=\"http://cxf.apache.org/transform/header\" "
+                + "xmlns:ns3=\"http://cxf.apache.org/transform/header/element\" "
+                + "xmlns:ns4=\"http://cxf.apache.org/transform/fault\" />"
+                + "</soap:Body></soap:Envelope>").getBytes());
+        XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
+        
+        Map<String, String> inMap = new HashMap<String, String>();
+        inMap.put("{http://cxf.apache.org/transform/header/element}*", 
+                "{http://cxf.apache.org/transform/header/otherelement}*");
+        inMap.put("{http://cxf.apache.org/transform/test}*", 
+                "{http://cxf.apache.org/transform/othertest}*");
+        inMap.put("{http://schemas.xmlsoap.org/soap/envelope/}Envelope", 
+                "{http://schemas.xmlsoap.org/soap/envelope/}TheEnvelope");
+        
+        // set the block original reader flag to true
+        reader = new InTransformReader(reader, 
+                                       inMap,
+                                       null, true);
+        
+        QName bodyTag = new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body");
+        PartialXMLStreamReader filteredReader = new PartialXMLStreamReader(reader, bodyTag);
+        
+        Document doc = StaxUtils.read(filteredReader);
+        
+        assertNotNull(doc);
+        
+        ByteArrayOutputStream bos = new ByteArrayOutputStream(); 
+        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(bos);
+        StaxUtils.copy(doc, writer);
+        writer.flush();
+        
+        String value = bos.toString();
+        
+        Document docTransformed = DOMUtils.readXml(new StringReader(value));
+        Element env = docTransformed.getDocumentElement();
+        assertEquals("http://schemas.xmlsoap.org/soap/envelope/", env.getNamespaceURI());
+        assertEquals("ps1", env.getPrefix());
+        assertEquals("TheEnvelope", env.getLocalName());
+        
+        Element header = getElement(env, "http://schemas.xmlsoap.org/soap/envelope/", "Header",
"soap");
+        
+        Element customHeader = getElement(header, "http://cxf.apache.org/transform/header",

+                                          "SoapHeaderIn", "ns2");
+        NamedNodeMap map = customHeader.getAttributes();
+        assertEquals(4, map.getLength());
+        validateAttribute(map, "xmlns:ps3", "http://cxf.apache.org/transform/othertest");
+        validateAttribute(map, "xmlns:ns2", "http://cxf.apache.org/transform/header");
+        validateAttribute(map, "xmlns:ns4", "http://cxf.apache.org/transform/fault");
+        validateAttribute(map, "xmlns:ps2", "http://cxf.apache.org/transform/header/otherelement");
+        
+        Element mode = 
+            getElement(customHeader, "http://cxf.apache.org/transform/header", "OperationalMode",
"ns2");
+        assertEquals("SIMULATION1", mode.getTextContent());
+        Element headerType = 
+            getElement(customHeader, "http://cxf.apache.org/transform/header", 
+                       "SomeComplexHeaderType", "ns2");
+        
+        Element correlationId = 
+            getElement(headerType, "http://cxf.apache.org/transform/header/otherelement",

+                       "CallerCorrelationId", "ps2");
+        assertEquals("SomeComplexValue", correlationId.getTextContent());
+        getElement(env, "http://schemas.xmlsoap.org/soap/envelope/", "Body", "soap");
+        
+    }
+    
+    
+    private Element getElement(Element parent, String namespace, String name, String prefix)
{
+        NodeList list = parent.getElementsByTagNameNS(namespace, name);
+        assertEquals(1, list.getLength());
+        Element el = (Element)list.item(0);
+        assertEquals(prefix, el.getPrefix());
+        return el;
+    }
+    
+    private void validateAttribute(NamedNodeMap map, String name, String value) {
+        Node attr = map.getNamedItem(name);
+        assertEquals(attr.getTextContent(), value);
+    }
 }



Mime
View raw message