diff --git a/spring-apache-camel/pom.xml b/spring-apache-camel/pom.xml index fbea9b779d..1e08a977c7 100644 --- a/spring-apache-camel/pom.xml +++ b/spring-apache-camel/pom.xml @@ -12,24 +12,24 @@ 2.16.1 4.2.4.RELEASE 1.7 - 4.1 + 4.12 - + junit junit ${junit.version} test - + org.apache.camel camel-core ${env.camel.version} - + org.apache.camel camel-spring @@ -49,7 +49,7 @@ - + @@ -62,6 +62,20 @@ ${java.version} + + + org.apache.maven.plugins + maven-surefire-plugin + ${maven-surefire-plugin.version} + + + **/*IntegrationTest.java + + + + + + diff --git a/spring-apache-camel/src/test/java/org/apache/camel/file/processor/FileProcessorIntegrationTest.java b/spring-apache-camel/src/test/java/org/apache/camel/file/processor/FileProcessorIntegrationTest.java new file mode 100644 index 0000000000..e73ad1e4a4 --- /dev/null +++ b/spring-apache-camel/src/test/java/org/apache/camel/file/processor/FileProcessorIntegrationTest.java @@ -0,0 +1,68 @@ +package org.apache.camel.file.processor; + +import java.io.File; + +import org.apache.camel.CamelContext; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.impl.DefaultCamelContext; +import org.junit.Before; +import org.junit.Test; +import org.springframework.context.support.ClassPathXmlApplicationContext; + +import com.baeldung.camel.file.FileProcessor; + + +public class FileProcessorIntegrationTest { + + private static final long DURATION_MILIS = 10000; + private static final String SOURCE_FOLDER = "src/test/source-folder"; + private static final String DESTINATION_FOLDER = "src/test/destination-folder"; + + @Before + public void setUp() throws Exception { + File sourceFolder = new File(SOURCE_FOLDER); + File destinationFolder = new File(DESTINATION_FOLDER); + + cleanFolder(sourceFolder); + cleanFolder(destinationFolder); + + sourceFolder.mkdirs(); + File file1 = new File(SOURCE_FOLDER + "/File1.txt"); + File file2 = new File(SOURCE_FOLDER + "/File2.txt"); + file1.createNewFile(); + file2.createNewFile(); + } + + private void cleanFolder(File folder) { + File[] files = folder.listFiles(); + if (files != null) { + for (File file : files) { + if (file.isFile()) { + file.delete(); + } + } + } + } + + @Test + public void moveFolderContentJavaDSLTest() throws Exception { + final CamelContext camelContext = new DefaultCamelContext(); + camelContext.addRoutes(new RouteBuilder() { + @Override + public void configure() throws Exception { + from("file://" + SOURCE_FOLDER + "?delete=true").process(new FileProcessor()).to("file://" + DESTINATION_FOLDER); + } + }); + camelContext.start(); + Thread.sleep(DURATION_MILIS); + camelContext.stop(); + } + + @Test + public void moveFolderContentSpringDSLTest() throws InterruptedException { + ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext("camel-context-test.xml"); + Thread.sleep(DURATION_MILIS); + applicationContext.close(); + + } +} \ No newline at end of file diff --git a/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java b/spring-apache-camel/src/test/java/org/apache/camel/main/AppIntegrationTest.java similarity index 95% rename from spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java rename to spring-apache-camel/src/test/java/org/apache/camel/main/AppIntegrationTest.java index 87b20369f3..fc7fa9653b 100644 --- a/spring-apache-camel/src/test/java/org/apache/camel/main/AppTest.java +++ b/spring-apache-camel/src/test/java/org/apache/camel/main/AppIntegrationTest.java @@ -15,7 +15,7 @@ import java.nio.channels.FileChannel; import java.nio.file.Files; import java.nio.file.Paths; -public class AppTest extends TestCase { +public class AppIntegrationTest extends TestCase { private static final String FILE_NAME = "file.txt"; private static final String SAMPLE_INPUT_DIR = "src/test/data/sampleInputFile/";