This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.8.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.8.x by this push:
new 10fd585b15b CAMEL-21239: Fix route-coverate to dump all data
10fd585b15b is described below
commit 10fd585b15b7e65c28c58743bb1cd5a2bb408f53
Author: Claus Ibsen <[email protected]>
AuthorDate: Mon Sep 23 09:25:15 2024 +0200
CAMEL-21239: Fix route-coverate to dump all data
---
.../src/main/docs/camel-report-maven-plugin.adoc | 2 +-
.../java/org/apache/camel/maven/RouteCoverageMojo.java | 14 +++++++++-----
.../camel/test/spring/junit5/RouteCoverageDumper.java | 5 +----
.../apache/camel/management/mbean/ManagedCamelContext.java | 2 +-
4 files changed, 12 insertions(+), 11 deletions(-)
diff --git
a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
index f60afeb4d7f..fd3202a8532 100644
---
a/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
+++
b/catalog/camel-report-maven-plugin/src/main/docs/camel-report-maven-plugin.adoc
@@ -357,7 +357,7 @@ The maven plugin *coverage* goal supports the following
options which can be con
patterns (wildcard and regular expression). Multiple values can be separated
by comma.
| excludes | | To filter the names of java and xml files to exclude files
matching any of the given list of
patterns (wildcard and regular expression). Multiple values can be separated
by comma.
-| anonymousRoutes | false | Whether to allow anonymous routes (routes without
any route id assigned).
+| anonymousRoutes | false | **Deprecated** Whether to allow anonymous routes
(routes without any route id assigned).
By using route id's then it is safer to match the route cover data with the
route source code.
Anonymous routes are less safe to use for route coverage as its harder to
know exactly which route
that was tested corresponds to which of the routes from the source code.
diff --git
a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java
b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java
index 1008f9d860a..c0681586dd3 100644
---
a/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java
+++
b/catalog/camel-report-maven-plugin/src/main/java/org/apache/camel/maven/RouteCoverageMojo.java
@@ -133,12 +133,13 @@ public class RouteCoverageMojo extends AbstractMojo {
private String excludes;
/**
- * Whether to allow anonymous routes (routes without any route id
assigned). By using route id's then its safer to
- * match the route cover data with the route source code. Anonymous routes
are less safe to use for route coverage
- * as its harder to know exactly which route that was tested corresponds
to which of the routes from the source
- * code.
+ * Deprecated: Whether to allow anonymous routes (routes without any route
id assigned). By using route id's then
+ * its safer to match the route cover data with the route source code.
Anonymous routes are less safe to use for
+ * route coverage as its harder to know exactly which route that was
tested corresponds to which of the routes from
+ * the source code.
*/
@Parameter(property = "camel.anonymousRoutes", defaultValue = "false")
+ @Deprecated
private boolean anonymousRoutes;
/**
@@ -170,6 +171,9 @@ public class RouteCoverageMojo extends AbstractMojo {
getLog().info("skipping route coverage as per configuration");
return;
}
+ if (anonymousRoutes) {
+ getLog().warn("AnonymousRoutes is deprecated. Add route ids to
these routes for route coverage support.");
+ }
List<CamelNodeDetails> routeTrees = discoverRoutes();
@@ -280,7 +284,7 @@ public class RouteCoverageMojo extends AbstractMojo {
long anonymous = routeTrees.stream().filter(t -> t.getRouteId() ==
null).count();
if (!anonymousRoutes && anonymous > 0) {
getLog().warn(
- "Discovered " + anonymous + " anonymous routes. Add route
ids to these routes for route coverage support");
+ "Discovered " + anonymous + " anonymous routes. Add route
ids to these routes for route coverage support.");
}
return routeTrees;
diff --git
a/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/RouteCoverageDumper.java
b/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/RouteCoverageDumper.java
index 421cab65301..981d782420d 100644
---
a/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/RouteCoverageDumper.java
+++
b/components/camel-test/camel-test-spring-junit5/src/main/java/org/apache/camel/test/spring/junit5/RouteCoverageDumper.java
@@ -60,10 +60,7 @@ public final class RouteCoverageDumper {
File file = new File(dir);
// ensure dir exists
- boolean result = file.mkdirs();
- if (!result) {
- LOG.error("mkdirs() failed for {}", file);
- }
+ file.mkdirs();
file = new File(dir, name);
LOG.info("Dumping route coverage to file: {}", file);
diff --git
a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
index a7e838b3fe9..44fdaa92c63 100644
---
a/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
+++
b/core/camel-management/src/main/java/org/apache/camel/management/mbean/ManagedCamelContext.java
@@ -771,7 +771,7 @@ public class ManagedCamelContext extends
ManagedPerformanceCounter implements Ti
getExchangesTotal(), getTotalProcessingTime()))
.append(">\n");
- String xml = dumpRoutesAsXml(false, false);
+ String xml = dumpRoutesAsXml(false, true);
if (xml != null) {
// use the coverage xml parser to dump the routes and enrich with
coverage stats
Document dom = RouteCoverageXmlParser.parseXml(context, new
ByteArrayInputStream(xml.getBytes()));