cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dan Diephouse <...@envoisolutions.com>
Subject Re: svn commit: r451929 - in /incubator/cxf/trunk: rt/core/src/main/java/org/apache/cxf/binding/attachment/ rt/core/src/main/java/org/apache/cxf/interceptor/ rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/attachment/ rt/frontend/jaxws/src/main/java/...
Date Thu, 05 Oct 2006 05:02:46 GMT
I doubt that anyone's gone out and fixed this yet - but I've fixed in my 
tree. I'm stuck trying to get the XML binding to work correctly, but I 
have a large commit coming in soon with it...

- Dan

Daniel Kulp wrote:
>   
>>  add JAXBElement check in wrap in interceptor
>>     
>
> I'm -1 to this change.   The JAXBElement is a JAXB specific thing and thus 
> goes into the JAXB data binding or into the JAX-WS frontend.    It should not 
> be going into the core interceptors that need to work for other databindings 
> and frontends.
>
>
> That said, thanks for fixing the MTOM test.   Looks much better.
>
> Dan
>
>
>
>   
>> Added:
>>    
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> AttachmentOutInterceptor.java   (with props)
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> MultipartMessageInterceptor.java   (with props) Modified:
>>    
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/attachment
>> /AttachmentImpl.java
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Wrappe
>> dInInterceptor.java
>> incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/a
>> ttachment/JAXBAttachmentMarshaller.java
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/En
>> dpointInvocationHandler.java
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Clie
>> ntServerMtomXopTest.java
>>
>> Modified:
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/attachment
>> /AttachmentImpl.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/
>> apache/cxf/binding/attachment/AttachmentImpl.java?view=diff&rev=451929&r1=45
>> 1928&r2=451929
>> ===========================================================================
>> === ---
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/attachment
>> /AttachmentImpl.java (original) +++
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/binding/attachment
>> /AttachmentImpl.java Mon Oct  2 02:28:29 2006 @@ -48,11 +48,11 @@
>>      }
>>
>>      public void setHeader(String name, String value) {
>> -        headers.put(name, value);
>> +        headers.put(name.toLowerCase(), value);
>>      }
>>
>>      public String getHeader(String name) {
>> -        return headers.get(name);
>> +        return headers.get(name.toLowerCase());
>>      }
>>
>>      public Iterator<String> getHeaderNames() {
>>
>> Modified:
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Wrappe
>> dInInterceptor.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/
>> apache/cxf/interceptor/WrappedInInterceptor.java?view=diff&rev=451929&r1=451
>> 928&r2=451929
>> ===========================================================================
>> === ---
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Wrappe
>> dInInterceptor.java (original) +++
>> incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/interceptor/Wrappe
>> dInInterceptor.java Mon Oct  2 02:28:29 2006 @@ -23,6 +23,7 @@
>>  import java.util.List;
>>  import java.util.ResourceBundle;
>>
>> +import javax.xml.bind.JAXBElement;
>>  import javax.xml.stream.XMLStreamException;
>>  import javax.xml.stream.XMLStreamReader;
>>
>> @@ -90,6 +91,9 @@
>>          if (operation.isUnwrapped() || operation.isUnwrappedCapable()) {
>>              objects = new ArrayList<Object>();
>>              Object wrappedObject = dr.read(message);
>> +            if (wrappedObject instanceof JAXBElement) {
>> +                wrappedObject = ((JAXBElement) wrappedObject).getValue();
>> +            }
>>              objects.add(wrappedObject);
>>          } else {
>>              // Unwrap each part individually if we don't have a wrapper
>>
>> Modified:
>> incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/a
>> ttachment/JAXBAttachmentMarshaller.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/jaxb/src/ma
>> in/java/org/apache/cxf/jaxb/attachment/JAXBAttachmentMarshaller.java?view=di
>> ff&rev=451929&r1=451928&r2=451929
>> ===========================================================================
>> === ---
>> incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/a
>> ttachment/JAXBAttachmentMarshaller.java (original) +++
>> incubator/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/a
>> ttachment/JAXBAttachmentMarshaller.java Mon Oct  2 02:28:29 2006 @@ -53,7
>> +53,7 @@
>>              return null;
>>          }
>>          ByteDataSource source = new ByteDataSource(data, offset, length);
>> -        if (mimeType == null) {
>> +        if (mimeType != null) {
>>              source.setContentType(mimeType);
>>          } else {
>>              source.setContentType("application/octet-stream");
>>
>> Modified:
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/En
>> dpointInvocationHandler.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main
>> /java/org/apache/cxf/jaxws/EndpointInvocationHandler.java?view=diff&rev=4519
>> 29&r1=451928&r2=451929
>> ===========================================================================
>> === ---
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/En
>> dpointInvocationHandler.java (original) +++
>> incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/En
>> dpointInvocationHandler.java Mon Oct  2 02:28:29 2006 @@ -52,7 +52,7 @@
>>
>>      private Client client;
>>
>> -    EndpointInvocationHandler(Client c, Binding b) {
>> +    public EndpointInvocationHandler(Client c, Binding b) {
>>          super(b);
>>          endpoint = c.getEndpoint();
>>          client = c;
>>
>> Modified:
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Clie
>> ntServerMtomXopTest.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org
>> /apache/cxf/systest/mtom/ClientServerMtomXopTest.java?view=diff&rev=451929&r
>> 1=451928&r2=451929
>> ===========================================================================
>> === ---
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Clie
>> ntServerMtomXopTest.java (original) +++
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Clie
>> ntServerMtomXopTest.java Mon Oct  2 02:28:29 2006 @@ -19,38 +19,80 @@
>>  package org.apache.cxf.systest.mtom;
>>
>>  import java.io.InputStream;
>> +import java.lang.reflect.InvocationHandler;
>> +import java.lang.reflect.Proxy;
>>  import java.lang.reflect.UndeclaredThrowableException;
>> +import java.util.List;
>>
>>  import javax.activation.DataHandler;
>>  import javax.activation.DataSource;
>>  import javax.mail.util.ByteArrayDataSource;
>> -import javax.xml.ws.Binding;
>> +import javax.xml.namespace.QName;
>>  import javax.xml.ws.BindingProvider;
>> -import javax.xml.ws.Endpoint;
>>  import javax.xml.ws.Holder;
>>  import javax.xml.ws.soap.SOAPBinding;
>>
>>  import junit.framework.Test;
>>  import junit.framework.TestSuite;
>>
>> +import org.apache.cxf.Bus;
>> +import org.apache.cxf.BusFactoryHelper;
>> +import org.apache.cxf.binding.soap.SoapBinding;
>> +import org.apache.cxf.binding.soap.interceptor.AttachmentOutInterceptor;
>> +import
>> org.apache.cxf.binding.soap.interceptor.MultipartMessageInterceptor;
>> +import org.apache.cxf.endpoint.Client;
>> +import org.apache.cxf.endpoint.ClientImpl;
>> +import org.apache.cxf.endpoint.ServerImpl;
>> +import org.apache.cxf.interceptor.Interceptor;
>> +import org.apache.cxf.jaxws.EndpointInvocationHandler;
>> +import org.apache.cxf.jaxws.JAXWSMethodInvoker;
>> +import org.apache.cxf.jaxws.binding.soap.SOAPBindingImpl;
>> +import org.apache.cxf.jaxws.support.JaxWsEndpointImpl;
>> +import org.apache.cxf.jaxws.support.JaxWsImplementorInfo;
>> +import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
>>  import org.apache.cxf.mime.Hello;
>> -import org.apache.cxf.mime.HelloService;
>>  import org.apache.cxf.mtom_xop.HelloImpl;
>> +import org.apache.cxf.service.Service;
>> +import org.apache.cxf.service.factory.AbstractServiceFactoryBean;
>> +import org.apache.cxf.service.model.EndpointInfo;
>> +import org.apache.cxf.service.model.ServiceInfo;
>>  import org.apache.cxf.systest.common.ClientServerSetupBase;
>>  import org.apache.cxf.systest.common.ClientServerTestBase;
>>  import org.apache.cxf.systest.common.TestServerBase;
>> +import org.apache.cxf.transport.ChainInitiationObserver;
>> +import org.apache.cxf.transport.MessageObserver;
>>
>>  public class ClientServerMtomXopTest extends ClientServerTestBase {
>>
>> +    public static final QName HELLO_PORT = new
>> QName("http://cxf.apache.org/mime", "HelloPort"); +    public static final
>> QName HELLO_SERVICE = new QName("http://cxf.apache.org/mime",
>> "HelloService"); +
>>      public static class Server extends TestServerBase {
>>
>>          protected void run() {
>>              Object implementor = new HelloImpl();
>>              String address = "http://localhost:9036/mime-test";
>> -            Endpoint ep = Endpoint.publish(address, implementor);
>> -            Binding binding = ep.getBinding();
>> -            assertTrue(binding instanceof SOAPBinding);
>> -            ((SOAPBinding)binding).setMTOMEnabled(true);
>> +            try {
>> +                Bus bus = BusFactoryHelper.newInstance().getDefaultBus();
>> +                JaxWsImplementorInfo implInfo = new
>> JaxWsImplementorInfo(implementor.getClass()); +               
>> AbstractServiceFactoryBean serviceFactory = new
>> JaxWsServiceFactoryBean(implInfo); +               
>> serviceFactory.setBus(bus);
>> +                Service service = serviceFactory.create();
>> +                QName endpointName = implInfo.getEndpointName();
>> +                EndpointInfo ei =
>> service.getServiceInfo().getEndpoint(endpointName); +               
>> service.setInvoker(new JAXWSMethodInvoker(implementor)); +               
>> org.apache.cxf.endpoint.EndpointImpl endpoint = new JaxWsEndpointImpl(bus,
>> service, ei); +                SOAPBinding jaxWsSoapBinding = new
>> SOAPBindingImpl((SoapBinding) endpoint.getBinding()); +               
>> jaxWsSoapBinding.setMTOMEnabled(true);
>> +               
>> modifyBindingInterceptors(endpoint.getBinding().getInInterceptors(),
>> endpoint.getBinding() +                        .getOutInterceptors());
>> +                endpoint.getEndpointInfo().setAddress(address);
>> +                MessageObserver observer = new
>> ChainInitiationObserver(endpoint, bus); +                ServerImpl server
>> = new ServerImpl(bus, endpoint, observer); +                server.start();
>> +            } catch (Exception e) {
>> +                Thread.currentThread().interrupt();
>> +            }
>>          }
>>
>>          public static void main(String args[]) {
>> @@ -76,11 +118,7 @@
>>      }
>>
>>      public void testMtomSWA() throws Exception {
>> -        HelloService hs = new HelloService();
>> -        Hello hello = hs.getPort(Hello.class);
>> -        Binding binding = ((BindingProvider)hello).getBinding();
>> -        assertTrue(binding instanceof SOAPBinding);
>> -        ((SOAPBinding)binding).setMTOMEnabled(true);
>> +        Hello hello = createPort(HELLO_SERVICE, HELLO_PORT, Hello.class);
>>          try {
>>              InputStream pre =
>> this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl"); long fileSize =
>> 0;
>> @@ -89,7 +127,7 @@
>>              }
>>
>>              ByteArrayDataSource bads = new
>> ByteArrayDataSource(this.getClass().getResourceAsStream( -                 
>>           "/wsdl/mtom_xop.wsdl"), "application/octet-stream"); +           
>>         "/wsdl/mtom_xop.wsdl"), "application/octet-stream"); DataHandler dh
>> = new DataHandler(bads);
>>              DataHandler dhResp = hello.claimForm(dh);
>>              DataSource ds = dhResp.getDataSource();
>> @@ -105,11 +143,7 @@
>>      }
>>
>>      public void testMtomXop() throws Exception {
>> -        HelloService hs = new HelloService();
>> -        Hello hello = hs.getPort(Hello.class);
>> -        Binding binding = ((BindingProvider)hello).getBinding();
>> -        assertTrue(binding instanceof SOAPBinding);
>> -        ((SOAPBinding)binding).setMTOMEnabled(true);
>> +        Hello hello = createPort(HELLO_SERVICE, HELLO_PORT, Hello.class);
>>          try {
>>              InputStream pre =
>> this.getClass().getResourceAsStream("/wsdl/mtom_xop.wsdl"); long fileSize =
>> 0;
>> @@ -126,6 +160,56 @@
>>              assertEquals("attachinfo changed", target, new
>> String(param.value)); } catch (UndeclaredThrowableException ex) {
>>              throw (Exception) ex.getCause();
>> +        }
>> +    }
>> +
>> +    private static <T> T createPort(QName serviceName, QName portName,
>> Class<T> serviceEndpointInterface) +        throws Exception {
>> +        Bus bus = BusFactoryHelper.newInstance().getDefaultBus();
>> +        JaxWsServiceFactoryBean serviceFactory = new
>> JaxWsServiceFactoryBean(); +        serviceFactory.setBus(bus);
>> +        serviceFactory.setServiceName(serviceName);
>> +        serviceFactory.setServiceClass(serviceEndpointInterface);
>> +        Service service = serviceFactory.create();
>> +        ServiceInfo si = service.getServiceInfo();
>> +        EndpointInfo ei = null;
>> +        ei = si.getEndpoint(portName);
>> +        JaxWsEndpointImpl jaxwsEndpoint = new JaxWsEndpointImpl(bus,
>> service, ei); +        SOAPBinding jaxWsSoapBinding = new
>> SOAPBindingImpl((SoapBinding) jaxwsEndpoint.getBinding()); +       
>> jaxWsSoapBinding.setMTOMEnabled(true);
>> +       
>> modifyBindingInterceptors(jaxwsEndpoint.getBinding().getInInterceptors(),
>> jaxwsEndpoint.getBinding() +                .getOutInterceptors());
>> +        Client client = new ClientImpl(bus, jaxwsEndpoint);
>> +        InvocationHandler ih = new EndpointInvocationHandler(client,
>> jaxwsEndpoint.getJaxwsBinding()); +        Object obj =
>> Proxy.newProxyInstance(serviceEndpointInterface.getClassLoader(), new
>> Class[] { +            serviceEndpointInterface, BindingProvider.class },
>> ih); +        return serviceEndpointInterface.cast(obj);
>> +    }
>> +
>> +    private static void modifyBindingInterceptors(List<Interceptor> in,
>> List<Interceptor> out) { +        Interceptor inRemoved = null;
>> +        Interceptor outRemoved = null;
>> +        for (Interceptor i : in) {
>> +            if (i instanceof MultipartMessageInterceptor) {
>> +                inRemoved = i;
>> +            }
>> +        }
>> +        if (inRemoved != null) {
>> +            in.add(new TestMultipartMessageInterceptor());
>> +            in.remove(inRemoved);
>> +        } else {
>> +            fail("hasn't found MultipartMessageInterceptor in soap
>> binding"); +        }
>> +        for (Interceptor o : out) {
>> +            if (o instanceof AttachmentOutInterceptor) {
>> +                outRemoved = o;
>> +            }
>> +        }
>> +        if (outRemoved != null) {
>> +            out.add(new TestAttachmentOutInterceptor());
>> +            out.remove(outRemoved);
>> +        } else {
>> +            fail("hasn't found AttachmentOutInterceptor in soap binding");
>>          }
>>      }
>>
>>
>> Added:
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> AttachmentOutInterceptor.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org
>> /apache/cxf/systest/mtom/TestAttachmentOutInterceptor.java?view=auto&rev=451
>> 929
>> ===========================================================================
>> === ---
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> AttachmentOutInterceptor.java (added) +++
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> AttachmentOutInterceptor.java Mon Oct  2 02:28:29 2006 @@ -0,0 +1,40 @@
>> +/**
>> + * 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.mtom;
>> +
>> +import junit.framework.TestCase;
>> +
>> +import org.apache.cxf.binding.soap.SoapMessage;
>> +import org.apache.cxf.binding.soap.interceptor.AttachmentOutInterceptor;
>> +import org.apache.cxf.interceptor.Fault;
>> +import org.apache.cxf.message.Attachment;
>> +
>> +public class TestAttachmentOutInterceptor extends AttachmentOutInterceptor
>> { +
>> +    public void handleMessage(SoapMessage message) throws Fault {
>> +        super.handleMessage(message);
>> +        TestCase.assertEquals("check attachment count",
>> message.getAttachments().size(), 1); +        Attachment att =
>> message.getAttachments().iterator().next(); +       
>> TestCase.assertNotNull("Attachment is null", att);
>> +        TestCase.assertNotNull("Attachment content-type is null",
>> att.getDataHandler().getDataSource() +                .getContentType());
>> +    }
>> +
>> +}
>>
>> Propchange:
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> AttachmentOutInterceptor.java
>> ---------------------------------------------------------------------------
>> --- svn:eol-style = native
>>
>> Propchange:
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> AttachmentOutInterceptor.java
>> ---------------------------------------------------------------------------
>> --- svn:keywords = Rev Date
>>
>> Added:
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> MultipartMessageInterceptor.java URL:
>> http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org
>> /apache/cxf/systest/mtom/TestMultipartMessageInterceptor.java?view=auto&rev=
>> 451929
>> ===========================================================================
>> === ---
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> MultipartMessageInterceptor.java (added) +++
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> MultipartMessageInterceptor.java Mon Oct  2 02:28:29 2006 @@ -0,0 +1,36 @@
>> +/**
>> + * 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.mtom;
>> +
>> +import junit.framework.TestCase;
>> +
>> +import org.apache.cxf.binding.soap.SoapMessage;
>> +import
>> org.apache.cxf.binding.soap.interceptor.MultipartMessageInterceptor;
>> +import org.apache.cxf.interceptor.Fault;
>> +import org.apache.cxf.jaxb.attachment.AttachmentDeserializer;
>> +
>> +public class TestMultipartMessageInterceptor extends
>> MultipartMessageInterceptor { +
>> +    public void handleMessage(SoapMessage message) throws Fault {
>> +        super.handleMessage(message);
>> +        AttachmentDeserializer ad =
>> message.get(AttachmentDeserializer.class); +       
>> TestCase.assertNotNull("Not MIME Message received, Attachment Deserializer
>> hasn't been created", ad); +    }
>> +}
>>
>> Propchange:
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> MultipartMessageInterceptor.java
>> ---------------------------------------------------------------------------
>> --- svn:eol-style = native
>>
>> Propchange:
>> incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/mtom/Test
>> MultipartMessageInterceptor.java
>> ---------------------------------------------------------------------------
>> --- svn:keywords = Rev Date
>>     
>
>   


-- 
Dan Diephouse
Envoi Solutions
http://envoisolutions.com
http://netzooid.com/blog


Mime
View raw message