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/12 09:43:55 UTC

svn commit: r773813 - in /servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc: CxfBcProviderMtomTest.java CxfBcProviderTest.java

Author: ffang
Date: Tue May 12 07:43:54 2009
New Revision: 773813

URL: http://svn.apache.org/viewvc?rev=773813&view=rev
Log:
[SMXCOMP-535]Refactor CxfBcProviderTest

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderMtomTest.java   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderMtomTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderMtomTest.java?rev=773813&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderMtomTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderMtomTest.java Tue May 12 07:43:54 2009
@@ -0,0 +1,105 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.net.URL;
+
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+import javax.xml.ws.soap.SOAPBinding;
+
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.EndpointImpl;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.cxfbc.mtom.TestMtomImpl;
+import org.apache.servicemix.cxfse.CxfSeComponent;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+
+public class CxfBcProviderMtomTest extends SpringTestSupport {
+
+    private DefaultServiceMixClient client;
+    private InOut io;
+    private CxfSeComponent component;
+ 
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        component = new CxfSeComponent();
+        jbi.activateComponent(component, "CxfSeComponent");
+        //Deploy proxy SU
+        component.getServiceUnitManager().deploy("proxy", getServiceUnitPath("provider"));
+        component.getServiceUnitManager().init("proxy", getServiceUnitPath("provider"));
+        component.getServiceUnitManager().start("proxy");
+    }
+    
+    protected void tearDown() throws Exception {
+        component.getServiceUnitManager().stop("proxy");
+        component.getServiceUnitManager().shutDown("proxy");
+        component.getServiceUnitManager().undeploy("proxy", getServiceUnitPath("provider"));
+    }
+    
+    
+    public void testMtom() throws Exception {
+        //start external service
+        EndpointImpl endpointMtom =
+            (EndpointImpl)javax.xml.ws.Endpoint.publish("http://localhost:9001/mtombridgetest", 
+                new TestMtomImpl());
+             
+        SOAPBinding binding = (SOAPBinding)endpointMtom.getBinding();
+        binding.setMTOMEnabled(true);
+        endpointMtom.getInInterceptors().add(new LoggingInInterceptor());
+        endpointMtom.getOutInterceptors().add(new LoggingOutInterceptor());
+        client = new DefaultServiceMixClient(jbi);
+        io = client.createInOutExchange();
+        io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
+        io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
+        io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
+        //send message to proxy
+        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>"
+              + "ffang with mtom"
+              + "</requestType></greetMe>"
+              + "</part> "
+              + "</message>"));
+        client.sendSync(io);
+        assertTrue(new SourceTransformer().contentToString(
+                io.getOutMessage()).indexOf("testfoobar") >= 0);
+        
+    }
+    
+       
+    @Override
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/cxfbc/provider.xml");
+    }
+
+    protected String getServiceUnitPath(String name) {
+        URL url = getClass().getClassLoader().getResource("org/apache/servicemix/cxfbc/" + name + "/xbean.xml");
+        File path = new File(url.getFile());
+        path = path.getParentFile();
+        return path.getAbsolutePath();
+    }
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderMtomTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderMtomTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java?rev=773813&r1=773812&r2=773813&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcProviderTest.java Tue May 12 07:43:54 2009
@@ -22,7 +22,6 @@
 
 import javax.jbi.messaging.InOut;
 import javax.xml.namespace.QName;
-import javax.xml.ws.soap.SOAPBinding;
 
 import org.apache.cxf.calculator.CalculatorImpl;
 import org.apache.cxf.calculator.CalculatorPortType;
@@ -31,13 +30,11 @@
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.interceptor.LoggingInInterceptor;
 import org.apache.cxf.interceptor.LoggingOutInterceptor;
-import org.apache.cxf.jaxws.EndpointImpl;
 import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.hello_world_soap_http.Greeter;
 import org.apache.hello_world_soap_http.GreeterImpl;
 import org.apache.servicemix.client.DefaultServiceMixClient;
-import org.apache.servicemix.cxfbc.mtom.TestMtomImpl;
 import org.apache.servicemix.cxfse.CxfSeComponent;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
@@ -97,7 +94,7 @@
         
     }
     
-    public void xtestTargetServiceNotExist() throws Exception {
+    public void testTargetServiceNotExist() throws Exception {
         client = new DefaultServiceMixClient(jbi);
         io = client.createInOutExchange();
         io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
@@ -118,35 +115,6 @@
         
     }
     
-    public void testMtom() throws Exception {
-        //start external service
-        EndpointImpl endpointMtom =
-            (EndpointImpl)javax.xml.ws.Endpoint.publish("http://localhost:9001/mtombridgetest", 
-                new TestMtomImpl());
-             
-        SOAPBinding binding = (SOAPBinding)endpointMtom.getBinding();
-        binding.setMTOMEnabled(true);
-        endpointMtom.getInInterceptors().add(new LoggingInInterceptor());
-        endpointMtom.getOutInterceptors().add(new LoggingOutInterceptor());
-        client = new DefaultServiceMixClient(jbi);
-        io = client.createInOutExchange();
-        io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
-        io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
-        io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
-        //send message to proxy
-        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>"
-              + "ffang with mtom"
-              + "</requestType></greetMe>"
-              + "</part> "
-              + "</message>"));
-        client.sendSync(io);
-        assertTrue(new SourceTransformer().contentToString(
-                io.getOutMessage()).indexOf("testfoobar") >= 0);
-        
-    }
     
     public void testProvider() throws Exception {
         LOG.info("test provider");