data folder moved under test/data. Test cases added. Code & POM updated.

This commit is contained in:
ypatil
2016-02-15 15:29:13 +05:30
parent c385d23cd5
commit aedffc1d13
10 changed files with 163 additions and 31 deletions
@@ -4,9 +4,9 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class App {
public static void main(final String[] args) throws Exception {
//Load application context
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context.xml");
Thread.sleep(5000);
// Keep main thread alive for some time to let application finish processing the input files.
Thread.sleep(5000);
applicationContext.close();
}
}
@@ -6,13 +6,8 @@ import org.apache.camel.Processor;
public class FileProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
//Read file content
String originalFileContent = (String)exchange.getIn().getBody(String.class);
//Convert file content to upper case.
String originalFileContent = exchange.getIn().getBody(String.class);
String upperCaseFileContent = originalFileContent.toUpperCase();
//Update file content.
exchange.getIn().setBody(upperCaseFileContent);
}
@@ -1,40 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<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:util="http://www.springframework.org/schema/util"
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-3.1.xsd
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd">
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route customId="true" id="rout1">
<route customId="true" id="route1">
<!-- Read files from input directory -->
<from uri="file://data/input" />
<from uri="file://src/test/data/input" />
<!-- Transform content to UpperCase -->
<process ref="myFileProcessor" />
<!-- Write converted file content -->
<to uri="file://data/outputUppperCase" />
<to uri="file://src/test/data/outputUpperCase" />
<!-- Transform content to LowerCase -->
<transform>
<simple>${body.toLowerCase()}</simple>
</transform>
<!-- Write converted file content -->
<to uri="file://data/outputLowerCase" />
<to uri="file://src/test/data/outputLowerCase" />
<!-- Display process completion message on console -->
<transform>
<simple> .......... File content conversion completed ..........</simple>
<simple> .......... File content conversion completed ..........
</simple>
</transform>
<to uri="stream:out" />
</route>
</camelContext>
<bean id="myFileProcessor" class="org.apache.camel.processor.FileProcessor" />