gdaniels    2003/02/19 05:37:31

  Modified:    java/test/MSGDispatch TestService.java
                        TestMessageService.java
               java/src/org/apache/axis/description ServiceDesc.java
  Log:
  Explicitly test message-style default namespace echoing.  Confirms
  that this isn't a problem:
  
  http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16666
  
  Revision  Changes    Path
  1.4       +7 -0      xml-axis/java/test/MSGDispatch/TestService.java
  
  Index: TestService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/MSGDispatch/TestService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TestService.java  11 Dec 2002 22:40:14 -0000      1.3
  +++ TestService.java  19 Feb 2003 13:37:31 -0000      1.4
  @@ -114,9 +114,16 @@
           return new Element [] { result };
       }
   
  +    public Element [] testElementEcho(Element [] bodyElems)
  +            throws Exception {
  +        return bodyElems;
  +    }
  +    
       public void testEnvelope(SOAPEnvelope req, SOAPEnvelope resp)
               throws Exception {
           // Throw a header in and echo back.
  +        SOAPBodyElement body = req.getFirstBody();
  +        resp.addBodyElement(body);
           resp.addHeader(new SOAPHeaderElement("http://db.com";, "local", "value"));
       }
   }
  
  
  
  1.3       +46 -3     xml-axis/java/test/MSGDispatch/TestMessageService.java
  
  Index: TestMessageService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/MSGDispatch/TestMessageService.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestMessageService.java   11 Dec 2002 22:40:14 -0000      1.2
  +++ TestMessageService.java   19 Feb 2003 13:37:31 -0000      1.3
  @@ -72,8 +72,10 @@
   import org.apache.axis.utils.XMLUtils;
   import org.w3c.dom.Document;
   
  +import javax.xml.namespace.QName;
   import java.io.ByteArrayInputStream;
   import java.util.Vector;
  +import java.util.Iterator;
   
   /**
    * Test for message style service dispatch.
  @@ -117,7 +119,7 @@
           input[0] = new SOAPBodyElement(doc.getDocumentElement());
           Vector          elems = (Vector) call.invoke( input );
           assertNotNull("Return was null!", elems);
  -        assert("Return had " + elems.size() + " elements (needed 1)",
  +        assertTrue("Return had " + elems.size() + " elements (needed 1)",
                  elems.size() == 1);
           SOAPBodyElement firstBody = (SOAPBodyElement)elems.get(0);
           assertEquals("http://db.com";, firstBody.getNamespaceURI());
  @@ -134,7 +136,7 @@
           input[0] = new SOAPBodyElement(doc.getDocumentElement());
           Vector          elems = (Vector) call.invoke( input );
           assertNotNull("Return was null!", elems);
  -        assert("Return had " + elems.size() + " elements (needed 1)",
  +        assertTrue("Return had " + elems.size() + " elements (needed 1)",
                  elems.size() == 1);
           SOAPBodyElement firstBody = (SOAPBodyElement)elems.get(0);
           assertEquals("http://db.com";, firstBody.getNamespaceURI());
  @@ -145,18 +147,59 @@
           Call call = new Call(new Service());
           call.setTransport(transport);
   
  -        String xml = "<m:testEnvelope xmlns:m=\"http://db.com\";></m:testEnvelope>";
  +        String xml = "<testEnvelope xmlns=\"http://db.com\";></testEnvelope>";
           Document doc = XMLUtils.newDocument(new 
ByteArrayInputStream(xml.getBytes()));
           SOAPBodyElement body = new SOAPBodyElement(doc.getDocumentElement());
           SOAPEnvelope env = new SOAPEnvelope();
           env.addBodyElement(body);
           SOAPEnvelope result = call.invoke( env );
           assertNotNull("Return was null!", result);
  +        
  +        SOAPBodyElement respBody = result.getFirstBody();
  +        assertEquals(new QName("http://db.com";, "testEnvelope"), 
respBody.getQName());
  +        Iterator i = respBody.getNamespacePrefixes();
  +        assertNotNull("No namespace mappings");
  +        assertEquals("Non-default namespace found", "", (String)i.next());
  +        assertTrue("Multiple namespace mappings", !i.hasNext());
  +        
           Vector headers = result.getHeaders();
           assertEquals("Had " + headers.size() + " headers, needed 1", 1, 
headers.size());
           SOAPHeaderElement firstHeader = (SOAPHeaderElement)headers.get(0);
           assertEquals("http://db.com";, firstHeader.getNamespaceURI());
           assertEquals("local", firstHeader.getName());
           assertEquals(firstHeader.getValue(), "value");
  +    }
  +
  +    /**
  +     * Confirm that we get back EXACTLY what we put in when using the
  +     * Element[]/Element[] signature for MESSAGE services.
  +     * 
  +     * @throws Exception
  +     */ 
  +    public void testElementEcho() throws Exception {
  +        Call call = new Call(new Service());
  +        call.setTransport(transport);
  +
  +        // Create a DOM document using a default namespace, since bug
  +        // http://nagoya.apache.org/bugzilla/show_bug.cgi?id=16666 indicated
  +        // that we might have had a problem here.
  +        String xml = "<testElementEcho xmlns=\"http://db.com\";></testElementEcho>";
  +        Document doc = XMLUtils.newDocument(new 
ByteArrayInputStream(xml.getBytes()));
  +        SOAPBodyElement body = new SOAPBodyElement(doc.getDocumentElement());
  +        SOAPEnvelope env = new SOAPEnvelope();
  +        env.addBodyElement(body);
  +        
  +        // Send it along
  +        SOAPEnvelope result = call.invoke( env );
  +        assertNotNull("Return was null!", result);
  +        
  +        // Make sure we get back exactly what we expect, with no extraneous
  +        // namespace mappings
  +        SOAPBodyElement respBody = result.getFirstBody();
  +        assertEquals(new QName("http://db.com";, "testElementEcho"), 
respBody.getQName());
  +        Iterator i = respBody.getNamespacePrefixes();
  +        assertNotNull("No namespace mappings");
  +        assertEquals("Non-default namespace found", "", (String)i.next());
  +        assertTrue("Multiple namespace mappings", !i.hasNext());
       }
   }
  
  
  
  1.72      +3 -5      xml-axis/java/src/org/apache/axis/description/ServiceDesc.java
  
  Index: ServiceDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v
  retrieving revision 1.71
  retrieving revision 1.72
  diff -u -r1.71 -r1.72
  --- ServiceDesc.java  6 Feb 2003 04:16:29 -0000       1.71
  +++ ServiceDesc.java  19 Feb 2003 13:37:31 -0000      1.72
  @@ -503,13 +503,11 @@
               qname2OperationsMap = new HashMap();
               for (Iterator i = operations.iterator(); i.hasNext();) {
                   OperationDesc operationDesc = (OperationDesc) i.next();
  -                ArrayList list =
  -                        (ArrayList)qname2OperationsMap.get(operationDesc.
  -                                                          getElementQName());
  +                QName qname = operationDesc.getElementQName();
  +                ArrayList list = (ArrayList)qname2OperationsMap.get(qname);
                   if (list == null) {
                       list = new ArrayList();
  -                    qname2OperationsMap.put(operationDesc.getElementQName(),
  -                                           list);
  +                    qname2OperationsMap.put(qname, list);
                   }
                   list.add(operationDesc);
               }
  
  
  


Reply via email to