Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 36645 invoked from network); 1 May 2007 08:31:21 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 1 May 2007 08:31:21 -0000 Received: (qmail 62087 invoked by uid 500); 1 May 2007 08:31:15 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 61924 invoked by uid 500); 1 May 2007 08:31:11 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 61905 invoked by uid 99); 1 May 2007 08:31:11 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2007 01:31:11 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (herse.apache.org: domain of james.mao@iona.com designates 65.223.216.181 as permitted sender) Received: from [65.223.216.181] (HELO amereast-smg1.iona.com) (65.223.216.181) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 01 May 2007 01:31:03 -0700 Received: from amer-ems1.IONAGLOBAL.COM ([10.65.6.25]) by amereast-smg1.iona.com (Switch-3.1.7/Switch-3.1.7) with ESMTP id l418UBiN001944; Tue, 1 May 2007 04:30:11 -0400 (EDT) Received: from [10.129.9.111] ([10.129.9.111]) by amer-ems1.IONAGLOBAL.COM with Microsoft SMTPSVC(6.0.3790.1830); Tue, 1 May 2007 04:30:37 -0400 Message-ID: <4636FA99.5040808@iona.com> Date: Tue, 01 May 2007 16:30:17 +0800 From: James Mao User-Agent: Thunderbird 1.5.0.10 (Windows/20070221) MIME-Version: 1.0 To: cxf-dev@incubator.apache.org CC: cxf-commits@incubator.apache.org Subject: Re: svn commit: r533897 - in /incubator/cxf/trunk: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/ systests/src/test/java/org/apache/cxf/systest/mtom/ References: <20070501005608.6D7641A9838@eris.apache.org> In-Reply-To: <20070501005608.6D7641A9838@eris.apache.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 01 May 2007 08:30:38.0561 (UTC) FILETIME=[FF436510:01C78BCA] X-Virus-Checked: Checked by ClamAV on apache.org Hi Dan, I saw this after i updated to the latest trunk Running org.apache.cxf.systest.mtom.MtomServerTest Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 2.475 sec <<< FA ILURE! testURLBasedAttachment(org.apache.cxf.systest.mtom.MtomServerTest) Time elapsed : 0.265 sec <<< FAILURE! java.lang.AssertionError: expected:<197> but was:<200> at org.junit.Assert.fail(Assert.java:71) at org.junit.Assert.failNotEquals(Assert.java:451) at org.junit.Assert.assertEquals(Assert.java:99) at org.junit.Assert.assertEquals(Assert.java:116) James. dandiep@apache.org wrote: > Author: dandiep > Date: Mon Apr 30 17:56:07 2007 > New Revision: 533897 > > URL: http://svn.apache.org/viewvc?view=rev&rev=533897 > Log: > Some fixes to allow the AttachmentUnarshaller read XOP packages > that use a URL instead of a CID. > > > Added: > incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/request-url-attachment (with props) > Modified: > incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java > incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java > > Modified: incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java?view=diff&rev=533897&r1=533896&r2=533897 > ============================================================================== > --- incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java (original) > +++ incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentUnmarshaller.java Mon Apr 30 17:56:07 2007 > @@ -23,12 +23,15 @@ > import java.io.IOException; > import java.io.InputStream; > import java.io.UnsupportedEncodingException; > +import java.net.MalformedURLException; > +import java.net.URL; > import java.net.URLDecoder; > import java.util.Collection; > import java.util.logging.Logger; > > import javax.activation.DataHandler; > import javax.activation.DataSource; > +import javax.activation.URLDataSource; > import javax.xml.bind.attachment.AttachmentUnmarshaller; > > import org.apache.cxf.attachment.LazyDataSource; > @@ -41,7 +44,7 @@ > private static final Logger LOG = LogUtils.getL7dLogger(JAXBAttachmentUnmarshaller.class); > > private Collection attachments; > - > + > public JAXBAttachmentUnmarshaller(Collection attachments) { > super(); > this.attachments = attachments; > @@ -68,7 +71,7 @@ > > @Override > public boolean isXOPPackage() { > - return attachments != null && attachments.iterator().hasNext(); > + return attachments != null; > } > > private DataSource getAttachmentDataSource(String contentId) { > @@ -78,7 +81,14 @@ > } catch (UnsupportedEncodingException ue) { > contentId = contentId.substring(4); > } > + return new LazyDataSource(contentId, attachments); > + } else { > + try { > + return new URLDataSource(new URL(contentId)); > + } catch (MalformedURLException e) { > + throw new Fault(e); > + } > } > - return new LazyDataSource(contentId, attachments); > + > } > } > > Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java?view=diff&rev=533897&r1=533896&r2=533897 > ============================================================================== > --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java (original) > +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/MtomServerTest.java Mon Apr 30 17:56:07 2007 > @@ -22,6 +22,7 @@ > import java.io.ByteArrayOutputStream; > import java.io.InputStream; > import java.io.OutputStream; > +import java.net.URL; > import java.util.Collection; > import java.util.HashMap; > import java.util.Map; > @@ -33,6 +34,7 @@ > import org.apache.cxf.helpers.IOUtils; > import org.apache.cxf.jaxws.JaxWsServerFactoryBean; > import org.apache.cxf.message.Attachment; > +import org.apache.cxf.message.ExchangeImpl; > import org.apache.cxf.message.Message; > import org.apache.cxf.message.MessageImpl; > import org.apache.cxf.service.model.EndpointInfo; > @@ -40,10 +42,16 @@ > import org.apache.cxf.transport.Conduit; > import org.apache.cxf.transport.ConduitInitiator; > import org.apache.cxf.transport.ConduitInitiatorManager; > +import org.apache.cxf.transport.Destination; > +import org.apache.cxf.transport.DestinationFactory; > +import org.apache.cxf.transport.DestinationFactoryManager; > +import org.apache.cxf.transport.MessageObserver; > import org.junit.Test; > > public class MtomServerTest extends AbstractCXFTest { > > + private static final String HTTP_ID = "http://schemas.xmlsoap.org/wsdl/http/"; > + > @Test > public void testMtomRequest() throws Exception { > JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); > @@ -56,7 +64,7 @@ > sf.setProperties(props); > sf.create(); > > - EndpointInfo ei = new EndpointInfo(null, "http://schemas.xmlsoap.org/wsdl/http"); > + EndpointInfo ei = new EndpointInfo(null, HTTP_ID); > ei.setAddress(address); > > ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); > @@ -105,9 +113,120 @@ > assertEquals(37448, out.size()); > } > > + @Test > + public void testURLBasedAttachment() throws Exception { > + JaxWsServerFactoryBean sf = new JaxWsServerFactoryBean(); > + sf.setServiceBean(new EchoService()); > + sf.setBus(getBus()); > + String address = "http://localhost:9036/EchoService"; > + sf.setAddress(address); > + Map props = new HashMap(); > + props.put(Message.MTOM_ENABLED, "true"); > + sf.setProperties(props); > + sf.create(); > + > + servStatic(getClass().getResource("mtom-policy.xsd"), > + "http://localhost:9036/policy.xsd"); > + > + > + > + EndpointInfo ei = new EndpointInfo(null, HTTP_ID); > + ei.setAddress(address); > + > + ConduitInitiatorManager conduitMgr = getBus().getExtension(ConduitInitiatorManager.class); > + ConduitInitiator conduitInit = conduitMgr.getConduitInitiator("http://schemas.xmlsoap.org/soap/http"); > + Conduit conduit = conduitInit.getConduit(ei); > + > + TestMessageObserver obs = new TestMessageObserver(); > + conduit.setMessageObserver(obs); > + > + Message m = new MessageImpl(); > + String ct = "multipart/related; type=\"application/xop+xml\"; " > + + "start=\"\"; " > + + "start-info=\"text/xml; charset=utf-8\"; " > + + "boundary=\"----=_Part_4_701508.1145579811786\""; > + > + m.put(Message.CONTENT_TYPE, ct); > + conduit.prepare(m); > + > + OutputStream os = m.getContent(OutputStream.class); > + InputStream is = getResourceAsStream("request-url-attachment"); > + if (is == null) { > + throw new RuntimeException("Could not find resource " + "request"); > + } > + > + IOUtils.copy(is, os); > + > + os.flush(); > + is.close(); > + os.close(); > + > + byte[] res = obs.getResponseStream().toByteArray(); > + MessageImpl resMsg = new MessageImpl(); > + resMsg.setContent(InputStream.class, new ByteArrayInputStream(res)); > + resMsg.put(Message.CONTENT_TYPE, obs.getResponseContentType()); > + AttachmentDeserializer deserializer = new AttachmentDeserializer(resMsg); > + deserializer.initializeAttachments(); > + > + Collection attachments = resMsg.getAttachments(); > + assertNotNull(attachments); > + assertEquals(1, attachments.size()); > + > + Attachment inAtt = attachments.iterator().next(); > + ByteArrayOutputStream out = new ByteArrayOutputStream(); > + IOUtils.copy(inAtt.getDataHandler().getInputStream(), out); > + out.close(); > + assertEquals(197, out.size()); > + } > + > @Override > protected Bus createBus() throws BusException { > return BusFactory.getDefaultBus(); > } > + > + /** > + * Serve static file > + */ > + private void servStatic(final URL resource, > + final String add) throws Exception { > + Bus bus = getBus(); > + DestinationFactoryManager dfm = bus.getExtension(DestinationFactoryManager.class); > + DestinationFactory df = dfm > + .getDestinationFactory("http://cxf.apache.org/transports/http/configuration"); > + > + EndpointInfo ei = new EndpointInfo(); > + ei.setAddress(add); > + > + Destination d = df.getDestination(ei); > + d.setMessageObserver(new MessageObserver() { > + > + public void onMessage(Message message) { > + try { > + // HTTP seems to need this right now... > + ExchangeImpl ex = new ExchangeImpl(); > + ex.setInMessage(message); > + > + Conduit backChannel = message.getDestination().getBackChannel(message, null, null); > + > + MessageImpl res = new MessageImpl(); > + res.put(Message.CONTENT_TYPE, "text/xml"); > + backChannel.prepare(res); > + > + OutputStream out = res.getContent(OutputStream.class); > + InputStream is = resource.openStream(); > + IOUtils.copy(is, out, 2048); > + > + out.flush(); > + > + out.close(); > + is.close(); > + > + backChannel.close(res); > + } catch (Exception e) { > + e.printStackTrace(); > + } > + } > > + }); > + } > } > > Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/request-url-attachment > URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/request-url-attachment?view=auto&rev=533897 > ============================================================================== > --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/request-url-attachment (added) > +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/request-url-attachment Mon Apr 30 17:56:07 2007 > @@ -0,0 +1,19 @@ > + > +------=_Part_4_701508.1145579811786 > +Content-Type: text/xml > +Content-Transfer-Encoding: binary > +Content-ID: > + > + > + > + > + > + + xmlns:xop='http://www.w3.org/2004/08/xop/include' > + href='http://localhost:9036/policy.xsd'/> > + > + > + > + > + > +------=_Part_4_701508.1145579811786-- > > Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/request-url-attachment > ------------------------------------------------------------------------------ > svn:executable = * > > > >