whitlock 2003/03/14 08:22:18
Modified: java/test/mime MimeTest.java MimeImpl.java
java/src/org/apache/wsif/providers/soap/apacheaxis
WSIFOperation_ApacheAxis.java
Log:
16993: fixes for unreferenced attachments
Revision Changes Path
1.20 +73 -11 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.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- MimeTest.java 14 Mar 2003 11:41:41 -0000 1.19
+++ MimeTest.java 14 Mar 2003 16:22:17 -0000 1.20
@@ -68,6 +68,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import java.util.StringTokenizer;
import javax.activation.DataHandler;
import javax.activation.FileDataSource;
@@ -79,6 +80,7 @@
import junit.framework.TestCase;
import junit.framework.TestSuite;
+import org.apache.axis.attachments.PlainTextDataSource;
import org.apache.wsif.WSIFAttachmentPart;
import org.apache.wsif.WSIFConstants;
import org.apache.wsif.WSIFException;
@@ -147,6 +149,7 @@
private final static String OPTIONAL_SOAP_BODY = "OPTIONAL_SOAP_BODY";
private final static String MIX_MIME_PARTS = "MIX_MIME_PARTS";
private final static String SEND_UNREF_AP = "SEND_UNREF_AP";
+ private final static String SEND_UNREF_AP_LOTS = "SEND_UNREF_AP_LOTS";
private final static String SEND_AP = "SEND_AP";
private final static String RECEIVE_AP = "RECEIVE_AP";
private final static String MAP_TYPE = "MAP-TYPE";
@@ -362,6 +365,10 @@
public void testSendUnrefAttachmentPartHttp() {
doit(server + "Port", SEND_UNREF_AP, "Mime.wsdl");
}
+
+ public void testSendUnrefAttachmentPartLotsHttp() {
+ doit(server + "Port", SEND_UNREF_AP_LOTS, "Mime.wsdl");
+ }
// public void testSendAttachmentPartHttp() {
// doit(server + "Port", SEND_AP, "Mime.wsdl");
@@ -466,6 +473,10 @@
public void testSendUnrefAttachmentPartJava() {
doit("JavaPort", SEND_UNREF_AP, "Mime.wsdl");
}
+
+ public void testSendUnrefAttachmentPartLotsJava() {
+ doit("JavaPort", SEND_UNREF_AP_LOTS, "Mime.wsdl");
+ }
/* ***************************************************/
/* ERROR tests */
@@ -515,6 +526,18 @@
&& !TestUtilities.areWeTesting("jms"))
return;
+ // The unreferenced attachment tests over Axis needs axis on the
+ // server and needs wsif.unreferencedattachments=on in wsif.properties.
+ if (cmd.indexOf("UNREF") != -1) {
+ if (!WSIFProperties.areUnreferencedAttachmentsSupported())
+ return;
+
+ // Doing soap/http or soap/jms needs axis on the server
+ if (portName.indexOf("SOAP") != -1
+ && !"axis".equalsIgnoreCase(server))
+ return;
+ }
+
WSIFPluggableProviders.overrideDefaultProvider(
"http://schemas.xmlsoap.org/wsdl/soap/",
new org
@@ -601,6 +624,8 @@
mix_mime_parts(portName, service, stub);
else if (cmd.equals(SEND_UNREF_AP))
send_unref_ap(portName, service);
+ else if (cmd.equals(SEND_UNREF_AP_LOTS))
+ send_unref_ap_lots(portName, service);
else if (cmd.equals(SEND_AP))
send_ap(service, stub);
else if (cmd.equals(RECEIVE_AP))
@@ -965,19 +990,12 @@
assertTrue(expected.equals(s));
}
- /**
- * The send unreferenced attachment test needs axis on the server and
- * needs wsif.unreferencedattachments=on in wsif.properties.
- */
private void send_unref_ap(String portName, WSIFService service)
throws Exception {
- if (!WSIFProperties.areUnreferencedAttachmentsSupported()
- || !"axis".equalsIgnoreCase(server))
- return;
-
DataHandler dh = new DataHandler(new FileDataSource(flatfileLocation));
WSIFAttachmentPart ap = new WSIFAttachmentPart(dh);
ap.setProperty("Content-Location", "peculiar");
+ ap.setProperty("AnotherMimeHeader", "something else");
List apList = new ArrayList(Arrays.asList(new Object[] { ap }));
WSIFPort port = service.getPort(portName);
@@ -993,9 +1011,53 @@
assertTrue(success);
String buff = (String) (out.getObjectPart("buff"));
- assertTrue(buff.startsWith("Content-Location=peculiar!"));
- buff = buff.substring(buff.indexOf("!")+1);
- assertTrue(compareFiles(flatfileLocation, buff));
+ StringTokenizer tok = new StringTokenizer(buff, ":");
+ for (int i = 0; i < 2; i++) {
+ String next = (String)tok.nextElement();
+ assertTrue(
+ next.equals("Content-Location=peculiar")
+ || next.equals("AnotherMimeHeader=something else"));
+ }
+
+ String next = (String)tok.nextElement();
+ assertTrue(compareFiles(flatfileLocation, next));
+ }
+
+ private void send_unref_ap_lots(String portName, WSIFService service)
+ throws Exception {
+
+ final int lots = 150;
+ List apList = new ArrayList();
+ for (int i = 0; i < lots; i++) {
+ PlainTextDataSource ptds =
+ new PlainTextDataSource("Attachment" + i, "value%" + i);
+ DataHandler dh = new DataHandler(ptds);
+
+ WSIFAttachmentPart ap = new WSIFAttachmentPart(dh);
+ ap.setProperty("Index", "" + i);
+ apList.add(ap);
+ }
+
+ WSIFPort port = service.getPort(portName);
+ WSIFOperation op = port.createOperation("unref");
+ WSIFMessage in = op.createInputMessage();
+ WSIFMessage out = op.createOutputMessage();
+ WSIFMessage fault = op.createFaultMessage();
+ in.setObjectPart(
+ WSIFConstants.UNREFERENCED_ATTACHMENT_PART_NAME,
+ apList);
+
+ boolean success = op.executeRequestResponseOperation(in, out, fault);
+ assertTrue(success);
+
+ String buff = (String) (out.getObjectPart("buff"));
+ StringTokenizer tok = new StringTokenizer(buff, ":");
+ for (int i = 0; i < lots; i++) {
+ String next = (String) tok.nextElement();
+ assertTrue(next.equals("Index=" + i));
+ next = (String) tok.nextElement();
+ assertTrue(next.equals("value%" + i));
+ }
}
private void send_ap(WSIFService service, Mime stub) throws Exception {
1.14 +12 -6 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.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- MimeImpl.java 14 Mar 2003 11:41:41 -0000 1.13
+++ MimeImpl.java 14 Mar 2003 16:22:17 -0000 1.14
@@ -273,16 +273,22 @@
while (it.hasNext()) {
Object next = it.next();
if (next instanceof WSIFAttachmentPart) {
+
WSIFAttachmentPart wap = (WSIFAttachmentPart) next;
+ Iterator itProp = wap.getPropertyIterator();
+ while (itProp.hasNext()) {
- if (wap.containsProperty("Content-Location")) {
- s = s + "Content-Location="
- + wap.getProperty("Content-Location")
- + "!";
+ String prop = (String) itProp.next();
+ if ("Content-Location".equals(prop)
+ || !prop.startsWith("Content-")) {
+ s = s + prop
+ + "="
+ + wap.getProperty(prop)
+ + ":";
+ }
}
-
DataHandler dh = wap.getDataHandler();
- s = s + dataHandlerToString(dh);
+ s = s + dataHandlerToString(dh) + ":";
}
}
return s;
1.78 +3 -4
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.77
retrieving revision 1.78
diff -u -r1.77 -r1.78
--- WSIFOperation_ApacheAxis.java 12 Mar 2003 11:42:24 -0000 1.77
+++ WSIFOperation_ApacheAxis.java 14 Mar 2003 16:22:17 -0000 1.78
@@ -63,7 +63,6 @@
import java.util.Hashtable;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.Vector;
@@ -2247,9 +2246,9 @@
}
if (l != null && !l.isEmpty()) {
- ListIterator lit = l.listIterator();
- while (lit.hasNext()) {
- Object next = lit.next();
+ Iterator it = l.listIterator();
+ while (it.hasNext()) {
+ Object next = it.next();
AttachmentPart ap = MIMEHelper.getAttachementPart(next);
call.addAttachmentPart(ap);
}