whitlock 2002/11/11 07:36:04
Modified: java/test/mime MimeTest.java Mime.wsdl
DeploymentDescriptor.xml MimeImpl.java Mime.java
java/test wsif.test.properties
java/src/org/apache/wsif/providers/soap/apacheaxis
WSIFOperation_ApacheAxis.java
WSIFPort_ApacheAxis.java
java/test/util WSIFTestRunner.java
Added: java/test/mime test2.txt
Log:
More mime fixes
Revision Changes Path
1.2 +285 -57 xml-axis-wsif/java/test/mime/MimeTest.java
Index: MimeTest.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/MimeTest.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MimeTest.java 7 Nov 2002 09:58:00 -0000 1.1
+++ MimeTest.java 11 Nov 2002 15:36:04 -0000 1.2
@@ -77,6 +77,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.wsif.WSIFException;
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
@@ -99,6 +100,8 @@
* Sending attachments and receiving them
* Send or receive a null attachment
* Sending or receiving an object that extends DataHandler, DataSource, etc
+ * Multiple mime parts, multiple soap bodies, or no soap body at all.
+ * Is the Mime type that is specified in the WSDL passed into Axis?
*
* @author Mark Whitlock
*/
@@ -108,6 +111,7 @@
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 flatfileLocation2 = wsdlPath + "test2.txt";
private final static String SEND_DH = "SEND-DH";
private final static String RECEIVE_DH = "RECEIVE-DH";
@@ -116,10 +120,23 @@
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 BOUNCE_IMAGE4_DEFAULT = "BOUNCE-IMAGE4-DEFAULT";
+ private final static String BOUNCE_IMAGE4_FALSE = "BOUNCE-IMAGE4-FALSE";
+ private final static String BOUNCE_IMAGE4_NULL = "BOUNCE-IMAGE4-NULL";
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";
+ private final static String NO_SOAP_BODY = "NO-SOAP-BODY";
+ private final static String MULTIPARTS1 = "MULTIPARTS1";
+ private final static String MULTIPARTS2 = "MULTIPARTS2";
+ private final static String MULTIPARTS3 = "MULTIPARTS3";
+ private final static String NESTED = "NESTED";
+ private final static String BAD_NO_TYPE = "BAD-NO-TYPE";
+ private final static String BAD_NO_PART = "BAD-NO-PART";
+ private final static String BAD_NO_CONTENT = "BAD-NO-CONTENT";
+ private final static String BAD_TYPE = "BAD-TYPE";
+ private final static String BAD_PART = "BAD-PART";
/**
* Milliseconds to sleep while the user looks at the displayed images.
@@ -190,40 +207,102 @@
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);
- * }
- */
+ public void testAxisBounceImage4Default() {
+ doit("SOAPPort", BOUNCE_IMAGE4_DEFAULT, 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);
- * }
- */
+// public void testAxisBounceImage4False() {
+// doit("SOAPPort", BOUNCE_IMAGE4_FALSE, SYNC);
+// }
+//
+// public void testAxisBounceImage4Null() {
+// doit("SOAPPort", BOUNCE_IMAGE4_NULL, SYNC);
+// }
+//
+// /*
+// * bounceImage5 doesn't work because the soap:body (which contains a
+// * boolean) is within the mime:part. bounceImage4 works because the
+// * soap:body is a direct child of the binding input. When I try to
+// * run bounceImage5, WSDL4J says the soap:body doesn't contain any
+// * parts. But having the soap:body inside the mime:part is valid WSDL
+// * (according to the wsdl4j PopulatedExtensionRegistry). So what does
+// * it mean?
+// */
+//
+// /*
+// * 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);
+// * }
+// */
+//
+// public void testAxisNoSoapBody() {
+// doit("SOAPPort", NO_SOAP_BODY, SYNC);
+// }
+//
+// public void testAxisMultiParts1() {
+// doit("SOAPPort", MULTIPARTS1, SYNC);
+// }
+//
+// public void testAxisMultiParts2() {
+// doit("SOAPPort", MULTIPARTS2, SYNC);
+// }
+//
+// public void testAxisMultiParts3() {
+// doit("SOAPPort", MULTIPARTS3, SYNC);
+// }
+//
+// public void testAxisNested() {
+// doit("SOAPPort", NESTED, SYNC);
+// }
+//
+// public void testAxisBadNoType() {
+// doit("SOAPPort", BAD_NO_TYPE, SYNC);
+// }
+//
+// public void testAxisBadNoPart() {
+// doit("SOAPPort", BAD_NO_PART, SYNC);
+// }
+//
+// public void testAxisBadNoContent() {
+// doit("SOAPPort", BAD_NO_CONTENT, SYNC);
+// }
+//
+// public void testAxisBadType() {
+// doit("SOAPPort", BAD_TYPE, SYNC);
+// }
+//
+// public void testAxisBadPart() {
+// doit("SOAPPort", BAD_PART, SYNC);
+// }
/**
* doit should probably do the mapTypes() but unfortunately plain text
@@ -236,7 +315,9 @@
* is done.
*/
private void doit(String portName, String cmd, boolean blocking) {
-
+ if (!TestUtilities.areWeTesting("mime"))
+ return;
+
WSIFPluggableProviders.overrideDefaultProvider(
"http://schemas.xmlsoap.org/wsdl/soap/",
new org.apache.wsif.providers.soap.apacheaxis
@@ -268,6 +349,12 @@
bounce_image2(service,stub,portName);
else if (cmd.equals(BOUNCE_IMAGE3))
bounce_image3(service,stub,portName);
+ else if (cmd.equals(BOUNCE_IMAGE4_DEFAULT))
+ bounce_image4_default(service,stub,portName);
+ else if (cmd.equals(BOUNCE_IMAGE4_FALSE))
+ bounce_image4_false(service,stub,portName);
+ else if (cmd.equals(BOUNCE_IMAGE4_NULL))
+ bounce_image4_null(service,stub,portName);
else if (cmd.equals(SEND_SOURCE))
send_source(service,stub);
else if (cmd.equals(RECEIVE_SOURCE))
@@ -276,6 +363,26 @@
send_mimemultipart(service,stub);
else if (cmd.equals(RECEIVE_MIMEMULTIPART))
receive_mimemultipart(service,stub);
+ else if (cmd.equals(NO_SOAP_BODY))
+ no_soap_body(service,stub);
+ else if (cmd.equals(MULTIPARTS1))
+ multiparts(service,stub);
+ else if (cmd.equals(MULTIPARTS2))
+ multiparts(service,stub);
+ else if (cmd.equals(MULTIPARTS3))
+ multiparts(service,stub);
+ else if (cmd.equals(NESTED))
+ nested(service,stub);
+ else if (cmd.equals(BAD_NO_TYPE))
+ bad_no_type(service,stub);
+ else if (cmd.equals(BAD_NO_PART))
+ bad_no_part(service,stub);
+ else if (cmd.equals(BAD_NO_CONTENT))
+ bad_no_content(service,stub);
+ else if (cmd.equals(BAD_PART))
+ bad_part(service,stub);
+ else if (cmd.equals(BAD_TYPE))
+ bad_type(service,stub);
else
assertTrue(false);
@@ -301,7 +408,7 @@
DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
String buff = stub.dataHandlerToString(dh);
- compareFiles(flatfileLocation, buff);
+ assertTrue(compareFiles(flatfileLocation, buff));
}
private void receive_dh(WSIFService service, Mime stub) throws Exception {
@@ -310,7 +417,7 @@
DataHandler.class);
DataHandler dh = stub.stringToDataHandler(rhyme[0]);
- compareFiles(dh, rhyme[0]);
+ assertTrue(compareFiles(dh, rhyme[0]));
}
private void send_plaintext(WSIFService service, Mime stub)
@@ -358,8 +465,6 @@
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");
@@ -373,32 +478,40 @@
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");
+// InputStream is = dh2.getInputStream();
+// byte[] bBuff = new byte[is.available()];
+// is.read(bBuff);
+// Image im = new ImageIcon(bBuff).getImage();
+// WSIFFrame.display(im,"Image");
+
+ assertTrue(compareFiles(dh1,dh2));
}
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);
+ assertTrue(compareFiles(dh1,dh2));
+ }
+
+ private void bounce_image4_default(WSIFService service, Mime stub, String
portName)
+ throws Exception {
+ DataHandler dh1 = new DataHandler(new FileDataSource(imageLocation));
+ DataHandler dh2 = stub.bounceImage4(dh1, true);
+ assertTrue(compareFiles(dh1,dh2));
+ }
- 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_image4_false(WSIFService service, Mime stub, String
portName)
+ throws Exception {
+ DataHandler dh1 = new DataHandler(new FileDataSource(imageLocation));
+ DataHandler dh2 = stub.bounceImage4(dh1, false);
+ assertTrue(dh2==null);
+ }
+
+ private void bounce_image4_null(WSIFService service, Mime stub, String portName)
+ throws Exception {
+ DataHandler dh2 = stub.bounceImage4(null, true);
+ assertTrue(dh2==null);
}
private void send_source(WSIFService service, Mime stub) throws Exception {
@@ -407,6 +520,7 @@
Source.class);
// String buff = stub.plainTextToString(rhyme[0]);
// assertTrue(rhyme[0].equals(buff));
+ assertTrue(false);
}
private void receive_source(WSIFService service, Mime stub) throws Exception {
@@ -415,6 +529,7 @@
Source.class);
// String buff = stub.stringToPlainText(rhyme[1]);
// assertTrue(rhyme[1].equals(buff));
+ assertTrue(false);
}
private void send_mimemultipart(WSIFService service, Mime stub) throws
Exception {
@@ -423,6 +538,7 @@
MimeMultipart.class);
// String buff = stub.plainTextToString(rhyme[0]);
// assertTrue(rhyme[0].equals(buff));
+ assertTrue(false);
}
private void receive_mimemultipart(WSIFService service, Mime stub) throws
Exception {
@@ -431,8 +547,89 @@
MimeMultipart.class);
// String buff = stub.stringToPlainText(rhyme[1]);
// assertTrue(rhyme[1].equals(buff));
+ assertTrue(false);
+ }
+
+ private void no_soap_body(WSIFService service, Mime stub) throws Exception {
+ stub.noSoapBody(new DataHandler(new FileDataSource(imageLocation)));
}
+ private void multiparts(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh1 = new DataHandler(new FileDataSource(flatfileLocation));
+ DataHandler dh2 = new DataHandler(new FileDataSource(flatfileLocation2));
+ String buff = stub.multiParts(dh1,dh2);
+
+ assertTrue(concat(flatfileLocation, flatfileLocation2).equals(buff));
+ }
+
+ private void nested(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
+ String buff = stub.nested(dh);
+ assertTrue(compareFiles(flatfileLocation, buff));
+ }
+
+ private void bad_no_type(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
+ boolean exceptionCaught = false;
+ try {
+ String buff = stub.badNoType(dh);
+ } catch (WSIFException we) {
+ exceptionCaught = true;
+ System.out.println("Expected exception="+we);
+ }
+ assertTrue(exceptionCaught);
+ }
+
+ private void bad_no_part(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
+ boolean exceptionCaught = false;
+ try {
+ String buff = stub.badNoPart(dh);
+ } catch (WSIFException we) {
+ exceptionCaught = true;
+ System.out.println("Expected exception="+we);
+ }
+ assertTrue(exceptionCaught);
+ }
+
+ private void bad_no_content(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
+ boolean exceptionCaught = false;
+ try {
+ String buff = stub.badNoContent(dh);
+ } catch (WSIFException we) {
+ exceptionCaught = true;
+ System.out.println("Expected exception="+we);
+ }
+ assertTrue(exceptionCaught);
+ }
+
+ private void bad_part(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
+ boolean exceptionCaught = false;
+ try {
+ String buff = stub.badPart(dh);
+ } catch (WSIFException we) {
+ exceptionCaught = true;
+ System.out.println("Expected exception="+we);
+ }
+ assertTrue(exceptionCaught);
+ }
+
+ private void bad_type(WSIFService service, Mime stub) throws Exception {
+ DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
+ boolean exceptionCaught = false;
+ try {
+ String buff = stub.badType(dh);
+ } catch (WSIFException we) {
+ exceptionCaught = true;
+ System.out.println("Expected exception="+we);
+ }
+ assertTrue(exceptionCaught);
+ }
+
+ /*********************************************************************/
+
private boolean compareFiles(DataHandler dh1, DataHandler dh2)
throws FileNotFoundException, IOException {
InputStream is1 = dh1.getInputStream();
@@ -511,4 +708,35 @@
return true;
}
+ private String concat(String one, String two)
+ throws FileNotFoundException, IOException {
+ InputStream is1 = null;
+ InputStream is2 = null;
+ try {
+ is1 = (new DataHandler(new FileDataSource(one))).getInputStream();
+ is2 = (new DataHandler(new FileDataSource(two))).getInputStream();
+ int avail1 = is1.available();
+ int avail2 = is2.available();
+
+ 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);
+ return s1 + s2;
+
+ } finally {
+ if (null != is1)
+ is1.close();
+ if (null != is2)
+ is2.close();
+ }
+ }
}
1.2 +295 -0 xml-axis-wsif/java/test/mime/Mime.wsdl
Index: Mime.wsdl
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/Mime.wsdl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Mime.wsdl 7 Nov 2002 09:58:00 -0000 1.1
+++ Mime.wsdl 11 Nov 2002 15:36:04 -0000 1.2
@@ -34,6 +34,16 @@
<part name="buff" type="xsd:string"/>
</message>
+ <message name="BounceImage4Message">
+ <part name="file" type="tns:datahandler"/>
+ <part name="shouldBounce" type="xsd:boolean"/>
+ </message>
+
+ <message name="MultiMimePartsMessage">
+ <part name="file" type="tns:datahandler"/>
+ <part name="file2" type="tns:datahandler"/>
+ </message>
+
<!-- port type declns -->
<portType name="Mime">
<operation name="dataHandlerToString">
@@ -60,6 +70,53 @@
<input message="tns:DataHandlerMessage"/>
<output message="tns:DataHandler2Message"/>
</operation>
+ <operation name="bounceImage4">
+ <input message="tns:BounceImage4Message"/>
+ <output message="tns:DataHandler2Message"/>
+ </operation>
+ <operation name="bounceImage5">
+ <input message="tns:BounceImage4Message"/>
+ <output message="tns:DataHandler2Message"/>
+ </operation>
+ <operation name="noSoapBody">
+ <input message="tns:DataHandlerMessage"/>
+ </operation>
+ <operation name="multiMimeParts1">
+ <input message="tns:MultiMimePartsMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
+ <operation name="multiMimeParts2">
+ <input message="tns:MultiMimePartsMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
+ <!--operation name="multiMimeParts3">
+ <input message="tns:MultiMimePartsMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation-->
+ <operation name="nested">
+ <input message="tns:DataHandlerMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
+ <operation name="badNoType">
+ <input message="tns:DataHandlerMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
+ <operation name="badNoPart">
+ <input message="tns:DataHandlerMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
+ <operation name="badNoContent">
+ <input message="tns:DataHandlerMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
+ <operation name="badType">
+ <input message="tns:DataHandlerMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
+ <operation name="badPart">
+ <input message="tns:DataHandlerMessage"/>
+ <output message="tns:StringMessage"/>
+ </operation>
</portType>
<!-- binding declns -->
@@ -182,6 +239,244 @@
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</mime:part>
</mime:multipartRelated>
+ </output>
+ </operation>
+
+ <!-- bounceImage4 takes a boolean as well as an image. The boolean says
+ whether the image should be returned. This allows us to test mixing
+ soap and mime parts, and passing and returning null attachments -->
+ <operation name="bounceImage4">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="image/jpeg"/>
+ </mime:part>
+ </mime:multipartRelated>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file2" type="image/jpeg"/>
+ </mime:part>
+ </mime:multipartRelated>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+
+ <!-- bounceImage5 doesn't work because the soap:body (which contains a
+ boolean) is within the mime:part. bounceImage4 works because the
+ soap:body is a direct child of the binding input. When I try to
+ run bounceImage5, WSDL4J says the soap:body doesn't contain any
+ parts. But having the soap:body inside the mime:part is valid WSDL
+ (according to the wsdl4j PopulatedExtensionRegistry). So what does
+ it mean?
+ Must test soap:body parts="a b c" as well here ?? -->
+ <operation name="bounceImage5">
+ <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>
+
+ <!-- Is it valid to have no soap body at all? -->
+ <operation name="noSoapBody">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="image/jpeg"/>
+ </mime:part>
+ </mime:multipartRelated>
+ </input>
+ </operation>
+
+ <!-- multiMimeParts tests passing in multiple mime parts -->
+ <operation name="multiMimeParts1">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="text/plain"/>
+ <mime:content part="file2" type="text/plain"/>
+ </mime:part>
+ </mime:multipartRelated>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ <operation name="multiMimeParts2">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="text/plain"/>
+ </mime:part>
+ <mime:part>
+ <mime:content part="file2" type="text/plain"/>
+ </mime:part>
+ </mime:multipartRelated>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+ <!--operation name="multiMimeParts3">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="text/plain"/>
+ </mime:part>
+ </mime:multipartRelated>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file2" type="text/plain"/>
+ </mime:part>
+ </mime:multipartRelated>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+-->
+ <operation name="nested">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="text/plain"/>
+ </mime:part>
+ </mime:multipartRelated>
+ </mime:part>
+ </mime:multipartRelated>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
+
+ <!--+++++++++++++++++++++++++ ERRORS +++++++++++++++++++++++++-->
+ <operation name="badNoType">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file"/>
+ <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="badNoPart">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content 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="badNoContent">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <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="badPart">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="trash" 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="badType">
+ <soap:operation soapAction=""/>
+ <input>
+ <mime:multipartRelated>
+ <mime:part>
+ <mime:content part="file" type="trash"/>
+ <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>
</binding>
1.2 +1 -1 xml-axis-wsif/java/test/mime/DeploymentDescriptor.xml
Index: DeploymentDescriptor.xml
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/DeploymentDescriptor.xml,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DeploymentDescriptor.xml 7 Nov 2002 09:58:00 -0000 1.1
+++ DeploymentDescriptor.xml 11 Nov 2002 15:36:04 -0000 1.2
@@ -2,7 +2,7 @@
id="http://mime/">
<isd:provider type="java"
scope="Application"
- methods="dataHandlerToString stringToDataHandler plainTextToString
stringToPlainText bounceImage bounceImage2">
+ methods="dataHandlerToString stringToDataHandler plainTextToString
stringToPlainText bounceImage bounceImage2 bounceImage4 multiParts noSoapBody nested
badNoType badNoPart badNoContent badType badPart">
<isd:java class="mime.MimeImpl" static="false"/>
</isd:provider>
1.2 +52 -0 xml-axis-wsif/java/test/mime/MimeImpl.java
Index: MimeImpl.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/MimeImpl.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- MimeImpl.java 7 Nov 2002 09:58:00 -0000 1.1
+++ MimeImpl.java 11 Nov 2002 15:36:04 -0000 1.2
@@ -156,6 +156,58 @@
return bounceImage(ds);
}
+ public DataHandler bounceImage4(DataHandler ds, boolean b) {
+ if (b && (ds != null))
+ return bounceImage(ds);
+ else
+ return null;
+ }
+
+ public void noSoapBody(DataHandler dh) {}
+
+ public String multiParts(DataHandler dh1, DataHandler dh2) {
+ try {
+ InputStream is1 = dh1.getInputStream();
+ byte[] bBuff1 = new byte[is1.available()];
+ is1.read(bBuff1);
+ StringBuffer sBuff = new StringBuffer(new String(bBuff1));
+
+ InputStream is2 = dh2.getInputStream();
+ byte[] bBuff2 = new byte[is2.available()];
+ is2.read(bBuff2);
+ sBuff.append(new String(bBuff2));
+
+ return sBuff.toString();
+ } catch (IOException ioe) {
+ ioe.printStackTrace();
+ return null;
+ }
+ }
+
+ public String nested(DataHandler dh) {
+ return dataHandlerToString(dh);
+ }
+
+ public String badNoType(DataHandler dh) {
+ return dataHandlerToString(dh);
+ }
+
+ public String badNoPart(DataHandler dh) {
+ return dataHandlerToString(dh);
+ }
+
+ public String badNoContent(DataHandler dh) {
+ return dataHandlerToString(dh);
+ }
+
+ public String badType(DataHandler dh) {
+ return dataHandlerToString(dh);
+ }
+
+ public String badPart(DataHandler dh) {
+ return dataHandlerToString(dh);
+ }
+
private FileDataSource getTempFile() throws IOException {
File f = File.createTempFile("WSIFMimeTest", "txt");
f.deleteOnExit();
1.2 +10 -0 xml-axis-wsif/java/test/mime/Mime.java
Index: Mime.java
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/mime/Mime.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Mime.java 7 Nov 2002 09:58:00 -0000 1.1
+++ Mime.java 11 Nov 2002 15:36:04 -0000 1.2
@@ -70,6 +70,7 @@
public Image bounceImage(Image im);
public DataHandler bounceImage2(DataHandler dh);
+ public DataHandler bounceImage4(DataHandler dh, boolean b);
// public String dataSourceToString(DataSource ds);
// public DataSource stringToDataSource(String buff);
@@ -79,4 +80,13 @@
//
// public String dataSourceToString(DataSource ds);
// public DataSource stringToDataSource(String buff);
+
+ public void noSoapBody(DataHandler dh);
+ public String multiParts(DataHandler dh1, DataHandler dh2);
+ public String nested(DataHandler dh);
+ public String badNoType(DataHandler dh) throws Exception;
+ public String badNoPart(DataHandler dh) throws Exception;
+ public String badNoContent(DataHandler dh) throws Exception;
+ public String badType(DataHandler dh) throws Exception;
+ public String badPart(DataHandler dh) throws Exception;
}
1.1 xml-axis-wsif/java/test/mime/test2.txt
Index: test2.txt
===================================================================
Goodbye Mark!
1.8 +2 -2 xml-axis-wsif/java/test/wsif.test.properties
Index: wsif.test.properties
===================================================================
RCS file: /home/cvs/xml-axis-wsif/java/test/wsif.test.properties,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- wsif.test.properties 6 Nov 2002 14:12:35 -0000 1.7
+++ wsif.test.properties 11 Nov 2002 15:36:04 -0000 1.8
@@ -17,8 +17,8 @@
# wsif.test.components switches off some areas of unit test so that you can run
# whole suite without jms, ejb, remotewsdl (in WsdlLoadingTest) or jndi. By default,
# all areas are on unless you explicitly turn them off.
-#
wsif.test.components=[ejb=on|off,][jms=on|off,][remotewsdl=on|off,][jndi=on|off,][async=on|off]
-wsif.test.components=ejb=on,jms=on,remotewsdl=on,jndi=on,fix=off,async=on
+#
wsif.test.components=[ejb=on|off,][jms=on|off,][remotewsdl=on|off,][jndi=on|off,][async=on|off][mime=on|off]
+wsif.test.components=ejb=on,jms=on,remotewsdl=on,jndi=on,fix=off,async=on,mime=on
#
# wsif.jms.output=terse|verbose Controls how much output you get from the
# JMS2HTTPBridge when running the testcases. Default is terse.
1.31 +34 -29
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java
Index: WSIFOperation_ApacheAxis.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFOperation_ApacheAxis.java,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WSIFOperation_ApacheAxis.java 6 Nov 2002 16:13:38 -0000 1.30
+++ WSIFOperation_ApacheAxis.java 11 Nov 2002 15:36:04 -0000 1.31
@@ -129,7 +129,6 @@
transient protected WSIFPort_ApacheAxis portInstance;
transient protected Operation operation;
transient protected Definition definition;
- transient protected List partNames;
transient protected List soapPartNames;
transient protected List mimePartNames;
transient protected String names[];
@@ -182,7 +181,8 @@
op.setInputNamespace(getInputNamespace());
op.setInputEncodingStyle(getInputEncodingStyle());
op.setOutputEncodingStyle(getOutputEncodingStyle());
- op.setPartNames(soapPartNames,mimePartNames);
+ op.setSoapPartNames(getSoapPartNames());
+ op.setMimePartNames(getMimePartNames());
op.setReturnName(getReturnName());
op.setAsyncOperation(isAsyncOperation());
op.setResponseHandler(getResponseHandler());
@@ -238,10 +238,16 @@
return outputEncodingStyle;
}
- public List getPartNames() {
+ public List getSoapPartNames() {
Trc.entry(this);
- Trc.exit(partNames);
- return partNames;
+ Trc.exit(soapPartNames);
+ return soapPartNames;
+ }
+
+ public List getMimePartNames() {
+ Trc.entry(this);
+ Trc.exit(mimePartNames);
+ return mimePartNames;
}
public String getReturnName() {
@@ -801,6 +807,7 @@
}
private void prepare(Call call) throws WSIFException {
+ Trc.entry(this,call);
// This registerTypeMapping code is duplicated in
deserialiseResponseObject
TypeMappingRegistry registry =
@@ -868,10 +875,10 @@
Input input = operation.getInput();
if (input != null) {
Object obj;
- if (partNames != null) {
+ if (soapPartNames != null) {
obj = new Vector();
Part part1;
- for (Iterator iterator1 = partNames.iterator();
+ for (Iterator iterator1 = soapPartNames.iterator();
iterator1.hasNext();
((List) (obj)).add(part1)) {
String s = (String) iterator1.next();
@@ -911,7 +918,9 @@
// Automatically register mime types as DataHandler (unless
// the user has already typemapped them explicitly).
- if (types[j] == null && mimePartNames.contains(names[j])) {
+ if (types[j] == null
+ && mimePartNames != null
+ && mimePartNames.contains(names[j])) {
types[j] = DataHandler.class;
call.registerTypeMapping(
DataHandler.class,
@@ -957,7 +966,9 @@
// Automatically register mime types as DataHandler (unless
// the user has already typemapped them explicitly).
- if (returnType == null && mimePartNames.contains(returnName)) {
+ if (returnType == null
+ && mimePartNames != null
+ && mimePartNames.contains(returnName)) {
returnType = DataHandler.class;
call.registerTypeMapping(
DataHandler.class,
@@ -978,6 +989,7 @@
setWSDLOutParams(wsdlOutParams);
}
}
+ Trc.exit();
}
/**
@@ -1046,30 +1058,24 @@
Trc.exit();
}
- public void setPartNames(List soapList, List mimeList) {
- Trc.entry(this, soapList, mimeList);
- if (soapList != null && !soapList.isEmpty())
- soapPartNames = soapList;
- else
+ public void setSoapPartNames(List soapList) {
+ Trc.entry(this, soapList);
+ if (soapList == null || soapList.isEmpty())
soapPartNames = null;
-
- if (mimeList != null && !mimeList.isEmpty())
- mimePartNames = mimeList;
else
+ soapPartNames = soapList;
+ Trc.exit();
+ }
+
+ public void setMimePartNames(List mimeList) {
+ Trc.entry(this, mimeList);
+ if (mimeList == null || mimeList.isEmpty())
mimePartNames = null;
-
- if (soapPartNames != null || mimePartNames != null) {
- partNames = new Vector();
- if (mimeList != null)
- partNames.addAll(mimeList);
- if (soapList != null)
- partNames.addAll(soapList);
- } else
- partNames = null;
-
+ else
+ mimePartNames = mimeList;
Trc.exit();
}
-
+
public void setReturnName(String s) {
Trc.entry(this, s);
returnName = s;
@@ -1342,7 +1348,6 @@
buff += "portInstance:" + portInstance;
buff += " operation:" + Trc.brief(operation);
buff += " definition:" + Trc.brief(definition);
- buff += " partNames:" + partNames;
buff += " soapPartNames:" + soapPartNames;
buff += " mimePartNames:" + mimePartNames;
buff += " names:" + names;
1.15 +29 -23
xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java
Index: WSIFPort_ApacheAxis.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/soap/apacheaxis/WSIFPort_ApacheAxis.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- WSIFPort_ApacheAxis.java 6 Nov 2002 16:13:38 -0000 1.14
+++ WSIFPort_ApacheAxis.java 11 Nov 2002 15:36:04 -0000 1.15
@@ -231,6 +231,7 @@
operation.getInput().getName(),
operation.getOutput() == null ? null :
operation.getOutput().getName(),
wsifoperation_apacheaxis)) {
+
operation = (Operation) iterator.next();
String s3 = operation.getName();
Input input = operation.getInput();
@@ -276,23 +277,27 @@
javax.wsdl.extensions.soap.SOAPBody.class,
inExtElems);
if (soapbody != null) {
- List list2 =
parseSoapBody(wsifoperation_apacheaxis,soapoperation,soapbody,true);
- if (list2 != null)
- wsifoperation_apacheaxis.setPartNames(list2,null);
- } else {
- MIMEMultipartRelated mimeMultipart =
- (MIMEMultipartRelated) getExtElem(bindinginput,
- MIMEMultipartRelated.class,
- inExtElems);
- if (mimeMultipart != null)
- parseMimeMultipart(
- mimeMultipart,
- bindingoperation,
+ List list2 =
+ parseSoapBody(
wsifoperation_apacheaxis,
soapoperation,
+ soapbody,
true);
+ wsifoperation_apacheaxis.setSoapPartNames(list2);
}
+ MIMEMultipartRelated mimeMultipart =
+ (MIMEMultipartRelated) getExtElem(bindinginput,
+ MIMEMultipartRelated.class,
+ inExtElems);
+ if (mimeMultipart != null)
+ parseMimeMultipart(
+ mimeMultipart,
+ bindingoperation,
+ wsifoperation_apacheaxis,
+ soapoperation,
+ true);
+
SOAPHeader soapheader =
(SOAPHeader) getExtElem(bindinginput,
javax.wsdl.extensions.soap.SOAPHeader.class,
@@ -381,22 +386,18 @@
Trc.entry(this, op, soapoperation, soapbody, new Boolean(isInput));
- if (isInput) {
- String s6 = soapbody.getNamespaceURI();
- op.setInputNamespace(s6);
- }
+ if (isInput)
+ op.setInputNamespace(soapbody.getNamespaceURI());
- String s7 = soapbody.getUse();
- if (!"encoded".equals(s7))
+ String use = soapbody.getUse();
+ if (!"encoded".equals(use))
throw new WSIFException(
- "unsupported use " + s7 + " in " + soapoperation);
+ "unsupported use " + use + " in " + soapoperation);
if (isInput) {
List list1 = soapbody.getEncodingStyles();
- if (list1 != null) {
- list1.size();
+ if (list1 != null && list1.size() > 0)
op.setInputEncodingStyle((String) list1.get(0));
- }
}
List list2 = soapbody.getParts();
@@ -469,7 +470,12 @@
}
}
}
- wsifoperation_apacheaxis.setPartNames(soapPartNames, mimePartNames);
+
+ if (soapPartNames != null && !soapPartNames.isEmpty())
+ wsifoperation_apacheaxis.setSoapPartNames(soapPartNames);
+
+ if (mimePartNames != null && !mimePartNames.isEmpty())
+ wsifoperation_apacheaxis.setMimePartNames(mimePartNames);
Trc.exit();
}
1.19 +4 -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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- WSIFTestRunner.java 7 Nov 2002 09:58:01 -0000 1.18
+++ WSIFTestRunner.java 11 Nov 2002 15:36:04 -0000 1.19
@@ -127,7 +127,10 @@
suite.addTest(new TestSuite(InputPartsTest.class));
suite.addTest(new TestSuite(OutputPartsTest.class));
suite.addTest(new TestSuite(WildcardTest.class));
- suite.addTest(new TestSuite(MimeTest.class));
+
+ if (TestUtilities.areWeTesting("mime"))
+ suite.addTest(new TestSuite(MimeTest.class));
+
if (TestUtilities.areWeTesting("jms")) {
suite.addTest(new TestSuite(JmsTest.class));
suite.addTest(new TestSuite(JmsFaultTest.class));