CAMEL-7027 Added an unit test for SpringZipSplitterRouteTest
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3ad2ccbd Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3ad2ccbd Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3ad2ccbd Branch: refs/heads/camel-gora Commit: 3ad2ccbdd4b34eb8ec4b9804c413450754fbe8d9 Parents: 102843f Author: Willem Jiang <willem.ji...@gmail.com> Authored: Mon Dec 2 17:49:50 2013 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Mon Dec 2 17:51:33 2013 +0800 ---------------------------------------------------------------------- components/camel-zipfile/pom.xml | 10 +++++ .../zipfile/SpringZipSplitterRouteTest.java | 39 +++++++++++++++++ .../ZipFileMultipleFilesSplitterTest.java | 2 +- .../zipfile/ZipSplitterRouteTest.java | 2 +- .../zipfile/SpringZipSplitterRouteTest.xml | 43 +++++++++++++++++++ .../camel/dataformat/zipfile/data/resources.zip | Bin 0 -> 306 bytes .../camel/dataformat/zipfile/resources.zip | Bin 306 -> 0 bytes 7 files changed, 94 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/3ad2ccbd/components/camel-zipfile/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/pom.xml b/components/camel-zipfile/pom.xml index f9a20db..008e7ca 100644 --- a/components/camel-zipfile/pom.xml +++ b/components/camel-zipfile/pom.xml @@ -47,6 +47,16 @@ <scope>test</scope> </dependency> <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-spring</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-test-spring</artifactId> + <scope>test</scope> + </dependency> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-log4j12</artifactId> <scope>test</scope> http://git-wip-us.apache.org/repos/asf/camel/blob/3ad2ccbd/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java new file mode 100644 index 0000000..cd7189c --- /dev/null +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.java @@ -0,0 +1,39 @@ +/** + * 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.dataformat.zipfile; + + +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.camel.test.spring.CamelSpringTestSupport; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +public class SpringZipSplitterRouteTest extends CamelSpringTestSupport { + + @Test + public void testSplitter() throws InterruptedException { + MockEndpoint processZipEntry = getMockEndpoint("mock:processZipEntry"); + processZipEntry.expectedBodiesReceivedInAnyOrder("chau", "hi", "hola"); + assertMockEndpointsSatisfied(); + } + + @Override + protected ClassPathXmlApplicationContext createApplicationContext() { + return new ClassPathXmlApplicationContext("org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.xml"); + } + +} http://git-wip-us.apache.org/repos/asf/camel/blob/3ad2ccbd/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java index 54b5e54..9490e94 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipFileMultipleFilesSplitterTest.java @@ -44,7 +44,7 @@ public class ZipFileMultipleFilesSplitterTest extends ZipSplitterRouteTest { // Unzip file and Split it according to FileEntry ZipFileDataFormat zipFile = new ZipFileDataFormat(); zipFile.setUsingIterator(true); - from("file:src/test/resources/org/apache/camel/dataformat/zipfile/?consumer.delay=1000&noop=true") + from("file:src/test/resources/org/apache/camel/dataformat/zipfile/data/?consumer.delay=1000&noop=true") .unmarshal(zipFile) .split(body(Iterator.class)) .streaming() http://git-wip-us.apache.org/repos/asf/camel/blob/3ad2ccbd/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java index d94e0c7..64d5ef8 100644 --- a/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java +++ b/components/camel-zipfile/src/test/java/org/apache/camel/dataformat/zipfile/ZipSplitterRouteTest.java @@ -36,7 +36,7 @@ public class ZipSplitterRouteTest extends CamelTestSupport { @Override public void configure() throws Exception { // Unzip file and Split it according to FileEntry - from("file:src/test/resources/org/apache/camel/dataformat/zipfile?consumer.delay=1000&noop=true") + from("file:src/test/resources/org/apache/camel/dataformat/zipfile/data?consumer.delay=1000&noop=true") .log("Start processing big file: ${header.CamelFileName}") .split(new ZipSplitter()).streaming() .to("log:entry") http://git-wip-us.apache.org/repos/asf/camel/blob/3ad2ccbd/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.xml ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.xml b/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.xml new file mode 100644 index 0000000..fae435e --- /dev/null +++ b/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/SpringZipSplitterRouteTest.xml @@ -0,0 +1,43 @@ +<?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" + 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 + "> + + <!-- START SNIPPET: e1 --> + + <!-- use a bean to define a custom expression --> + <bean id="zipSplitter" class="org.apache.camel.dataformat.zipfile.ZipSplitter"/> + + <camelContext xmlns="http://camel.apache.org/schema/spring"> + <route> + <from uri="file:src/test/resources/org/apache/camel/dataformat/zipfile/data?consumer.delay=1000&noop=true"/> + <split streaming="true"> + <!-- refer to our custom expression, using ref tag --> + <ref>zipSplitter</ref> + <convertBodyTo type="java.lang.String" charset="UTF-8"/> + <to uri="mock:processZipEntry"/> + </split> + </route> + </camelContext> + <!-- END SNIPPET: e1 --> + +</beans> http://git-wip-us.apache.org/repos/asf/camel/blob/3ad2ccbd/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/data/resources.zip ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/data/resources.zip b/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/data/resources.zip new file mode 100644 index 0000000..7ab9690 Binary files /dev/null and b/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/data/resources.zip differ http://git-wip-us.apache.org/repos/asf/camel/blob/3ad2ccbd/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/resources.zip ---------------------------------------------------------------------- diff --git a/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/resources.zip b/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/resources.zip deleted file mode 100644 index 7ab9690..0000000 Binary files a/components/camel-zipfile/src/test/resources/org/apache/camel/dataformat/zipfile/resources.zip and /dev/null differ