Author: ningjiang
Date: Tue Oct 12 08:14:07 2010
New Revision: 1021658
URL: http://svn.apache.org/viewvc?rev=1021658&view=rev
Log:
CAMEL-3221 clean up the camel-example-cxf-proxy moduel, add an unit test for it
Added:
camel/trunk/examples/camel-example-cxf-proxy/src/test/
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
(with props)
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
(with props)
Added:
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java?rev=1021658&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
(added)
+++
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
Tue Oct 12 08:14:07 2010
@@ -0,0 +1,89 @@
+/**
+ * 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.Main;
+import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
+import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+
+/**
+ * Unit test of our routes
+ */
+public class ReportIncidentRoutesTest {
+
+ // should be the same address as we have in our route
+ private static final String URL =
"http://localhost:9080/camel-example-cxf-proxy/webservices/incident";
+
+ protected Main main;
+
+ protected void startCamel() throws Exception {
+ main = new Main();
+ main.setApplicationContextUri("camel-config.xml");
+ main.start();
+ }
+
+ protected void stopCamel() throws Exception {
+ if (main != null) {
+ main.stop();
+ }
+ }
+
+ 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 {
+ // start camel
+ startCamel();
+
+ runTest();
+
+ // stop camel
+ stopCamel();
+ }
+
+ 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("OK;456", 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-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange:
camel/trunk/examples/camel-example-cxf-proxy/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added:
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
URL:
http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties?rev=1021658&view=auto
==============================================================================
---
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
(added)
+++
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
Tue Oct 12 08:14:07 2010
@@ -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.
+## ------------------------------------------------------------------------
+
+# default properties to initialise log4j
+log4j.rootLogger=INFO, file
+
+# Console appender
+log4j.appender.console=org.apache.log4j.ConsoleAppender
+log4j.appender.console.layout=org.apache.log4j.PatternLayout
+log4j.appender.console.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1}
- %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} -
%m%n
+log4j.appender.file.file=target/camel-example-reportincident.log
+log4j.appender.file.append=true
+
+# settings for specific packages
+log4j.logger.org.springframework=WARN
+log4j.logger.org.apache.cxf=WARN
+
+# Camel logging
+log4j.logger.org.apache.camel=DEBUG
\ No newline at end of file
Propchange:
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:executable = *
Propchange:
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:keywords = Rev Date
Propchange:
camel/trunk/examples/camel-example-cxf-proxy/src/test/resources/log4j.properties
------------------------------------------------------------------------------
svn:mime-type = text/plain