You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by wh...@apache.org on 2002/11/07 10:58:01 UTC

cvs commit: xml-axis-wsif/java/test/util WSIFTestRunner.java

whitlock    2002/11/07 01:58:01

  Modified:    java/test/util WSIFTestRunner.java
  Added:       java/test/mime axis.jpg MimeTest.java test.txt Mime.wsdl
                        WSIFFrame.java DeploymentDescriptor.xml
                        MimeImpl.java Mime.java
  Removed:     java/test/proposals/mime axis.jpg MimeTest.java test.txt
                        Mime.wsdl WSIFFrame.java MimeImpl.java Mime.java
                        DeploymentDescriptor.xml
  Log:
  Move mime tests out of proposals
  
  Revision  Changes    Path
  1.1                  xml-axis-wsif/java/test/mime/axis.jpg
  
  	<<Binary file>>
  
  
  1.1                  xml-axis-wsif/java/test/mime/MimeTest.java
  
  Index: MimeTest.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package mime;
  
  import java.awt.Image;
  import java.io.BufferedInputStream;
  import java.io.ByteArrayInputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  import java.io.InputStream;
  import java.util.Arrays;
  
  import javax.activation.DataHandler;
  import javax.activation.FileDataSource;
  import javax.mail.internet.MimeMultipart;
  import javax.swing.ImageIcon;
  import javax.xml.namespace.QName;
  import javax.xml.transform.Source;
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  
  import org.apache.wsif.WSIFMessage;
  import org.apache.wsif.WSIFOperation;
  import org.apache.wsif.WSIFPort;
  import org.apache.wsif.WSIFService;
  import org.apache.wsif.WSIFServiceFactory;
  import org.apache.wsif.util.WSIFPluggableProviders;
  import util.TestUtilities;
  
  /**
   * Junit test for Mime attachments
   * 
   * There should be tests here for...
   * DataHandler, DataSource and other datatypes (not sure of the list)
   * Sync and async
   * rpc-style and doc-style
   * Other mime types
   * Axis and Soap 2.3
   * Soap Http and Jms
   * Does this function make sense for NativeJms, Java, EJB, etc?
   * Sending attachments and receiving them
   * Send or receive a null attachment
   * Sending or receiving an object that extends DataHandler, DataSource, etc
   * 
   * @author Mark Whitlock
   */
  public class MimeTest extends TestCase {
      private final static String wsdlPath =
          TestUtilities.getWsdlPath("java\\test\\mime");
      private final static String wsdlLocation = wsdlPath + "Mime.wsdl";
      private final static String imageLocation = wsdlPath + "axis.jpg";
      private final static String flatfileLocation = wsdlPath + "test.txt";
  
      private final static String SEND_DH = "SEND-DH";
      private final static String RECEIVE_DH = "RECEIVE-DH";
      private final static String SEND_PLAINTEXT = "SEND-PLAINTEXT";
      private final static String RECEIVE_PLAINTEXT = "RECEIVE-PLAINTEXT";
      private final static String BOUNCE_IMAGE = "BOUNCE-IMAGE";
      private final static String BOUNCE_IMAGE2 = "BOUNCE-IMAGE2";
      private final static String BOUNCE_IMAGE3 = "BOUNCE-IMAGE3";
      private final static String SEND_SOURCE = "SEND-SOURCE";
      private final static String RECEIVE_SOURCE = "RECEIVE-SOURCE";
      private final static String SEND_MIMEMULTIPART = "SEND-MIMEMULTIPART";
      private final static String RECEIVE_MIMEMULTIPART = "RECEIVE-MIMEMULTIPART";
  
      /** 
       * Milliseconds to sleep while the user looks at the displayed images.
       */
      private int SLEEPY_TIME = 0;
      
      private final static String[] rhyme =
          { "The owl and the pussy cat went to sea in a beautiful pea-green boat,",
            "They took some honey and plenty of money wrapped up in a five pound note" };
  
      private final boolean SYNC = true;
      private final boolean ASYNC = false;
      
      public MimeTest(String name) {
          super(name);
  
          try {
              SLEEPY_TIME =
                  Integer.parseInt(
                      TestUtilities.getWsifProperty("wsif.displaytime"));
          } finally {
              if (SLEEPY_TIME <= 0)
                  SLEEPY_TIME = 2000;
          }
      }
  
      public static void main(String[] args) {
  	   // TestUtilities.startListeners(TestUtilities.ADDRESSBOOK_LISTENER);	
  	   junit.textui.TestRunner.run (suite());
  	   // TestUtilities.stopListeners();	
      }
  
      public static Test suite() {
          return new TestSuite(MimeTest.class);
      }
  
      public void setUp() {
          TestUtilities.setUpExtensionsAndProviders();
      }
  
      public void testAxisSendHandlerSync() {
          doit("SOAPPort", SEND_DH, SYNC);
      }
  
      public void testAxisReceiveHandlerSync() {
          doit("SOAPPort", RECEIVE_DH, SYNC);
      }
  
      public void testAxisSendPlainTextSync() {
          doit("SOAPPort", SEND_PLAINTEXT, SYNC);
      }
  
      /*
       * public void testAxisReceivePlainTextSync() {
       *    doit("SOAPPort", RECEIVE_PLAINTEXT, SYNC);
       * }
       */
  
      public void testAxisBounceImageSync() {
          doit("SOAPPort", BOUNCE_IMAGE, SYNC);
      }
  
      public void testAxisBounceImage2Sync() {
          doit("SOAPPort", BOUNCE_IMAGE2, SYNC);
      }
  
      public void testAxisBounceImage3Sync() {
          doit("SOAPPort", BOUNCE_IMAGE3, SYNC);
      }
  
      /*
       * public void testAxisSendSourceSync() {
       *     doit("SOAPPort", SEND_SOURCE, SYNC);
       * }
       *
       * public void testAxisReceiveSourceSync() {
       *     doit("SOAPPort", RECEIVE_SOURCE, SYNC);
       * }
       *
       * public void testAxisSendMimeMultipartSync() {
       *     doit("SOAPPort", SEND_MIMEMULTIPART, SYNC);
       * }
       *
       * public void testAxisReceiveMimeMultipartSync() {
       *     doit("SOAPPort", RECEIVE_MIMEMULTIPART, SYNC);
       * }
       */
  
      /*
       * Sending MIME messages using Axis over Jms should be supported 
       * by WSIF, but currently this does not work. I think the problem
       * is that WSIFJmsSender does not set up the necessary headers needed
       * for MIME. I don't know whether these headers can go inline in the
       * message or whether they will have to go as JMS properties which 
       * will then get converted into HTTP headers by the JMS2HTTPBridge.
       * For more information about the headers please see 
       * org.apache.axis.transport.http.HTTPSender. For the moment I have 
       * commented out this Jms test (and omitted other JMS tests like 
       * the async tests) because it fails.
       *
       * public void testAxisJmsSendSync() {
       *   doit("SOAPJMSPort", SEND, SYNC);
       * }
       */
  
      /**
       * doit should probably do the mapTypes() but unfortunately plain text
       * means that Strings are serialized with the JAFDataHandlerSerializer
       * and I can't find a way to differentiate between strings that should
       * be treated as a mime part and those that should not. Basically if I
       * mapTypes(plaintext,String) all Strings get mapped to a DataHandler,
       * and soap on the server looks for a web service that takes a 
       * DataHandler, not a String. So be careful where mapTypes(plaintext,String)
       * is done.
       */
      private void doit(String portName, String cmd, boolean blocking) {
  
          WSIFPluggableProviders.overrideDefaultProvider(
              "http://schemas.xmlsoap.org/wsdl/soap/",
              new org.apache.wsif.providers.soap.apacheaxis
                  .WSIFDynamicProvider_ApacheAxis());
  
          try {
              WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
              WSIFService service =
                  factory.getService(
                      wsdlLocation,
                      null,
                      null,
                      "http://mime/",
                      "Mime");
  
              Mime stub = (Mime) service.getStub(portName, Mime.class);
  
              if (cmd.equals(SEND_DH))
                  send_dh(service,stub);
              else if (cmd.equals(RECEIVE_DH))
                  receive_dh(service,stub);
              else if (cmd.equals(SEND_PLAINTEXT))
                  send_plaintext(service,stub);
              else if (cmd.equals(RECEIVE_PLAINTEXT))
                  receive_plaintext(service,stub);
              else if (cmd.equals(BOUNCE_IMAGE))
                  bounce_image(service,stub);
              else if (cmd.equals(BOUNCE_IMAGE2))
                  bounce_image2(service,stub,portName);
              else if (cmd.equals(BOUNCE_IMAGE3))
                  bounce_image3(service,stub,portName);
              else if (cmd.equals(SEND_SOURCE))
                  send_source(service,stub);
              else if (cmd.equals(RECEIVE_SOURCE))
                  receive_source(service,stub);
              else if (cmd.equals(SEND_MIMEMULTIPART))
                  send_mimemultipart(service,stub);
              else if (cmd.equals(RECEIVE_MIMEMULTIPART))
                  receive_mimemultipart(service,stub);
              else
                  assertTrue(false);
  
          } catch (Exception e) {
              System.err.println(
                  "MimeTest(" + portName + ") caught exception " + e);
              e.printStackTrace();
              assertTrue(false);
          } finally {
              WSIFPluggableProviders.overrideDefaultProvider(
                  "http://schemas.xmlsoap.org/wsdl/soap/",
                  null);
                  
              WSIFFrame.close();
          }
  
      }
  
      private void send_dh(WSIFService service, Mime stub) throws Exception {
          service.mapType(
              new QName("http://mime/", "datahandler"),
              DataHandler.class);
  
          DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
          String buff = stub.dataHandlerToString(dh);
          compareFiles(flatfileLocation, buff);
      }
  
      private void receive_dh(WSIFService service, Mime stub) throws Exception {
          service.mapType(
              new QName("http://mime/", "datahandler"),
              DataHandler.class);
  
          DataHandler dh = stub.stringToDataHandler(rhyme[0]);
          compareFiles(dh, rhyme[0]);
      }
  
      private void send_plaintext(WSIFService service, Mime stub)
          throws Exception {
          service.mapType(
              new QName("http://mime/", "plaintext"),
              String.class);
          String buff = stub.plainTextToString(rhyme[0]);
          assertTrue(rhyme[0].equals(buff));
      }
  
      private void receive_plaintext(WSIFService service, Mime stub)
          throws Exception {
          service.mapType(
              new QName("http://mime/", "plaintext"),
              String.class);
          String buff = stub.stringToPlainText(rhyme[1]);
          assertTrue(rhyme[1].equals(buff));
      }
  
      private void bounce_image(WSIFService service, Mime stub) throws Exception {
          service.mapType(
              new QName("http://mime/", "image"),
              Image.class);
  
          // This blocks until the image is loaded.
          Image im1 = new ImageIcon(imageLocation).getImage();
          WSIFFrame.display(im1,"Original image");
  
          // Could use Image image2 = Toolkit.getDefaultToolkit().getImage("image.gif");
          // which loads the image in the background.
  
          Image im2 = stub.bounceImage(im1);
          WSIFFrame.display(im2,"Bounced image");
  
      	System.out.println("Sleeping");
      	Thread.sleep(SLEEPY_TIME);
      	System.out.println("Woken up");
      }
  
      /**
       * This test does not do any mapTypes() to test that WSIF will 
       * automatically register mime parts as a DataHandler. 
       */
      private void bounce_image2(WSIFService service, Mime stub, String portName)
          throws Exception {
          DataHandler dh1 = new DataHandler(new FileDataSource(imageLocation));
          Image im1 = new ImageIcon(imageLocation).getImage();
          WSIFFrame.display(im1, "Original image");
  
          WSIFPort port = service.getPort(portName);
          WSIFOperation op = port.createOperation("bounceImage2");
          WSIFMessage in = op.createInputMessage();
          WSIFMessage out = op.createOutputMessage();
          WSIFMessage fault = op.createFaultMessage();
          in.setObjectPart("file",dh1);
  
          boolean success = op.executeRequestResponseOperation(in,out,fault);
          assertTrue(success);
  
          DataHandler dh2 = (DataHandler)(out.getObjectPart("file2"));
  
          InputStream is = dh2.getInputStream();
          byte[] bBuff = new byte[is.available()];
          is.read(bBuff);
          Image im2 = new ImageIcon(bBuff).getImage();
          WSIFFrame.display(im2, "Bounced image");
          System.out.println("Sleeping");
          Thread.sleep(SLEEPY_TIME);
          System.out.println("Woken up");
      }
  
      private void bounce_image3(WSIFService service, Mime stub, String portName)
          throws Exception {
          DataHandler dh1 = new DataHandler(new FileDataSource(imageLocation));
          Image im1 = new ImageIcon(imageLocation).getImage();
          WSIFFrame.display(im1, "Original image");
  
          DataHandler dh2 = stub.bounceImage2(dh1);
  
          InputStream is = dh2.getInputStream();
          byte[] bBuff = new byte[is.available()];
          is.read(bBuff);
          Image im2 = new ImageIcon(bBuff).getImage();
          WSIFFrame.display(im2, "Bounced image");
          System.out.println("Sleeping");
          Thread.sleep(SLEEPY_TIME);
          System.out.println("Woken up");
      }
  
      private void send_source(WSIFService service, Mime stub) throws Exception {
              service.mapType(
                  new QName("http://mime/", "source"),
                  Source.class);
  //        String buff = stub.plainTextToString(rhyme[0]);
  //        assertTrue(rhyme[0].equals(buff));
      }
  
      private void receive_source(WSIFService service, Mime stub) throws Exception {
              service.mapType(
                  new QName("http://mime/", "source"),
                  Source.class);
  //        String buff = stub.stringToPlainText(rhyme[1]);
  //        assertTrue(rhyme[1].equals(buff));
      }
  
      private void send_mimemultipart(WSIFService service, Mime stub) throws Exception {
              service.mapType(
                  new QName("http://mime/", "mimemultipart"),
                  MimeMultipart.class);
  //        String buff = stub.plainTextToString(rhyme[0]);
  //        assertTrue(rhyme[0].equals(buff));
      }
  
      private void receive_mimemultipart(WSIFService service, Mime stub) throws Exception {
              service.mapType(
                  new QName("http://mime/", "mimemultipart"),
                  MimeMultipart.class);
  //        String buff = stub.stringToPlainText(rhyme[1]);
  //        assertTrue(rhyme[1].equals(buff));
      }
  
      private boolean compareFiles(DataHandler dh1, DataHandler dh2)
          throws FileNotFoundException, IOException {
          InputStream is1 = dh1.getInputStream();
          InputStream is2 = dh2.getInputStream();
          boolean success = false;
          try {
              success = compareFiles(is1, is2);
          } finally {
              if (null != is1)
                  is1.close();
              if (null != is2)
                  is2.close();
          }
          return success;
      }
  
      private boolean compareFiles(DataHandler dh, String buff)
          throws FileNotFoundException, IOException {
          InputStream is = dh.getInputStream();
          boolean success = false;
          try {
              success = compareFiles(is, buff);
          } finally {
              if (null != is)
                  is.close();
          }
          return success;
      }
  
      private boolean compareFiles(String one, String buff)
          throws FileNotFoundException, IOException {
          BufferedInputStream oneStream = null;
          File f1 = new File(one);
  
          boolean success = false;
          try {
              oneStream =
                  new BufferedInputStream(
                      new FileInputStream(one),
                      buff.length());
              success = compareFiles(oneStream, buff);
          } finally {
              if (null != oneStream)
                  oneStream.close();
          }
          return success;
      }
  
      private boolean compareFiles(InputStream is, String buff)
          throws FileNotFoundException, IOException {
          return compareFiles(is, new ByteArrayInputStream(buff.getBytes()));
      }
      
      private boolean compareFiles(InputStream is1, InputStream is2) 
          throws FileNotFoundException, IOException {
  
          int avail1 = is1.available();
          int avail2 = is2.available();
          if (avail1 != avail2) return false;
          if (avail1==0) return true;
  
          byte[] buff1 = new byte[avail1];
          byte[] buff2 = new byte[avail2];
  
          Arrays.fill(buff1, (byte) 0);
          Arrays.fill(buff2, (byte) 0);
  
          int bread1 = -1;
          int bread2 = -1;
          bread1 = is1.read(buff1, 0, avail1);
          bread2 = is2.read(buff2, 0, avail2);
          String s1 = new String(buff1);
          String s2 = new String(buff2);
          if (!s1.equals(s2))
              return false;
          return true;
      }
      
  }
  
  
  
  1.1                  xml-axis-wsif/java/test/mime/test.txt
  
  Index: test.txt
  ===================================================================
  Hello Mark!
  
  
  1.1                  xml-axis-wsif/java/test/mime/Mime.wsdl
  
  Index: Mime.wsdl
  ===================================================================
  <?xml version="1.0" ?>
  
  <definitions targetNamespace="http://mime/"
               xmlns:tns="http://mime/"
               xmlns:xsd="http://www.w3.org/1999/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
               xmlns:jms="http://schemas.xmlsoap.org/wsdl/jms/"
               xmlns:format="http://schemas.xmlsoap.org/wsdl/formatbinding/"
               xmlns:java="http://schemas.xmlsoap.org/wsdl/java/"
               xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
               xmlns="http://schemas.xmlsoap.org/wsdl/">
  
    <message name="DataHandlerMessage">
      <part name="file" type="tns:datahandler"/>
    </message>
  
    <message name="DataHandler2Message">
      <part name="file2" type="tns:datahandler"/>
    </message>
  
    <message name="PlainTextMessage">
      <part name="plaintext" type="tns:plaintext"/>
    </message>
  
    <message name="Image1Message">
      <part name="image1" type="tns:image"/>
    </message>
  
    <message name="Image2Message">
      <part name="image2" type="tns:image"/>
    </message>
  
    <message name="StringMessage">
      <part name="buff" type="xsd:string"/>
    </message>
  
    <!-- port type declns -->
    <portType name="Mime">
      <operation name="dataHandlerToString">
        <input message="tns:DataHandlerMessage"/>
        <output message="tns:StringMessage"/>
      </operation>
      <operation name="stringToDataHandler">
        <input message="tns:StringMessage"/>
        <output message="tns:DataHandlerMessage"/>
      </operation>
      <operation name="plainTextToString">
        <input message="tns:PlainTextMessage"/>
        <output message="tns:StringMessage"/>
      </operation>
      <operation name="stringToPlainText">
        <input message="tns:StringMessage"/>
        <output message="tns:PlainTextMessage"/>
      </operation>
      <operation name="bounceImage">
        <input message="tns:Image1Message"/>
        <output message="tns:Image2Message"/>
      </operation>
      <operation name="bounceImage2">
        <input message="tns:DataHandlerMessage"/>
        <output message="tns:DataHandler2Message"/>
      </operation>
    </portType>
  
    <!-- binding declns -->
    <binding name="SOAPHttpBinding" type="tns:Mime">
      <soap:binding style="rpc"
                    transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="dataHandlerToString">
        <soap:operation soapAction=""/>
        <input>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file" type="text/html"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
      <operation name="stringToDataHandler">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file" type="text/html"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </output>
      </operation>
      <operation name="plainTextToString">
        <soap:operation soapAction=""/>
        <input>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="plaintext" type="text/plain"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
      <operation name="stringToPlainText">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="plaintext" type="text/plain"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </output>
      </operation>
      <operation name="bounceImage">
        <soap:operation soapAction=""/>
        <input>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="image1" type="image/jpeg"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </input>
        <output>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="image2" type="image/jpeg"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </output>
      </operation>
      <operation name="bounceImage2">
        <soap:operation soapAction=""/>
        <input>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file" type="image/jpeg"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </input>
        <output>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file2" type="image/jpeg"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </output>
      </operation>
    </binding>
  
    <!-- binding name="SOAPJmsBinding" type="tns:Mime">
      <soap:binding style="rpc"
                    transport="http://schemas.xmlsoap.org/soap/jms"/>
      <operation name="dataHandlerToString">
        <soap:operation soapAction=""/>
        <input>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file" type="text/html"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
      <operation name="stringToDataHandler">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file" type="text/html"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </output>
      </operation>
      <operation name="dataSourceToString">
        <soap:operation soapAction=""/>
        <input>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file" type="text/html"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
      <operation name="stringToDataSource">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="http://mime/"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <mime:multipartRelated>
            <mime:part>
              <mime:content part="file" type="text/html"/>
              <soap:body use="encoded"
                         namespace="http://mime/"
                         encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
            </mime:part>
          </mime:multipartRelated> 
        </output>
      </operation>
    </binding -->
  
    <!-- service decln -->
    <service name="MimeService">
      <port name="SOAPPort" binding="tns:SOAPHttpBinding">
        <soap:address location="http://localhost:8080/soap/servlet/rpcrouter"/>
      </port>
      <!-- port name="SOAPJMSPort" binding="tns:SOAPJmsBinding">
        <jms:address jndiDestinationName="SoapJmsAddressBookQueue"
                     destinationStyle="queue"
                     jndiConnectionFactoryName="WSIFSampleQCF"
                     initialContextFactory="com.sun.jndi.fscontext.RefFSContextFactory"
                     jndiProviderURL="file:///JNDI-Directory"/>
      </port -->
    </service>
  
  </definitions>
  
  
  1.1                  xml-axis-wsif/java/test/mime/WSIFFrame.java
  
  Index: WSIFFrame.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package mime;
  
  import java.awt.Canvas;
  import java.awt.Frame;
  import java.awt.Graphics;
  import java.awt.Image;
  
  public class WSIFFrame extends Frame {
      private static Frame[] frames = new Frame[2];
      private static int frameIndex = 0;
      private Image im = null;
  
      public static void display(Image im, String title) throws Exception {
          Frame f = new WSIFFrame(im,title);
          frames[frameIndex] = f;
          frameIndex++;
          f.add(new WSIFCanvas(im));
          f.pack();
          f.setLocation(300*frameIndex,200);
          f.show();
      }
  
      public WSIFFrame(Image im, String title) {
          super(title);
          this.im = im;
      }
  
  
      public static void close() {
          for (int i = 0; i < frameIndex; i++) {
              frames[i].dispose();
              frames[i] = null;
          }
          frameIndex=0;
      }
      
      public void finalize() throws Throwable {
          for (int i = 0; i < frameIndex; i++) {
              frames[i].dispose();
              frames[i] = null;
          }
          frameIndex=0;
      }
      
      static class WSIFCanvas extends Canvas {
          Image im;
  
          WSIFCanvas(Image im) {
              super();
              this.setSize(200,200);
              this.im = im;
          }
  
          public void paint(Graphics g) {
              g.drawImage(im, 0, 0, this);
          }
      }
  }
  
  
  
  
  1.1                  xml-axis-wsif/java/test/mime/DeploymentDescriptor.xml
  
  Index: DeploymentDescriptor.xml
  ===================================================================
  <isd:service xmlns:isd="http://xml.apache.org/xml-soap/deployment"
               id="http://mime/">
    <isd:provider type="java"
                  scope="Application"
                  methods="dataHandlerToString stringToDataHandler plainTextToString stringToPlainText bounceImage bounceImage2">
      <isd:java class="mime.MimeImpl" static="false"/>
    </isd:provider>
  
    <isd:faultListener>org.apache.soap.server.DOMFaultListener</isd:faultListener>
  
    <isd:mappings>
      <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
            xmlns:x="http://mime/" 
            qname="x:datahandler" 
            javaType="javax.activation.DataHandler" 
            java2XMLClassName="org.apache.soap.encoding.soapenc.MimePartSerializer" 
            xml2JavaClassName="org.apache.soap.encoding.soapenc.MimePartSerializer" /> 
      <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 
            xmlns:x="http://mime/" 
            qname="x:datasource" 
            javaType="javax.activation.DataSource" 
            java2XMLClassName="org.apache.soap.encoding.soapenc.MimePartSerializer" 
            xml2JavaClassName="org.apache.soap.encoding.soapenc.MimePartSerializer" /> 
    </isd:mappings>    
  </isd:service>
  
  
  1.1                  xml-axis-wsif/java/test/mime/MimeImpl.java
  
  Index: MimeImpl.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package mime;
  
  import java.awt.Image;
  import java.io.File;
  import java.io.IOException;
  import java.io.InputStream;
  
  import javax.activation.DataHandler;
  import javax.activation.FileDataSource;
  import javax.swing.ImageIcon;
  
  import util.TestUtilities;
  
  /**
   * Mime service used by MimeTest 
   * @author Mark Whitlock
   */
  public class MimeImpl {
  
      public String dataHandlerToString(DataHandler dh) {
          try {
              InputStream is = dh.getInputStream();
              byte[] bBuff = new byte[is.available()];
              is.read(bBuff);
              String sBuff = new String(bBuff);
              return sBuff;
          } catch (IOException ioe) {
              ioe.printStackTrace();
              return null;
          }
      }
  
      public DataHandler stringToDataHandler(String buff) {
          try {
              FileDataSource fds = getTempFile();
              fds.getOutputStream().write(buff.getBytes());
              DataHandler dh = new DataHandler(fds);
              return dh;
          } catch (IOException ioe) {
              ioe.printStackTrace();
              return null;
          }
      }
  
      public String plainTextToString(DataHandler ds) {
          try {
              InputStream is = ds.getInputStream();
              byte[] bBuff = new byte[is.available()];
              is.read(bBuff);
              String sBuff = new String(bBuff);
              return sBuff;
          } catch (IOException ioe) {
              ioe.printStackTrace();
              return null;
          }
      }
  
      public DataHandler stringToPlainText(String buff) {
          try {
              FileDataSource fds = getTempFile();
              fds.getOutputStream().write(buff.getBytes());
              return new DataHandler(fds);
          } catch (IOException ioe) {
              ioe.printStackTrace();
              return null;
          }
      }
  
      public DataHandler bounceImage(DataHandler ds) {
          try {
              InputStream is = ds.getInputStream();
              byte[] bBuff = new byte[is.available()];
              is.read(bBuff);
  
  //            Image im = new ImageIcon(bBuff).getImage();
  //            WSIFFrame.display(im, "Backend image");
  //            int t = 0;
  //            try {
  //                t = Integer.parseInt(
  //                    TestUtilities.getWsifProperty("wsif.displaytime"));
  //            } finally {
  //                if (t <= 0)
  //                    t = 2000;
  //            }
  //            Thread.sleep(t);
  
              FileDataSource fds = getTempFile();
              fds.getOutputStream().write(bBuff);
              return new DataHandler(fds);
          } catch (Exception e) {
              e.printStackTrace();
              return null;
          } finally {
              WSIFFrame.close();
          }
      }
  
      public DataHandler bounceImage2(DataHandler ds) {
          return bounceImage(ds);
      }
  
      private FileDataSource getTempFile() throws IOException {
          File f = File.createTempFile("WSIFMimeTest", "txt");
          f.deleteOnExit();
          return new FileDataSource(f);
      }
  }
  
  
  
  1.1                  xml-axis-wsif/java/test/mime/Mime.java
  
  Index: Mime.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2002 The Apache Software Foundation.  All rights 
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer. 
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:  
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "WSIF" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written 
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2001, 2002, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package mime;
  
  import java.awt.Image;
  
  import javax.activation.DataHandler;
  
  public interface Mime {
      public String dataHandlerToString(DataHandler dh);
      public DataHandler stringToDataHandler(String buff);
  
      public String plainTextToString(String s);
      public String stringToPlainText(String buff);
  
      public Image bounceImage(Image im);
      public DataHandler bounceImage2(DataHandler dh);
  
  //    public String dataSourceToString(DataSource ds);
  //    public DataSource stringToDataSource(String buff);
  //
  //    public String dataSourceToString(DataSource ds);
  //    public DataSource stringToDataSource(String buff);
  //
  //    public String dataSourceToString(DataSource ds);
  //    public DataSource stringToDataSource(String buff);
  }
  
  
  
  1.18      +1 -1      xml-axis-wsif/java/test/util/WSIFTestRunner.java
  
  Index: WSIFTestRunner.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/test/util/WSIFTestRunner.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- WSIFTestRunner.java	21 Oct 2002 09:48:19 -0000	1.17
  +++ WSIFTestRunner.java	7 Nov 2002 09:58:01 -0000	1.18
  @@ -68,7 +68,7 @@
   import junit.framework.Test;
   import junit.framework.TestSuite;
   
  -import proposals.mime.MimeTest;
  +import mime.MimeTest;
   import providers.PlugableProvidersTest;
   import providers.ProvidersInitialisationTest;
   import shop.ShoppingCartTest;