77import org .junit .Test ;
88import org .junit .runner .RunWith ;
99import org .junit .runners .JUnit4 ;
10+ import org .springframework .context .annotation .AnnotationConfigApplicationContext ;
11+ import org .springframework .context .support .AbstractApplicationContext ;
1012import org .springframework .context .support .ClassPathXmlApplicationContext ;
1113
14+ import com .baeldung .camel .file .cfg .ContentBasedFileRouterConfig ;
15+
1216@ RunWith (JUnit4 .class )
1317public class ContentBasedFileRouterIntegrationTest {
1418
15- private static final long DURATION_MILIS = 10000 ;
16- private static final String SOURCE_FOLDER = "src/test/source-folder" ;
17- private static final String DESTINATION_FOLDER_TXT = "src/test/destination-folder-txt" ;
18- private static final String DESTINATION_FOLDER_OTHER = "src/test/destination-folder-other" ;
19-
20- @ Before
21- public void setUp () throws Exception {
22- File sourceFolder = new File (SOURCE_FOLDER );
23- File destinationFolderTxt = new File (DESTINATION_FOLDER_TXT );
24- File destinationFolderOther = new File (DESTINATION_FOLDER_OTHER );
25-
26- cleanFolder (sourceFolder );
27- cleanFolder (destinationFolderTxt );
28- cleanFolder (destinationFolderOther );
29-
30- sourceFolder .mkdirs ();
31- File file1 = new File (SOURCE_FOLDER + "/File1.txt" );
32- File file2 = new File (SOURCE_FOLDER + "/File2.csv" );
33- file1 .createNewFile ();
34- file2 .createNewFile ();
35- }
36-
37- private void cleanFolder (File folder ) {
38- File [] files = folder .listFiles ();
39- if (files != null ) {
40- for (File file : files ) {
41- if (file .isFile ()) {
42- file .delete ();
43- }
44- }
45- }
46- }
47-
48- @ Test
49- @ Ignore
50- public void routeTest () throws InterruptedException {
51- ClassPathXmlApplicationContext applicationContext = new ClassPathXmlApplicationContext ("camel-context-ContentBasedFileRouterTest.xml" );
52- Thread .sleep (DURATION_MILIS );
53- applicationContext .close ();
54-
55- }
19+ private static final long DURATION_MILIS = 10000 ;
20+ private static final String SOURCE_FOLDER = "src/test/source-folder" ;
21+ private static final String DESTINATION_FOLDER_TXT = "src/test/destination-folder-txt" ;
22+ private static final String DESTINATION_FOLDER_OTHER = "src/test/destination-folder-other" ;
23+
24+ @ Before
25+ public void setUp () throws Exception {
26+ File sourceFolder = new File (SOURCE_FOLDER );
27+ File destinationFolderTxt = new File (DESTINATION_FOLDER_TXT );
28+ File destinationFolderOther = new File (DESTINATION_FOLDER_OTHER );
29+
30+ cleanFolder (sourceFolder );
31+ cleanFolder (destinationFolderTxt );
32+ cleanFolder (destinationFolderOther );
33+
34+ sourceFolder .mkdirs ();
35+ File file1 = new File (SOURCE_FOLDER + "/File1.txt" );
36+ File file2 = new File (SOURCE_FOLDER + "/File2.csv" );
37+ file1 .createNewFile ();
38+ file2 .createNewFile ();
39+ }
40+
41+ private void cleanFolder (File folder ) {
42+ File [] files = folder .listFiles ();
43+ if (files != null ) {
44+ for (File file : files ) {
45+ if (file .isFile ()) {
46+ file .delete ();
47+ }
48+ }
49+ }
50+ }
51+
52+ @ Test
53+ @ Ignore
54+ public void routeWithXMLConfigTest () throws InterruptedException {
55+ AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext (
56+ "camel-context-ContentBasedFileRouterTest.xml" );
57+ Thread .sleep (DURATION_MILIS );
58+ applicationContext .close ();
59+
60+ }
61+
62+ @ Test
63+ @ Ignore
64+ public void routeWithJavaConfigTest () throws InterruptedException {
65+ AbstractApplicationContext applicationContext = new AnnotationConfigApplicationContext (
66+ ContentBasedFileRouterConfig .class );
67+ Thread .sleep (DURATION_MILIS );
68+ applicationContext .close ();
69+
70+ }
5671}
0 commit comments