cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r798345 - in /cxf/trunk: api/src/main/java/org/apache/cxf/io/ rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ rt/core/src/main/java/org/apache/cxf/attachment/ rt/core/src/main/java/org/apache/cxf/endpoint/ rt/core/src/main/jav...
Date Tue, 28 Jul 2009 01:07:45 GMT
Author: dkulp
Date: Tue Jul 28 01:07:44 2009
New Revision: 798345

URL: http://svn.apache.org/viewvc?rev=798345&view=rev
Log:
Allow databindings to be optionally be InterceptorProviders
Hack around the JAXB attachment schema-validation issue by forcing it to
load the attachments (which validation would do anyway) and locking them
to keep them from being deleted during the extent of the reading.

Added:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
  (with props)
Modified:
    cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
    cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java

Modified: cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java
URL: http://svn.apache.org/viewvc/cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java (original)
+++ cxf/trunk/api/src/main/java/org/apache/cxf/io/CachedOutputStream.java Tue Jul 28 01:07:44
2009
@@ -76,6 +76,7 @@
     private boolean tempFileFailed;
     private File tempFile;
     private File outputDir = DEFAULT_TEMP_DIR;
+    private boolean allowDeleteOfFile = true;
 
     private List<CachedOutputStreamCallback> callbacks;
     
@@ -97,6 +98,13 @@
         inmem = true;
     }
 
+    public void holdTempFile() {
+        allowDeleteOfFile = false;
+    }
+    public void releaseTempFileHold() {
+        allowDeleteOfFile = true;
+    }
+    
     public void registerCallback(CachedOutputStreamCallback cb) {
         if (null == callbacks) {
             callbacks = new ArrayList<CachedOutputStreamCallback>();
@@ -451,7 +459,7 @@
     
     private void maybeDeleteTempFile(Object stream) {
         streamList.remove(stream);
-        if (!inmem && tempFile != null && streamList.isEmpty()) {
+        if (!inmem && tempFile != null && streamList.isEmpty() &&
allowDeleteOfFile) {
             if (currentStream != null) {
                 try {
                     currentStream.close();

Modified: cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
(original)
+++ cxf/trunk/rt/bindings/coloc/src/main/java/org/apache/cxf/binding/coloc/ColocUtil.java
Tue Jul 28 01:07:44 2009
@@ -30,6 +30,7 @@
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.phase.Phase;
 import org.apache.cxf.phase.PhaseInterceptorChain;
@@ -83,6 +84,15 @@
             LOG.fine("Interceptors contributed by bus: " + il);
         }
         chain.add(il);
+        
+        if (ep.getService().getDataBinding() instanceof InterceptorProvider) {
+            il = ((InterceptorProvider)ep.getService().getDataBinding()).getOutInterceptors();
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Interceptors contributed by databinding: " + il);
+            }
+            chain.add(il);
+
+        }
 
         return chain;
     }
@@ -107,6 +117,14 @@
             LOG.fine("Interceptors contributed by bus: " + il);
         }
         chain.add(il);
+        
+        if (ep.getService().getDataBinding() instanceof InterceptorProvider) {
+            il = ((InterceptorProvider)ep.getService().getDataBinding()).getInInterceptors();
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Interceptors contributed by databinding: " + il);
+            }
+            chain.add(il);
+        }
         chain.setFaultObserver(new ColocOutFaultObserver(bus));
 
         return chain;

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDataSource.java Tue
Jul 28 01:07:44 2009
@@ -40,6 +40,13 @@
         cache.lockOutputStream();
     }
 
+    public void hold() {
+        cache.holdTempFile();
+    }
+    public void release() {
+        cache.releaseTempFileHold();
+    }
+    
     public String getContentType() {
         return ct;
     }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/endpoint/ClientImpl.java Tue Jul 28 01:07:44
2009
@@ -46,6 +46,7 @@
 import org.apache.cxf.interceptor.ClientOutFaultObserver;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -615,7 +616,17 @@
             LOG.fine("Interceptors contributed by binding: " + i4);
         }
 
-        PhaseInterceptorChain chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3,
i4);
+        PhaseInterceptorChain chain;
+        if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
+            InterceptorProvider p = (InterceptorProvider)endpoint.getService().getDataBinding();
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Interceptors contributed by databinging: " + p.getInInterceptors());
+            }
+            chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4,
+                                          p.getInInterceptors());
+        } else {
+            chain = inboundChainCache.get(pm.getInPhases(), i1, i2, i3, i4);
+        }
         message.setInterceptorChain(chain);
 
         chain.setFaultObserver(outFaultObserver);
@@ -782,6 +793,16 @@
         if (LOG.isLoggable(Level.FINE)) {
             LOG.fine("Interceptors contributed by binding: " + i4);
         }
+        List<Interceptor> i5 = null;
+        if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
+            i5 = ((InterceptorProvider)endpoint.getService().getDataBinding()).getOutInterceptors();
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Interceptors contributed by databinding: " + i5);
+            }
+        }
+        if (i5 != null) {
+            return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4, i5);
+        }
         return outboundChainCache.get(pm.getOutPhases(), i1, i2, i3, i4);
     }
 

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/InFaultChainInitiatorObserver.java
Tue Jul 28 01:07:44 2009
@@ -45,6 +45,9 @@
         chain.add(e.getService().getInFaultInterceptors());
         chain.add(e.getInFaultInterceptors());
         chain.add(e.getBinding().getInFaultInterceptors());
+        if (e.getService().getDataBinding() instanceof InterceptorProvider) {
+            chain.add(((InterceptorProvider)e.getService().getDataBinding()).getInFaultInterceptors());
+        }
     }
     
     protected SortedSet<Phase> getPhases() {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutFaultChainInitiatorObserver.java
Tue Jul 28 01:07:44 2009
@@ -45,6 +45,9 @@
         chain.add(e.getService().getOutFaultInterceptors());
         chain.add(e.getOutFaultInterceptors());
         chain.add(e.getBinding().getOutFaultInterceptors());
+        if (e.getService().getDataBinding() instanceof InterceptorProvider) {
+            chain.add(((InterceptorProvider)e.getService().getDataBinding()).getOutFaultInterceptors());
+        }
     }
     
     protected SortedSet<Phase> getPhases() {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/OutgoingChainInterceptor.java
Tue Jul 28 01:07:44 2009
@@ -146,14 +146,28 @@
             LOG.fine("Interceptors contributed by endpoint: " + i3);
         }
         List<Interceptor> i4 = null;
-        PhaseInterceptorChain chain;
         if (binding != null) {
             i4 = binding.getOutInterceptors();
             if (LOG.isLoggable(Level.FINE)) {
                 LOG.fine("Interceptors contributed by binding: " + i4);
             }
         }
-        if (i4 != null) {
+        List<Interceptor> i5 = null;
+        if (ep.getService().getDataBinding() instanceof InterceptorProvider) {
+            i5 = ((InterceptorProvider)ep.getService().getDataBinding()).getOutInterceptors();
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Interceptors contributed by databinding: " + i5);
+            }
+            if (i4 == null) {
+                i4 = i5;
+                i5 = null;
+            }
+        }
+        PhaseInterceptorChain chain;
+        if (i5 != null) {
+            chain = chainCache.get(bus.getExtension(PhaseManager.class).getOutPhases(),
+                                   i1, i2, i3, i4, i5);
+        } else if (i4 != null) {
             chain = chainCache.get(bus.getExtension(PhaseManager.class).getOutPhases(),
                                    i1, i2, i3, i4);
         } else {

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/transport/ChainInitiationObserver.java
Tue Jul 28 01:07:44 2009
@@ -30,6 +30,7 @@
 import org.apache.cxf.binding.Binding;
 import org.apache.cxf.endpoint.Endpoint;
 import org.apache.cxf.interceptor.InterceptorChain;
+import org.apache.cxf.interceptor.InterceptorProvider;
 import org.apache.cxf.message.Exchange;
 import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
@@ -74,12 +75,26 @@
             exchange.setInMessage(message);
             setExchangeProperties(exchange, message);
     
+            InterceptorProvider dbp = null;
+            if (endpoint.getService().getDataBinding() instanceof InterceptorProvider) {
+                dbp = (InterceptorProvider)endpoint.getService().getDataBinding();
+            }
             // setup chain
-            phaseChain = chainCache.get(bus.getExtension(PhaseManager.class).getInPhases(),
-                                                         bus.getInInterceptors(),
-                                                         endpoint.getService().getInInterceptors(),
-                                                         endpoint.getInInterceptors(),
-                                                         getBinding().getInInterceptors());
+            if (dbp == null) {
+                phaseChain = chainCache.get(bus.getExtension(PhaseManager.class).getInPhases(),
+                                                             bus.getInInterceptors(),
+                                                             endpoint.getService().getInInterceptors(),
+                                                             endpoint.getInInterceptors(),
+                                                             getBinding().getInInterceptors());
+            } else {
+                phaseChain = chainCache.get(bus.getExtension(PhaseManager.class).getInPhases(),
+                                            bus.getInInterceptors(),
+                                            endpoint.getService().getInInterceptors(),
+                                            endpoint.getInInterceptors(),
+                                            getBinding().getInInterceptors(),
+                                            dbp.getInInterceptors());
+            }
+        
             
             
             message.setInterceptorChain(phaseChain);

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java (original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBDataBinding.java Tue
Jul 28 01:07:44 2009
@@ -63,6 +63,7 @@
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.CacheMap;
 import org.apache.cxf.common.util.CachedClass;
+import org.apache.cxf.common.util.ModCountCopyOnWriteArrayList;
 import org.apache.cxf.common.util.PackageUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.common.xmlschema.SchemaCollection;
@@ -73,6 +74,9 @@
 import org.apache.cxf.databinding.WrapperCapableDatabinding;
 import org.apache.cxf.databinding.WrapperHelper;
 import org.apache.cxf.helpers.XMLUtils;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.interceptor.InterceptorProvider;
+import org.apache.cxf.jaxb.attachment.JAXBAttachmentSchemaValidationHack;
 import org.apache.cxf.jaxb.io.DataReaderImpl;
 import org.apache.cxf.jaxb.io.DataWriterImpl;
 import org.apache.cxf.resource.URIResolver;
@@ -81,7 +85,9 @@
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.ws.addressing.ObjectFactory;
 
-public class JAXBDataBinding extends AbstractDataBinding  implements WrapperCapableDatabinding
{
+public class JAXBDataBinding extends AbstractDataBinding 
+    implements WrapperCapableDatabinding, InterceptorProvider {
+    
     public static final String SCHEMA_RESOURCE = "SCHEMRESOURCE";
     public static final String MTOM_THRESHOLD = "org.apache.cxf.jaxb.mtomThreshold";
 
@@ -219,6 +225,11 @@
 
     private boolean qualifiedSchemas;
     private Service service;
+    
+    private List<Interceptor> in = new ModCountCopyOnWriteArrayList<Interceptor>();
+    private List<Interceptor> out = new ModCountCopyOnWriteArrayList<Interceptor>();
+    private List<Interceptor> outFault  = new ModCountCopyOnWriteArrayList<Interceptor>();
+    private List<Interceptor> inFault  = new ModCountCopyOnWriteArrayList<Interceptor>();
 
     public JAXBDataBinding() {
     }
@@ -296,6 +307,10 @@
     @SuppressWarnings("unchecked")
     public void initialize(Service aservice) {
         this.service = aservice;
+        
+        getInInterceptors().add(JAXBAttachmentSchemaValidationHack.INSTANCE);
+        getInFaultInterceptors().add(JAXBAttachmentSchemaValidationHack.INSTANCE);
+        
         // context is already set, don't redo it
         if (context != null) {
             return;
@@ -880,5 +895,22 @@
         }
         return null;
     }   
+    
+    public List<Interceptor> getOutFaultInterceptors() {
+        return outFault;
+    }
+
+    public List<Interceptor> getInFaultInterceptors() {
+        return inFault;
+    }
+
+    public List<Interceptor> getInInterceptors() {
+        return in;
+    }
+
+    public List<Interceptor> getOutInterceptors() {
+        return out;
+    }
+
 
 }

Added: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java?rev=798345&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
(added)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
Tue Jul 28 01:07:44 2009
@@ -0,0 +1,80 @@
+/**
+ * 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.jaxb.attachment;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.cxf.attachment.AttachmentDataSource;
+import org.apache.cxf.helpers.CastUtils;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.interceptor.Interceptor;
+import org.apache.cxf.message.Attachment;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+/**
+ * 
+ */
+public final class JAXBAttachmentSchemaValidationHack extends AbstractPhaseInterceptor<Message>
{
+    public static final Interceptor INSTANCE = new JAXBAttachmentSchemaValidationHack();
+    private static final String SAVED_DATASOURCES 
+        = JAXBAttachmentSchemaValidationHack.class.getName() + ".SAVED_DATASOURCES";
+
+    private JAXBAttachmentSchemaValidationHack() {
+        super(Phase.POST_PROTOCOL);
+    }
+    
+    public void handleMessage(Message message) throws Fault {
+        Object en = message.getContextualProperty(Message.SCHEMA_VALIDATION_ENABLED);
+        if ((Boolean.TRUE.equals(en) || "true".equals(en)) && message.getAttachments()
!= null) {
+            Collection<AttachmentDataSource> dss = new ArrayList<AttachmentDataSource>();
+            for (Attachment at : message.getAttachments()) {
+                if (at.getDataHandler().getDataSource() instanceof AttachmentDataSource)
{
+                    AttachmentDataSource ds = (AttachmentDataSource)at.getDataHandler().getDataSource();
+                    ds.hold();
+                    dss.add(ds);
+                }
+            }
+            if (!dss.isEmpty()) {
+                message.put(SAVED_DATASOURCES, dss);
+                message.getInterceptorChain().add(EndingInterceptor.INSTANCE);
+            }
+        }
+    }
+    
+    static class EndingInterceptor extends AbstractPhaseInterceptor<Message> {
+        static final EndingInterceptor INSTANCE = new EndingInterceptor();
+        
+        EndingInterceptor() {
+            super(Phase.PRE_LOGICAL);
+        }
+
+        public void handleMessage(Message message) throws Fault {
+            Collection<AttachmentDataSource> dss = CastUtils.cast((List<?>)message.get(SAVED_DATASOURCES));
+            for (AttachmentDataSource ds : dss) {
+                ds.release();
+            }
+        }
+    }
+
+}

Propchange: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentSchemaValidationHack.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/client/AbstractClient.java
Tue Jul 28 01:07:44 2009
@@ -510,6 +510,7 @@
         List<Interceptor> i1 = cfg.getBus().getInInterceptors();
         List<Interceptor> i2 = cfg.getInInterceptors();
         List<Interceptor> i3 = cfg.getConduitSelector().getEndpoint().getInInterceptors();
+        
         return new PhaseChainCache().get(pm.getInPhases(), i1, i2, i3);
     }
     

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java?rev=798345&r1=798344&r2=798345&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/ClientMtomXopTest.java Tue
Jul 28 01:07:44 2009
@@ -30,6 +30,7 @@
 import javax.xml.ws.Holder;
 import javax.xml.ws.soap.SOAPBinding;
 
+import org.apache.axiom.attachments.utils.IOUtils;
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.endpoint.Client;
@@ -59,7 +60,7 @@
     @BeforeClass
     public static void startServers() throws Exception {
         TestUtilities.setKeepAliveSystemProperty(false);
-        assertTrue("server did not launch correctly", launchServer(Server.class, true));
+        assertTrue("server did not launch correctly", launchServer(Server.class));
     }
 
     @AfterClass
@@ -67,22 +68,6 @@
         TestUtilities.recoverKeepAliveSystemProperty();
     }
 
-    /*
-     * @Test @Ignore public void testMtomSWA() throws Exception { TestMtom
-     * mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class); try {
-     * InputStream pre =
-     * this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl"); long fileSize =
-     * 0; for (int i = pre.read(); i != -1; i = pre.read()) { fileSize++; }
-     * ByteArrayDataSource bads = new
-     * ByteArrayDataSource(this.getClass().getResourceAsStream(
-     * "/wsdl/mtom_xop.wsdl"), "application/octet-stream"); DataHandler dh = new
-     * DataHandler(bads); DataHandler dhResp = mtomPort.testSWA(dh); DataSource
-     * ds = dhResp.getDataSource(); InputStream in = ds.getInputStream(); long
-     * count = 0; for (int i = in.read(); i != -1; i = in.read()) { count++; }
-     * assertEquals("attachemnt length different", fileSize, count); } catch
-     * (UndeclaredThrowableException ex) { throw (Exception) ex.getCause(); } }
-     */
-
     @Test
     public void testMtomXop() throws Exception {
         TestMtom mtomPort = createPort(MTOM_SERVICE, MTOM_PORT, TestMtom.class, true, true);
@@ -110,8 +95,23 @@
             mtomPort.testXop(name, param);
             assertEquals("name unchanged", "return detail + call detail", name.value);
             assertNotNull(param.value);
-            param.value.getInputStream().close();
             
+            InputStream in = param.value.getInputStream();
+            byte bytes[] = IOUtils.getStreamAsByteArray(in);
+            assertEquals(data.length, bytes.length);
+            in.close();
+
+            param.value = new DataHandler(new ByteArrayDataSource(data, "application/octet-stream"));
+            name = new Holder<String>("call detail");
+            mtomPort.testXop(name, param);
+            assertEquals("name unchanged", "return detail + call detail", name.value);
+            assertNotNull(param.value);
+            
+            in = param.value.getInputStream();
+            bytes = IOUtils.getStreamAsByteArray(in);
+            assertEquals(data.length, bytes.length);
+            in.close();
+
         } catch (UndeclaredThrowableException ex) {
             throw (Exception)ex.getCause();
         }



Mime
View raw message