Camel route coverage should dump if a route is explicit assigned an id or not, which the tooling then uses to filter anonymous vs named routes.
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/ceccd28a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/ceccd28a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/ceccd28a Branch: refs/heads/master Commit: ceccd28a0a50a0e1d27c2ac0b087ce7217797652 Parents: a0eb2b35 Author: Claus Ibsen <davscl...@apache.org> Authored: Tue Oct 17 10:32:15 2017 +0200 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Oct 17 11:22:11 2017 +0200 ---------------------------------------------------------------------- .../camel/management/mbean/RouteCoverageXmlParser.java | 8 ++++++-- .../ManagedCamelContextDumpRoutesCoverageAsXml.java | 1 + .../org/apache/camel/parser/helper/RouteCoverageHelper.java | 5 +++-- 3 files changed, 10 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/ceccd28a/camel-core/src/main/java/org/apache/camel/management/mbean/RouteCoverageXmlParser.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/RouteCoverageXmlParser.java b/camel-core/src/main/java/org/apache/camel/management/mbean/RouteCoverageXmlParser.java index a28ff71..6cfc70d 100644 --- a/camel-core/src/main/java/org/apache/camel/management/mbean/RouteCoverageXmlParser.java +++ b/camel-core/src/main/java/org/apache/camel/management/mbean/RouteCoverageXmlParser.java @@ -23,6 +23,8 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import org.apache.camel.util.ObjectHelper; +import org.apache.camel.util.StringHelper; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; @@ -126,8 +128,10 @@ public final class RouteCoverageXmlParser { } } - // we do not want customId in output - el.removeAttribute("customId"); + // we do not want customId in output of the EIPs + if (!"route".equals(qName)) { + el.removeAttribute("customId"); + } elementStack.push(el); } http://git-wip-us.apache.org/repos/asf/camel/blob/ceccd28a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextDumpRoutesCoverageAsXml.java ---------------------------------------------------------------------- diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextDumpRoutesCoverageAsXml.java b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextDumpRoutesCoverageAsXml.java index ac5c207..829a582 100644 --- a/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextDumpRoutesCoverageAsXml.java +++ b/camel-core/src/test/java/org/apache/camel/management/ManagedCamelContextDumpRoutesCoverageAsXml.java @@ -50,6 +50,7 @@ public class ManagedCamelContextDumpRoutesCoverageAsXml extends ManagementTestSu assertTrue(xml.contains("exchangesTotal=\"3\"")); assertTrue(xml.contains("exchangesTotal=\"2\"")); + assertTrue(xml.contains("customId=\"true\"")); // should be valid XML Document doc = context.getTypeConverter().convertTo(Document.class, xml); http://git-wip-us.apache.org/repos/asf/camel/blob/ceccd28a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java ---------------------------------------------------------------------- diff --git a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java index 09692f7..a124dda 100644 --- a/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java +++ b/tooling/camel-route-parser/src/main/java/org/apache/camel/parser/helper/RouteCoverageHelper.java @@ -68,8 +68,9 @@ public final class RouteCoverageHelper { for (int i = 0; i < routes.getLength(); i++) { Node route = routes.item(i); String id = route.getAttributes().getNamedItem("id").getNodeValue(); - // must be the target route - if (routeId.equals(id)) { + String customId = route.getAttributes().getNamedItem("customId") != null ? route.getAttributes().getNamedItem("customId").getNodeValue() : "false"; + // must be the target route and the route must be explicit assigned with that route id (not anonymous route) + if ("true".equals(customId) && routeId.equals(id)) { // parse each route and build a List<CoverageData> for line by line coverage data AtomicInteger counter = new AtomicInteger(); parseRouteData(catalog, route, answer, counter);