This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 1ea87afce99 Fix flaky test (#10796)
1ea87afce99 is described below

commit 1ea87afce995b975eb025727e30fe557a2d7f525
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Jul 24 10:02:16 2023 +0200

    Fix flaky test (#10796)
---
 .../file/AntPathMatcherGenericFileFilterTest.java  | 153 ++++++++++++++++-----
 1 file changed, 115 insertions(+), 38 deletions(-)

diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
index 98eee7f8275..8044f9863f5 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/file/AntPathMatcherGenericFileFilterTest.java
@@ -30,6 +30,11 @@ import org.junit.jupiter.api.Test;
  */
 public class AntPathMatcherGenericFileFilterTest extends ContextTestSupport {
 
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
     @Override
     protected Registry createRegistry() throws Exception {
         AntPathMatcherGenericFileFilter<File> filterNotCaseSensitive = new 
AntPathMatcherGenericFileFilter<>("**/c*");
@@ -43,6 +48,18 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
 
     @Test
     public void testInclude() throws Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(fileUri(
+                        
"files/ant-path-1?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=true"))
+                        .convertBodyTo(String.class)
+                        .to("mock:result1");
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result1");
         mock.expectedBodiesReceivedInAnyOrder("Hello World");
 
@@ -50,11 +67,23 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World", 
Exchange.FILE_NAME, "report.txt");
         template.sendBodyAndHeader(endpointUri, "Hello World 2", 
Exchange.FILE_NAME, "b.TXT");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testExclude() throws Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                
from(fileUri("files/ant-path-2?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak"))
+                        .convertBodyTo(String.class).to("mock:result2");
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result2");
         mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 
3", "Hello World 4");
 
@@ -64,11 +93,25 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World 3", 
Exchange.FILE_NAME, "b.BAK");
         template.sendBodyAndHeader(endpointUri, "Hello World 4", 
Exchange.FILE_NAME, "b.TXT");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testIncludesAndExcludes() throws Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(fileUri(
+                        
"files/ant-path-3?initialDelay=0&delay=10&recursive=true&antInclude=**/*.pdf,**/*.txt&antExclude=**/a*,**/b*"))
+                        .convertBodyTo(String.class)
+                        .to("mock:result3");
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result3");
         mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 
4");
 
@@ -86,11 +129,25 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World 11", 
Exchange.FILE_NAME, "by.BAK");
         template.sendBodyAndHeader(endpointUri, "Hello World 12", 
Exchange.FILE_NAME, "my.BaK");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testIncludesAndExcludesAndFilter() throws Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(fileUri(
+                        
"files/ant-path-4?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#filter"))
+                        .convertBodyTo(String.class)
+                        .to("mock:result4");
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result4");
         mock.expectedBodiesReceivedInAnyOrder("Hello World 3");
 
@@ -100,11 +157,25 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World 3", 
Exchange.FILE_NAME, "c.txt");
         template.sendBodyAndHeader(endpointUri, "Hello World 4", 
Exchange.FILE_NAME, "Cy.txt");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testIncludeAndAntFilterNotCaseSensitive() throws Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(fileUri(
+                        
"files/ant-path-5?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=false"))
+                        .convertBodyTo(String.class)
+                        .to("mock:result5");
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result5");
         mock.expectedBodiesReceivedInAnyOrder("Hello World");
 
@@ -112,11 +183,26 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World", 
Exchange.FILE_NAME,
                 "report.TXT");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testExcludeAndAntFilterNotCaseSensitive() throws Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(fileUri(
+                        
"files/ant-path-6?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak&antFilterCaseSensitive=false"))
+                        .convertBodyTo(String.class)
+                        .to("mock:result6");
+
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result6");
         mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 
4");
 
@@ -126,11 +212,25 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World 3", 
Exchange.FILE_NAME, "b.BAK");
         template.sendBodyAndHeader(endpointUri, "Hello World 4", 
Exchange.FILE_NAME, "b.TXT");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testIncludesAndExcludesAndAntFilterNotCaseSensitive() throws 
Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(fileUri(
+                        
"files/ant-path-7?initialDelay=0&delay=10&recursive=true&antInclude=**/*.Pdf,**/*.txt&antExclude=**/a*,**/b*&antFilterCaseSensitive=false"))
+                        .convertBodyTo(String.class).to("mock:result7");
+
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result7");
         mock.expectedBodiesReceivedInAnyOrder("Hello World 2", "Hello World 
4", "Hello World 8", "Hello World 10");
 
@@ -148,11 +248,24 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World 11", 
Exchange.FILE_NAME, "By.BAK");
         template.sendBodyAndHeader(endpointUri, "Hello World 12", 
Exchange.FILE_NAME, "My.BaK");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
     @Test
     public void testIncludesAndExcludesAndFilterAndAntFilterNotCaseSensitive() 
throws Exception {
+        context.setAutoStartup(false);
+        context.addRoutes(new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from(fileUri(
+                        
"files/ant-path-8?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#caseInsensitiveFilter"))
+                        .convertBodyTo(String.class).to("mock:result8");
+            }
+        });
+        context.start();
+
         MockEndpoint mock = getMockEndpoint("mock:result8");
         mock.expectedBodiesReceivedInAnyOrder("Hello World 3", "Hello World 
4");
 
@@ -162,45 +275,9 @@ public class AntPathMatcherGenericFileFilterTest extends 
ContextTestSupport {
         template.sendBodyAndHeader(endpointUri, "Hello World 3", 
Exchange.FILE_NAME, "c.txt");
         template.sendBodyAndHeader(endpointUri, "Hello World 4", 
Exchange.FILE_NAME, "Cy.txt");
 
+        context.getRouteController().startAllRoutes();
+
         assertMockEndpointsSatisfied();
     }
 
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {
-            public void configure() throws Exception {
-                from(fileUri(
-                        
"files/ant-path-1?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=true"))
-                        .convertBodyTo(String.class)
-                        .to("mock:result1");
-                from(fileUri(
-                        
"files/ant-path-5?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antFilterCaseSensitive=false"))
-                        .convertBodyTo(String.class)
-                        .to("mock:result5");
-
-                
from(fileUri("files/ant-path-2?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak"))
-                        .convertBodyTo(String.class).to("mock:result2");
-                from(fileUri(
-                        
"files/ant-path-6?initialDelay=0&delay=10&recursive=true&antExclude=**/*.bak&antFilterCaseSensitive=false"))
-                        .convertBodyTo(String.class)
-                        .to("mock:result6");
-
-                from(fileUri(
-                        
"files/ant-path-3?initialDelay=0&delay=10&recursive=true&antInclude=**/*.pdf,**/*.txt&antExclude=**/a*,**/b*"))
-                        .convertBodyTo(String.class)
-                        .to("mock:result3");
-                from(fileUri(
-                        
"files/ant-path-7?initialDelay=0&delay=10&recursive=true&antInclude=**/*.Pdf,**/*.txt&antExclude=**/a*,**/b*&antFilterCaseSensitive=false"))
-                        .convertBodyTo(String.class).to("mock:result7");
-
-                from(fileUri(
-                        
"files/ant-path-4?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#filter"))
-                        .convertBodyTo(String.class)
-                        .to("mock:result4");
-                from(fileUri(
-                        
"files/ant-path-8?initialDelay=0&delay=10&recursive=true&antInclude=**/*.txt&antExclude=**/a*&filter=#caseInsensitiveFilter"))
-                        .convertBodyTo(String.class).to("mock:result8");
-            }
-        };
-    }
 }

Reply via email to