Author: ningjiang Date: Mon Jul 11 11:57:31 2011 New Revision: 1145129 URL: http://svn.apache.org/viewvc?rev=1145129&view=rev Log: CAME-4210 Add unit test on camel-example-cxf-osgi
Added: camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java (contents, props changed) - copied, changed from r1145066, camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/ camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml (with props) camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties (with props) Removed: camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java Modified: camel/trunk/examples/camel-example-cxf-osgi/pom.xml camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java 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=1145129&r1=1145128&r2=1145129&view=diff ============================================================================== --- camel/trunk/examples/camel-example-cxf-osgi/pom.xml (original) +++ camel/trunk/examples/camel-example-cxf-osgi/pom.xml Mon Jul 11 11:57:31 2011 @@ -57,6 +57,27 @@ <version>${cxf-version}</version> </dependency> <dependency> + <groupId>org.apache.cxf</groupId> + <artifactId>cxf-rt-transports-http-jetty</artifactId> + <version>${cxf-version}</version> + <scope>test</scope> + </dependency> + <!-- logging --> + <dependency> + <groupId>org.slf4j</groupId> + <artifactId>slf4j-log4j12</artifactId> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + </dependency> + <!-- test --> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <scope>test</scope> Modified: camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java?rev=1145129&r1=1145128&r2=1145129&view=diff ============================================================================== --- camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java (original) +++ camel/trunk/examples/camel-example-cxf-osgi/src/main/java/org/apache/camel/example/reportincident/ReportIncidentRoutes.java Mon Jul 11 11:57:31 2011 @@ -29,12 +29,16 @@ public class ReportIncidentRoutes extend public void configure() throws Exception { // webservice response for OK OutputReportIncident ok = new OutputReportIncident(); - ok.setCode("0"); + ok.setCode("OK"); + OutputReportIncident accepted = new OutputReportIncident(); + accepted.setCode("Accepted"); from("cxf:bean:reportIncident") - .convertBodyTo(InputReportIncident.class) // TODO remove? + .convertBodyTo(InputReportIncident.class) .setHeader(Exchange.FILE_NAME, constant("request-${date:now:yyyy-MM-dd-HHmmssSSS}")) - .to("file://target/inbox/") - .transform(constant(ok)); + .wireTap("file://target/inbox/") + .choice().when(simple("${body.givenName} == 'Claus'")).transform(constant(ok)) + .otherwise().transform(constant(accepted)); + } } \ No newline at end of file Copied: camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java (from r1145066, 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/ReportIncidentRoutesClientTest.java?p2=camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java&p1=camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java&r1=1145066&r2=1145129&rev=1145129&view=diff ============================================================================== --- camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClient.java (original) +++ camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java Mon Jul 11 11:57:31 2011 @@ -16,17 +16,16 @@ */ package org.apache.camel.example.reportincident; -import org.apache.camel.CamelContext; -import org.apache.camel.impl.DefaultCamelContext; +import org.apache.camel.test.junit4.CamelSpringTestSupport; import org.apache.cxf.jaxws.JaxWsProxyFactoryBean; import org.junit.Test; - -import static org.junit.Assert.assertEquals; +import org.springframework.context.support.AbstractApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; /** * Unit test of our routes */ -public class ReportIncidentRoutesClient { +public class ReportIncidentRoutesClientTest extends CamelSpringTestSupport { // 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"; @@ -61,10 +60,19 @@ public class ReportIncidentRoutesClient OutputReportIncident out = client.reportIncident(input); // assert we got a OK back - assertEquals("0", out.getCode()); + assertEquals("OK", out.getCode()); + + // test the input with other users + input.setGivenName("Guest"); + out = client.reportIncident(input); + + // assert we got a Accept back + assertEquals("Accepted", out.getCode()); - // let some time pass to allow Camel to pickup the file and send it as an email - Thread.sleep(3000); + } + @Override + protected AbstractApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext(new String[] {"camel-context.xml"}); } } Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java ------------------------------------------------------------------------------ svn:executable = * Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/java/org/apache/camel/example/reportincident/ReportIncidentRoutesClientTest.java ------------------------------------------------------------------------------ svn:keywords = Rev Date Added: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml?rev=1145129&view=auto ============================================================================== --- camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml (added) +++ camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml Mon Jul 11 11:57:31 2011 @@ -0,0 +1,39 @@ +<?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.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"> + + <cxf:cxfEndpoint id="reportIncident" + address="http://localhost:8181/cxf/camel-example-cxf-osgi/webservices/incident" + wsdlURL="META-INF/wsdl/report_incident.wsdl" + serviceClass="org.apache.camel.example.reportincident.ReportIncidentEndpoint"> + </cxf:cxfEndpoint> + + <bean id="reportIncidentRoutes" class="org.apache.camel.example.reportincident.ReportIncidentRoutes" /> + + <camel:camelContext id="camel"> + <camel:routeBuilder ref="reportIncidentRoutes"/> + </camel:camelContext> +</beans> Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/camel-context.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Added: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties URL: http://svn.apache.org/viewvc/camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties?rev=1145129&view=auto ============================================================================== --- camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties (added) +++ camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties Mon Jul 11 11:57:31 2011 @@ -0,0 +1,32 @@ +## ------------------------------------------------------------------------ +## 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. +## ------------------------------------------------------------------------ + +# +# The logging properties used +# +log4j.rootLogger=INFO, out + +# +# uncomment the following line to enable debugging of Camel +# +#log4j.logger.org.apache.camel=DEBUG + +log4j.appender.out=org.apache.log4j.ConsoleAppender +log4j.appender.out.layout=org.apache.log4j.PatternLayout +log4j.appender.out.layout.ConversionPattern=[%10.10t] %-30.30c{1} %-5p %m%n + +log4j.throwableRenderer=org.apache.log4j.EnhancedThrowableRenderer \ No newline at end of file Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties ------------------------------------------------------------------------------ svn:eol-style = native Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: camel/trunk/examples/camel-example-cxf-osgi/src/test/resources/log4j.properties ------------------------------------------------------------------------------ svn:mime-type = text/plain