[1/3] camel git commit: Importing some testing features from boot2 branch

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

[1/3] camel git commit: Importing some testing features from boot2 branch

nferraro
Repository: camel
Updated Branches:
  refs/heads/master ea4a722bc -> 6556320fd


Importing some testing features from boot2 branch


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

Branch: refs/heads/master
Commit: f75d8056b5761975dd1dd941e755cc9fb1bd414e
Parents: ea4a722
Author: Nicola Ferraro <[hidden email]>
Authored: Mon Sep 25 11:38:47 2017 +0200
Committer: Nicola Ferraro <[hidden email]>
Committed: Mon Sep 25 14:55:57 2017 +0200

----------------------------------------------------------------------
 tests/camel-itest-spring-boot/pom.xml           |   4 +
 .../camel/itest/springboot/ITestConfig.java     |  64 ++++++-----
 .../itest/springboot/ITestConfigBuilder.java    |  19 ++++
 .../itest/springboot/CamelCassandraqlTest.java  |   6 -
 .../springboot/util/ArquillianPackager.java     |  21 ++--
 .../itest/springboot/util/BOMResolver.java      |  46 +++++---
 .../springboot/util/DependencyResolver.java     |   7 ++
 .../itest/springboot/util/JarExporter.java      |   4 +-
 .../src/test/resources/application-pom-sb1.xml  | 112 +++++++++++++++++++
 .../src/test/resources/application-pom.xml      | 107 ------------------
 10 files changed, 229 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/pom.xml b/tests/camel-itest-spring-boot/pom.xml
index fa6a001..9a7d637 100644
--- a/tests/camel-itest-spring-boot/pom.xml
+++ b/tests/camel-itest-spring-boot/pom.xml
@@ -198,6 +198,10 @@
               <name>itest.springboot.mavenOfflineResolution</name>
               <value>false</value>
             </property>
+            <property>
+              <name>itest.springboot.springBootVersion</name>
+              <value>${spring-boot-version}</value>
+            </property>
 
           </systemProperties>
         </configuration>

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
index c4d332b..611c9a0 100644
--- a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
+++ b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
@@ -71,6 +71,8 @@ public class ITestConfig implements Serializable {
 
     private Map<String, String> testLibraryVersions;
 
+    private String springBootVersion;
+
     public ITestConfig() {
     }
 
@@ -250,32 +252,44 @@ public class ITestConfig implements Serializable {
         this.testLibraryVersions = testLibraryVersions;
     }
 
+    public String getSpringBootVersion() {
+        return springBootVersion;
+    }
+
+    public Integer getSpringBootMajorVersion() {
+        return Integer.parseInt(springBootVersion.substring(0, 1));
+    }
+
+    public void setSpringBootVersion(String springBootVersion) {
+        this.springBootVersion = springBootVersion;
+    }
+
     @Override
     public String toString() {
-        final StringBuilder sb = new StringBuilder("ITestConfig{");
-        sb.append("moduleName='").append(moduleName).append('\'');
-        sb.append(", mavenGroup='").append(mavenGroup).append('\'');
-        sb.append(", mavenVersion='").append(mavenVersion).append('\'');
-        sb.append(", mavenOfflineResolution=").append(mavenOfflineResolution);
-        sb.append(", modulesPath='").append(modulesPath).append('\'');
-        sb.append(", moduleBasePath='").append(moduleBasePath).append('\'');
-        sb.append(", includeTestDependencies=").append(includeTestDependencies);
-        sb.append(", includeProvidedDependencies=").append(includeProvidedDependencies);
-        sb.append(", unitTestEnabled=").append(unitTestEnabled);
-        sb.append(", unitTestInclusionPattern='").append(unitTestInclusionPattern).append('\'');
-        sb.append(", unitTestExclusionPattern='").append(unitTestExclusionPattern).append('\'');
-        sb.append(", unitTestBasePackage='").append(unitTestBasePackage).append('\'');
-        sb.append(", unitTestsExpectedNumber=").append(unitTestsExpectedNumber);
-        sb.append(", resources=").append(resources);
-        sb.append(", additionalDependencies=").append(additionalDependencies);
-        sb.append(", mavenExclusions=").append(mavenExclusions);
-        sb.append(", autoStartComponent=").append(autoStartComponent);
-        sb.append(", jmxDisabledNames=").append(jmxDisabledNames);
-        sb.append(", systemProperties=").append(systemProperties);
-        sb.append(", useCustomLog=").append(useCustomLog);
-        sb.append(", ignoreLibraryMismatch=").append(ignoreLibraryMismatch);
-        sb.append(", testLibraryVersions=").append(testLibraryVersions);
-        sb.append('}');
-        return sb.toString();
+        return "ITestConfig{" +
+                "moduleName='" + moduleName + '\'' +
+                ", mavenGroup='" + mavenGroup + '\'' +
+                ", mavenVersion='" + mavenVersion + '\'' +
+                ", mavenOfflineResolution=" + mavenOfflineResolution +
+                ", modulesPath='" + modulesPath + '\'' +
+                ", moduleBasePath='" + moduleBasePath + '\'' +
+                ", includeTestDependencies=" + includeTestDependencies +
+                ", includeProvidedDependencies=" + includeProvidedDependencies +
+                ", unitTestEnabled=" + unitTestEnabled +
+                ", unitTestInclusionPattern='" + unitTestInclusionPattern + '\'' +
+                ", unitTestExclusionPattern='" + unitTestExclusionPattern + '\'' +
+                ", unitTestBasePackage='" + unitTestBasePackage + '\'' +
+                ", unitTestsExpectedNumber=" + unitTestsExpectedNumber +
+                ", resources=" + resources +
+                ", additionalDependencies=" + additionalDependencies +
+                ", mavenExclusions=" + mavenExclusions +
+                ", autoStartComponent=" + autoStartComponent +
+                ", jmxDisabledNames=" + jmxDisabledNames +
+                ", systemProperties=" + systemProperties +
+                ", useCustomLog=" + useCustomLog +
+                ", ignoreLibraryMismatch=" + ignoreLibraryMismatch +
+                ", testLibraryVersions=" + testLibraryVersions +
+                ", springBootVersion=" + springBootVersion +
+                '}';
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
index 647b8ef..1b529d8 100644
--- a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
+++ b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
@@ -165,6 +165,11 @@ public class ITestConfigBuilder {
         return this;
     }
 
+    public ITestConfigBuilder springBootVersion(String springBootVersion) {
+        config.setSpringBootVersion(springBootVersion);
+        return this;
+    }
+
     public ITestConfig build() {
 
         // Checking conditions
@@ -253,6 +258,10 @@ public class ITestConfigBuilder {
             config.setTestLibraryVersions(new HashMap<>());
         }
 
+        if (config.getSpringBootVersion() == null) {
+            config.setSpringBootVersion(propertyOr("springBootVersion", null));
+        }
+
         return config;
     }
 
@@ -277,4 +286,14 @@ public class ITestConfigBuilder {
 
         return res;
     }
+
+    private Integer integerPropertyOr(String name, Integer defaultVal) {
+        String prop = propertyOr(name, null);
+        Integer res = defaultVal;
+        if (prop != null) {
+            res = Integer.valueOf(prop);
+        }
+
+        return res;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelCassandraqlTest.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelCassandraqlTest.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelCassandraqlTest.java
index 17c45c7..ae838cb 100644
--- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelCassandraqlTest.java
+++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/CamelCassandraqlTest.java
@@ -36,13 +36,7 @@ public class CamelCassandraqlTest extends AbstractSpringBootTestSupport {
     public static ITestConfig createTestConfig() {
         return new ITestConfigBuilder()
                 .module(inferModuleName(CamelCassandraqlTest.class))
-                .dependency("io.netty:netty-all:" + DependencyResolver.resolveParentProperty("${cassandra-netty-version-testing}"))
-                //.dependency(DependencyResolver.withVersion("io.netty:netty-all"))
-//                .dependency(DependencyResolver.withVersion("io.dropwizard.metrics:metrics-core"))
-//                .exclusion("com.codahale.metrics:*")
                 .unitTestExclusionPattern(".*(\\.integration\\..*|IntegrationTest$|CassandraComponentProducerTest$|CassandraComponentBeanRefTest$|CassandraComponentConsumerTest$)")
-                //.unitTestInclusionPattern(".*NamedCassandraAggregationRepositoryTest$")
-                // excluded tests have been checked manually (they need to run on their own JVM)
                 .build();
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/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 d3a577d..a71f9d6 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
@@ -464,7 +464,8 @@ public final class ArquillianPackager {
     private static File createUserPom(ITestConfig config, List<String> cleanTestProvidedDependencies) throws Exception {
 
         String pom;
-        try (InputStream pomTemplate = ArquillianPackager.class.getResourceAsStream("/application-pom.xml")) {
+        String template = "/application-pom-sb" + config.getSpringBootMajorVersion() + ".xml";
+        try (InputStream pomTemplate = ArquillianPackager.class.getResourceAsStream(template)) {
             pom = IOUtils.toString(pomTemplate);
         }
 
@@ -578,22 +579,28 @@ public final class ArquillianPackager {
         String groupId = textBetween(dependencyXml, "<groupId>", "</groupId>");
         String artifactId = textBetween(dependencyXml, "<artifactId>", "</artifactId>");
 
-        String bomVersion = config.getTestLibraryVersions().get(groupId + ":" + artifactId);
-        if (bomVersion == null) {
-            bomVersion = BOMResolver.getInstance().getBOMVersion(groupId, artifactId);
+        String version = config.getTestLibraryVersions().get(groupId + ":" + artifactId);
+        boolean stripVersion = false;
+        if (version == null) {
+            boolean testsLib = dependencyXml.contains("<classifier>tests");
+            stripVersion = !testsLib && BOMResolver.getInstance(config).getBOMVersion(groupId, artifactId) != null;
         }
 
-        if (bomVersion != null) {
+        if (version != null) {
             if (dependencyXml.contains("<version>")) {
                 int from = dependencyXml.indexOf("<version>") + 9;
                 int to = dependencyXml.indexOf("</version>");
 
-                dependencyXml = dependencyXml.substring(0, from) + bomVersion + dependencyXml.substring(to);
+                dependencyXml = dependencyXml.substring(0, from) + version + dependencyXml.substring(to);
             } else {
                 String kw = "</artifactId>";
                 int pos = dependencyXml.indexOf(kw) + kw.length();
-                dependencyXml = dependencyXml.substring(0, pos) + "<version>" + bomVersion + "</version>" + dependencyXml.substring(pos);
+                dependencyXml = dependencyXml.substring(0, pos) + "<version>" + version + "</version>" + dependencyXml.substring(pos);
             }
+        } else if (stripVersion && dependencyXml.contains("<version>")) {
+            int from = dependencyXml.indexOf("<version>");
+            int to = dependencyXml.indexOf("</version>") + 10;
+            dependencyXml = dependencyXml.substring(0, from) + dependencyXml.substring(to);
         }
 
         return dependencyXml;

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/BOMResolver.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/BOMResolver.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/BOMResolver.java
index 8ffaea5..08794ec 100644
--- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/BOMResolver.java
+++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/BOMResolver.java
@@ -31,6 +31,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 
+import org.apache.camel.itest.springboot.ITestConfig;
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
 import org.eclipse.aether.DefaultRepositorySystemSession;
@@ -58,13 +59,16 @@ public final class BOMResolver {
 
     private static final File CACHE_FILE = LocationUtils.camelRoot("tests/camel-itest-spring-boot/target/bom-versions-cache");
 
-    private static final BOMResolver INSTANCE = new BOMResolver();
+    private static BOMResolver INSTANCE;
+
+    private ITestConfig config;
 
     private Map<String, String> versions;
 
     @SuppressWarnings("unchecked")
-    private BOMResolver() {
+    private BOMResolver(ITestConfig config) {
         try {
+            this.config = config;
             cleanupLocalRepo();
 
             if (canUseCache()) {
@@ -107,19 +111,21 @@ public final class BOMResolver {
         String camelVersion = DependencyResolver.resolveCamelParentProperty("${project.version}");
 
         List<Artifact> neededArtifacts = new LinkedList<>();
-        neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel:pom:"
-            + camelVersion).setFile(camelRoot("pom.xml")));
-        neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-parent:pom:"
-            + camelVersion).setFile(camelRoot("parent/pom.xml")));
+        Artifact camelRoot = new DefaultArtifact("org.apache.camel:camel:pom:"
+                + camelVersion).setFile(camelRoot("pom.xml"));
+        neededArtifacts.add(camelRoot);
+        Artifact camelParent = new DefaultArtifact("org.apache.camel:camel-parent:pom:"
+                + camelVersion).setFile(camelRoot("parent/pom.xml"));
+        neededArtifacts.add(camelParent);
         neededArtifacts.add(new DefaultArtifact("org.apache.camel:spring-boot:pom:"
             + camelVersion).setFile(camelRoot("platforms/spring-boot/pom.xml")));
         neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dm:pom:"
             + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/pom.xml")));
         neededArtifacts.add(new DefaultArtifact("org.apache.camel:camel-spring-boot-dependencies:pom:"
             + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-spring-boot-dependencies/pom.xml")));
-        Artifact camelSpringBootParent = new DefaultArtifact("org.apache.camel:camel-starter-parent:pom:"
+        Artifact camelStarterParent = new DefaultArtifact("org.apache.camel:camel-starter-parent:pom:"
             + camelVersion).setFile(camelRoot("platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml"));
-        neededArtifacts.add(camelSpringBootParent);
+        neededArtifacts.add(camelStarterParent);
 
         RemoteRepository localRepoDist = new RemoteRepository.Builder("org.apache.camel.itest.springboot", "default", new File(LOCAL_REPO).toURI().toString()).build();
 
@@ -131,22 +137,34 @@ public final class BOMResolver {
             system.deploy(session, deployRequest);
         }
 
-
         RemoteRepository mavenCentral = new RemoteRepository.Builder("central", "default", "http://repo1.maven.org/maven2/").build();
         RemoteRepository apacheSnapshots = new RemoteRepository.Builder("apache-snapshots", "default", "http://repository.apache.org/snapshots/").build();
-
-        ArtifactDescriptorRequest dReq = new ArtifactDescriptorRequest(camelSpringBootParent, Arrays.asList(localRepoDist, mavenCentral, apacheSnapshots), null);
-        ArtifactDescriptorResult dRes = system.readArtifactDescriptor(session, dReq);
+        RemoteRepository springMilestones = new RemoteRepository.Builder("spring-milestones", "default", "https://repo.spring.io/libs-milestone/").build();
 
         this.versions = new TreeMap<>();
-        for (Dependency dependency : dRes.getManagedDependencies()) {
+
+        ArtifactDescriptorRequest springBootParentReq = new ArtifactDescriptorRequest(camelStarterParent, Arrays.asList(localRepoDist, mavenCentral, apacheSnapshots, springMilestones), null);
+        ArtifactDescriptorResult springBootParentRes = system.readArtifactDescriptor(session, springBootParentReq);
+        for (Dependency dependency : springBootParentRes.getManagedDependencies()) {
+            Artifact a = dependency.getArtifact();
+            String key = a.getGroupId() + ":" + a.getArtifactId();
+            versions.put(key, dependency.getArtifact().getVersion());
+        }
+
+        Artifact springBootDependencies = new DefaultArtifact("org.springframework.boot:spring-boot-dependencies:pom:" + config.getSpringBootVersion());
+        ArtifactDescriptorRequest springBootDependenciesReq = new ArtifactDescriptorRequest(springBootDependencies, Arrays.asList(localRepoDist, mavenCentral, apacheSnapshots, springMilestones), null);
+        ArtifactDescriptorResult springBootDependenciesRes = system.readArtifactDescriptor(session, springBootDependenciesReq);
+        for (Dependency dependency : springBootDependenciesRes.getManagedDependencies()) {
             Artifact a = dependency.getArtifact();
             String key = a.getGroupId() + ":" + a.getArtifactId();
             versions.put(key, dependency.getArtifact().getVersion());
         }
     }
 
-    public static BOMResolver getInstance() {
+    public static BOMResolver getInstance(ITestConfig config) {
+        if (INSTANCE == null) {
+            INSTANCE = new BOMResolver(config);
+        }
         return INSTANCE;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/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 7b05ff0..5bd525e 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
@@ -85,6 +85,9 @@ public final class DependencyResolver {
         if (property != null && !isResolved(property)) {
             property = resolveCamelParentProperty(property);
         }
+        if (property != null && !isResolved(property)) {
+            property = resolveCamelProperty(property);
+        }
 
         return property;
     }
@@ -106,6 +109,10 @@ public final class DependencyResolver {
         return resolveProperty(camelRoot("parent/pom.xml"), property, 0);
     }
 
+    public static String resolveCamelProperty(String property) {
+        return resolveProperty(camelRoot("pom.xml"), property, 0);
+    }
+
 
     private static String resolveProperty(File pom, String property, int depth) {
         try {

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/JarExporter.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/JarExporter.java b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/JarExporter.java
index 84dde29..10c7aaf 100644
--- a/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/JarExporter.java
+++ b/tests/camel-itest-spring-boot/src/test/java/org/apache/camel/itest/springboot/util/JarExporter.java
@@ -24,7 +24,7 @@ import org.jboss.shrinkwrap.impl.base.exporter.zip.ZipExporterImpl;
 import org.junit.Test;
 
 /**
- * Utililty to export a spring-boot jar and check the content.
+ * Utility to export a spring-boot jar and check the content.
  */
 public class JarExporter {
 
@@ -32,7 +32,7 @@ public class JarExporter {
     public void exportJar() throws Exception {
 
         Archive<?> archive = ArquillianPackager.springBootPackage(new ITestConfigBuilder()
-                .module("camel-ahc")
+                .module("camel-websocket")
                 .build());
 
         new ZipExporterImpl(archive).exportTo(new File("target/export.zip"), true);

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/src/test/resources/application-pom-sb1.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/resources/application-pom-sb1.xml b/tests/camel-itest-spring-boot/src/test/resources/application-pom-sb1.xml
new file mode 100644
index 0000000..67eed1f
--- /dev/null
+++ b/tests/camel-itest-spring-boot/src/test/resources/application-pom-sb1.xml
@@ -0,0 +1,112 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>com.company</groupId>
+    <artifactId>spring-boot-application</artifactId>
+    <version>1.0</version>
+
+    <name>Spring-Boot Application</name>
+    <description>This a the base pom of spring-boot applications launched by the users</description>
+
+    <dependencyManagement>
+        <dependencies>
+
+            <!-- The two BOMs -->
+            <dependency>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-dependencies</artifactId>
+                <version>${spring-boot-version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.camel</groupId>
+                <artifactId>camel-spring-boot-dependencies</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>camel-spring-boot-starter</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.camel</groupId>
+            <artifactId>#{module}-starter</artifactId>
+        </dependency>
+
+        <!-- Required by the integration tests to run -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+        </dependency>
+
+        <!-- DEPENDENCIES -->
+
+    </dependencies>
+
+    <repositories>
+        <repository>
+            <id>central</id>
+            <name>Maven Central</name>
+            <url>http://repo1.maven.org/maven2/</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+        <repository>
+            <id>apache-snapshots</id>
+            <name>Apache Snapshots</name>
+            <url>http://repository.apache.org/snapshots/</url>
+            <releases>
+                <enabled>false</enabled>
+            </releases>
+            <snapshots>
+                <enabled>true</enabled>
+            </snapshots>
+        </repository>
+        <repository>
+            <id>atlassian-public</id>
+            <name>Atlassian Public</name>
+            <url>https://maven.atlassian.com/repository/public</url>
+            <releases>
+                <enabled>true</enabled>
+            </releases>
+            <snapshots>
+                <enabled>false</enabled>
+            </snapshots>
+        </repository>
+    </repositories>
+
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/f75d8056/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml b/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml
deleted file mode 100644
index a06bd78..0000000
--- a/tests/camel-itest-spring-boot/src/test/resources/application-pom.xml
+++ /dev/null
@@ -1,107 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    Licensed to the Apache Software Foundation (ASF) under one or more
-    contributor license agreements.  See the NOTICE file distributed with
-    this work for additional information regarding copyright ownership.
-    The ASF licenses this file to You under the Apache License, Version 2.0
-    (the "License"); you may not use this file except in compliance with
-    the License.  You may obtain a copy of the License at
-
-         http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing, software
-    distributed under the License is distributed on an "AS IS" BASIS,
-    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-    See the License for the specific language governing permissions and
-    limitations under the License.
-
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <groupId>com.company</groupId>
-    <artifactId>spring-boot-application</artifactId>
-    <version>1.0</version>
-
-    <name>Spring-Boot Application</name>
-    <description>This a the base pom of spring-boot applications launched by the users</description>
-
-    <dependencyManagement>
-        <dependencies>
-
-            <!-- The two BOMs -->
-            <dependency>
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-dependencies</artifactId>
-                <version>${spring-boot-version}</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.camel</groupId>
-                <artifactId>camel-spring-boot-dependencies</artifactId>
-                <version>${project.version}</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-
-        </dependencies>
-    </dependencyManagement>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.apache.camel</groupId>
-            <artifactId>#{module}-starter</artifactId>
-        </dependency>
-
-        <!-- Required by the integration tests to run -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-        </dependency>
-
-        <!-- DEPENDENCIES -->
-
-    </dependencies>
-
-    <repositories>
-        <repository>
-            <id>central</id>
-            <name>Maven Central</name>
-            <url>http://repo1.maven.org/maven2/</url>
-            <releases>
-                <enabled>true</enabled>
-            </releases>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-        </repository>
-        <repository>
-            <id>apache-snapshots</id>
-            <name>Apache Snapshots</name>
-            <url>http://repository.apache.org/snapshots/</url>
-            <releases>
-                <enabled>false</enabled>
-            </releases>
-            <snapshots>
-                <enabled>true</enabled>
-            </snapshots>
-        </repository>
-        <repository>
-            <id>atlassian-public</id>
-            <name>Atlassian Public</name>
-            <url>https://maven.atlassian.com/repository/public</url>
-            <releases>
-                <enabled>true</enabled>
-            </releases>
-            <snapshots>
-                <enabled>false</enabled>
-            </snapshots>
-        </repository>
-    </repositories>
-
-</project>

Reply | Threaded
Open this post in threaded view
|

[2/3] camel git commit: Using recursive BOM check from boot2 branch

nferraro
Using recursive BOM check from boot2 branch


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

Branch: refs/heads/master
Commit: ea6747b4e0a1423aa3d370f23dc37a4fdba3d639
Parents: f75d805
Author: Nicola Ferraro <[hidden email]>
Authored: Mon Sep 25 11:40:09 2017 +0200
Committer: Nicola Ferraro <[hidden email]>
Committed: Mon Sep 25 14:55:58 2017 +0200

----------------------------------------------------------------------
 .../maven/bom/generator/BomGeneratorMojo.java   | 33 ++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/ea6747b4/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java
----------------------------------------------------------------------
diff --git a/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java b/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java
index 9bfcb2a..3f47f15 100644
--- a/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java
+++ b/tooling/maven/bom-generator-maven-plugin/src/main/java/org/apache/camel/maven/bom/generator/BomGeneratorMojo.java
@@ -385,21 +385,50 @@ public class BomGeneratorMojo extends AbstractMojo {
     }
 
     private Set<String> getProvidedDependencyManagement(String groupId, String artifactId, String version) throws Exception {
+        return getProvidedDependencyManagement(groupId, artifactId, version, new TreeSet<>());
+    }
+
+    private Set<String> getProvidedDependencyManagement(String groupId, String artifactId, String version, Set<String> gaChecked) throws Exception {
+        String ga = groupId + ":" + artifactId;
+        gaChecked.add(ga);
         Artifact bom = resolveArtifact(groupId, artifactId, version, "pom");
         MavenProject bomProject = loadExternalProjectPom(bom.getFile());
 
         Set<String> provided = new HashSet<>();
         if (bomProject.getDependencyManagement() != null && bomProject.getDependencyManagement().getDependencies() != null) {
             for (Dependency dep : bomProject.getDependencyManagement().getDependencies()) {
-                provided.add(comparisonKey(dep));
+                if ("pom".equals(dep.getType()) && "import".equals(dep.getScope())) {
+                    String subGa = dep.getGroupId() + ":" + dep.getArtifactId();
+                    if (!gaChecked.contains(subGa)) {
+                        Set<String> sub = getProvidedDependencyManagement(dep.getGroupId(), dep.getArtifactId(), resolveVersion(bomProject, dep.getVersion()), gaChecked);
+                        provided.addAll(sub);
+                    }
+                } else {
+                    provided.add(comparisonKey(dep));
+                }
             }
         }
 
         return provided;
     }
 
+    private String resolveVersion(MavenProject project, String version) {
+        if (version.contains("${")) {
+            int start = version.indexOf("${");
+            int end = version.indexOf("}");
+            if (end > start) {
+                String prop = version.substring(start + 2, end);
+                String resolved = project.getProperties().getProperty(prop);
+                if (resolved != null) {
+                    version = version.substring(0, start) + resolved + version.substring(end + 1);
+                }
+            }
+        }
+        return version;
+    }
+
     private String comparisonKey(Dependency dependency) {
-        return dependency.getGroupId() + ":" + dependency.getArtifactId();
+        return dependency.getGroupId() + ":" + dependency.getArtifactId() + ":" + (dependency.getType() != null ? dependency.getType() : "jar");
     }
 
     private Artifact resolveArtifact(String groupId, String artifactId, String version, String type) throws Exception {

Reply | Threaded
Open this post in threaded view
|

[3/3] camel git commit: Fix spring-boot compatibility

nferraro
In reply to this post by nferraro
Fix spring-boot compatibility


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

Branch: refs/heads/master
Commit: 6556320fd2fcf6c1ae57def187c3952d5caf6316
Parents: ea6747b
Author: Nicola Ferraro <[hidden email]>
Authored: Mon Sep 25 13:14:20 2017 +0200
Committer: Nicola Ferraro <[hidden email]>
Committed: Mon Sep 25 14:55:58 2017 +0200

----------------------------------------------------------------------
 components/camel-servlet/pom.xml                             | 1 +
 .../components-starter/camel-salesforce-starter/pom.xml      | 4 ++++
 .../src/main/resources/META-INF/spring.factories             | 1 -
 .../spring-boot/spring-boot-dm/camel-starter-parent/pom.xml  | 8 --------
 platforms/spring-boot/spring-boot-dm/pom.xml                 | 1 -
 .../java/org/apache/camel/itest/springboot/ITestConfig.java  | 8 +++++++-
 .../apache/camel/itest/springboot/ITestConfigBuilder.java    | 4 ++--
 .../camel/itest/springboot/util/ArquillianPackager.java      | 4 ++++
 8 files changed, 18 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/components/camel-servlet/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-servlet/pom.xml b/components/camel-servlet/pom.xml
index a80f3c5..83cde13 100644
--- a/components/camel-servlet/pom.xml
+++ b/components/camel-servlet/pom.xml
@@ -148,6 +148,7 @@
     <dependency>
       <groupId>org.jboss.arquillian.junit</groupId>
       <artifactId>arquillian-junit-container</artifactId>
+      <version>${arquillian-version}</version>
       <scope>test</scope>
     </dependency>
     <!--jetty-->

http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/platforms/spring-boot/components-starter/camel-salesforce-starter/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-salesforce-starter/pom.xml b/platforms/spring-boot/components-starter/camel-salesforce-starter/pom.xml
index ce17340..a77e3eb 100644
--- a/platforms/spring-boot/components-starter/camel-salesforce-starter/pom.xml
+++ b/platforms/spring-boot/components-starter/camel-salesforce-starter/pom.xml
@@ -39,6 +39,10 @@
       <artifactId>camel-salesforce</artifactId>
       <version>${project.version}</version>
     </dependency>
+    <dependency>
+      <groupId>org.hibernate</groupId>
+      <artifactId>hibernate-validator</artifactId>
+    </dependency>
     <!--START OF GENERATED CODE-->
     <dependency>
       <groupId>org.apache.camel</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/resources/META-INF/spring.factories
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/resources/META-INF/spring.factories b/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/resources/META-INF/spring.factories
index f75f320..e1b6c66 100644
--- a/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/resources/META-INF/spring.factories
+++ b/platforms/spring-boot/components-starter/camel-servicenow-starter/src/main/resources/META-INF/spring.factories
@@ -15,5 +15,4 @@
 ## limitations under the License.
 ## ---------------------------------------------------------------------------
 org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
-org.apache.camel.component.servicenow.springboot.health.ServiceNowHealthAutoConfiguration,\
 org.apache.camel.component.servicenow.springboot.ServiceNowComponentAutoConfiguration

http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml b/platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml
index 1eaf84c..31231fa 100644
--- a/platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/camel-starter-parent/pom.xml
@@ -77,14 +77,6 @@
         <scope>import</scope>
       </dependency>
 
-      <!-- Testing -->
-      <dependency>
-        <groupId>org.jboss.arquillian.junit</groupId>
-        <artifactId>arquillian-junit-container</artifactId>
-        <version>${arquillian-version}</version>
-        <scope>test</scope>
-      </dependency>
-
       <!-- Forcing Hadoop in starters -->
       <dependency>
         <groupId>org.apache.hadoop</groupId>

http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/platforms/spring-boot/spring-boot-dm/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/spring-boot/spring-boot-dm/pom.xml b/platforms/spring-boot/spring-boot-dm/pom.xml
index 6b0dff6..a9fd4d3 100644
--- a/platforms/spring-boot/spring-boot-dm/pom.xml
+++ b/platforms/spring-boot/spring-boot-dm/pom.xml
@@ -59,7 +59,6 @@
     <maven-checkstyle-plugin-version>2.17</maven-checkstyle-plugin-version>
     <maven-checkstyle-version>7.6.1</maven-checkstyle-version>
 
-    <arquillian-version>1.1.13.Final</arquillian-version>
     <hadoop2-version>2.7.2</hadoop2-version>
 
     <!-- Custom dependency required by some modules -->

http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
index 611c9a0..c1d9ea8 100644
--- a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
+++ b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfig.java
@@ -25,6 +25,8 @@ import java.util.Set;
  */
 public class ITestConfig implements Serializable {
 
+    private static final int DEFAULT_SPRING_BOOT_MAJOR_VERSION = 1;
+
     private static final long serialVersionUID = -3641997669166217595L;
 
     private String moduleName;
@@ -257,7 +259,11 @@ public class ITestConfig implements Serializable {
     }
 
     public Integer getSpringBootMajorVersion() {
-        return Integer.parseInt(springBootVersion.substring(0, 1));
+        if (springBootVersion != null) {
+            return Integer.parseInt(springBootVersion.substring(0, 1));
+        } else {
+            return DEFAULT_SPRING_BOOT_MAJOR_VERSION;
+        }
     }
 
     public void setSpringBootVersion(String springBootVersion) {

http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
----------------------------------------------------------------------
diff --git a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
index 1b529d8..ce309ef 100644
--- a/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
+++ b/tests/camel-itest-spring-boot/src/main/java/org/apache/camel/itest/springboot/ITestConfigBuilder.java
@@ -89,7 +89,7 @@ public class ITestConfigBuilder {
 
     public ITestConfigBuilder resource(String file, String dest) {
         if (config.getResources() == null) {
-            config.setResources(new HashMap<String, String>());
+            config.setResources(new HashMap<>());
         }
         config.getResources().put(file, dest);
         return this;
@@ -97,7 +97,7 @@ public class ITestConfigBuilder {
 
     public ITestConfigBuilder dependency(String dependencyCanonicalForm) {
         if (config.getAdditionalDependencies() == null) {
-            config.setAdditionalDependencies(new HashSet<String>());
+            config.setAdditionalDependencies(new HashSet<>());
         }
         config.getAdditionalDependencies().add(dependencyCanonicalForm);
         return this;

http://git-wip-us.apache.org/repos/asf/camel/blob/6556320f/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 a71f9d6..8a65c78 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
@@ -543,6 +543,10 @@ public final class ArquillianPackager {
 
     private static String enforceExclusions(ITestConfig config, String dependencyXml, List<MavenDependencyExclusion> exclusions) {
 
+        if (dependencyXml.contains("<groupId>org.springframework.boot</groupId>") && dependencyXml.contains("<artifactId>spring-boot-starter")) {
+            return dependencyXml;
+        }
+
         if (!dependencyXml.contains("<exclusions>")) {
             dependencyXml = dependencyXml.replace("</dependency>", "<exclusions></exclusions></dependency>");
         }