Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from markbrooks/master
Updated for Camel 2.8 / Fuse IDE 2.1 + Added a Unit test using a Mock
- Loading branch information
Showing
17 changed files
with
147 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
Copyright 2011 FuseSource | ||
Copyright 2012 FuseSource |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
File Batch Splitter Camel Project | ||
================================= | ||
|
||
This project demonstrates how to consume files from the file system and split the content of the file into multiple messages using Apache Camel. | ||
|
||
The sample implements the Splitter EIP (Enterprise Integration Pattern) which splits an incoming message into a series of outgoing messages. Each of the outgoing messages contains a piece of the original message. | ||
|
||
A sample incoming message file 'batch1.xml' is located in src/data/inbox. When the route is run, the split result files will be located in target/data/outbox. | ||
|
||
This project was created with FuseSource Camel IDE available at http://fusesource.com/products/fuse-ide-camel/ which gives you a nice visualization of your routes, the ability to drag and drop Apache Camel components to design and edit routes, and testing capabilities within the Eclipse IDE. | ||
|
||
To build the project and execute the unit test, execute the following command: | ||
> mvn clean install | ||
To run the example project as a standalone Camel route, execute the following command: | ||
> mvn camel:run | ||
For more help see the Apache Camel documentation | ||
|
||
http://camel.apache.org/splitter.html | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
src/test/java/com/fusesource/byexample/filebatchsplitter/CamelContextXmlTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2012 FuseSource | ||
* | ||
* Licensed 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 com.fusesource.byexample.filebatchsplitter; | ||
|
||
import org.apache.camel.builder.AdviceWithRouteBuilder; | ||
import org.apache.camel.test.junit4.CamelSpringTestSupport; | ||
import org.junit.Test; | ||
import org.springframework.context.support.ClassPathXmlApplicationContext; | ||
|
||
public final class CamelContextXmlTest extends CamelSpringTestSupport { | ||
|
||
private static final int EXPECTED_NUMBER_OF_LINE_ITEMS = 5; | ||
|
||
private static final String OUTBOX_DIR = "target/data/outbox"; | ||
|
||
/** | ||
* This test relies on the batch file 'order1.xml' in the src/data/inbox dir | ||
* which includes five line items. The Camel route under test should create | ||
* one file per line item in the target/data/outbox dir. | ||
*/ | ||
@Test | ||
public void testCamelRoute() throws Exception { | ||
|
||
// Mock the file endpoints | ||
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() { | ||
@Override | ||
public void configure() throws Exception { | ||
|
||
mockEndpoints("file*"); | ||
|
||
} | ||
}); | ||
|
||
// make sure we get the right number of line items | ||
getMockEndpoint("mock:file:" + OUTBOX_DIR).expectedMessageCount(EXPECTED_NUMBER_OF_LINE_ITEMS); | ||
|
||
assertMockEndpointsSatisfied(); | ||
} | ||
|
||
@Override | ||
public void setUp() throws Exception { | ||
super.setUp(); | ||
deleteDirectory(OUTBOX_DIR); | ||
createDirectory(OUTBOX_DIR); | ||
} | ||
|
||
@Override | ||
public void tearDown() throws Exception { | ||
super.tearDown(); | ||
deleteDirectory(OUTBOX_DIR); | ||
} | ||
|
||
@Override | ||
protected ClassPathXmlApplicationContext createApplicationContext() { | ||
return new ClassPathXmlApplicationContext("META-INF/spring/camel-context.xml"); | ||
} | ||
} |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.