You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2011/03/15 03:45:43 UTC
svn commit: r1081648 - in /cxf/trunk:
rt/core/src/main/java/org/apache/cxf/attachment/
rt/core/src/test/java/org/apache/cxf/attachment/
systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/
Author: dkulp
Date: Tue Mar 15 02:45:43 2011
New Revision: 1081648
URL: http://svn.apache.org/viewvc?rev=1081648&view=rev
Log:
[CXF-3383] In some very strange situations with several small
attachments and read(buf, off, len) called with off != 0, the data at
the end of various buffers can get lost and boundaries might not be
found.
Added:
cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/cxf3383.data
cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java (with props)
cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java (with props)
Modified:
cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java?rev=1081648&r1=1081647&r2=1081648&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/MimeBodyPartInputStream.java Tue Mar 15 02:45:43 2011
@@ -178,7 +178,7 @@ public class MimeBodyPartInputStream ext
//boundary matched (may or may not be last mime boundary)
int processed = initialI - off;
if ((len - (i + 2)) > 0) {
- inStream.unread(buffer, i + 2, len - (i + 2));
+ inStream.unread(buffer, i + 2, len - (i + 2) + off);
}
return processed;
}
Modified: cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=1081648&r1=1081647&r2=1081648&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java (original)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java Tue Mar 15 02:45:43 2011
@@ -29,6 +29,7 @@ import java.util.Iterator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.activation.DataSource;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
@@ -456,5 +457,42 @@ public class AttachmentDeserializerTest
}
return bout.toString();
}
+
+ @Test
+ public void testCXF3383() throws Exception {
+ String contentType = "multipart/related; type=\"application/xop+xml\";"
+ + " boundary=\"uuid:7a555f51-c9bb-4bd4-9929-706899e2f793\"; start="
+ + "\"<ro...@cxf.apache.org>\"; start-info=\"text/xml\"";
+
+ Message message = new MessageImpl();
+ message.put(Message.CONTENT_TYPE, contentType);
+ message.setContent(InputStream.class, getClass().getResourceAsStream("cxf3383.data"));
+ message.put(AttachmentDeserializer.ATTACHMENT_DIRECTORY, System
+ .getProperty("java.io.tmpdir"));
+ message.put(AttachmentDeserializer.ATTACHMENT_MEMORY_THRESHOLD, String
+ .valueOf(AttachmentDeserializer.THRESHOLD));
+
+
+ AttachmentDeserializer ad
+ = new AttachmentDeserializer(message,
+ Collections.singletonList("multipart/related"));
+
+ ad.initializeAttachments();
+
+
+ for (int x = 1; x < 50; x++) {
+ String cid = "1882f79d-e20a-4b36-a222-7a75518cf395-" + x + "@cxf.apache.org";
+ DataSource ds = AttachmentUtil.getAttachmentDataSource(cid, message.getAttachments());
+ byte bts[] = new byte[1024];
+
+ InputStream ins = ds.getInputStream();
+ int count = ins.read(bts, 0, bts.length);
+ int sz = ins.read(bts, count, bts.length - count);
+ while (sz != -1) {
+ sz = ins.read(bts, count, bts.length - count);
+ }
+ assertEquals(x + 1, count);
+ }
+ }
}
\ No newline at end of file
Added: cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/cxf3383.data
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/cxf3383.data?rev=1081648&view=auto
==============================================================================
--- cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/cxf3383.data (added)
+++ cxf/trunk/rt/core/src/test/java/org/apache/cxf/attachment/cxf3383.data Tue Mar 15 02:45:43 2011
@@ -0,0 +1,301 @@
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/xop+xml; charset=UTF-8; type="text/xml";
+Content-Transfer-Encoding: binary
+Content-ID: <ro...@cxf.apache.org>
+
+<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><ns2:getHashMapDataResponse xmlns:ns2="http://jaxb.systest.cxf.apache.org/"><return><keyData><entry key="1"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-1@cxf.apache.org"/></entry><entry key="2"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-2@cxf.apache.org"/></entry><entry key="3"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-3@cxf.apache.org"/></entry><entry key="4"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-4@cxf.apache.org"/></entry><entry key="5"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-5@cxf.apache.org"/></entry><entry key="6"><xop:Include xmlns:xop="http://www.w3.or
g/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-6@cxf.apache.org"/></entry><entry key="7"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-7@cxf.apache.org"/></entry><entry key="8"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-8@cxf.apache.org"/></entry><entry key="9"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-9@cxf.apache.org"/></entry><entry key="a"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-10@cxf.apache.org"/></entry><entry key="b"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-11@cxf.apache.org"/></entry><entry key="c"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-12@cx
f.apache.org"/></entry><entry key="d"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-13@cxf.apache.org"/></entry><entry key="e"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-14@cxf.apache.org"/></entry><entry key="f"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-15@cxf.apache.org"/></entry><entry key="10"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-16@cxf.apache.org"/></entry><entry key="11"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-17@cxf.apache.org"/></entry><entry key="12"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-18@cxf.apache.org"/></entry><entry key="13"><xop:Include xmlns:xop="http:
//www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-19@cxf.apache.org"/></entry><entry key="14"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-20@cxf.apache.org"/></entry><entry key="15"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-21@cxf.apache.org"/></entry><entry key="16"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-22@cxf.apache.org"/></entry><entry key="17"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-23@cxf.apache.org"/></entry><entry key="18"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-24@cxf.apache.org"/></entry><entry key="19"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a2
22-7a75518cf395-25@cxf.apache.org"/></entry><entry key="1a"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-26@cxf.apache.org"/></entry><entry key="1b"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-27@cxf.apache.org"/></entry><entry key="1c"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-28@cxf.apache.org"/></entry><entry key="1d"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-29@cxf.apache.org"/></entry><entry key="1e"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-30@cxf.apache.org"/></entry><entry key="1f"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-31@cxf.apache.org"/></entry><entry key="20"><xop:
Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-32@cxf.apache.org"/></entry><entry key="21"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-33@cxf.apache.org"/></entry><entry key="22"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-34@cxf.apache.org"/></entry><entry key="23"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-35@cxf.apache.org"/></entry><entry key="24"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-36@cxf.apache.org"/></entry><entry key="25"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-37@cxf.apache.org"/></entry><entry key="26"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="c
id:1882f79d-e20a-4b36-a222-7a75518cf395-38@cxf.apache.org"/></entry><entry key="27"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-39@cxf.apache.org"/></entry><entry key="28"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-40@cxf.apache.org"/></entry><entry key="29"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-41@cxf.apache.org"/></entry><entry key="2a"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-42@cxf.apache.org"/></entry><entry key="2b"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-43@cxf.apache.org"/></entry><entry key="2c"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-44@cxf.apache.org"/></ent
ry><entry key="2d"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-45@cxf.apache.org"/></entry><entry key="2e"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-46@cxf.apache.org"/></entry><entry key="2f"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-47@cxf.apache.org"/></entry><entry key="30"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-48@cxf.apache.org"/></entry><entry key="31"><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:1882f79d-e20a-4b36-a222-7a75518cf395-49@cxf.apache.org"/></entry></keyData><name>Test</name></return></ns2:getHashMapDataResponse></soap:Body></soap:Envelope>
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+A
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+AB
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABC
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCD
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDE
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEF
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFG
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGH
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHI
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJ
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJK
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKL
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLM
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMN
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNO
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOP
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQ
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQR
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRS
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRST
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTU
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUV
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVW
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWX
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXY
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`ab
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abc
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcd
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcde
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdef
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefg
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefgh
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghi
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghij
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijk
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijkl
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklm
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmn
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmno
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnop
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793
+Content-Type: application/octet-stream
+Content-Transfer-Encoding: binary
+Content-ID: <18...@cxf.apache.org>
+
+ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopq
+--uuid:7a555f51-c9bb-4bd4-9929-706899e2f793--
Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java?rev=1081648&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java (added)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java Tue Mar 15 02:45:43 2011
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxb;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlType;
+import javax.xml.bind.annotation.XmlValue;
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ *
+ */
+public class HashMapAdapter extends XmlAdapter<HashMapAdapter.HashMapType, Map<String, byte[]>> {
+
+ @XmlType()
+ @XmlAccessorType(XmlAccessType.FIELD)
+ public static class HashMapEntryType {
+ @XmlAttribute
+ private String key;
+ @XmlValue
+ private byte[] value;
+
+ public String getKey() {
+ return key;
+ }
+
+ public void setKey(String key) {
+ this.key = key;
+ }
+
+ public byte[] getValue() {
+ return value;
+ }
+
+ public void setValue(byte[] value) {
+ this.value = value;
+ }
+ }
+
+ public static class HashMapType {
+ private List<HashMapEntryType> entry = new ArrayList<HashMapEntryType>();
+
+ public List<HashMapEntryType> getEntry() {
+ return entry;
+ }
+
+ public void setEntry(List<HashMapEntryType> entry) {
+ this.entry = entry;
+ }
+ }
+
+ public HashMapType marshal(Map<String, byte[]> arg0) throws Exception {
+ HashMapType myHashMapType = new HashMapType();
+ if (arg0 != null && arg0.size() > 0) {
+ for (Map.Entry<String, byte[]> entry : arg0.entrySet()) {
+ if (entry != null) {
+ HashMapEntryType myHashEntryType = new HashMapEntryType();
+ myHashEntryType.key = entry.getKey();
+ myHashEntryType.value = entry.getValue();
+ myHashMapType.entry.add(myHashEntryType);
+ }
+ }
+ }
+ return myHashMapType;
+ }
+
+ public Map<String, byte[]> unmarshal(HashMapType arg0) throws Exception {
+ Map<String, byte[]> hashMap = new HashMap<String, byte[]>();
+ if (arg0 != null && arg0.entry != null) {
+ for (HashMapEntryType myHashEntryType : arg0.entry) {
+ if (myHashEntryType.key != null) {
+ hashMap.put(myHashEntryType.key, myHashEntryType.value);
+ }
+ }
+ }
+ return hashMap;
+ }
+
+}
Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/HashMapAdapter.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java?rev=1081648&view=auto
==============================================================================
--- cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java (added)
+++ cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java Tue Mar 15 02:45:43 2011
@@ -0,0 +1,141 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.cxf.systest.jaxb;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import javax.jws.WebService;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import javax.xml.namespace.QName;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Service;
+import javax.xml.ws.soap.MTOM;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.annotations.Logging;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.cxf.testutil.common.AbstractBusTestServerBase;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ */
+public class MTOMTest extends AbstractBusClientServerTestBase {
+ static final String PORT = allocatePort(MTOMTest.class);
+ static final String ADDRESS = "http://localhost:" + PORT + "/MTOM";
+
+ public static class ObjectWithHashMapData {
+ private String name;
+ private Map<String, byte[]> keyData = new LinkedHashMap<String, byte[]>();
+
+ public ObjectWithHashMapData() {
+ }
+
+ @XmlJavaTypeAdapter(HashMapAdapter.class)
+ public Map<String, byte[]> getKeyData() {
+ return keyData;
+ }
+
+ public void setKeyData(Map<String, byte[]> d) {
+ keyData = d;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+ }
+
+ @Logging
+ @WebService
+ @MTOM(threshold = 1)
+ public static interface MTOMService {
+ ObjectWithHashMapData getHashMapData(int y);
+ }
+ @WebService
+ public static class MTOMServer implements MTOMService {
+ public ObjectWithHashMapData getHashMapData(int y) {
+ ObjectWithHashMapData ret = new ObjectWithHashMapData();
+ ret.setName("Test");
+ for (int x = 1; x < y; x++) {
+ ret.getKeyData().put(Integer.toHexString(x), generateByteData(x));
+ }
+ return ret;
+ }
+
+ private byte[] generateByteData(int x) {
+ byte bytes[] = new byte[x];
+ for (int y = 0; y < x; y++) {
+ int z = 'A' + y;
+ if (z > 'z') {
+ z -= 'A';
+ }
+ bytes[y] = (byte)z;
+ }
+ return bytes;
+ }
+ }
+ public static class Server extends AbstractBusTestServerBase {
+
+ protected void run() {
+ Endpoint.publish(ADDRESS, new MTOMServer());
+ }
+ public static void main(String[] args) {
+ try {
+ Server s = new Server();
+ s.start();
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ System.exit(-1);
+ } finally {
+ System.out.println("done!");
+ }
+ }
+ }
+ @BeforeClass
+ public static void startServers() throws Exception {
+ assertTrue("server did not launch correctly", launchServer(Server.class, true));
+ }
+
+ @Test
+ public void testMTOMInHashMap() throws Exception {
+ Service service = Service.create(new QName("http://foo", "bar"));
+ service.addPort(new QName("http://foo", "bar"), SOAPBinding.SOAP11HTTP_BINDING,
+ ADDRESS);
+ MTOMService port = service.getPort(new QName("http://foo", "bar"),
+ MTOMService.class);
+
+ final int count = 99;
+ ObjectWithHashMapData data = port.getHashMapData(count);
+ for (int y = 1; y < count; y++) {
+ byte bytes[] = data.getKeyData().get(Integer.toHexString(y));
+ if (bytes.length != y) {
+ System.out.println(new String(bytes));
+ }
+ assertEquals(y, bytes.length);
+ }
+ }
+}
Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cxf/trunk/systests/databinding/src/test/java/org/apache/cxf/systest/jaxb/MTOMTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date