You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2010/03/23 10:12:15 UTC

svn commit: r926506 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src: main/java/org/apache/servicemix/cxfbc/ test/java/org/apache/servicemix/cxfbc/ws/rm/ test/resources/org/apache/servicemix/cxfbc/ws/rm/

Author: ffang
Date: Tue Mar 23 09:12:15 2010
New Revision: 926506

URL: http://svn.apache.org/viewvc?rev=926506&view=rev
Log:
[SMXCOMP-727]cxf bc consumer should be able to add BareOutInterceptor automatically in case that RMFeature added on bus

Added:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMFeatureTest.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/rm/rmfeature.xml
Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?rev=926506&r1=926505&r2=926506&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Tue Mar 23 09:12:15 2010
@@ -56,6 +56,7 @@ import org.apache.cxf.binding.soap.inter
 import org.apache.cxf.binding.soap.interceptor.SoapActionOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapOutInterceptor;
 import org.apache.cxf.binding.soap.interceptor.SoapPreProtocolOutInterceptor;
+import org.apache.cxf.bus.CXFBusImpl;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.catalog.OASISCatalogManager;
 import org.apache.cxf.continuations.Continuation;
@@ -69,6 +70,7 @@ import org.apache.cxf.feature.AbstractFe
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.interceptor.AttachmentInInterceptor;
 import org.apache.cxf.interceptor.AttachmentOutInterceptor;
+import org.apache.cxf.interceptor.BareOutInterceptor;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.Interceptor;
 import org.apache.cxf.interceptor.OutgoingChainInterceptor;
@@ -529,6 +531,7 @@ public class CxfBcConsumer extends Consu
 
             chain = new JbiChainInitiationObserver(ep, getBus());
             removeDatabindingInterceptprs();
+            addRMFeatureRequiredInterceptors();
             server = new ServerImpl(getBus(), ep, null, chain);
 
             super.validate();
@@ -539,6 +542,17 @@ public class CxfBcConsumer extends Consu
         }
     }
 
+    private void addRMFeatureRequiredInterceptors() {
+        CXFBusImpl bus = (CXFBusImpl) getBus();
+        if (bus.getFeatures() != null) {
+            for (AbstractFeature feature : bus.getFeatures()){
+                if (feature.getClass().getName().equals("org.apache.cxf.ws.rm.feature.RMFeature")) {
+                    bus.getOutInterceptors().add(new BareOutInterceptor());
+                }
+            }
+        }
+    }
+
     private void removeDatabindingInterceptprs() {
         for (Interceptor interceptor : ep.getBinding().getInInterceptors()) {
             if (interceptor.getClass().getName().equals("org.apache.cxf.interceptor.DocLiteralInInterceptor")

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMFeatureTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMFeatureTest.java?rev=926506&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMFeatureTest.java (added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/ws/rm/CxfBcRMFeatureTest.java Tue Mar 23 09:12:15 2010
@@ -0,0 +1,104 @@
+/*
+ * 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.servicemix.cxfbc.ws.rm;
+
+import java.net.URL;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Holder;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Client;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.servicemix.components.util.MockServiceComponent;
+import org.apache.servicemix.cxfbc.CxfBcComponent;
+import org.apache.servicemix.cxfbc.CxfBcConsumer;
+import org.apache.servicemix.cxfbc.CxfBcEndpointType;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.springframework.core.io.ClassPathResource;
+
+import uri.helloworld.HelloHeader;
+import uri.helloworld.HelloPortType;
+import uri.helloworld.HelloRequest;
+import uri.helloworld.HelloResponse;
+import uri.helloworld.HelloService;
+
+public class CxfBcRMFeatureTest extends TestCase {
+
+    static final Logger LOG = LogUtils.getL7dLogger(CxfBcRMFeatureTest.class);
+
+    private final QName serviceName = new QName("uri:HelloWorld",
+            "HelloService");
+
+    private JBIContainer jbi;
+
+    protected void setUp() throws Exception {
+        jbi = new JBIContainer();
+        jbi.setEmbedded(true);
+        jbi.init();
+        jbi.start();
+
+    }
+
+    protected void tearDown() throws Exception {
+        jbi.shutDown();
+    }
+
+    public void testRMEndpointWithExternalConsumer() throws Exception {
+        CxfBcComponent comp = new CxfBcComponent();
+        CxfBcConsumer ep = new CxfBcConsumer();
+        ep.setBusCfg("org/apache/servicemix/cxfbc/ws/rm/rmfeature.xml");
+        ep.setWsdl(new ClassPathResource("HelloWorld-DOC.wsdl"));
+        ep.setTargetService(new QName("urn:test", "target"));
+        comp.setEndpoints(new CxfBcEndpointType[] {ep});
+        jbi.activateComponent(comp, "servicemix-cxfbc");
+
+        MockServiceComponent echo = new MockServiceComponent();
+        echo.setService(new QName("urn:test", "target"));
+        echo.setEndpoint("endpoint");
+        echo.setResponseXml("<jbi:message xmlns:jbi='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'><jbi:part>" 
+                + "<ns2:HelloResponse xmlns:ns2='uri:HelloWorld'><text>helloffang</text></ns2:HelloResponse></jbi:part></jbi:message>");
+        jbi.activateComponent(echo, "echo");
+
+        SpringBusFactory bf = new SpringBusFactory();
+        Bus clientBus = bf.createBus("org/apache/servicemix/cxfbc/ws/rm/rminterceptors.xml");
+        BusFactory.setDefaultBus(clientBus);
+        URL wsdl = getClass().getResource("/HelloWorld-DOC.wsdl");
+        assertNotNull(wsdl);
+        HelloService helloService = new HelloService(wsdl, serviceName);
+        HelloPortType port = helloService.getHelloPort();
+        Client client = ClientProxy.getClient(port);
+        client.getInInterceptors().add(new LoggingInInterceptor());
+        HelloRequest req = new HelloRequest();
+        req.setText("hello");
+        HelloHeader header = new HelloHeader();
+        header.setId("ffang");
+        Holder<HelloHeader> header1 = new Holder<HelloHeader>();
+        header1.value = header;
+        HelloResponse rep = port.hello(req, header1);
+        Thread.sleep(1000);
+        assertEquals(rep.getText(), "helloffang");
+    }
+
+}

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/rm/rmfeature.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/rm/rmfeature.xml?rev=926506&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/rm/rmfeature.xml (added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/ws/rm/rmfeature.xml Tue Mar 23 09:12:15 2010
@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+  -->
+<beans xmlns="http://www.springframework.org/schema/beans"
+  xmlns:cxf="http://cxf.apache.org/core"
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xmlns:jaxws="http://cxf.apache.org/jaxws"
+       xmlns:wsa="http://cxf.apache.org/ws/addressing"
+  xmlns:http="http://cxf.apache.org/transports/http/configuration"
+  xmlns:wsrm-policy="http://schemas.xmlsoap.org/ws/2005/02/rm/policy"
+  xmlns:wsrm-mgr="http://cxf.apache.org/ws/rm/manager"
+  xsi:schemaLocation="
+    http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+    http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+    http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+    http://schemas.xmlsoap.org/ws/2005/02/rm/policy http://schemas.xmlsoap.org/ws/2005/02/rm/wsrm-policy.xsd
+    http://cxf.apache.org/ws/rm/manager http://cxf.apache.org/schemas/configuration/wsrm-manager.xsd
+    http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
+
+  <cxf:bus name="bcBus">
+    <cxf:features>
+      <cxf:logging />
+      <wsa:addressing />
+      <wsrm-mgr:reliableMessaging>
+        <wsrm-policy:RMAssertion>
+          <wsrm-policy:BaseRetransmissionInterval
+            Milliseconds="4000" />
+          <wsrm-policy:AcknowledgementInterval
+            Milliseconds="2000" />
+        </wsrm-policy:RMAssertion>
+        <wsrm-mgr:destinationPolicy>
+          <wsrm-mgr:acksPolicy intraMessageThreshold="0" />
+        </wsrm-mgr:destinationPolicy>
+      </wsrm-mgr:reliableMessaging>
+    </cxf:features>
+  </cxf:bus>
+</beans>
+
+
+