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 2009/05/27 09:02:12 UTC
svn commit: r779030 - in
/servicemix/components/engines/servicemix-cxf-se/trunk/src/test:
java/org/apache/servicemix/cxfse/ resources/org/apache/servicemix/cxfse/mtom/
resources/org/apache/servicemix/cxfse/payload/
resources/org/apache/servicemix/cxfse...
Author: ffang
Date: Wed May 27 07:02:11 2009
New Revision: 779030
URL: http://svn.apache.org/viewvc?rev=779030&view=rev
Log:
[SMXCOMP-523]Improve test coverage - ServiceMix :: CXF Service Engine
Added:
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientMtomProxyTest.java (with props)
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientPayloadProxyTest.java (with props)
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml (with props)
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml (with props)
Modified:
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImplForClientProxy.java
servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/proxy/xbean.xml
Added: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientMtomProxyTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientMtomProxyTest.java?rev=779030&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientMtomProxyTest.java (added)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientMtomProxyTest.java Wed May 27 07:02:11 2009
@@ -0,0 +1,111 @@
+/*
+ * 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.cxfse;
+
+import java.io.File;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.InOut;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
+
+public class CxfSeClientMtomProxyTest extends TestCase {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(CxfSeClientMtomProxyTest.class);
+ private DefaultServiceMixClient client;
+ private InOut io;
+ private JBIContainer container;
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setMonitorInstallationDirectory(false);
+ container.setNamingContext(new InitialContext());
+ container.setEmbedded(true);
+ container.init();
+
+ }
+
+
+
+ public void testMtomProxy() throws Exception {
+
+ CxfSeComponent component = new CxfSeComponent();
+ container.activateComponent(component, "CxfSeComponent");
+
+ // Start container
+ container.start();
+
+ // Deploy SU
+ component.getServiceUnitManager().deploy("target", getServiceUnitPath("mtom"));
+ component.getServiceUnitManager().init("target", getServiceUnitPath("mtom"));
+ component.getServiceUnitManager().start("target");
+
+ component.getServiceUnitManager().deploy("proxy", getServiceUnitPath("proxy"));
+ component.getServiceUnitManager().init("proxy", getServiceUnitPath("proxy"));
+ component.getServiceUnitManager().start("proxy");
+
+
+ client = new DefaultServiceMixClient(container);
+ io = client.createInOutExchange();
+ io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPService"));
+ io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
+ io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
+
+ LOG.info("test clientProxy");
+ io.getInMessage().setContent(new StringSource(
+ "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+ + "<part> "
+ + "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+ + "mtom"
+ + "</requestType></greetMe>"
+ + "</part> "
+ + "</message>"));
+ client.sendSync(io);
+ assertTrue(new SourceTransformer().contentToString(
+ io.getOutMessage()).indexOf("Hello mtom testfoobar") > 0);
+ client.done(io);
+
+
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ protected String getServiceUnitPath(String name) {
+ URL url = getClass().getClassLoader().getResource("org/apache/servicemix/cxfse/" + name + "/xbean.xml");
+ File path = new File(url.getFile());
+ path = path.getParentFile();
+ return path.getAbsolutePath();
+ }
+
+
+}
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientMtomProxyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientMtomProxyTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientPayloadProxyTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientPayloadProxyTest.java?rev=779030&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientPayloadProxyTest.java (added)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientPayloadProxyTest.java Wed May 27 07:02:11 2009
@@ -0,0 +1,111 @@
+/*
+ * 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.cxfse;
+
+import java.io.File;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.InOut;
+import javax.naming.InitialContext;
+import javax.xml.namespace.QName;
+
+import junit.framework.TestCase;
+
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.jbi.container.JBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+
+
+public class CxfSeClientPayloadProxyTest extends TestCase {
+
+ private static final Logger LOG = LogUtils.getL7dLogger(CxfSeClientPayloadProxyTest.class);
+ private DefaultServiceMixClient client;
+ private InOut io;
+ private JBIContainer container;
+
+ protected void setUp() throws Exception {
+ container = new JBIContainer();
+ container.setUseMBeanServer(false);
+ container.setCreateMBeanServer(false);
+ container.setMonitorInstallationDirectory(false);
+ container.setNamingContext(new InitialContext());
+ container.setEmbedded(true);
+ container.init();
+
+ }
+
+
+
+ public void testPayloadProxy() throws Exception {
+
+ CxfSeComponent component = new CxfSeComponent();
+ container.activateComponent(component, "CxfSeComponent");
+
+ // Start container
+ container.start();
+
+ // Deploy SU
+ component.getServiceUnitManager().deploy("target", getServiceUnitPath("payload"));
+ component.getServiceUnitManager().init("target", getServiceUnitPath("payload"));
+ component.getServiceUnitManager().start("target");
+
+ component.getServiceUnitManager().deploy("proxy", getServiceUnitPath("proxy"));
+ component.getServiceUnitManager().init("proxy", getServiceUnitPath("proxy"));
+ component.getServiceUnitManager().start("proxy");
+
+
+ client = new DefaultServiceMixClient(container);
+ io = client.createInOutExchange();
+ io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPService"));
+ io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
+ io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
+
+ LOG.info("test clientProxy");
+ io.getInMessage().setContent(new StringSource(
+ "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+ + "<part> "
+ + "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+ + "payload"
+ + "</requestType></greetMe>"
+ + "</part> "
+ + "</message>"));
+ client.sendSync(io);
+ assertTrue(new SourceTransformer().contentToString(
+ io.getOutMessage()).indexOf("Hello payload 3") > 0);
+ client.done(io);
+
+
+ }
+
+ protected void tearDown() throws Exception {
+ if (container != null) {
+ container.shutDown();
+ }
+ }
+
+ protected String getServiceUnitPath(String name) {
+ URL url = getClass().getClassLoader().getResource("org/apache/servicemix/cxfse/" + name + "/xbean.xml");
+ File path = new File(url.getFile());
+ path = path.getParentFile();
+ return path.getAbsolutePath();
+ }
+
+
+}
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientPayloadProxyTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/CxfSeClientPayloadProxyTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Modified: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImplForClientProxy.java
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImplForClientProxy.java?rev=779030&r1=779029&r2=779030&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImplForClientProxy.java (original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/java/org/apache/servicemix/cxfse/GreeterImplForClientProxy.java Wed May 27 07:02:11 2009
@@ -16,15 +16,19 @@
*/
package org.apache.servicemix.cxfse;
-
+import java.io.InputStream;
import java.util.concurrent.Future;
+import javax.activation.DataHandler;
import javax.jbi.component.ComponentContext;
import javax.jws.WebService;
+import javax.mail.util.ByteArrayDataSource;
import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Holder;
import javax.xml.ws.Response;
import org.apache.cxf.calculator.CalculatorPortType;
+import org.apache.cxf.mime.TestMtom;
import org.apache.hello_world_soap_http.BadRecordLitFault;
import org.apache.hello_world_soap_http.Greeter;
import org.apache.hello_world_soap_http.NoSuchCodeLitFault;
@@ -46,16 +50,38 @@
private ComponentContext context;
private CalculatorPortType calculator;
+ private CalculatorPortType calculatorPayload;
+ private TestMtom mtom;
+
public String greetMe(String me) {
int ret = 0;
try {
-
- ret = getCalculator().add(1, 2);
+ if ("ffang".equals(me)) {
+ ret = getCalculator().add(1, 2);
+ return "Hello " + me + " " + ret;
+ } else if ("mtom".equals(me)) {
+ Holder<DataHandler> param = new Holder<DataHandler>();
+
+ param.value = new DataHandler(new ByteArrayDataSource("foobar".getBytes(),
+ "application/octet-stream"));
+
+ Holder<String> name = new Holder<String>("call detail");
+ mtom.testXop(name, param);
+ InputStream bis = param.value.getDataSource().getInputStream();
+ byte b[] = new byte[10];
+ bis.read(b, 0, 10);
+ String attachContent = new String(b);
+ return "Hello " + me + " " + attachContent;
+ } else if ("payload".equals(me)) {
+ ret = getCalculatorPayload().add(1, 2);
+ return "Hello " + me + " " + ret;
+ }
} catch (Exception e) {
e.printStackTrace();
}
- return "Hello " + me + " " + ret;
+ return null;
+
}
public ComponentContext getContext() {
@@ -164,6 +190,20 @@
return null;
}
-
+ public void setMtom(TestMtom mtom) {
+ this.mtom = mtom;
+ }
+
+ public TestMtom getMtom() {
+ return mtom;
+ }
+
+ public void setCalculatorPayload(CalculatorPortType calculatorPayload) {
+ this.calculatorPayload = calculatorPayload;
+ }
+
+ public CalculatorPortType getCalculatorPayload() {
+ return calculatorPayload;
+ }
}
Added: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml?rev=779030&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml (added)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml Wed May 27 07:02:11 2009
@@ -0,0 +1,42 @@
+<?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:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
+ >
+ <cxfse:endpoint mtomEnabled="true">
+ <cxfse:pojo>
+ <bean class="org.apache.servicemix.cxfse.TestMtomImpl" />
+ </cxfse:pojo>
+ <cxfse:inInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfse:inInterceptors>
+ <cxfse:outInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfse:outInterceptors>
+ <cxfse:inFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfse:inFaultInterceptors>
+ <cxfse:outFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfse:outFaultInterceptors>
+ </cxfse:endpoint>
+
+</beans>
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/mtom/xbean.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Added: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml?rev=779030&view=auto
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml (added)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml Wed May 27 07:02:11 2009
@@ -0,0 +1,42 @@
+<?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:sm="http://servicemix.apache.org/config/1.0"
+ xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
+ xmlns:calculator="http://apache.org/cxf/calculator">
+
+ <cxfse:endpoint useJBIWrapper="false" useSOAPEnvelope="false">
+ <cxfse:pojo>
+ <bean class="org.apache.cxf.calculator.CalculatorImpl" />
+ </cxfse:pojo>
+ <cxfse:inInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfse:inInterceptors>
+ <cxfse:outInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfse:outInterceptors>
+ <cxfse:inFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+ </cxfse:inFaultInterceptors>
+ <cxfse:outFaultInterceptors>
+ <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+ </cxfse:outFaultInterceptors>
+ </cxfse:endpoint>
+
+</beans>
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/payload/xbean.xml
------------------------------------------------------------------------------
svn:mime-type = text/xml
Modified: servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/proxy/xbean.xml
URL: http://svn.apache.org/viewvc/servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/proxy/xbean.xml?rev=779030&r1=779029&r2=779030&view=diff
==============================================================================
--- servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/proxy/xbean.xml (original)
+++ servicemix/components/engines/servicemix-cxf-se/trunk/src/test/resources/org/apache/servicemix/cxfse/proxy/xbean.xml Wed May 27 07:02:11 2009
@@ -21,6 +21,7 @@
xmlns:sm="http://servicemix.apache.org/config/1.0"
xmlns:cxfse="http://servicemix.apache.org/cxfse/1.0"
xmlns:test="urn:test"
+ xmlns:mtom="http://cxf.apache.org/mime"
xmlns:calculator="http://apache.org/cxf/calculator"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
@@ -34,6 +35,11 @@
<property name="calculator">
<cxfse:proxy service="calculator:CalculatorService" context="#context" type="org.apache.cxf.calculator.CalculatorPortType" />
</property>
+ <property name="mtom">
+ <cxfse:proxy service="mtom:TestMtomService" context="#context" type="org.apache.cxf.mime.TestMtom" mtomEnabled="true"/>
+ </property> <property name="calculatorPayload">
+ <cxfse:proxy service="calculator:CalculatorService" context="#context" useJBIWrapper="false" useSOAPEnvelope="false" type="org.apache.cxf.calculator.CalculatorPortType" />
+ </property>
</bean>
</cxfse:pojo>