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 TestAttachment.java
Date Fri, 05 Jul 2002 12:34:50 GMT
dims        2002/07/05 05:34:49

  Modified:    java/src/org/apache/axis/attachments AttachmentPart.java
               java/test/saaj TestAttachment.java
  Log:
  - Fix to make sure that msg.getAttachments(mimeHeaders) works.
  - Added testcase
  
  Revision  Changes    Path
  1.23      +2 -2      xml-axis/java/src/org/apache/axis/attachments/AttachmentPart.java
  
  Index: AttachmentPart.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/attachments/AttachmentPart.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- AttachmentPart.java	3 Jul 2002 17:50:25 -0000	1.22
  +++ AttachmentPart.java	5 Jul 2002 12:34:49 -0000	1.23
  @@ -162,9 +162,9 @@
        * TODO: Am not sure about the logic.
        */
       public boolean matches(javax.xml.soap.MimeHeaders headers) {
  -        for (Iterator i = mimeHeaders.getAllHeaders(); i.hasNext();) {
  +        for (Iterator i = headers.getAllHeaders(); i.hasNext();) {
               javax.xml.soap.MimeHeader hdr = (javax.xml.soap.MimeHeader) i.next();
  -            String values[] = headers.getHeader(hdr.getName());
  +            String values[] = mimeHeaders.getHeader(hdr.getName());
               boolean found = false;
               if (values != null) {
                   for (int j = 0; j < values.length; j++) {
  
  
  
  1.6       +35 -0     xml-axis/java/test/saaj/TestAttachment.java
  
  Index: TestAttachment.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/saaj/TestAttachment.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestAttachment.java	2 Jul 2002 11:31:47 -0000	1.5
  +++ TestAttachment.java	5 Jul 2002 12:34:49 -0000	1.6
  @@ -43,8 +43,43 @@
           assertTrue(message.countAttachments()==0);
       }
   
  +    public void testMultipleAttachments() throws Exception {
  +        SOAPConnectionFactory scFactory = SOAPConnectionFactory.newInstance();
  +        SOAPConnection con = scFactory.createConnection();
  +
  +        MessageFactory factory = MessageFactory.newInstance();
  +        SOAPMessage msg = factory.createMessage();
  +        java.net.URL url1 = new java.net.URL("http://slashdot.org/slashdot.xml");
  +        java.net.URL url2 = new java.net.URL("http://www.apache.org/LICENSE.txt");
  +
  +        AttachmentPart a1 = msg.createAttachmentPart(new javax.activation.DataHandler(url1));
  +        a1.setContentType("text/xml");
  +        msg.addAttachmentPart(a1);
  +        AttachmentPart a2 = msg.createAttachmentPart(new javax.activation.DataHandler(url1));
  +        a2.setContentType("text/xml");
  +        msg.addAttachmentPart(a2);
  +        AttachmentPart a3 = msg.createAttachmentPart(new javax.activation.DataHandler(url2));
  +        a3.setContentType("text/plain");
  +        msg.addAttachmentPart(a3);
  +
  +        assertTrue(msg.countAttachments()==3);
  +
  +        javax.xml.soap.MimeHeaders mimeHeaders = new javax.xml.soap.MimeHeaders();
  +        mimeHeaders.addHeader("Content-Type", "text/xml");
  +
  +        int nAttachments = 0;
  +        java.util.Iterator iterator = msg.getAttachments(mimeHeaders);
  +	    while (iterator.hasNext()) {
  +            nAttachments++;
  +	        AttachmentPart ap = (AttachmentPart)iterator.next();
  +	        assertTrue(ap.equals(a1) || ap.equals(a2));
  +	    }
  +        assertTrue(nAttachments==2);
  +    }
  +
       public static void main(String[] args) throws Exception {
           test.saaj.TestAttachment tester = new test.saaj.TestAttachment("TestSAAJ");
  +        tester.testMultipleAttachments();
           tester.testStringAttachment();
       }
   }
  
  
  

Mime
View raw message