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 5e59d49 enhance test (#6963)
5e59d49 is described below
commit 5e59d49484e40f2be3e89df770bf8167a5c7a55a
Author: JP Moresmau <[email protected]>
AuthorDate: Thu Feb 17 07:02:16 2022 +0100
enhance test (#6963)
---
.../support/RouteWatcherReloadStrategyTest.java | 42 +++++++++++++++++++---
1 file changed, 38 insertions(+), 4 deletions(-)
diff --git
a/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadStrategyTest.java
b/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadStrategyTest.java
index f0d24ce..90a60f0 100644
---
a/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadStrategyTest.java
+++
b/core/camel-core/src/test/java/org/apache/camel/support/RouteWatcherReloadStrategyTest.java
@@ -29,7 +29,41 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
public class RouteWatcherReloadStrategyTest extends ContextTestSupport {
@Test
- public void testBasePath() throws Exception {
+ public void testBasePathExact() throws Exception {
+ RouteWatcherReloadStrategy strategy = new
RouteWatcherReloadStrategy("./src/test/resources");
+ strategy.setPattern("log4j2.properties");
+ strategy.setCamelContext(context);
+ strategy.doStart();
+
+ assertNotNull(strategy.getFileFilter());
+ File folder = new File("./src/test/resources");
+ assertTrue(folder.isDirectory());
+
+ File[] fs = folder.listFiles(strategy.getFileFilter());
+ assertNotNull(fs);
+ assertEquals(1,fs.length);
+ assertEquals("log4j2.properties",fs[0].getName());
+ }
+
+ @Test
+ public void testBasePathWildcardExtension() throws Exception {
+ RouteWatcherReloadStrategy strategy = new
RouteWatcherReloadStrategy("./src/test/resources");
+ strategy.setPattern("*.properties");
+ strategy.setCamelContext(context);
+ strategy.doStart();
+
+ assertNotNull(strategy.getFileFilter());
+ File folder = new File("./src/test/resources");
+ assertTrue(folder.isDirectory());
+
+ File[] fs = folder.listFiles(strategy.getFileFilter());
+ assertNotNull(fs);
+ assertTrue(fs.length >= 5);
+ assertTrue(Arrays.stream(fs).anyMatch(f ->
f.getName().equals("log4j2.properties")));
+ }
+
+ @Test
+ public void testBasePathFullWildcard() throws Exception {
RouteWatcherReloadStrategy strategy = new
RouteWatcherReloadStrategy("./src/test/resources");
strategy.setPattern("*");
strategy.setCamelContext(context);
@@ -47,18 +81,18 @@ public class RouteWatcherReloadStrategyTest extends
ContextTestSupport {
@Test
public void testNullPattern() throws Exception {
- RouteWatcherReloadStrategy strategy = new
RouteWatcherReloadStrategy("./src/test/resources");
+ RouteWatcherReloadStrategy strategy = new
RouteWatcherReloadStrategy("./src/test/resources/org/apache/camel/model");
strategy.setPattern(null);
strategy.setCamelContext(context);
strategy.doStart();
assertNotNull(strategy.getFileFilter());
- File folder = new File("./src/test/resources");
+ File folder = new File("./src/test/resources/org/apache/camel/model");
assertTrue(folder.isDirectory());
File[] fs = folder.listFiles(strategy.getFileFilter());
assertNotNull(fs);
- assertEquals(0, fs.length);
+ assertTrue(fs.length >= 40,String.valueOf(fs.length));
// null goes back to default
assertEquals("*.yaml,*.xml", strategy.getPattern());
}