Clean up Apache Camel example

This commit is contained in:
David Morley 2016-02-18 21:31:51 -06:00
parent 9d6f56c40a
commit 54a1235d17
7 changed files with 147 additions and 148 deletions

View File

@ -23,6 +23,6 @@ To build this application execute following maven command in ApacheCamelFileProc
<code>mvn clean install</code>
To run this application you can either run our main class org.apache.camel.main.App from your IDE or you can execute following maven command:
To run this application you can either run our main class App from your IDE or you can execute following maven command:
<code>mvn exec:java -Dexec.mainClass="org.apache.camel.main.App"</code>
<code>mvn exec:java -Dexec.mainClass="App"</code>

View File

@ -1,4 +1,4 @@
package org.apache.camel.main;
package com.baeldung.camel.main;
import org.springframework.context.support.ClassPathXmlApplicationContext;

View File

@ -0,0 +1,14 @@
package com.baeldung.camel.processor;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
public class FileProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String originalFileContent = exchange.getIn().getBody(String.class);
String upperCaseFileContent = originalFileContent.toUpperCase();
exchange.getIn().setBody(upperCaseFileContent);
}
}

View File

@ -1,14 +0,0 @@
package org.apache.camel.processor;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
public class FileProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
String originalFileContent = exchange.getIn().getBody(String.class);
String upperCaseFileContent = originalFileContent.toUpperCase();
exchange.getIn().setBody(upperCaseFileContent);
}
}

View File

@ -27,8 +27,7 @@
<!-- Display process completion message on console -->
<transform>
<simple> .......... File content conversion completed ..........
</simple>
<simple>.......... File content conversion completed ..........</simple>
</transform>
<to uri="stream:out"/>
@ -36,5 +35,5 @@
</camelContext>
<bean id="myFileProcessor" class="org.apache.camel.processor.FileProcessor" />
<bean id="myFileProcessor" class="com.baeldung.camel.processor.FileProcessor"/>
</beans>

View File

@ -1 +1 @@
THIS IS UPPERCASE CONTENT. this is lowercase content.
This is data that will be processed by a Camel route!

View File

@ -1,5 +1,12 @@
package org.apache.camel.main;
import com.baeldung.camel.main.App;
import junit.framework.TestCase;
import org.apache.camel.util.FileUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@ -8,19 +15,12 @@ import java.nio.channels.FileChannel;
import java.nio.file.Files;
import java.nio.file.Paths;
import junit.framework.TestCase;
import org.apache.camel.util.FileUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
public class AppTest extends TestCase {
private static final String FILE_NAME = "file.txt";
private static final String SAMPLE_INPUT_DIR = "src/test/data/sampleInputFile/";
private static final String TEST_INPUT_DIR = "src/test/data/input/";
private static final String UPPERCARE_OUTPUT_DIR = "src/test/data/outputUpperCase/";
private static final String UPPERCASE_OUTPUT_DIR = "src/test/data/outputUpperCase/";
private static final String LOWERCASE_OUTPUT_DIR = "src/test/data/outputLowerCase/";
@Before
@ -34,7 +34,7 @@ public class AppTest extends TestCase {
System.out.println("Deleting the test input and output files...");
deleteFile(TEST_INPUT_DIR);
deleteFile(LOWERCASE_OUTPUT_DIR);
deleteFile(UPPERCARE_OUTPUT_DIR);
deleteFile(UPPERCASE_OUTPUT_DIR);
}
@Test
@ -42,7 +42,7 @@ public class AppTest extends TestCase {
App.main(null);
String inputFileContent = readFileContent(SAMPLE_INPUT_DIR + FILE_NAME);
String outputUpperCase = readFileContent(UPPERCARE_OUTPUT_DIR+FILE_NAME);
String outputUpperCase = readFileContent(UPPERCASE_OUTPUT_DIR + FILE_NAME);
String outputLowerCase = readFileContent(LOWERCASE_OUTPUT_DIR + FILE_NAME);
System.out.println("Input File content = [" + inputFileContent + "]");