axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/test/message TestMessageElement.java
Date Mon, 03 Mar 2003 15:11:53 GMT
dims        2003/03/03 07:11:52

  Modified:    java/src/org/apache/axis/message MessageElement.java
               java/test/message TestMessageElement.java
  Log:
  1. Fix for Bug 16948 - SOAPElement does not associated with specified prefix
  2. Test case for Bug 16948 from stuart.wheater@arjuna.com (Stuart Wheater)
  
  Revision  Changes    Path
  1.148     +2 -2      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.147
  retrieving revision 1.148
  diff -u -r1.147 -r1.148
  --- MessageElement.java	2 Mar 2003 18:59:38 -0000	1.147
  +++ MessageElement.java	3 Mar 2003 15:11:52 -0000	1.148
  @@ -164,12 +164,12 @@
           this.namespaceURI = namespace;
           this.name = localPart;
           this.prefix = prefix;
  +        addMapping(new Mapping(namespace, prefix));
       }
   
       public MessageElement(Name eltName)
       {
  -        this(eltName.getURI(), eltName.getLocalName());
  -        prefix = eltName.getPrefix();
  +        this(eltName.getLocalName(),eltName.getPrefix(), eltName.getURI());
       }
   
       public MessageElement(String namespace, String localPart, Object value)
  
  
  
  1.11      +45 -0     xml-axis/java/test/message/TestMessageElement.java
  
  Index: TestMessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/message/TestMessageElement.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- TestMessageElement.java	2 Mar 2003 18:59:39 -0000	1.10
  +++ TestMessageElement.java	3 Mar 2003 15:11:52 -0000	1.11
  @@ -70,6 +70,12 @@
   import javax.xml.namespace.QName;
   import javax.xml.soap.Name;
   import javax.xml.soap.SOAPElement;
  +import javax.xml.soap.MessageFactory;
  +import javax.xml.soap.SOAPMessage;
  +import javax.xml.soap.SOAPPart;
  +import javax.xml.soap.SOAPEnvelope;
  +import javax.xml.soap.SOAPBody;
  +import javax.xml.soap.SOAPBodyElement;
   import java.util.Iterator;
   import java.io.StringReader;
   
  @@ -213,6 +219,45 @@
           assertEquals("aNamespace",elem.getNamespaceURI("ns1"));
           assertEquals("ns1",elem.getPrefix("aNamespace"));
       }    
  +    
  +    public void testSOAPElementMessageDoesNotHavePrefix() throws Exception {
  +            String A_TAG = "A";
  +            String A_PREFIX = "a";
  +            String A_NAMESPACE_URI = "http://schemas.com/a";
  +            String AA_TAG = "AA";
  +            String B_TAG = "B";
  +            String B_PREFIX = "b";
  +            String B_NAMESPACE_URI = "http://schemas.com/b";
  +
  +            MessageFactory messageFactory = MessageFactory.newInstance();
  +            SOAPMessage message = messageFactory.createMessage();
  +            SOAPPart part = message.getSOAPPart();
  +            SOAPEnvelope envelope = part.getEnvelope();
  +            SOAPBody body = envelope.getBody();
  +
  +            envelope.getHeader().detachNode();
  +
  +            Name aName = envelope.createName(A_TAG, A_PREFIX, A_NAMESPACE_URI);
  +            SOAPBodyElement aBodyElement = body.addBodyElement(aName);
  +            SOAPElement bElement = aBodyElement.addChildElement(AA_TAG, A_PREFIX);
  +            String data = envelope.toString();
  +
  +            MessageContext ctx = new MessageContext(new AxisClient());
  +            DeserializationContext dser = new DeserializationContextImpl(
  +                    new org.xml.sax.InputSource(new StringReader(data)),
  +                    ctx,
  +                    Message.REQUEST);
  +            dser.parse();
  +            MessageElement elem = dser.getEnvelope().getBodyByName(A_NAMESPACE_URI, A_TAG);
  +            Iterator iterator = elem.getChildElements();
  +            while(iterator.hasNext()){
  +                MessageElement elem2 = (MessageElement)iterator.next();
  +                Name name = elem2.getElementName();
  +                assertEquals(A_NAMESPACE_URI, name.getURI());
  +                assertEquals(AA_TAG, name.getLocalName());
  +            }    
  +    }
  +    
       public static void main(String[] args) throws Exception {
           TestMessageElement tester = new TestMessageElement("TestMessageElement");
           tester.testQNameAttrTest();
  
  
  

Mime
View raw message