svn commit: r735758 - in /activemq/camel/branches/camel-1.x/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/invoker/ main/java/org/apache/camel/component/cxf/transport/ test/java/org/apache/c...

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r735758 - in /activemq/camel/branches/camel-1.x/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/ main/java/org/apache/camel/component/cxf/invoker/ main/java/org/apache/camel/component/cxf/transport/ test/java/org/apache/c...

ningjiang
Author: ningjiang
Date: Mon Jan 19 09:45:56 2009
New Revision: 735758

URL: http://svn.apache.org/viewvc?rev=735758&view=rev
Log:
Fixed some unit tests error relate to camel transport

Modified:
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
    activemq/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfConsumer.java Mon Jan 19 09:45:56 2009
@@ -46,14 +46,19 @@
         Bus bus = null;
         this.endpoint = endpoint;
         boolean isWebServiceProvider = false;
-        if (endpoint.getApplicationContext() != null) {            
-            bus = endpoint.getCxfEndpointBean().getBus();
+        if (endpoint.getApplicationContext() != null) {
+            if (endpoint.getCxfEndpointBean() != null) {
+                bus = endpoint.getCxfEndpointBean().getBus();
+            } else {
+                SpringBusFactory busFactory = new SpringBusFactory(endpoint.getApplicationContext());
+                bus = busFactory.createBus();
+            }
             if (CxfEndpointUtils.getSetDefaultBus(endpoint)) {
-                BusFactory.setThreadDefaultBus(bus);
+                BusFactory.setDefaultBus(bus);
             }
         } else {
             // now we just use the default bus here
-            bus = BusFactory.getThreadDefaultBus();
+            bus = BusFactory.getDefaultBus();
         }
         
         Class serviceClass = CxfEndpointUtils.getServiceClass(endpoint);

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Mon Jan 19 09:45:56 2009
@@ -24,6 +24,7 @@
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.HeaderFilterStrategy;
 import org.apache.camel.spring.SpringCamelContext;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.cxf.configuration.spring.ConfigurerImpl;
 import org.apache.cxf.message.Message;
 import org.springframework.context.ApplicationContext;
@@ -67,7 +68,7 @@
             SpringCamelContext context = (SpringCamelContext) this.getCamelContext();
             configurer = new ConfigurerImpl(context.getApplicationContext());
             cxfEndpointBean = (CxfEndpointBean) context.getApplicationContext().getBean(beanId);
-            assert cxfEndpointBean != null;
+            ObjectHelper.notNull(cxfEndpointBean, "cxfEndpointBean");
         }
     }
 

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfProducer.java Mon Jan 19 09:45:56 2009
@@ -94,13 +94,18 @@
     private Client createClientFromClientFactoryBean(ClientProxyFactoryBean cfb) throws Exception {
         Bus bus = null;
         if (endpoint.getApplicationContext() != null) {            
-            bus = endpoint.getCxfEndpointBean().getBus();
+            if (endpoint.getCxfEndpointBean() != null) {
+                bus = endpoint.getCxfEndpointBean().getBus();
+            } else {
+                SpringBusFactory busFactory = new SpringBusFactory(endpoint.getApplicationContext());
+                bus = busFactory.createBus();
+            }
             if (CxfEndpointUtils.getSetDefaultBus(endpoint)) {
-                BusFactory.setThreadDefaultBus(bus);
+                BusFactory.setDefaultBus(bus);
             }
         } else {
             // now we just use the default bus here
-            bus = BusFactory.getThreadDefaultBus();
+            bus = BusFactory.getDefaultBus();
         }
         
         Class serviceClass = CxfEndpointUtils.getServiceClass(endpoint);
@@ -196,7 +201,7 @@
                 ex = new ExchangeImpl();
                 exchange.setExchange(ex);
             }
-            assert ex != null;
+            ObjectHelper.notNull(ex, "exchange");
             InvokingContext invokingContext = ex.get(InvokingContext.class);
             if (invokingContext == null) {
                 invokingContext = InvokingContextFactory.createContext(dataFormat);

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfSoapBinding.java Mon Jan 19 09:45:56 2009
@@ -26,6 +26,7 @@
 import org.apache.camel.component.cxf.util.CxfHeaderHelper;
 import org.apache.camel.impl.DefaultHeaderFilterStrategy;
 import org.apache.camel.spi.HeaderFilterStrategy;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.cxf.message.ExchangeImpl;
@@ -56,7 +57,7 @@
         } else {
             message = exchange.getIn();
         }
-        assert message != null;
+        ObjectHelper.notNull(message, "message");
         if (cxfExchange == null) {
             cxfExchange = new ExchangeImpl();
             exchange.setProperty(CxfConstants.CXF_EXCHANGE, cxfExchange);
@@ -87,7 +88,7 @@
     public static org.apache.cxf.message.Message getCxfOutMessage(HeaderFilterStrategy headerFilterStrategy,
             org.apache.camel.Exchange exchange, boolean isClient) {
         org.apache.cxf.message.Exchange cxfExchange = exchange.getProperty(CxfConstants.CXF_EXCHANGE, org.apache.cxf.message.Exchange.class);
-        assert cxfExchange != null;
+        ObjectHelper.notNull(cxfExchange, "cxfExchange");
         org.apache.cxf.endpoint.Endpoint cxfEndpoint = cxfExchange.get(org.apache.cxf.endpoint.Endpoint.class);
         org.apache.cxf.message.Message outMessage = cxfEndpoint.getBinding().createMessage();
         outMessage.setExchange(cxfExchange);

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/invoker/CxfClient.java Mon Jan 19 09:45:56 2009
@@ -20,6 +20,7 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import org.apache.camel.util.ObjectHelper;
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.endpoint.ClientImpl;
@@ -54,7 +55,7 @@
 
         Object retval = null;
         InvokingContext invokingContext = exchange.get(InvokingContext.class);
-        assert invokingContext != null;
+        ObjectHelper.notNull(invokingContext, "invokingContext");
 
         // get InBound binding operation info from the exchange object
         BindingOperationInfo inBoundOp = exchange.get(BindingOperationInfo.class);

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java Mon Jan 19 09:45:56 2009
@@ -87,6 +87,9 @@
     }
 
     public CamelContext getCamelContext() {
+        if (camelContext == null) {
+            camelContext = new DefaultCamelContext();
+        }
         return camelContext;
     }
 
@@ -123,9 +126,8 @@
     }
 
     public ProducerTemplate<Exchange> getCamelTemplate() {
-        if (camelTemplate == null) {
-            CamelContext ctx = camelContext != null ? camelContext : new DefaultCamelContext();
-            camelTemplate = ctx.createProducerTemplate();
+        if (camelTemplate == null) {            
+            camelTemplate = getCamelContext().createProducerTemplate();
         }
         return camelTemplate;
     }

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java Mon Jan 19 09:45:56 2009
@@ -96,8 +96,8 @@
         getLogger().log(Level.FINE, "CamelDestination activate().... ");
 
         try {
-            getLogger().log(Level.FINE, "establishing Camel connection");
-            distinationEndpoint = camelContext.getEndpoint(camelDestinationUri);
+            getLogger().log(Level.FINE, "establishing Camel connection");            
+            distinationEndpoint = getCamelContext().getEndpoint(camelDestinationUri);
             consumer = distinationEndpoint.createConsumer(new ConsumerProcessor());
             consumer.start();
 
@@ -122,9 +122,8 @@
     }
 
     public ProducerTemplate<Exchange> getCamelTemplate() {
-        if (camelTemplate == null) {
-            CamelContext ctx = camelContext != null ? camelContext : new DefaultCamelContext();
-            camelTemplate = ctx.createProducerTemplate();
+        if (camelTemplate == null) {            
+            camelTemplate = getCamelContext().createProducerTemplate();
         }
         return camelTemplate;
     }
@@ -138,6 +137,9 @@
     }
 
     public CamelContext getCamelContext() {
+        if (camelContext == null) {
+            camelContext = new DefaultCamelContext();
+        }
         return camelContext;
     }
 
@@ -150,9 +152,9 @@
         ((MessageImpl)inMessage).setDestination(this);
 
         // Handling the incoming message
-        // The response message will be send back by the outgoingchain
+        // The response message will be send back by the outgoingchain        
         incomingObserver.onMessage(inMessage);
-
+        
     }
 
     public String getBeanName() {

Modified: activemq/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java?rev=735758&r1=735757&r2=735758&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java Mon Jan 19 09:45:56 2009
@@ -111,7 +111,7 @@
         Message message = new MessageImpl();
         // set the isOneWay to be true
         sendoutMessage(conduit, message, true, "HelloWorld");
-        assertMockEndpointsSatisifed();
+        assertMockEndpointsSatisfied();
         // verify the endpoint get the response
     }
 
@@ -124,7 +124,7 @@
         // set the isOneWay to be false
         sendoutMessage(conduit, message, false, "HelloWorld");
         // verify the endpoint get the response
-        assertMockEndpointsSatisifed();
+        assertMockEndpointsSatisfied();
         verifyReceivedMessage("HelloWorld");
     }