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 2017/02/14 19:12:14 UTC
[3/3] camel git commit: CAMEL-10828: camel-catalog-nexus - Initial
work
CAMEL-10828: camel-catalog-nexus - Initial work
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a118fa9a
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a118fa9a
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a118fa9a
Branch: refs/heads/master
Commit: a118fa9ab2a87dbb088e222c8e3810d89e32b0e7
Parents: 8dfed85
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Feb 14 20:12:01 2017 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Feb 14 20:12:07 2017 +0100
----------------------------------------------------------------------
platforms/catalog-nexus/pom.xml | 14 ++++++++++-
.../catalog/nexus/ComponentNexusRepository.java | 3 ++-
.../catalog/nexus/LocalFileNexusRepository.java | 23 +++++++++++++++++-
.../catalog/nexus/LocalNexusRepositoryTest.java | 25 ++++++++++----------
.../src/test/resources/nexus-sample-result.xml | 8 +++----
5 files changed, 54 insertions(+), 19 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/a118fa9a/platforms/catalog-nexus/pom.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/pom.xml b/platforms/catalog-nexus/pom.xml
index e0fbc32..a3653bf 100644
--- a/platforms/catalog-nexus/pom.xml
+++ b/platforms/catalog-nexus/pom.xml
@@ -77,8 +77,20 @@
</dependencies>
<build>
- <plugins>
+ <defaultGoal>install</defaultGoal>
+
+ <resources>
+ <resource>
+ <targetPath>${project.build.directory}/test-classes</targetPath>
+ <directory>src/test/resources</directory>
+ <includes>
+ <include>*.xml</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
http://git-wip-us.apache.org/repos/asf/camel/blob/a118fa9a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
index d1663ca..2fb15c3 100644
--- a/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
+++ b/platforms/catalog-nexus/src/main/java/org/apache/camel/catalog/nexus/ComponentNexusRepository.java
@@ -41,10 +41,11 @@ public class ComponentNexusRepository extends BaseNexusRepository {
// now download the new artifact JARs and look inside to find more details
for (NexusArtifactDto dto : newArtifacts) {
try {
+ log.debug("Processing new artifact: {}:{}:{}", dto.getGroupId(), dto.getArtifactId(), dto.getVersion());
String url = createArtifactURL(dto);
URL jarUrl = new URL(url);
addCustomCamelComponentsFromArtifact(dto, jarUrl);
- } catch (Exception e) {
+ } catch (Throwable e) {
log.warn("Error downloading component JAR " + dto.getArtifactLink() + ". This exception is ignored. " + e.getMessage());
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/a118fa9a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
index f3c3327..3a05b5f 100644
--- a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
+++ b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalFileNexusRepository.java
@@ -20,11 +20,23 @@ import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
+import org.apache.camel.catalog.CamelCatalog;
+
public class LocalFileNexusRepository extends ComponentNexusRepository {
+ private Runnable onAddComponent;
+
+ public Runnable getOnAddComponent() {
+ return onAddComponent;
+ }
+
+ public void setOnAddComponent(Runnable onAddComponent) {
+ this.onAddComponent = onAddComponent;
+ }
+
@Override
protected URL createNexusUrl() throws MalformedURLException {
- File file = new File("src/test/resources/nexus-sample-result.xml");
+ File file = new File("target/test-classes/nexus-sample-result.xml");
return new URL("file:" + file.getAbsolutePath());
}
@@ -33,4 +45,13 @@ public class LocalFileNexusRepository extends ComponentNexusRepository {
// load from local file instead
return "file:target/localrepo/" + dto.getArtifactId() + "-" + dto.getVersion() + ".jar";
}
+
+ @Override
+ protected void addComponent(NexusArtifactDto dto, CamelCatalog camelCatalog, String scheme, String javaType, String json) {
+ super.addComponent(dto, camelCatalog, scheme, javaType, json);
+
+ if (onAddComponent != null) {
+ onAddComponent.run();
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/a118fa9a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
index 5382b41..4c8a8c0 100644
--- a/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
+++ b/platforms/catalog-nexus/src/test/java/org/apache/camel/catalog/nexus/LocalNexusRepositoryTest.java
@@ -16,6 +16,9 @@
*/
package org.apache.camel.catalog.nexus;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
import junit.framework.TestCase;
import org.apache.camel.catalog.CamelCatalog;
import org.apache.camel.catalog.DefaultCamelCatalog;
@@ -23,26 +26,24 @@ import org.junit.Test;
public class LocalNexusRepositoryTest extends TestCase {
- private LocalFileNexusRepository repo = new LocalFileNexusRepository();
- private CamelCatalog catalog = new DefaultCamelCatalog();
+ private final CamelCatalog catalog = new DefaultCamelCatalog();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Test
+ public void testLocalNexus() throws Exception {
+ int before = catalog.findComponentNames().size();
+ LocalFileNexusRepository repo = new LocalFileNexusRepository();
repo.setCamelCatalog(catalog);
- repo.setInitialDelay(1);
+ repo.setInitialDelay(2);
+ repo.setDelay(3);
repo.setNexusUrl("dummy");
- }
- @Test
- public void testLocalNexus() throws Exception {
- int before = catalog.findComponentNames().size();
+ final CountDownLatch latch = new CountDownLatch(1);
+ repo.setOnAddComponent(latch::countDown);
repo.start();
- // TODO only wait as long until a new component is added
- Thread.sleep(5000);
+ assertTrue("Should have found component", latch.await(10, TimeUnit.SECONDS));
repo.stop();
http://git-wip-us.apache.org/repos/asf/camel/blob/a118fa9a/platforms/catalog-nexus/src/test/resources/nexus-sample-result.xml
----------------------------------------------------------------------
diff --git a/platforms/catalog-nexus/src/test/resources/nexus-sample-result.xml b/platforms/catalog-nexus/src/test/resources/nexus-sample-result.xml
index 8357e21..aae70b6 100644
--- a/platforms/catalog-nexus/src/test/resources/nexus-sample-result.xml
+++ b/platforms/catalog-nexus/src/test/resources/nexus-sample-result.xml
@@ -21,16 +21,16 @@
<tooManyResults>false</tooManyResults>
<data>
<artifact>
- <resourceURI>http://nexus.dummy/service/local/repositories/staging/content/org/apache/camel/dummy-component/2.19.0/dummy-component-2.19.0.jar</resourceURI>
+ <resourceURI>http://nexus.dummy/service/local/repositories/staging/content/org/apache/camel/dummy-component/${project.version}/dummy-component-${project.version}.jar</resourceURI>
<groupId>org.apache.camel</groupId>
<artifactId>dummy-component</artifactId>
- <version>2.19.0</version>
+ <version>${project.version}</version>
<packaging>jar</packaging>
<extension>jar</extension>
<repoId>staging</repoId>
<contextId>Staging</contextId>
- <pomLink>http://nexus.dummy/service/local/artifact/maven/redirect?r=staging&g=org.apache.camel&a=dummy-component&v=2.19.0&e=pom</pomLink>
- <artifactLink>http://nexus.dummy/service/local/artifact/maven/redirect?r=staging&g=org.apache.camel&a=dummy-component&v=2.19.0&e=jar</artifactLink>
+ <pomLink>http://nexus.dummy/service/local/artifact/maven/redirect?r=staging&g=org.apache.camel&a=dummy-component&v=${project.version}&e=pom</pomLink>
+ <artifactLink>http://nexus.dummy/service/local/artifact/maven/redirect?r=staging&g=org.apache.camel&a=dummy-component&v=${project.version}&e=jar</artifactLink>
<highlightedFragment><blockquote>Artifact ID<UL><LI>dummy-<B>component</B></LI></UL></blockquote></highlightedFragment>
</artifact>
</data>