Author: ningjiang
Date: Wed Jun 29 09:00:16 2011
New Revision: 1141013

URL: http://svn.apache.org/viewvc?rev=1141013&view=rev
Log:
Added some unit test client to help us test the camel-example-cxf in system test

Added:
    camel/trunk/examples/camel-example-cxf-blueprint/src/test/
    camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/
    camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/
    camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/
    
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/
    
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/
    
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/
    
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
   (with props)
    camel/trunk/examples/camel-example-cxf-osgi/src/test/
    camel/trunk/examples/camel-example-cxf-osgi/src/test/java/
    camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/
    camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/
    camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/
    
camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/
    
camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/
    
camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
   (with props)
Modified:
    camel/trunk/examples/camel-example-cxf-blueprint/pom.xml
    camel/trunk/examples/camel-example-cxf-osgi/pom.xml

Modified: camel/trunk/examples/camel-example-cxf-blueprint/pom.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-blueprint/pom.xml?rev=1141013&r1=1141012&r2=1141013&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-blueprint/pom.xml (original)
+++ camel/trunk/examples/camel-example-cxf-blueprint/pom.xml Wed Jun 29 
09:00:16 2011
@@ -41,6 +41,11 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-cxf</artifactId>
     </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency> 
   </dependencies>
 
   <build>

Added: 
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java?rev=1141013&view=auto
==============================================================================
--- 
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
 (added)
+++ 
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
 Wed Jun 29 09:00:16 2011
@@ -0,0 +1,70 @@
+/**
+ * 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.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit test of our routes
+ */
+public class ReportIncidentRoutesClient {
+
+    // should be the same address as we have in our route
+    private static final String URL = 
"http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident";;
+   
+    protected static ReportIncidentEndpoint createCXFClient() {
+        // we use CXF to create a client for us as its easier than JAXWS and 
works
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(ReportIncidentEndpoint.class);
+        factory.setAddress(URL);
+        return (ReportIncidentEndpoint) factory.create();
+    }
+
+    @Test
+    public void testRendportIncident() throws Exception {
+        runTest();
+    }
+    
+    protected void runTest() throws Exception {
+        // create input parameter
+        InputReportIncident input = new InputReportIncident();
+        input.setIncidentId("123");
+        input.setIncidentDate("2008-08-18");
+        input.setGivenName("Claus");
+        input.setFamilyName("Ibsen");
+        input.setSummary("Bla");
+        input.setDetails("Bla bla");
+        input.setEmail("[email protected]");
+        input.setPhone("0045 2962 7576");
+
+        // create the webservice client and send the request
+        ReportIncidentEndpoint client = createCXFClient();
+        OutputReportIncident out = client.reportIncident(input);
+
+        // assert we got a OK back
+        assertEquals("0", out.getCode());
+
+        // let some time pass to allow Camel to pickup the file and send it as 
an email
+        Thread.sleep(3000);
+
+    }
+}

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

Propchange: 
camel/trunk/examples/camel-example-cxf-blueprint/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
------------------------------------------------------------------------------
    svn:executable = *

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

Modified: camel/trunk/examples/camel-example-cxf-osgi/pom.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/pom.xml?rev=1141013&r1=1141012&r2=1141013&view=diff
==============================================================================
--- camel/trunk/examples/camel-example-cxf-osgi/pom.xml (original)
+++ camel/trunk/examples/camel-example-cxf-osgi/pom.xml Wed Jun 29 09:00:16 2011
@@ -56,6 +56,11 @@
                        <artifactId>cxf-rt-transports-http</artifactId>
                        <version>${cxf-version}</version>
                </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <scope>test</scope>
+               </dependency>
        </dependencies>
 
        <build>

Added: 
camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java?rev=1141013&view=auto
==============================================================================
--- 
camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
 (added)
+++ 
camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
 Wed Jun 29 09:00:16 2011
@@ -0,0 +1,70 @@
+/**
+ * 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.CamelContext;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit test of our routes
+ */
+public class ReportIncidentRoutesClient {
+
+    // should be the same address as we have in our route
+    private static final String URL = 
"http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident";;
+   
+    protected static ReportIncidentEndpoint createCXFClient() {
+        // we use CXF to create a client for us as its easier than JAXWS and 
works
+        JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
+        factory.setServiceClass(ReportIncidentEndpoint.class);
+        factory.setAddress(URL);
+        return (ReportIncidentEndpoint) factory.create();
+    }
+
+    @Test
+    public void testRendportIncident() throws Exception {
+        runTest();
+    }
+    
+    protected void runTest() throws Exception {
+        // create input parameter
+        InputReportIncident input = new InputReportIncident();
+        input.setIncidentId("123");
+        input.setIncidentDate("2008-08-18");
+        input.setGivenName("Claus");
+        input.setFamilyName("Ibsen");
+        input.setSummary("Bla");
+        input.setDetails("Bla bla");
+        input.setEmail("[email protected]");
+        input.setPhone("0045 2962 7576");
+
+        // create the webservice client and send the request
+        ReportIncidentEndpoint client = createCXFClient();
+        OutputReportIncident out = client.reportIncident(input);
+
+        // assert we got a OK back
+        assertEquals("0", out.getCode());
+
+        // let some time pass to allow Camel to pickup the file and send it as 
an email
+        Thread.sleep(3000);
+
+    }
+}

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

Propchange: 
camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java
------------------------------------------------------------------------------
    svn:executable = *

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


Reply via email to