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/saaj TestEnvelope.java
Date Sat, 29 Jun 2002 20:44:54 GMT
dims        2002/06/29 13:44:54

  Modified:    java/src/org/apache/axis/message SOAPFault.java
                        SOAPHeader.java
               java/test/saaj TestEnvelope.java
  Log:
  - Fixes for Faults and Header for SAAJ compliance.
  - Test cases for both.
  
  Revision  Changes    Path
  1.4       +1 -1      xml-axis/java/src/org/apache/axis/message/SOAPFault.java
  
  Index: SOAPFault.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFault.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SOAPFault.java	23 Jun 2002 14:25:51 -0000	1.3
  +++ SOAPFault.java	29 Jun 2002 20:44:53 -0000	1.4
  @@ -169,7 +169,7 @@
        * @return a <CODE>String</CODE> with the fault code
        */
       public String getFaultCode() {
  -        return fault.getFaultCode().toString();
  +        return fault.getFaultCode().getLocalPart();
       }
   
       /**
  
  
  
  1.45      +11 -7     xml-axis/java/src/org/apache/axis/message/SOAPHeader.java
  
  Index: SOAPHeader.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeader.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- SOAPHeader.java	29 Jun 2002 18:05:19 -0000	1.44
  +++ SOAPHeader.java	29 Jun 2002 20:44:53 -0000	1.45
  @@ -131,8 +131,8 @@
           addHeader(headerElement);
           return headerElement;
       }
  -
  -    public Iterator examineHeaderElements(String actor) {
  +    
  +    private Vector findHeaderElements(String actor) {
           Vector results = new Vector();
           Iterator i = headers.iterator();
   
  @@ -146,19 +146,23 @@
                   results.add(header);
               }
           }
  +        return results;
  +    }
   
  -        return results.iterator();
  +    public Iterator examineHeaderElements(String actor) {
  +        return findHeaderElements(actor).iterator();
       }
   
       public Iterator extractHeaderElements(String actor) {
  -        Iterator elts = examineHeaderElements(actor);
  +        Vector results = findHeaderElements(actor);
   
  +        Iterator iterator = results.iterator();
           // Detach the header elements from the header
  -        while (elts.hasNext()) {
  -            ((SOAPHeaderElement)elts.next()).detachNode();
  +        while (iterator.hasNext()) {
  +            ((SOAPHeaderElement)iterator.next()).detachNode();
           }
   
  -        return elts;
  +        return results.iterator();
       }
   
       Vector getHeaders() {
  
  
  
  1.2       +39 -1     xml-axis/java/test/saaj/TestEnvelope.java
  
  Index: TestEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/saaj/TestEnvelope.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestEnvelope.java	29 Jun 2002 19:19:16 -0000	1.1
  +++ TestEnvelope.java	29 Jun 2002 20:44:53 -0000	1.2
  @@ -6,6 +6,9 @@
   import javax.xml.soap.SOAPConnection;
   import javax.xml.soap.SOAPConnectionFactory;
   import javax.xml.soap.SOAPEnvelope;
  +import javax.xml.soap.SOAPFault;
  +import javax.xml.soap.SOAPHeader;
  +import javax.xml.soap.SOAPHeaderElement;
   import javax.xml.soap.SOAPMessage;
   
   public class TestEnvelope extends junit.framework.TestCase {
  @@ -14,13 +17,18 @@
           super(name);
       }
   
  -    public void testAttributes() throws Exception {
  +    private SOAPEnvelope getSOAPEnvelope() throws Exception {
           SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
           SOAPConnection con = scFactory.createConnection();
   
           MessageFactory factory = MessageFactory.newInstance();
           SOAPMessage message = factory.createMessage();
           SOAPEnvelope envelope = message.getSOAPPart().getEnvelope();
  +        return envelope;
  +    }
  +
  +    public void testAttributes() throws Exception {
  +        SOAPEnvelope envelope = getSOAPEnvelope();
           SOAPBody body = envelope.getBody();
   
           Name name1 = envelope.createName("MyAttr1");
  @@ -50,6 +58,34 @@
           assertTrue(foundName1 && foundName2 && foundName3);
       }
   
  +    public void testFaults() throws Exception {
  +        SOAPEnvelope envelope = getSOAPEnvelope();
  +        SOAPBody body = envelope.getBody();
  +        SOAPFault sf = body.addFault();
  +        sf.setFaultCode("myFault");
  +        String fc = sf.getFaultCode();
  +        assertTrue(fc.equals("myFault"));
  +    }
  +
  +    public void testHeaderElements() throws Exception {
  +        SOAPEnvelope envelope = getSOAPEnvelope();
  +        SOAPBody body = envelope.getBody();
  +        SOAPHeader hdr = envelope.getHeader();
  +
  +        SOAPHeaderElement she1 = hdr.addHeaderElement(envelope.createName("foo1", "f1",
"foo1-URI"));
  +        she1.setActor("actor-URI");
  +        java.util.Iterator iterator = hdr.extractHeaderElements("actor-URI");
  +        int cnt = 0;
  +        while (iterator.hasNext()) {
  +            cnt++;
  +            SOAPHeaderElement she = (SOAPHeaderElement) iterator.next();
  +            assertTrue(she.equals(she1));
  +        }
  +        assertTrue(cnt == 1);
  +        iterator = hdr.extractHeaderElements("actor-URI");
  +        assertTrue(!iterator.hasNext());
  +    }
  +
       private int getIteratorCount(java.util.Iterator i) {
           int count = 0;
           while (i.hasNext()) {
  @@ -61,6 +97,8 @@
   
       public static void main(String[] args) throws Exception {
           test.saaj.TestEnvelope tester = new test.saaj.TestEnvelope("TestEnvelope");
  +        tester.testHeaderElements();
  +        tester.testFaults();
           tester.testAttributes();
       }
   }
  
  
  

Mime
View raw message