You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2016/07/07 07:20:03 UTC

[1/2] camel git commit: CAMEL-10118: source fix

Repository: camel
Updated Branches:
  refs/heads/master 316156373 -> 69e033368


CAMEL-10118: source fix


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/69e03336
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/69e03336
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/69e03336

Branch: refs/heads/master
Commit: 69e033368b8875ae35451982e64d5dcb3563fa41
Parents: e05899b
Author: Nicola Ferraro <ni...@gmail.com>
Authored: Wed Jul 6 17:19:18 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 7 09:19:56 2016 +0200

----------------------------------------------------------------------
 .../apache/camel/itest/springboot/util/ArquillianPackager.java   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/69e03336/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
index 865a49f..1c6e969 100644
--- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
+++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
@@ -172,11 +172,11 @@ public final class ArquillianPackager {
                 // Re-adding exclusions, as Arquillian resolver ignores them
                 Set<String> pomExclusions = DependencyResolver.getExclusions(config.getModuleBasePath() + "/pom.xml", c.getGroupId(), c.getArtifactId());
                 MavenDependencyExclusion[] artExclusions;
-                if(pomExclusions.isEmpty()) {
+                if (pomExclusions.isEmpty()) {
                     artExclusions = commonExclutionArray;
                 } else {
                     List<MavenDependencyExclusion> specificExclusions = new LinkedList<>(Arrays.asList(commonExclutionArray));
-                    for(String spEx : pomExclusions) {
+                    for (String spEx : pomExclusions) {
                         specificExclusions.add(MavenDependencies.createExclusion(spEx));
                     }
                     artExclusions = specificExclusions.toArray(new MavenDependencyExclusion[]{});


[2/2] camel git commit: CAMEL-10118: Test exclusions were ignored by arquillian

Posted by da...@apache.org.
CAMEL-10118: Test exclusions were ignored by arquillian


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e05899b5
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e05899b5
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e05899b5

Branch: refs/heads/master
Commit: e05899b5a419357460a3fd10ce10fac74439af45
Parents: 3161563
Author: Nicola Ferraro <ni...@gmail.com>
Authored: Wed Jul 6 17:17:18 2016 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Jul 7 09:19:56 2016 +0200

----------------------------------------------------------------------
 .../springboot/util/ArquillianPackager.java     | 18 ++++++-
 .../springboot/util/DependencyResolver.java     | 50 ++++++++++++++++++++
 2 files changed, 67 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e05899b5/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
index 4cb453f3..865a49f 100644
--- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
+++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/ArquillianPackager.java
@@ -120,6 +120,7 @@ public final class ArquillianPackager {
         List<MavenDependencyExclusion> commonExclusions = new LinkedList<>();
         commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-log4j12"));
         commonExclusions.add(MavenDependencies.createExclusion("log4j", "log4j"));
+        commonExclusions.add(MavenDependencies.createExclusion("log4j", "apache-log4j-extras"));
         commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-simple"));
         commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-simple"));
         commonExclusions.add(MavenDependencies.createExclusion("org.slf4j", "slf4j-jdk14"));
@@ -167,7 +168,22 @@ public final class ArquillianPackager {
                 if (!validTestDependency(config, c)) {
                     continue;
                 }
-                MavenDependency dep = MavenDependencies.createDependency(c, ScopeType.RUNTIME, false, commonExclutionArray);
+
+                // Re-adding exclusions, as Arquillian resolver ignores them
+                Set<String> pomExclusions = DependencyResolver.getExclusions(config.getModuleBasePath() + "/pom.xml", c.getGroupId(), c.getArtifactId());
+                MavenDependencyExclusion[] artExclusions;
+                if(pomExclusions.isEmpty()) {
+                    artExclusions = commonExclutionArray;
+                } else {
+                    List<MavenDependencyExclusion> specificExclusions = new LinkedList<>(Arrays.asList(commonExclutionArray));
+                    for(String spEx : pomExclusions) {
+                        specificExclusions.add(MavenDependencies.createExclusion(spEx));
+                    }
+                    artExclusions = specificExclusions.toArray(new MavenDependencyExclusion[]{});
+                }
+
+
+                MavenDependency dep = MavenDependencies.createDependency(c, ScopeType.RUNTIME, false, artExclusions);
                 moduleDependencies.add(dep);
             }
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/e05899b5/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/DependencyResolver.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/DependencyResolver.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/DependencyResolver.java
index 19fd33d..3b9cda8 100644
--- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/DependencyResolver.java
+++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/DependencyResolver.java
@@ -16,13 +16,20 @@
  */
 package org.apache.camel.itest.springboot.util;
 
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
 import javax.xml.xpath.XPathExpression;
 import javax.xml.xpath.XPathFactory;
 
 import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 /**
  * Resolves the currently used version of a library. Useful to run unit tests directly from the IDE, without passing additional parameters.
@@ -39,6 +46,49 @@ public final class DependencyResolver {
     }
 
     /**
+     * Retrieves a list of transitive exclusions included in the pom, given the coordinate of a maven dependency.
+     * Useful to overcome limitations of Arquillian maven resolver.
+     *
+     * @param pom the pom where dependencies should be looked up
+     * @param groupId the group id of the dependency
+     * @param artifactId the artifact id of the dependency
+     * @return the set of exclusions in the form groupId:artifactId
+     * @throws Exception if anything goes wrong
+     */
+    public static Set<String> getExclusions(String pom, String groupId, String artifactId) throws Exception {
+        String expression = "/project/dependencies/dependency[groupId='" + groupId + "' and artifactId='" + artifactId + "']/exclusions";
+
+        DocumentBuilder builder = factory.newDocumentBuilder();
+        Document doc = builder.parse(pom);
+        XPath xpath = xPathfactory.newXPath();
+        XPathExpression expr = xpath.compile(expression);
+
+        NodeList nodes = (NodeList) expr.evaluate(doc, XPathConstants.NODESET);
+        if (nodes == null || nodes.getLength() < 1) {
+            return Collections.emptySet();
+        }
+
+        Set<String> exclusionSet = new HashSet<>();
+
+        NodeList exclusions = nodes.item(0).getChildNodes();
+        for (int i = 0; i < exclusions.getLength(); i++) {
+            Node exclusionNode = exclusions.item(i);
+            if (exclusionNode instanceof Element) {
+                Element exclusion = (Element) exclusionNode;
+                NodeList exclGroupIds = exclusion.getElementsByTagName("groupId");
+                String exclGroupIdVal = exclGroupIds.getLength() == 0 ? null : exclGroupIds.item(0).getTextContent();
+                NodeList exclArtifactIds = exclusion.getElementsByTagName("artifactId");
+                String exclArtifactIdVal = exclGroupIds.getLength() == 0 ? null : exclArtifactIds.item(0).getTextContent();
+                if (exclGroupIdVal != null && exclArtifactIdVal != null) {
+                    exclusionSet.add(exclGroupIdVal + ":" + exclArtifactIdVal);
+                }
+            }
+        }
+
+        return exclusionSet;
+    }
+
+    /**
      * Gets a groupId and artifactId in the form "groupId:artifactId" and returns the current version from the pom.
      * Uses {@link DependencyResolver#withVersion(String, String)} using a default prefix.
      *