camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r602902 - in /activemq/camel/trunk/components/camel-cxf: ./ src/main/java/org/apache/camel/component/cxf/transport/ src/main/resources/META-INF/ src/test/java/org/apache/camel/component/cxf/ src/test/java/org/apache/camel/component/cxf/tran...
Date Mon, 10 Dec 2007 14:03:27 GMT
Author: hadrian
Date: Mon Dec 10 06:03:26 2007
New Revision: 602902

URL: http://svn.apache.org/viewvc?rev=602902&view=rev
Log:
Patch for camel-258.  Applied with thanks!

Modified:
    activemq/camel/trunk/components/camel-cxf/pom.xml
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
    activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
    activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.handlers
    activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.schemas
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java

Modified: activemq/camel/trunk/components/camel-cxf/pom.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/pom.xml?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/pom.xml (original)
+++ activemq/camel/trunk/components/camel-cxf/pom.xml Mon Dec 10 06:03:26 2007
@@ -226,7 +226,13 @@
           <useFile>true</useFile>
           <includes>
             <include>**/*Test.*</include>
-          </includes>          
+          </includes>
+          <systemProperties>
+               <property>
+                    <name>java.util.logging.config.file</name>
+                    <value>${basedir}/target/test-classes/logging.properties</value>
                        
+               </property>
+          </systemProperties>             
         </configuration>
       </plugin>
     </plugins>

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelConduit.java
Mon Dec 10 06:03:26 2007
@@ -102,13 +102,12 @@
     }
 
     public String getBeanName() {
-        
-        if (endpointInfo == null) {
-            return "default.camel-conduit";
+        if (endpointInfo == null || endpointInfo.getName() == null) {
+            return "default" + BASE_BEAN_NAME_SUFFIX;
         }
-        return endpointInfo.getName() + ".camel-conduit";
+        return endpointInfo.getName().toString() + BASE_BEAN_NAME_SUFFIX;
     }
-
+    
     private void initConfig() {
         // we could configure the camel context here 
         if(bus != null) {

Modified: activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/transport/CamelDestination.java
Mon Dec 10 06:03:26 2007
@@ -65,7 +65,7 @@
     private org.apache.camel.Endpoint distinationEndpoint;
 
     public CamelDestination(CamelContext camelContext, Bus bus, ConduitInitiator ci, EndpointInfo
info) throws IOException {
-        super(getTargetReference(info, bus), info);
+        super(bus, getTargetReference(info, bus), info);        
         this.camelContext = camelContext;
         conduitInitiator = ci;
         camelDestinationUri = endpointInfo.getAddress().substring(CxfConstants.CAMEL_TRANSPORT_PREFIX.length());
@@ -130,6 +130,14 @@
     public void setCamelTemplate(CamelTemplate<Exchange> template) {
         camelTemplate = template;
     }
+    
+    public void setCamelContext(CamelContext context) {
+        camelContext = context;
+    }
+    
+    public CamelContext getCamelContext() {
+        return camelContext;
+    }
 
     protected void incoming(org.apache.camel.Exchange camelExchange) {
         getLogger().log(Level.FINE, "server received request: ", camelExchange);
@@ -146,7 +154,10 @@
     }
 
     public String getBeanName() {
-        return endpointInfo.getName().toString() + ".camel-destination";
+        if (endpointInfo == null || endpointInfo.getName() == null) {
+            return "default" + BASE_BEAN_NAME_SUFFIX;
+        }
+        return endpointInfo.getName().toString() + BASE_BEAN_NAME_SUFFIX;
     }
 
     private void initConfig() {

Modified: activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.handlers
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.handlers?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.handlers
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.handlers
Mon Dec 10 06:03:26 2007
@@ -18,4 +18,5 @@
 #    under the License.
 #
 #
-http\://activemq.apache.org/camel/schema/cxfEndpoint=org.apache.camel.component.cxf.spring.NamespaceHandler
\ No newline at end of file
+http\://activemq.apache.org/camel/schema/cxfEndpoint=org.apache.camel.component.cxf.spring.NamespaceHandler
+http\://cxf.apache.org/transports/camel=org.apache.camel.component.cxf.transport.spring.NamespaceHandler
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.schemas
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.schemas?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.schemas (original)
+++ activemq/camel/trunk/components/camel-cxf/src/main/resources/META-INF/spring.schemas Mon
Dec 10 06:03:26 2007
@@ -18,4 +18,5 @@
 #    under the License.
 #
 #
-http\://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd=schema/cxfEndpoint.xsd
\ No newline at end of file
+http\://activemq.apache.org/camel/schema/cxf/cxfEndpoint.xsd=schema/cxfEndpoint.xsd
+http\://cxf.apache.org/transports/camel.xsd=schema/configuration/camel.xsd
\ No newline at end of file

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/HelloServiceImpl.java
Mon Dec 10 06:03:26 2007
@@ -16,18 +16,22 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.util.logging.Logger;
+
+
+
 public class HelloServiceImpl implements HelloService {
-	
-	private int invocationCount;
+    private static final Logger LOG = Logger.getLogger(HelloServiceImpl.class.getName());
+    private int invocationCount;
 	
     public String echo(String text) {        
-        System.out.println("call for echo with " + text);
+        LOG.info("call for echo with " + text);
         return text;
     }
 
     public void ping() {
     	invocationCount ++;
-    	System.out.println("call for oneway ping");
+    	LOG.info("call for oneway ping");
     }
     
     public int getInvocationCount() {

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelConduitTest.java
Mon Dec 10 06:03:26 2007
@@ -21,11 +21,14 @@
 import java.io.InputStream;
 import java.io.OutputStream;
 
+import javax.xml.namespace.QName;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.message.Exchange;
@@ -38,8 +41,7 @@
 import org.apache.cxf.ws.addressing.EndpointReferenceType;
 import org.easymock.classextension.EasyMock;
 
-public class CamelConduitTest extends CamelTestSupport {
-   
+public class CamelConduitTest extends CamelTestSupport {    
        
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
@@ -60,6 +62,35 @@
     
     protected CamelContext createCamelContext() throws Exception {
         return new DefaultCamelContext();
+    }    
+        
+    public void testCamelConduitConfiguration() throws Exception {
+        QName testEndpointQNameA = new QName("http://activemq.apache.org/camel-test", "portA");
+        QName testEndpointQNameB = new QName("http://activemq.apache.org/camel-test", "portB");
+        // set up the bus with configure file
+        SpringBusFactory bf = new SpringBusFactory();
+        BusFactory.setDefaultBus(null);
+        Bus bus = bf.createBus("/org/apache/camel/component/cxf/transport/CamelConduit.xml");
+        BusFactory.setDefaultBus(bus);
+        
+        // create the conduit and set the configuration with it
+        endpointInfo.setAddress("camel://direct:EndpointA");
+        endpointInfo.setName(testEndpointQNameA);
+        CamelConduit conduit = new CamelConduit(null, bus, endpointInfo);
+        CamelContext context = conduit.getCamelContext();
+        
+        assertNotNull("the camel context which get from camel conduit is not null", context);
+        assertEquals("get the wrong camel context", context.getName(), "conduit_context");
+        assertEquals(context.getRoutes().get(0).getEndpoint().getEndpointUri(), "direct:EndpointA");
+        
+        endpointInfo.setAddress("camel://direct:EndpointC");
+        endpointInfo.setName(testEndpointQNameB);
+        conduit = new CamelConduit(null, bus, endpointInfo);
+        context = conduit.getCamelContext();
+        assertNotNull("the camel context which get from camel conduit is not null", context);
+        assertEquals("get the wrong camel context", context.getName(), "context");
+        assertEquals(context.getRoutes().get(0).getEndpoint().getEndpointUri(), "direct:EndpointC");
+        bus.shutdown(false);
     }
 
     public void testPrepareSend() throws Exception {
@@ -101,10 +132,10 @@
         sendoutMessage(conduit, message, false, "HelloWorld");        
         // verify the endpoint get the response 
         assertMockEndpointsSatisifed();
-        verifyReceivedMessage();
+        verifyReceivedMessage("HelloWorld");
     }
 
-    public void verifyReceivedMessage() {
+    public void verifyReceivedMessage(String content) {
         ByteArrayInputStream bis = (ByteArrayInputStream)inMessage.getContent(InputStream.class);
         byte bytes[] = new byte[bis.available()];
         try {
@@ -113,9 +144,7 @@
             ex.printStackTrace();
         }
         String reponse = new String(bytes);
-        assertEquals("The reponse date should be equals", reponse, "HelloWorld");
-
-        
+        assertEquals("The reponse date should be equals", content, reponse);
 
     }
 }

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java?rev=602902&r1=602901&r2=602902&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/transport/CamelDestinationTest.java
Mon Dec 10 06:03:26 2007
@@ -22,10 +22,13 @@
 import java.io.IOException;
 import java.io.InputStream;
 
+import javax.xml.namespace.QName;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.message.Exchange;
@@ -54,6 +57,27 @@
         return new DefaultCamelContext();
     }
   
+    public void testCamelDestinationConfiguration() throws Exception {
+        QName testEndpointQName = new QName("http://activemq.apache.org/camel-test", "port");
+        // set up the bus with configure file
+        SpringBusFactory bf = new SpringBusFactory();
+        BusFactory.setDefaultBus(null);
+        Bus bus = bf.createBus("/org/apache/camel/component/cxf/transport/CamelDestination.xml");
+        BusFactory.setDefaultBus(bus);
+        
+        endpointInfo.setAddress("camel://direct:EndpointA");
+        endpointInfo.setName(testEndpointQName);
+        CamelDestination destination = new CamelDestination(null, bus, null, endpointInfo);
+        
+        System.out.println("get the destination bean name" + destination.getBeanName());
+        CamelContext context = destination.getCamelContext();
+        
+        assertNotNull("The camel context which get from camel destination is not null", context);
+        assertEquals("Get the wrong camel context", context.getName(), "dest_context");
+        assertEquals("The camel context should has two routers", context.getRoutes().size(),
2);
+        assertEquals("The router 0 start endpoint is wrong", context.getRoutes().get(0).getEndpoint().getEndpointUri(),
"direct:EndpointA");
+        bus.shutdown(false);
+    }
     
     public CamelDestination setupCamelDestination(EndpointInfo endpointInfo, boolean send)
throws IOException {
         ConduitInitiator conduitInitiator = EasyMock.createMock(ConduitInitiator.class);
       



Mime
View raw message