Skip to content

Commit 4e1be85

Browse files
authored
Merge pull request eugenp#835 from ante003/master
Intro to Apache Camel
2 parents 506bfb9 + d33c386 commit 4e1be85

3 files changed

Lines changed: 88 additions & 6 deletions

File tree

‎spring-apache-camel/pom.xml‎

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@
1212
<env.camel.version>2.16.1</env.camel.version>
1313
<env.spring.version>4.2.4.RELEASE</env.spring.version>
1414
<java.version>1.7</java.version>
15-
<junit.version>4.1</junit.version>
15+
<junit.version>4.12</junit.version>
1616
</properties>
1717

1818
<dependencies>
19-
19+
2020
<dependency>
2121
<groupId>junit</groupId>
2222
<artifactId>junit</artifactId>
2323
<version>${junit.version}</version>
2424
<scope>test</scope>
2525
</dependency>
26-
26+
2727
<dependency>
2828
<groupId>org.apache.camel</groupId>
2929
<artifactId>camel-core</artifactId>
3030
<version>${env.camel.version}</version>
3131
</dependency>
32-
32+
3333
<dependency>
3434
<groupId>org.apache.camel</groupId>
3535
<artifactId>camel-spring</artifactId>
@@ -49,7 +49,7 @@
4949
</dependency>
5050

5151
</dependencies>
52-
52+
5353
<build>
5454
<plugins>
5555
<plugin>
@@ -62,6 +62,20 @@
6262
<target>${java.version}</target>
6363
</configuration>
6464
</plugin>
65+
66+
<plugin>
67+
<groupId>org.apache.maven.plugins</groupId>
68+
<artifactId>maven-surefire-plugin</artifactId>
69+
<version>${maven-surefire-plugin.version}</version>
70+
<configuration>
71+
<excludes>
72+
<exclude>**/*IntegrationTest.java</exclude>
73+
</excludes>
74+
<systemPropertyVariables>
75+
<!-- <provPersistenceTarget>h2</provPersistenceTarget> -->
76+
</systemPropertyVariables>
77+
</configuration>
78+
</plugin>
6579
</plugins>
6680
</build>
6781
</project>
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package org.apache.camel.file.processor;
2+
3+
import java.io.File;
4+
5+
import org.apache.camel.CamelContext;
6+
import org.apache.camel.builder.RouteBuilder;
7+
import org.apache.camel.impl.DefaultCamelContext;
8+
import org.junit.Before;
9+
import org.junit.Test;
10+
import org.springframework.context.support.ClassPathXmlApplicationContext;
11+
12+
import com.baeldung.camel.file.FileProcessor;
13+
14+
15+
public class FileProcessorIntegrationTest {
16+
17+
private static final long DURATION_MILIS = 10000;
18+
private static final String SOURCE_FOLDER = "src/test/source-folder";
19+
private static final String DESTINATION_FOLDER = "src/test/destination-folder";
20+
21+
@Before
22+
public void setUp() throws Exception {
23+
File sourceFolder = new File(SOURCE_FOLDER);
24+
File destinationFolder = new File(DESTINATION_FOLDER);
25+
26+
cleanFolder(sourceFolder);
27+
cleanFolder(destinationFolder);
28+
29+
sourceFolder.mkdirs();
30+
File file1 = new File(SOURCE_FOLDER + "/File1.txt");
31+
File file2 = new File(SOURCE_FOLDER + "/File2.txt");
32+
file1.createNewFile();
33+
file2.createNewFile();
34+
}
35+
36+
private void cleanFolder(File folder) {
37+
File[] files = folder.listFiles();
38+
if (files != null) {
39+
for (File file : files) {
40+
if (file.isFile()) {
41+
file.delete();
42+
}
43+
}
44+
}
45+
}
46+
47+
@Test
48+
public void moveFolderContentJavaDSLTest() throws Exception {
49+
final CamelContext camelContext = new DefaultCamelContext();
50+
camelContext.addRoutes(new RouteBuilder() {
51+
@Override
52+
public void configure() throws Exception {
53+
from("file://" + SOURCE_FOLDER + "?delete=true").process(new FileProcessor()).to("file://" + DESTINATION_FOLDER);
54+
}
55+
});
56+
camelContext.start();
57+
Thread.sleep(DURATION_MILIS);
58+
camelContext.stop();
59+
}
60+
61+
@Test
62+
public void moveFolderContentSpringDSLTest() throws InterruptedException {
63+
ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context-test.xml");
64+
Thread.sleep(DURATION_MILIS);
65+
applicationContext.close();
66+
67+
}
68+
}

spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java renamed to spring-apache-camel/src/test/java/org/apache/camel/main/AppIntegrationTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import java.nio.file.Files;
1616
import java.nio.file.Paths;
1717

18-
public class AppTest extends TestCase {
18+
public class AppIntegrationTest extends TestCase {
1919

2020
private static final String FILE_NAME = "file.txt";
2121
private static final String SAMPLE_INPUT_DIR = "src/test/data/sampleInputFile/";

0 commit comments

Comments
 (0)