Skip to content

Commit e4902e3

Browse files
author
Richard Kettelerij
committed
Initial commit
1 parent d5a01c0 commit e4902e3

File tree

7 files changed

+145
-1
lines changed

7 files changed

+145
-1
lines changed

.gitignore

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
### /Users/rickette/.gitignore-boilerplates/Global/OSX.gitignore
2+
3+
.DS_Store
4+
.AppleDouble
5+
.LSOverride
6+
Icon
7+
8+
9+
# Thumbnails
10+
._*
11+
12+
# Files that might appear on external disk
13+
.Spotlight-V100
14+
.Trashes
15+
16+
17+
### /Users/rickette/.gitignore-boilerplates/Global/IntelliJ.gitignore
18+
19+
*.iml
20+
*.ipr
21+
*.iws
22+
.idea/
23+
24+
25+
### /Users/rickette/.gitignore-boilerplates/Java.gitignore
26+
27+
*.class
28+
29+
# Package Files #
30+
*.jar
31+
*.war
32+
*.ear
33+
34+
35+
### /Users/rickette/.gitignore-boilerplates/Maven.gitignore
36+
37+
target/
38+
39+

README

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This file was created by IntelliJ IDEA 11.1.4 for binding GitHub repository
1+
Demo for guest lecture on Apache Camel

pom.xml

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>guest-lecture-apache-camel</groupId>
8+
<artifactId>guest-lecture-apache-camel</artifactId>
9+
<version>1.0</version>
10+
11+
<dependencies>
12+
<dependency>
13+
<groupId>org.apache.camel</groupId>
14+
<artifactId>camel-core</artifactId>
15+
<version>2.10.3</version>
16+
</dependency>
17+
<dependency>
18+
<groupId>org.apache.camel</groupId>
19+
<artifactId>camel-test</artifactId>
20+
<version>2.10.3</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.slf4j</groupId>
24+
<artifactId>slf4j-log4j12</artifactId>
25+
<version>1.6.6</version>
26+
</dependency>
27+
<dependency>
28+
<groupId>log4j</groupId>
29+
<artifactId>log4j</artifactId>
30+
<version>1.2.17</version>
31+
</dependency>
32+
</dependencies>
33+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package nl.avisi.guestlecture.camel;
2+
3+
import org.apache.camel.LoggingLevel;
4+
import org.apache.camel.builder.RouteBuilder;
5+
6+
public class FileRoute extends RouteBuilder {
7+
8+
@Override
9+
public void configure() throws Exception {
10+
from("file://inbox/?move=../processed").from("direct:sendfile")
11+
.log(LoggingLevel.INFO, "Processing file ${headers.CamelFileName}")
12+
.transform(body().regexReplaceAll("V", "W"))
13+
.to("file://outbox/");
14+
}
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package nl.avisi.guestlecture.camel;
2+
3+
public class Main {
4+
5+
public static void main(String[] args) throws Exception {
6+
org.apache.camel.main.Main main = new org.apache.camel.main.Main();
7+
main.enableHangupSupport();
8+
main.addRouteBuilder(new FileRoute());
9+
main.run();
10+
}
11+
}

src/main/resources/log4j.properties

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Set root logger level to WARN.
2+
log4j.rootLogger=INFO, A1
3+
4+
# A1 is set to be a ConsoleAppender.
5+
log4j.appender.A1=org.apache.log4j.ConsoleAppender
6+
7+
# A1 uses PatternLayout.
8+
log4j.appender.A1.layout=org.apache.log4j.PatternLayout
9+
log4j.appender.A1.layout.ConversionPattern=%d [%t] %-5p %c - %m%n
10+
11+
log4j.logger.org.apache.camel=INFO
12+
log4j.logger.org.springframework=INFO
13+
log4j.logger.nl.avisi=DEBUG
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package nl.avisi.guestlecture.camel;
2+
3+
import nl.avisi.guestlecture.camel.FileRoute;
4+
5+
import org.apache.camel.builder.AdviceWithRouteBuilder;
6+
import org.apache.camel.builder.RouteBuilder;
7+
import org.apache.camel.test.junit4.CamelTestSupport;
8+
import org.junit.Test;
9+
10+
public class FileRouteTest extends CamelTestSupport {
11+
12+
@Test
13+
public void testConfigure() throws Exception {
14+
context.getRouteDefinitions().get(0).adviceWith(context, new AdviceWithRouteBuilder() {
15+
@Override
16+
public void configure() throws Exception {
17+
mockEndpointsAndSkip("file:outbox/");
18+
}
19+
});
20+
21+
getMockEndpoint("mock:file:outbox/").expectedMessageCount(1);
22+
getMockEndpoint("mock:file:outbox/").expectedBodiesReceived("Hello Wis");
23+
24+
template.sendBody("direct:sendfile", "Hello Vis");
25+
26+
assertMockEndpointsSatisfied();
27+
}
28+
29+
@Override
30+
protected RouteBuilder createRouteBuilder() throws Exception {
31+
return new FileRoute();
32+
}
33+
}

0 commit comments

Comments
 (0)