This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.4.x by this push:
new 20a92eed476 CAMEL-21239: Fix route-coverate to dump all data
20a92eed476 is described below
commit 20a92eed4769d4530db24ccd95fdf9e3fec7196a
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 | 4 ++--
.../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, 13 insertions(+), 12 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 ae758180b95..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,8 +357,8 @@ 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).
- By using route id's then its safer to match the route cover data with the
route source code.
+| 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.
| generateJacocoXmlReport | false | Whether to generate a coverage-report in
Jacoco XML format. When enabled it will generate the file:
`target/site/jacoco/xmlJacoco.xml`
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 4e8d8ee15c2..d119bd1f3fd 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
@@ -130,12 +130,13 @@ public class RouteCoverageMojo extends AbstractExecMojo {
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;
/**
@@ -152,6 +153,9 @@ public class RouteCoverageMojo extends AbstractExecMojo {
@Override
public void execute() throws MojoExecutionException {
+ if (anonymousRoutes) {
+ getLog().warn("AnonymousRoutes is deprecated. Add route ids to
these routes for route coverage support.");
+ }
Set<File> javaFiles = new LinkedHashSet<>();
Set<File> xmlFiles = new LinkedHashSet<>();
@@ -177,7 +181,7 @@ public class RouteCoverageMojo extends AbstractExecMojo {
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.");
}
final AtomicInteger notCovered = new AtomicInteger();
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 de96f2aebf6..a74ed1565c1 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 7f1fecc0631..5d5ee75c93a 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
@@ -698,7 +698,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()));