whitlock 2003/03/19 09:11:37
Modified: java/test/mime Mime.wsdl MimeTest.java
java/src/org/apache/wsif/providers/java
WSIFOperation_Java.java
java/src/org/apache/wsif/attachments WSIFAttachmentPart.java
Log:
16993: Get more attachments tests working
Revision Changes Path
1.16 +14 -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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- Mime.wsdl 13 Mar 2003 16:22:02 -0000 1.15
+++ Mime.wsdl 19 Mar 2003 17:11:36 -0000 1.16
@@ -999,6 +999,20 @@
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
+
+ <operation name="unref">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </input>
+ <output>
+ <soap:body use="encoded"
+ namespace="http://mime/"
+ encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
+ </output>
+ </operation>
</binding>
<!--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-->
1.24 +57 -40 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.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- MimeTest.java 18 Mar 2003 14:49:00 -0000 1.23
+++ MimeTest.java 19 Mar 2003 17:11:36 -0000 1.24
@@ -101,14 +101,16 @@
* 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
+ * Multiple output attachments
+ * output unreferenced attachments
+ * preserving mime headers in referenced attachments
+ * mixing referenced and unreferenced attachments
* 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?
+ * Input-only
+ * Native Jms, EJB
*
* @author Mark Whitlock
*/
@@ -246,14 +248,10 @@
doit(server + "Port", BOUNCE_IMAGE4_FALSE, "Mime.wsdl");
}
- /*
- * This next test fails because axis will not allow null
- * parameters to be passed in.
- *
- * public void testBounceImage4NullHttp() {
- * doit(server+"Port", BOUNCE_IMAGE4_NULL, "Mime.wsdl");
- * }
- */
+ public void testBounceImage4NullHttp() {
+ doit(server+"Port", BOUNCE_IMAGE4_NULL, "Mime.wsdl");
+ }
+
/*
* bounceImage5 doesn't work because the soap:body (which contains a
@@ -283,23 +281,6 @@
* }
*/
- /*
- * 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 testJmsSendHttp() {
- * doit(server+"Port", "SOAPJMSPort", SEND, "Mime.wsdl");
- * }
- */
-
public void testOrMultiParts1Http() {
doit(server + "Port", OR_MULTIPARTS1, "Mime.wsdl");
}
@@ -370,9 +351,9 @@
doit(server + "Port", SEND_UNREF_AP_LOTS, "Mime.wsdl");
}
-// public void testSendAttachmentPartHttp() {
-// doit(server + "Port", SEND_AP, "Mime.wsdl");
-// }
+ public void testSendAttachmentPartHttp() {
+ doit(server + "Port", SEND_AP, "Mime.wsdl");
+ }
// public void testReceiveAttachmentPartHttp() {
// doit(server + "Port", RECEIVE_AP, "Mime.wsdl");
@@ -406,6 +387,10 @@
doit("SOAPJMSPort", BOUNCE_IMAGE4_FALSE, "Mime.wsdl");
}
+ public void testBounceImage4NullJms() {
+ doit("SOAPJMSPort", BOUNCE_IMAGE4_NULL, "Mime.wsdl");
+ }
+
public void testOrMultiParts1Jms() {
doit("SOAPJMSPort", OR_MULTIPARTS1, "Mime.wsdl");
}
@@ -458,6 +443,18 @@
doit("SOAPJMSPort", MIX_MIME_PARTS, "Mime.wsdl");
}
+ public void testSendUnrefAttachmentPartJms() {
+ doit("SOAPJMSPort", SEND_UNREF_AP, "Mime.wsdl");
+ }
+
+ public void testSendUnrefAttachmentPartLotsJms() {
+ doit("SOAPJMSPort", SEND_UNREF_AP_LOTS, "Mime.wsdl");
+ }
+
+ public void testSendAttachmentPartJms() {
+ doit("SOAPJMSPort", SEND_AP, "Mime.wsdl");
+ }
+
/* ***************************************************/
/* Java tests */
/* ***************************************************/
@@ -478,6 +475,10 @@
doit("JavaPort", SEND_UNREF_AP_LOTS, "Mime.wsdl");
}
+ public void testSendAttachmentPartJava() {
+ doit("JavaPort", SEND_AP, "Mime.wsdl");
+ }
+
/* ***************************************************/
/* ERROR tests */
/* ***************************************************/
@@ -619,7 +620,7 @@
else if (cmd.equals(SEND_UNREF_AP_LOTS))
send_unref_ap_lots(portName, service);
else if (cmd.equals(SEND_AP))
- send_ap(service, stub);
+ send_ap(portName, service);
else if (cmd.equals(RECEIVE_AP))
receive_ap(service, stub);
else if (cmd.equals(BAD_NO_PART))
@@ -755,11 +756,17 @@
assertTrue(dh2 == null);
}
+ /**
+ * This test needs an axis server.
+ */
private void bounce_image4_null(
WSIFService service,
Mime stub,
String portName)
throws Exception {
+ if (!"axis".equalsIgnoreCase(server))
+ return;
+
DataHandler dh2 = stub.bounceImage4(true, null);
assertTrue(dh2 == null);
}
@@ -1056,13 +1063,23 @@
}
}
- private void send_ap(WSIFService service, Mime stub) throws Exception {
- assertTrue(false);
- // WSIFAttachmentPart ap =
- // new WSIFAttachmentPart(
- // new DataHandler(new FileDataSource(flatfileLocation)));
- // String buff = stub.dataHandlerToString(ap);
- // assertTrue(compareFiles(flatfileLocation, buff));
+ private void send_ap(String portName, WSIFService service) throws Exception {
+ WSIFAttachmentPart ap =
+ new WSIFAttachmentPart(
+ new DataHandler(new FileDataSource(flatfileLocation)));
+
+ WSIFPort port = service.getPort(portName);
+ WSIFOperation op = port.createOperation("dataHandlerToString");
+ WSIFMessage in = op.createInputMessage();
+ WSIFMessage out = op.createOutputMessage();
+ WSIFMessage fault = op.createFaultMessage();
+ in.setObjectPart("file", ap);
+
+ boolean success = op.executeRequestResponseOperation(in, out, fault);
+ assertTrue(success);
+
+ String buff = (String) (out.getObjectPart("buff"));
+ assertTrue(compareFiles(flatfileLocation, buff));
}
private void receive_ap(WSIFService service, Mime stub) throws Exception {
1.36 +15 -0
xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java
Index: WSIFOperation_Java.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/providers/java/WSIFOperation_Java.java,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- WSIFOperation_Java.java 18 Mar 2003 15:09:32 -0000 1.35
+++ WSIFOperation_Java.java 19 Mar 2003 17:11:36 -0000 1.36
@@ -86,6 +86,7 @@
import org.apache.wsif.WSIFMessage;
import org.apache.wsif.WSIFOperation;
import org.apache.wsif.WSIFPort;
+import org.apache.wsif.attachments.WSIFAttachmentPart;
import org.apache.wsif.base.WSIFDefaultOperation;
import org.apache.wsif.logging.MessageLogger;
import org.apache.wsif.logging.Trc;
@@ -804,6 +805,7 @@
// Go through each argument checking it's compatability with the method arg
// creating a compatible set along the way.
// In essence this just converts from String to Character when necessary
+ // Also converts between WSIFAttachmentParts and DataHandlers
// if there are further special case classes such as these which are
dependent
// on the object value, PUT THEM HERE :-)
if (args == null || parmTypes == null) {
@@ -870,6 +872,7 @@
// Usually cls1.isAssignableFrom(cls2) returning false means you can't cast
// instance of cls1 to cls2. There are some special cases we need to cover ...
// String->Character and Character->String
+ // WSIFAttachmentPart->DataHandler and DataHandler->WSIFAttachmentPart
// If a conversion is known then the obj is converted to class cls
// if that conversion failed, null is returned
// else the converted obj is returned
@@ -952,6 +955,18 @@
Trc.exit(obj.toString());
return (obj.toString());
}
+
+ if (cls.equals(WSIFAttachmentPart.class)
+ && obj.getClass().getName().equals("javax.activation.DataHandler")) {
+ obj = new WSIFAttachmentPart(obj);
+ }
+
+ if (cls.getName().equals("javax.activation.DataHandler")
+ && obj.getClass().equals(WSIFAttachmentPart.class)) {
+ WSIFAttachmentPart wap = (WSIFAttachmentPart) obj;
+ obj = wap.getDataHandler();
+ }
+
Trc.exit(obj);
return obj;
}
1.2 +7 -0
xml-axis-wsif/java/src/org/apache/wsif/attachments/WSIFAttachmentPart.java
Index: WSIFAttachmentPart.java
===================================================================
RCS file:
/home/cvs/xml-axis-wsif/java/src/org/apache/wsif/attachments/WSIFAttachmentPart.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- WSIFAttachmentPart.java 18 Mar 2003 14:49:00 -0000 1.1
+++ WSIFAttachmentPart.java 19 Mar 2003 17:11:37 -0000 1.2
@@ -91,6 +91,13 @@
Trc.exit();
}
+ public WSIFAttachmentPart(Object obj) {
+ Trc.entry(this, obj);
+ this.dh = (DataHandler)obj;
+ this.properties = new HashMap();
+ Trc.exit();
+ }
+
public WSIFAttachmentPart(DataHandler dh, Map properties)
throws WSIFException {
Trc.entry(this, dh, properties);