You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/03/18 07:53:57 UTC

svn commit: r755489 - in /camel/trunk/examples/camel-example-reportincident/src: main/java/org/apache/camel/example/reportincident/ main/resources/ main/resources/META-INF/spring/ test/java/org/apache/camel/example/reportincident/

Author: ningjiang
Date: Wed Mar 18 06:53:56 2009
New Revision: 755489

URL: http://svn.apache.org/viewvc?rev=755489&view=rev
Log:
CAMEL-1465 add the spring configuration for camel-example-reportincident

Added:
    camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/MyBean.java   (with props)
    camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/
    camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml   (with props)
    camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesSpringTest.java   (with props)
Modified:
    camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
    camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml
    camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java

Added: camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/MyBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/MyBean.java?rev=755489&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/MyBean.java (added)
+++ camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/MyBean.java Wed Mar 18 06:53:56 2009
@@ -0,0 +1,29 @@
+/**
+ * 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.camel.example.reportincident;
+
+/**
+ * 
+ */
+public class MyBean {
+    public OutputReportIncident getOK() {
+        OutputReportIncident ok = new OutputReportIncident();
+        ok.setCode("0");
+        return ok;
+    }
+}

Propchange: camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/MyBean.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/MyBean.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java?rev=755489&r1=755488&r2=755489&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java (original)
+++ camel/trunk/examples/camel-example-reportincident/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java Wed Mar 18 06:53:56 2009
@@ -69,6 +69,7 @@
             .setHeader("subject", constant("new incident reported"))
             // send the email
             .to("smtp://someone@localhost?password=secret&to=incident@mycompany.com");
+        
     }
     
     public static void main(String args[]) throws Exception {

Added: camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml?rev=755489&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml (added)
+++ camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml Wed Mar 18 06:53:56 2009
@@ -0,0 +1,65 @@
+<?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:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:camel="http://camel.apache.org/schema/spring"
+       xmlns:cxf="http://camel.apache.org/schema/cxf"       
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+       http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd">
+
+ <import resource="classpath:META-INF/cxf/cxf.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
+ <import resource="classpath:META-INF/cxf/cxf-extension-http-jetty.xml"/>
+
+ <cxf:cxfEndpoint id="reportIncident"
+                     address="http://localhost:9080/camel-example-reportincident/webservices/incident"
+                     wsdlURL="report_incident.wsdl"
+                     serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint">
+ </cxf:cxfEndpoint>
+ 
+ <bean id="myBean" class="org.apache.camel.example.reportincident.MyBean"/>
+ <bean id="filenameGenerator" class="org.apache.camel.example.reportincident.FilenameGenerator"/>
+ 
+ <camel:camelContext id="camel">
+	<camel:route>
+		<camel:from uri="cxf:bean:reportIncident" />
+		<camel:convertBodyTo
+			type="org.apache.camel.example.reportincident.InputReportIncident" />
+	    <camel:setHeader headerName="CamelFileName">
+          	<camel:method bean="filenameGenerator" method="generateFilename" />
+        </camel:setHeader>		
+        <camel:to uri="velocity:MailBody.vm"/>        
+        <camel:to uri="file://target/subfolder"/>		
+		<camel:transform>
+			<camel:method bean="myBean" method="getOK" />
+		</camel:transform>
+	</camel:route>
+	
+	<camel:route>
+        <camel:from uri="file://target/subfolder"/>
+        <camel:setOutHeader headerName="subject">
+          	<camel:constant>new incident reported</camel:constant>
+        </camel:setOutHeader>
+        <camel:to uri="smtp://someone@localhost?password=secret&amp;to=incident@mycompany.com"/>        
+	</camel:route>
+	
+</camel:camelContext>
+</beans>

Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/examples/camel-example-reportincident/src/main/resources/META-INF/spring/camel-context.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml?rev=755489&r1=755488&r2=755489&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml (original)
+++ camel/trunk/examples/camel-example-reportincident/src/main/resources/camel-config.xml Wed Mar 18 06:53:56 2009
@@ -24,7 +24,7 @@
     <import resource="classpath:META-INF/cxf/cxf.xml"/>
     <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml"/>
     <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
-    
+     
     <!-- create a camel context as to start Camel -->
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <package>org.apache.camel.example.reportincident</package>

Added: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesSpringTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesSpringTest.java?rev=755489&view=auto
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesSpringTest.java (added)
+++ camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesSpringTest.java Wed Mar 18 06:53:56 2009
@@ -0,0 +1,38 @@
+/**
+ * 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.camel.example.reportincident;
+
+import org.apache.camel.spring.SpringCamelContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ReportIncidentRoutesSpringTest extends ReportIncidentRoutesTest {
+    private ClassPathXmlApplicationContext applicationContext;
+    
+    protected void startCamel() throws Exception {
+        ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("/META-INF/spring/camel-context.xml");
+        camel = SpringCamelContext.springCamelContext(applicationContext);        
+        camel.start();
+    }
+    
+    protected void stopCamel() throws Exception {
+        super.stopCamel();
+        if (applicationContext != null) {
+            applicationContext.close();
+        }                
+    }
+
+}

Propchange: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesSpringTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesSpringTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java?rev=755489&r1=755488&r2=755489&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java (original)
+++ camel/trunk/examples/camel-example-reportincident/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java Wed Mar 18 06:53:56 2009
@@ -30,7 +30,7 @@
     // should be the same address as we have in our route
     private static final String URL = "http://localhost:9080/camel-example-reportincident/webservices/incident";
 
-    private CamelContext camel;
+    protected CamelContext camel;
 
     protected void startCamel() throws Exception {
         camel = new DefaultCamelContext();
@@ -39,6 +39,10 @@
         camel.addRoutes(routes);
         camel.start();
     }
+    
+    protected void stopCamel() throws Exception {
+        camel.stop();
+    }
 
     protected static ReportIncidentEndpoint createCXFClient() {
         // we use CXF to create a client for us as its easier than JAXWS and works
@@ -54,6 +58,7 @@
 
         // assert mailbox is empty before starting
         Mailbox inbox = Mailbox.get("incident@mycompany.com");
+        inbox.clear();
         assertEquals("Should not have mails", 0, inbox.size());
 
         // create input parameter
@@ -79,8 +84,10 @@
 
         // assert mail box
         assertEquals("Should have got 1 mail", 1, inbox.size());
+        assertTrue(" We should get the email address from the mail ",
+                   ((String)inbox.get(0).getContent()).indexOf("- email: davsclaus@apache.org") > 0);
 
         // stop camel
-        camel.stop();
+        stopCamel();
     }
 }