servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r669981 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk: ./ src/main/java/org/apache/servicemix/cxfbc/ src/test/java/org/apache/servicemix/cxfbc/ src/test/java/org/apache/servicemix/cxfbc/provider/ src/test/resources/org/apache...
Date Fri, 20 Jun 2008 16:32:28 GMT
Author: chirino
Date: Fri Jun 20 09:32:28 2008
New Revision: 669981

URL: http://svn.apache.org/viewvc?rev=669981&view=rev
Log:
Merged revisions 669381,669425 via svnmerge from 
https://svn.apache.org/repos/asf/servicemix/smx3/trunk/deployables/bindingcomponents/servicemix-cxf-bc

........
  r669381 | ffang | 2008-06-19 00:03:51 -0400 (Thu, 19 Jun 2008) | 1 line
  
  [SM-1400]cxf bc consumer should be able to retrieve wsdl from internal endpoint of JBI bus
if there is one
........
  r669425 | ffang | 2008-06-19 04:34:16 -0400 (Thu, 19 Jun 2008) | 1 line
  
  [SM-1413]test to verify both send and sendSync can work with cxf bc provider using jms transport
identically
........

Added:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBcRetrieveWsdlFromInternalEndpointTest.java
      - copied unchanged from r669425, servicemix/smx3/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcRetrieveWsdlFromInternalEndpointTest.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/xbean_retrieve_wsdl_from_internal_wsdl.xml
      - copied unchanged from r669425, servicemix/smx3/trunk/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean_retrieve_wsdl_from_internal_wsdl.xml
Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/   (props changed)
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/GreeterImplTwoWayJMS.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Jun 20 09:32:28 2008
@@ -1 +1 @@
-/servicemix/smx3/trunk/deployables/bindingcomponents/servicemix-cxf-bc:1-669197
+/servicemix/smx3/trunk/deployables/bindingcomponents/servicemix-cxf-bc:1-669979

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=669981&r1=669980&r2=669981&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
Fri Jun 20 09:32:28 2008
@@ -16,6 +16,7 @@
  */
 package org.apache.servicemix.cxfbc;
 
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
@@ -26,22 +27,24 @@
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.activation.DataHandler;
+import javax.jbi.JBIException;
 import javax.jbi.component.ComponentContext;
 import javax.jbi.management.DeploymentException;
 import javax.jbi.messaging.ExchangeStatus;
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.NormalizedMessage;
+import javax.jbi.servicedesc.ServiceEndpoint;
 import javax.wsdl.WSDLException;
-import javax.wsdl.factory.WSDLFactory;
-import javax.wsdl.xml.WSDLReader;
+import javax.wsdl.extensions.soap.SOAPBinding;
 import javax.xml.namespace.QName;
 import javax.xml.transform.Source;
 
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
+import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
+import com.ibm.wsdl.extensions.soap.SOAPBindingImpl;
 
-import com.ibm.wsdl.Constants;
 import org.apache.cxf.Bus;
 import org.apache.cxf.attachment.AttachmentImpl;
 import org.apache.cxf.binding.AbstractBindingFactory;
@@ -95,6 +98,7 @@
 import org.apache.servicemix.soap.util.DomUtil;
 import org.springframework.core.io.Resource;
 
+
 /**
  * 
  * @author gnodet
@@ -212,23 +216,8 @@
     public void validate() throws DeploymentException {
         try {
             if (definition == null) {
-                if (wsdl == null) {
-                    throw new DeploymentException("wsdl property must be set");
-                }
-                description = DomUtil.parse(wsdl.getInputStream());
-                WSDLFactory wsdlFactory = WSDLFactory.newInstance();
-                WSDLReader reader = wsdlFactory.newWSDLReader();
-                reader.setFeature(Constants.FEATURE_VERBOSE, false);
-                // definition = reader.readWSDL(wsdl.getURL().toString(),
-                // description);
-                try {
-                    // use wsdl manager to parse wsdl or get cached definition
-                    definition = getBus().getExtension(WSDLManager.class)
-                            .getDefinition(wsdl.getURL());
-                } catch (WSDLException ex) {
-                    // throw new ServiceConstructionException(new
-                    // Message("SERVICE_CREATION_MSG", LOG), ex);
-                }
+                
+                retrieveWSDL();
             }
             if (service == null) {
                 // looking for the servicename according to targetServiceName
@@ -242,6 +231,7 @@
             }
             WSDLServiceFactory factory = new WSDLServiceFactory(getBus(),
                     definition, service);
+            
             Service cxfService = factory.create();
 
             EndpointInfo ei = cxfService.getServiceInfos().iterator().next()
@@ -301,6 +291,7 @@
             cxfService.getOutFaultInterceptors().add(
                     new SoapOutInterceptor(getBus()));
 
+            
             ep = new EndpointImpl(getBus(), cxfService, ei);
             getInInterceptors().addAll(getBus().getInInterceptors());
             getInFaultInterceptors().addAll(getBus().getInFaultInterceptors());
@@ -344,6 +335,53 @@
         }
     }
 
+    private void retrieveWSDL() throws JBIException, WSDLException, DeploymentException,
IOException {
+        if (wsdl == null) {
+            if (getTargetService() != null && getTargetEndpoint() != null) {
+                ServiceEndpoint serviceEndpoint 
+                    = getServiceUnit().getComponent().getComponentContext().getEndpoint(getTargetService(),
getTargetEndpoint());
+                if (serviceEndpoint != null) {
+                    description = 
+                        this.getServiceUnit().getComponent().getComponentContext().getEndpointDescriptor(serviceEndpoint);
+                    definition = getBus().getExtension(WSDLManager.class)
+                        .getDefinition((Element)description.getFirstChild());
+                    List address = definition.getService(getTargetService()).getPort(getTargetEndpoint()).getExtensibilityElements();
+                    if (address == null || address.size() == 0) {
+                        SOAPAddressImpl soapAddress = new SOAPAddressImpl();
+                        //specify default transport if there is no one in the internal wsdl
+                        soapAddress.setLocationURI("http://localhost");
+                        definition.getService(getTargetService()).getPort(getTargetEndpoint()).addExtensibilityElement(soapAddress);
+                    }
+                    List binding = definition.getService(getTargetService()).getPort(
+                            getTargetEndpoint()).getBinding().getExtensibilityElements();
+                    if (binding == null || binding.size() == 0) {
+                        //no binding info in the internal wsdl so we need add default soap11
binding
+                        SOAPBinding soapBinding = new SOAPBindingImpl();
+                        soapBinding.setTransportURI("http://schemas.xmlsoap.org/soap/http");
+                        soapBinding.setStyle("document");
+                        definition.getService(getTargetService()).getPort(getTargetEndpoint()).getBinding().
+                            addExtensibilityElement(soapBinding);
+                    }
+                    
+                }
+            } else {
+                throw new DeploymentException("can't get wsdl");
+            }
+            
+        } else {
+            description = DomUtil.parse(wsdl.getInputStream());
+            try {
+                // use wsdl manager to parse wsdl or get cached
+                // definition
+                definition = getBus().getExtension(WSDLManager.class)
+                        .getDefinition(wsdl.getURL());
+            } catch (WSDLException ex) {
+                // throw new ServiceConstructionException(new
+                // Message("SERVICE_CREATION_MSG", LOG), ex);
+            }
+        }
+    }
+
     protected Bus getBus() {
         if (getBusCfg() != null) {
             if (bus == null) {

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/GreeterImplTwoWayJMS.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/GreeterImplTwoWayJMS.java?rev=669981&r1=669980&r2=669981&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/GreeterImplTwoWayJMS.java
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/GreeterImplTwoWayJMS.java
Fri Jun 20 09:32:28 2008
@@ -29,6 +29,14 @@
     extends org.apache.hello_world_soap_http.GreeterImpl {
     public String greetMe(String me) {
         System.out.println("\n\n*** GreetMe called with: " + me + "***\n\n");
+        if ("ffang".equals(me)) {
+            try {
+                Thread.sleep(3000);
+            } catch (InterruptedException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
         return "Hello " + me;
     }
         

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java?rev=669981&r1=669980&r2=669981&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
Fri Jun 20 09:32:28 2008
@@ -30,6 +30,8 @@
 
 import org.apache.servicemix.JbiConstants;
 import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.cxfbc.EmbededJMSBrokerLauncher;
+import org.apache.servicemix.cxfbc.MyJMSServer;
 import org.apache.servicemix.jbi.container.SpringJBIContainer;
 import org.apache.servicemix.jbi.jaxp.SourceTransformer;
 import org.apache.servicemix.jbi.jaxp.StringSource;
@@ -45,6 +47,8 @@
     private InOut io;    
 
     private ServerLauncher sl;
+    private ServerLauncher embeddedLauncher;
+    private ServerLauncher jmsLauncher;
     
     
     public void startServers() throws Exception {
@@ -53,9 +57,23 @@
         }
         Map<String, String> props = new HashMap<String, String>();          
     
         
-        assertTrue("server did not launch correctly", 
-                   launchServer(MyServer.class, props, false));
+        
 
+        if (System.getProperty("activemq.store.dir") != null) {
+            props.put("activemq.store.dir", System.getProperty("activemq.store.dir"));
+        }
+        props.put("java.util.logging.config.file", 
+                  System.getProperty("java.util.logging.config.file"));
+        
+        assertTrue("server did not launch correctly", 
+                   launchServer(EmbededJMSBrokerLauncher.class, props, false));
+        embeddedLauncher =  sl;
+        assertTrue("server did not launch correctly", 
+                launchServer(MyJMSServer.class, null, false));
+        jmsLauncher = sl;
+        
+        assertTrue("server did not launch correctly", 
+                launchServer(MyServer.class, props, false));
         
         serversStarted = true;
     }
@@ -109,6 +127,19 @@
         }
         
         try {
+            embeddedLauncher.stopServer();         
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("failed to stop server " + embeddedLauncher.getClass());
+        }
+        try {
+            jmsLauncher.stopServer();         
+        } catch (IOException ex) {
+            ex.printStackTrace();
+            fail("failed to stop server " + jmsLauncher.getClass());
+        } 
+        
+        try {
             sl.stopServer();         
         } catch (IOException ex) {
             ex.printStackTrace();
@@ -126,6 +157,26 @@
         setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml");
         greetMeProviderTestBase(true);
     }
+    
+    public void testGreetMeProviderWithJmSTransportSync() throws Exception {
+        setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml");
+        greetMeProviderJmsTestBase(true, "Edell");
+    }
+    
+    public void testGreetMeProviderWithJmSTransportAsync() throws Exception {
+        setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml");
+        greetMeProviderJmsTestBase(false, "Edell");
+    }
+    
+    public void testGreetMeProviderWithJmSTransportSyncTimeOut() throws Exception {
+        setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml");
+        greetMeProviderJmsTestBase(true, "ffang");
+    }
+    
+    public void testGreetMeProviderWithJmSTransportAsyncTimeOut() throws Exception {
+        setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml");
+        greetMeProviderJmsTestBase(false, "ffang");
+    }
         
     private void greetMeProviderTestBase(boolean useDynamicUri) throws Exception {
 
@@ -143,11 +194,43 @@
             io.getInMessage().setProperty(JbiConstants.HTTP_DESTINATION_URI, "http://localhost:9002/dynamicuritest");
         }
         client.sendSync(io);
+        
         assertTrue(new SourceTransformer().contentToString(
                 io.getOutMessage()).indexOf("Hello Edell") >= 0);        
         
     }
     
+    private void greetMeProviderJmsTestBase(boolean sync, String name) throws Exception {
+
+        client = new DefaultServiceMixClient(jbi);
+        
+        io = client.createInOutExchange();
+        io.setService(new QName("http://apache.org/hello_world_soap_http", "HelloWorldService"));
+        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(
+              "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+              + name
+              + "</requestType></greetMe>"));
+        
+        if (sync) {
+            client.sendSync(io);
+        } else {
+            client.send(io);
+            Thread.sleep(5000);
+        }
+        if ("ffang".equals(name)) {
+            //in this case, the server is intended to sleep 3 sec, 
+            //which will cause time out both for sync and async invoke
+            assertTrue(new SourceTransformer().contentToString(
+                    io.getFault()).indexOf("JMSClientTransport.receive() timed out. No message
available.") >= 0);
+        } else {
+            //in this case, both sync and async invocation shouldn't see the timeout problem
+            assertTrue(new SourceTransformer().contentToString(
+                io.getOutMessage()).indexOf("Hello " + name) >= 0);
+        }
+    }
 
     @Override
     protected AbstractXmlApplicationContext createBeanFactory() {

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml?rev=669981&r1=669980&r2=669981&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_without_jbi_wrapper.xml
Fri Jun 20 09:32:28 2008
@@ -20,7 +20,8 @@
 <beans xmlns:sm="http://servicemix.apache.org/config/1.0"
        xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
        xmlns:test="urn:test"
-       xmlns:greeter="http://apache.org/hello_world_soap_http_provider">
+       xmlns:greeter="http://apache.org/hello_world_soap_http_provider"
+       xmlns:jmsgreeter="http://apache.org/hello_world_soap_http">
 
        
   <sm:container id="jbi" embedded="true">
@@ -47,6 +48,26 @@
           <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
         </cxfbc:outFaultInterceptors>
       </cxfbc:provider>
+       
+      <cxfbc:provider wsdl="org/apache/servicemix/cxfbc/ws/security/hello_world.wsdl"
+                      service="jmsgreeter:HelloWorldService"
+                      endpoint="HelloWorldPortProxy"
+                      interfaceName="jmsgreeter:Greetr"
+                      useJBIWrapper="false"
+                     >
+          <cxfbc:inInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+          </cxfbc:inInterceptors>
+          <cxfbc:outInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+          </cxfbc:outInterceptors>
+          <cxfbc:inFaultInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+          </cxfbc:inFaultInterceptors>
+          <cxfbc:outFaultInterceptors>
+            <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+          </cxfbc:outFaultInterceptors>
+      </cxfbc:provider>
     </sm:endpoints>
     
   </sm:container>



Mime
View raw message