You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/10/10 17:10:00 UTC
[1/6] git commit: CAMEL-7900 Honored chunksize in camel-hdfs
Repository: camel
Updated Branches:
refs/heads/master 2275e28fb -> 627ffe78b
CAMEL-7900 Honored chunksize in camel-hdfs
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/2577217d
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/2577217d
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/2577217d
Branch: refs/heads/master
Commit: 2577217d4cd4078c9a7bd527ed6b5104a8fcb8d9
Parents: b32f5a3
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Oct 10 21:58:47 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Oct 10 23:02:24 2014 +0800
----------------------------------------------------------------------
.../main/java/org/apache/camel/component/hdfs/HdfsFileType.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/2577217d/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsFileType.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsFileType.java b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsFileType.java
index a3b2112..97c174f 100644
--- a/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsFileType.java
+++ b/components/camel-hdfs/src/main/java/org/apache/camel/component/hdfs/HdfsFileType.java
@@ -75,7 +75,7 @@ public enum HdfsFileType {
public long next(HdfsInputStream hdfsistr, Holder<Object> key, Holder<Object> value) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(hdfsistr.getChunkSize());
- byte buf[] = new byte[HdfsConstants.DEFAULT_BUFFERSIZE];
+ byte buf[] = new byte[hdfsistr.getChunkSize()];
int bytesRead = ((InputStream) hdfsistr.getIn()).read(buf);
if (bytesRead >= 0) {
bos.write(buf, 0, bytesRead);
[4/6] git commit: CAMEL-7902 restored initService() call for
repositoryService
Posted by ni...@apache.org.
CAMEL-7902 restored initService() call for repositoryService
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0ddef8a1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0ddef8a1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0ddef8a1
Branch: refs/heads/master
Commit: 0ddef8a13ccc824957be8138deea4295b28d938a
Parents: f1d4afe
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Fri Oct 10 14:53:32 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Oct 10 23:02:24 2014 +0800
----------------------------------------------------------------------
.../camel/component/github/producer/AbstractGitHubProducer.java | 1 +
1 file changed, 1 insertion(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0ddef8a1/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
index ce6fa86..fbcdde2 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
@@ -43,6 +43,7 @@ public abstract class AbstractGitHubProducer extends DefaultProducer {
} else {
repositoryService = new RepositoryService();
}
+ initService(repositoryService);
repository = repositoryService.getRepository(endpoint.getRepoOwner(), endpoint.getRepoName());
}
[2/6] git commit: CAMEL-7900 Honored chunksize in camel-hdfs2
Posted by ni...@apache.org.
CAMEL-7900 Honored chunksize in camel-hdfs2
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b32f5a32
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b32f5a32
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b32f5a32
Branch: refs/heads/master
Commit: b32f5a324afe13e311a8b284eb0e124405ab16b0
Parents: b867990
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Oct 10 21:58:11 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Oct 10 23:02:24 2014 +0800
----------------------------------------------------------------------
.../main/java/org/apache/camel/component/hdfs2/HdfsFileType.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b32f5a32/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
----------------------------------------------------------------------
diff --git a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
index 2df0bba..bbe0172 100644
--- a/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
+++ b/components/camel-hdfs2/src/main/java/org/apache/camel/component/hdfs2/HdfsFileType.java
@@ -76,7 +76,7 @@ public enum HdfsFileType {
public long next(HdfsInputStream hdfsistr, Holder<Object> key, Holder<Object> value) {
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream(hdfsistr.getChunkSize());
- byte buf[] = new byte[HdfsConstants.DEFAULT_BUFFERSIZE];
+ byte buf[] = new byte[hdfsistr.getChunkSize()];
int bytesRead = ((InputStream) hdfsistr.getIn()).read(buf);
if (bytesRead >= 0) {
bos.write(buf, 0, bytesRead);
[6/6] git commit: CAMEL-7902 Fixed the CS errors
Posted by ni...@apache.org.
CAMEL-7902 Fixed the CS errors
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/627ffe78
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/627ffe78
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/627ffe78
Branch: refs/heads/master
Commit: 627ffe78ba2b2896ddfdd218010d6c7f4d09b5a8
Parents: 2577217
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Oct 10 23:09:28 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Oct 10 23:09:28 2014 +0800
----------------------------------------------------------------------
.../github/consumer/AbstractGitHubConsumer.java | 2 +-
.../camel/component/github/consumer/CommitConsumer.java | 2 +-
.../github/consumer/PullRequestCommentConsumer.java | 2 +-
.../component/github/consumer/PullRequestConsumer.java | 2 +-
.../github/producer/AbstractGitHubProducer.java | 2 +-
.../github/producer/PullRequestCommentProducer.java | 3 +--
.../camel/component/github/GitHubComponentTestBase.java | 10 +++++-----
.../github/PullRequestCommentProducerTest.java | 10 +++++-----
.../component/github/consumer/MockCommitService.java | 10 +++++-----
.../component/github/consumer/MockIssueService.java | 8 ++++----
.../github/consumer/MockPullRequestService.java | 12 ++++++------
.../github/consumer/MockRepositoryService.java | 8 ++++----
12 files changed, 35 insertions(+), 36 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
index 89b306d..ba0d96c 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
@@ -41,7 +41,7 @@ public abstract class AbstractGitHubConsumer extends ScheduledPollConsumer {
Registry registry = endpoint.getCamelContext().getRegistry();
Object service = registry.lookupByName("githubRepositoryService");
- if (service !=null) {
+ if (service != null) {
LOG.debug("Using RepositoryService found in registry " + service.getClass().getCanonicalName());
repositoryService = (RepositoryService) service;
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
index d1001cf..3cee731 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
@@ -41,7 +41,7 @@ public class CommitConsumer extends AbstractGitHubConsumer {
Registry registry = endpoint.getCamelContext().getRegistry();
Object service = registry.lookupByName("githubCommitService");
- if (service !=null) {
+ if (service != null) {
LOG.debug("Using CommitService found in registry " + service.getClass().getCanonicalName());
commitService = (CommitService) service;
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
index 2d20c3f..0c76463 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
@@ -46,7 +46,7 @@ public class PullRequestCommentConsumer extends AbstractGitHubConsumer {
Registry registry = endpoint.getCamelContext().getRegistry();
Object service = registry.lookupByName("githubPullRequestService");
- if (service !=null) {
+ if (service != null) {
LOG.debug("Using PullRequestService found in registry " + service.getClass().getCanonicalName());
pullRequestService = (PullRequestService) service;
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
index 3d85d3a..53773c3 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
@@ -40,7 +40,7 @@ public class PullRequestConsumer extends AbstractGitHubConsumer {
Registry registry = endpoint.getCamelContext().getRegistry();
Object service = registry.lookupByName("githubPullRequestService");
- if (service !=null) {
+ if (service != null) {
LOG.debug("Using PullRequestService found in registry " + service.getClass().getCanonicalName());
pullRequestService = (PullRequestService) service;
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
index fbcdde2..36894c3 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
@@ -38,7 +38,7 @@ public abstract class AbstractGitHubProducer extends DefaultProducer {
Registry registry = endpoint.getCamelContext().getRegistry();
Object service = registry.lookupByName("githubRepositoryService");
- if (service !=null) {
+ if (service != null) {
repositoryService = (RepositoryService) service;
} else {
repositoryService = new RepositoryService();
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
index 2a3840c..03bd542 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
@@ -18,7 +18,6 @@ package org.apache.camel.component.github.producer;
import org.apache.camel.Exchange;
import org.apache.camel.component.github.GitHubEndpoint;
-import org.apache.camel.component.github.consumer.PullRequestCommentConsumer;
import org.apache.camel.spi.Registry;
import org.eclipse.egit.github.core.Comment;
import org.eclipse.egit.github.core.service.IssueService;
@@ -46,7 +45,7 @@ public class PullRequestCommentProducer extends AbstractGitHubProducer {
Registry registry = endpoint.getCamelContext().getRegistry();
Object service = registry.lookupByName("githubPullRequestService");
- if (service !=null) {
+ if (service != null) {
LOG.debug("Using PullRequestService found in registry " + service.getClass().getCanonicalName());
pullRequestService = (PullRequestService) service;
} else {
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java b/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java
index bd53fbc..ac93fb5 100644
--- a/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java
@@ -30,11 +30,11 @@ import org.junit.Test;
import org.junit.rules.TestName;
public abstract class GitHubComponentTestBase extends CamelTestSupport {
- public String USERNAME = "someguy";
- public String PASSWORD = "apassword";
- public String REPO_OWNER = "anotherguy";
- public String REPO_NAME = "somerepo";
- public String GITHUB_CREDENTIALS_STRING = "username=" + USERNAME + "&password=" + PASSWORD + "&repoOwner=" + REPO_OWNER + "&repoName=" + REPO_NAME;
+ public static final String USERNAME = "someguy";
+ public static final String PASSWORD = "apassword";
+ public static final String REPO_OWNER = "anotherguy";
+ public static final String REPO_NAME = "somerepo";
+ public static final String GITHUB_CREDENTIALS_STRING = "username=" + USERNAME + "&password=" + PASSWORD + "&repoOwner=" + REPO_OWNER + "&repoName=" + REPO_NAME;
@Rule
public TestName testName = new TestName();
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java
index d0b7d40..ef70c5e 100644
--- a/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java
@@ -16,6 +16,10 @@
*/
package org.apache.camel.component.github;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
import org.apache.camel.Endpoint;
import org.apache.camel.Exchange;
import org.apache.camel.Message;
@@ -27,13 +31,9 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-
public class PullRequestCommentProducerTest extends GitHubComponentTestBase {
protected static final Logger LOG = LoggerFactory.getLogger(PullRequestCommentProducerTest.class);
- private long latestPullRequestId = 0;
+ private long latestPullRequestId;
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java
index a37f403..8db3d58 100644
--- a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java
@@ -16,6 +16,11 @@
*/
package org.apache.camel.component.github.consumer;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
import org.eclipse.egit.github.core.IRepositoryIdProvider;
import org.eclipse.egit.github.core.RepositoryCommit;
import org.eclipse.egit.github.core.User;
@@ -23,11 +28,6 @@ import org.eclipse.egit.github.core.service.CommitService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
public class MockCommitService extends CommitService {
protected static final Logger LOG = LoggerFactory.getLogger(MockCommitService.class);
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java
index 52c2ab1..e7f662d 100644
--- a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java
@@ -16,14 +16,14 @@
*/
package org.apache.camel.component.github.consumer;
-import org.eclipse.egit.github.core.Comment;
-import org.eclipse.egit.github.core.IRepositoryIdProvider;
-import org.eclipse.egit.github.core.service.IssueService;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.egit.github.core.Comment;
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
+import org.eclipse.egit.github.core.service.IssueService;
+
public class MockIssueService extends IssueService {
private List<Comment> comments = new ArrayList<>();
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java
index 97e9838..db9427e 100644
--- a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java
@@ -16,6 +16,12 @@
*/
package org.apache.camel.component.github.consumer;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
import org.eclipse.egit.github.core.CommitComment;
import org.eclipse.egit.github.core.IRepositoryIdProvider;
import org.eclipse.egit.github.core.PullRequest;
@@ -24,12 +30,6 @@ import org.eclipse.egit.github.core.service.PullRequestService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicInteger;
-
public class MockPullRequestService extends PullRequestService {
protected static final Logger LOG = LoggerFactory.getLogger(MockPullRequestService.class);
http://git-wip-us.apache.org/repos/asf/camel/blob/627ffe78/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java
index 4b504d7..93ef397 100644
--- a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java
@@ -16,6 +16,10 @@
*/
package org.apache.camel.component.github.consumer;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.egit.github.core.IRepositoryIdProvider;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.RepositoryTag;
@@ -23,10 +27,6 @@ import org.eclipse.egit.github.core.service.RepositoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
public class MockRepositoryService extends RepositoryService {
protected static final Logger LOG = LoggerFactory.getLogger(MockRepositoryService.class);
[5/6] git commit: Upgarded the common-exec to 1.2
Posted by ni...@apache.org.
Upgarded the common-exec to 1.2
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/b8679903
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/b8679903
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/b8679903
Branch: refs/heads/master
Commit: b86799037f432b7aa2db8c8abbdca235588dbcfd
Parents: 0ddef8a
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Oct 10 21:56:31 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Oct 10 23:02:24 2014 +0800
----------------------------------------------------------------------
parent/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/b8679903/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index bf730bc..94a2c26 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -99,7 +99,7 @@
<commons-dbcp-version>1.4</commons-dbcp-version>
<commons-digester-1x-version>1.8.1</commons-digester-1x-version>
<commons-digester-version>2.1</commons-digester-version>
- <commons-exec-version>1.1</commons-exec-version>
+ <commons-exec-version>1.2</commons-exec-version>
<commons-httpclient-bundle-version>3.1_7</commons-httpclient-bundle-version>
<commons-io-version>1.4</commons-io-version>
<commons-jexl2-version>2.1.1</commons-jexl2-version>
[3/6] git commit: CAMEL-7902 New test for camel-github
Posted by ni...@apache.org.
CAMEL-7902 New test for camel-github
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/f1d4afe1
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/f1d4afe1
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/f1d4afe1
Branch: refs/heads/master
Commit: f1d4afe12b05f6021ab4dd9080254fe8762b2966
Parents: 2275e28
Author: Kevin Earls <ke...@kevinearls.com>
Authored: Fri Oct 10 14:39:47 2014 +0200
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Oct 10 23:02:24 2014 +0800
----------------------------------------------------------------------
.../github/consumer/AbstractGitHubConsumer.java | 18 +++-
.../github/consumer/CommitConsumer.java | 12 ++-
.../consumer/PullRequestCommentConsumer.java | 20 +++-
.../github/consumer/PullRequestConsumer.java | 13 ++-
.../github/producer/AbstractGitHubProducer.java | 12 ++-
.../producer/PullRequestCommentProducer.java | 22 +++-
.../component/github/CommitConsumerTest.java | 64 +++++++++++
.../github/GitHubComponentTestBase.java | 80 ++++++++++++++
.../github/PullRequestCommentConsumerTest.java | 69 ++++++++++++
.../github/PullRequestCommentProducerTest.java | 87 +++++++++++++++
.../github/PullRequestConsumerTest.java | 72 +++++++++++++
.../camel/component/github/TagConsumerTest.java | 62 +++++++++++
.../github/consumer/MockCommitService.java | 57 ++++++++++
.../github/consumer/MockIssueService.java | 47 ++++++++
.../github/consumer/MockPullRequestService.java | 106 +++++++++++++++++++
.../github/consumer/MockRepositoryService.java | 55 ++++++++++
16 files changed, 781 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
index 299f89d..89b306d 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/AbstractGitHubConsumer.java
@@ -19,12 +19,16 @@ package org.apache.camel.component.github.consumer;
import org.apache.camel.Processor;
import org.apache.camel.component.github.GitHubEndpoint;
import org.apache.camel.impl.ScheduledPollConsumer;
+import org.apache.camel.spi.Registry;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.service.GitHubService;
import org.eclipse.egit.github.core.service.RepositoryService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class AbstractGitHubConsumer extends ScheduledPollConsumer {
-
+ private static final transient Logger LOG = LoggerFactory.getLogger(AbstractGitHubConsumer.class);
+
private final GitHubEndpoint endpoint;
private RepositoryService repositoryService;
@@ -34,8 +38,16 @@ public abstract class AbstractGitHubConsumer extends ScheduledPollConsumer {
public AbstractGitHubConsumer(GitHubEndpoint endpoint, Processor processor) throws Exception {
super(endpoint, processor);
this.endpoint = endpoint;
-
- repositoryService = new RepositoryService();
+
+ Registry registry = endpoint.getCamelContext().getRegistry();
+ Object service = registry.lookupByName("githubRepositoryService");
+ if (service !=null) {
+ LOG.debug("Using RepositoryService found in registry " + service.getClass().getCanonicalName());
+ repositoryService = (RepositoryService) service;
+ } else {
+ repositoryService = new RepositoryService();
+ }
+
initService(repositoryService);
repository = repositoryService.getRepository(endpoint.getRepoOwner(), endpoint.getRepoName());
}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
index 65366a9..d1001cf 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/CommitConsumer.java
@@ -23,6 +23,7 @@ import java.util.Stack;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.github.GitHubEndpoint;
+import org.apache.camel.spi.Registry;
import org.eclipse.egit.github.core.RepositoryCommit;
import org.eclipse.egit.github.core.service.CommitService;
import org.slf4j.Logger;
@@ -37,8 +38,15 @@ public class CommitConsumer extends AbstractGitHubConsumer {
public CommitConsumer(String branchName, GitHubEndpoint endpoint, Processor processor) throws Exception {
super(endpoint, processor);
-
- commitService = new CommitService();
+
+ Registry registry = endpoint.getCamelContext().getRegistry();
+ Object service = registry.lookupByName("githubCommitService");
+ if (service !=null) {
+ LOG.debug("Using CommitService found in registry " + service.getClass().getCanonicalName());
+ commitService = (CommitService) service;
+ } else {
+ commitService = new CommitService();
+ }
initService(commitService);
LOG.info("GitHub CommitConsumer: Indexing current commits...");
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
index 8f297de..2d20c3f 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestCommentConsumer.java
@@ -23,6 +23,7 @@ import java.util.Stack;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.github.GitHubEndpoint;
+import org.apache.camel.spi.Registry;
import org.eclipse.egit.github.core.Comment;
import org.eclipse.egit.github.core.CommitComment;
import org.eclipse.egit.github.core.PullRequest;
@@ -42,10 +43,23 @@ public class PullRequestCommentConsumer extends AbstractGitHubConsumer {
public PullRequestCommentConsumer(GitHubEndpoint endpoint, Processor processor) throws Exception {
super(endpoint, processor);
-
- pullRequestService = new PullRequestService();
+
+ Registry registry = endpoint.getCamelContext().getRegistry();
+ Object service = registry.lookupByName("githubPullRequestService");
+ if (service !=null) {
+ LOG.debug("Using PullRequestService found in registry " + service.getClass().getCanonicalName());
+ pullRequestService = (PullRequestService) service;
+ } else {
+ pullRequestService = new PullRequestService();
+ }
initService(pullRequestService);
- issueService = new IssueService();
+
+ service = registry.lookupByName("githbIssueService");
+ if (service != null) {
+ issueService = (IssueService) service;
+ } else {
+ issueService = new IssueService();
+ }
initService(issueService);
LOG.info("GitHub PullRequestCommentConsumer: Indexing current pull request comments...");
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
index 5b2d6ad..3d85d3a 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/consumer/PullRequestConsumer.java
@@ -22,6 +22,7 @@ import java.util.Stack;
import org.apache.camel.Exchange;
import org.apache.camel.Processor;
import org.apache.camel.component.github.GitHubEndpoint;
+import org.apache.camel.spi.Registry;
import org.eclipse.egit.github.core.PullRequest;
import org.eclipse.egit.github.core.service.PullRequestService;
import org.slf4j.Logger;
@@ -36,8 +37,16 @@ public class PullRequestConsumer extends AbstractGitHubConsumer {
public PullRequestConsumer(GitHubEndpoint endpoint, Processor processor) throws Exception {
super(endpoint, processor);
-
- pullRequestService = new PullRequestService();
+
+ Registry registry = endpoint.getCamelContext().getRegistry();
+ Object service = registry.lookupByName("githubPullRequestService");
+ if (service !=null) {
+ LOG.debug("Using PullRequestService found in registry " + service.getClass().getCanonicalName());
+ pullRequestService = (PullRequestService) service;
+ } else {
+ pullRequestService = new PullRequestService();
+ }
+
initService(pullRequestService);
LOG.info("GitHub PullRequestConsumer: Indexing current pull requests...");
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
index 31d29b3..ce6fa86 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/AbstractGitHubProducer.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.github.producer;
import org.apache.camel.Exchange;
import org.apache.camel.component.github.GitHubEndpoint;
import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.spi.Registry;
import org.eclipse.egit.github.core.Repository;
import org.eclipse.egit.github.core.service.GitHubService;
import org.eclipse.egit.github.core.service.RepositoryService;
@@ -34,9 +35,14 @@ public abstract class AbstractGitHubProducer extends DefaultProducer {
public AbstractGitHubProducer(GitHubEndpoint endpoint) throws Exception {
super(endpoint);
this.endpoint = endpoint;
-
- repositoryService = new RepositoryService();
- initService(repositoryService);
+
+ Registry registry = endpoint.getCamelContext().getRegistry();
+ Object service = registry.lookupByName("githubRepositoryService");
+ if (service !=null) {
+ repositoryService = (RepositoryService) service;
+ } else {
+ repositoryService = new RepositoryService();
+ }
repository = repositoryService.getRepository(endpoint.getRepoOwner(), endpoint.getRepoName());
}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
index 87aec0f..2a3840c 100644
--- a/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
+++ b/components/camel-github/src/main/java/org/apache/camel/component/github/producer/PullRequestCommentProducer.java
@@ -18,9 +18,13 @@ package org.apache.camel.component.github.producer;
import org.apache.camel.Exchange;
import org.apache.camel.component.github.GitHubEndpoint;
+import org.apache.camel.component.github.consumer.PullRequestCommentConsumer;
+import org.apache.camel.spi.Registry;
import org.eclipse.egit.github.core.Comment;
import org.eclipse.egit.github.core.service.IssueService;
import org.eclipse.egit.github.core.service.PullRequestService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Producer endpoint that adds one of two types of comments on a GitHub pull request:
@@ -32,6 +36,7 @@ import org.eclipse.egit.github.core.service.PullRequestService;
* Both endpoints require the "GitHubPullRequest" header, identifying the pull request number (integer).
*/
public class PullRequestCommentProducer extends AbstractGitHubProducer {
+ private static final transient Logger LOG = LoggerFactory.getLogger(PullRequestCommentProducer.class);
private PullRequestService pullRequestService;
private IssueService issueService;
@@ -39,9 +44,22 @@ public class PullRequestCommentProducer extends AbstractGitHubProducer {
public PullRequestCommentProducer(GitHubEndpoint endpoint) throws Exception {
super(endpoint);
- pullRequestService = new PullRequestService();
+ Registry registry = endpoint.getCamelContext().getRegistry();
+ Object service = registry.lookupByName("githubPullRequestService");
+ if (service !=null) {
+ LOG.debug("Using PullRequestService found in registry " + service.getClass().getCanonicalName());
+ pullRequestService = (PullRequestService) service;
+ } else {
+ pullRequestService = new PullRequestService();
+ }
initService(pullRequestService);
- issueService = new IssueService();
+
+ service = registry.lookupByName("githbIssueService");
+ if (service != null) {
+ issueService = (IssueService) service;
+ } else {
+ issueService = new IssueService();
+ }
initService(issueService);
}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/CommitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/CommitConsumerTest.java b/components/camel-github/src/test/java/org/apache/camel/component/github/CommitConsumerTest.java
new file mode 100644
index 0000000..c9bd8b5
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/CommitConsumerTest.java
@@ -0,0 +1,64 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.egit.github.core.RepositoryCommit;
+import org.eclipse.egit.github.core.User;
+import org.junit.Test;
+
+public class CommitConsumerTest extends GitHubComponentTestBase {
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ context.addComponent("github", new GitHubComponent());
+ from("github://commit/master?" + GITHUB_CREDENTIALS_STRING).
+ process(new GitHubCommitProcessor())
+ .to(mockResultEndpoint);
+ }
+ };
+ }
+
+
+ @Test
+ public void commitConsumerTest() throws Exception {
+ mockResultEndpoint.expectedMessageCount(2);
+ RepositoryCommit commit1 = commitService.addRepositoryCommit();
+ RepositoryCommit commit2 = commitService.addRepositoryCommit();
+ mockResultEndpoint.expectedBodiesReceivedInAnyOrder(commit1, commit2);
+
+ Thread.sleep(1 * 1000);
+
+ mockResultEndpoint.assertIsSatisfied();
+ }
+
+ public class GitHubCommitProcessor implements Processor {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ RepositoryCommit commit = (RepositoryCommit) in.getBody();
+ User author = commit.getAuthor();
+ log.debug("Got commit with author: " + author.getLogin() + ": " + author.getHtmlUrl() + " SHA " + commit.getSha());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java b/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java
new file mode 100644
index 0000000..bd53fbc
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/GitHubComponentTestBase.java
@@ -0,0 +1,80 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.github.consumer.MockCommitService;
+import org.apache.camel.component.github.consumer.MockIssueService;
+import org.apache.camel.component.github.consumer.MockPullRequestService;
+import org.apache.camel.component.github.consumer.MockRepositoryService;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestName;
+
+public abstract class GitHubComponentTestBase extends CamelTestSupport {
+ public String USERNAME = "someguy";
+ public String PASSWORD = "apassword";
+ public String REPO_OWNER = "anotherguy";
+ public String REPO_NAME = "somerepo";
+ public String GITHUB_CREDENTIALS_STRING = "username=" + USERNAME + "&password=" + PASSWORD + "&repoOwner=" + REPO_OWNER + "&repoName=" + REPO_NAME;
+
+ @Rule
+ public TestName testName = new TestName();
+
+ protected MockCommitService commitService;
+ protected MockRepositoryService repositoryService;
+ protected MockPullRequestService pullRequestService;
+ protected MockIssueService issueService;
+
+ @EndpointInject(uri = "mock:result")
+ protected MockEndpoint mockResultEndpoint;
+
+ @Override
+ protected JndiRegistry createRegistry() throws Exception {
+ JndiRegistry registry = super.createRegistry();
+ commitService = new MockCommitService();
+ registry.bind("githubCommitService", commitService);
+
+ repositoryService = new MockRepositoryService();
+ registry.bind("githubRepositoryService", repositoryService);
+
+ pullRequestService = new MockPullRequestService();
+ registry.bind("githubPullRequestService", pullRequestService);
+
+ issueService = new MockIssueService(pullRequestService);
+ registry.bind("githbIssueService", issueService);
+
+ return registry;
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ log.debug("Starting test " + testName.getMethodName());
+ }
+
+ @Test
+ public void emptyAtStartupTest() throws Exception {
+ mockResultEndpoint.expectedMessageCount(0);
+ mockResultEndpoint.assertIsSatisfied();
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentConsumerTest.java b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentConsumerTest.java
new file mode 100644
index 0000000..ad489f6
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentConsumerTest.java
@@ -0,0 +1,69 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.egit.github.core.Comment;
+import org.eclipse.egit.github.core.CommitComment;
+import org.eclipse.egit.github.core.PullRequest;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PullRequestCommentConsumerTest extends GitHubComponentTestBase {
+ protected static final Logger LOG = LoggerFactory.getLogger(PullRequestCommentConsumerTest.class);
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ context.addComponent("github", new GitHubComponent());
+ from("github://pullRequestComment?" + GITHUB_CREDENTIALS_STRING)
+ .process(new PullRequestCommentProcessor())
+ .to(mockResultEndpoint);
+ }
+ };
+ }
+
+ @Test
+ public void pullRequestCommentTest() throws Exception {
+ PullRequest pr1 = pullRequestService.addPullRequest("First add");
+ PullRequest pr2 = pullRequestService.addPullRequest("Second");
+ CommitComment commitComment1 = pullRequestService.addComment(pr1.getId(), "First comment");
+ CommitComment commitComment2 = pullRequestService.addComment(pr2.getId(), "Second comment");
+ mockResultEndpoint.expectedBodiesReceivedInAnyOrder(commitComment1, commitComment2);
+
+ Thread.sleep(1 * 1000); // TODO do I need this?
+
+ mockResultEndpoint.assertIsSatisfied();
+ }
+
+
+ public class PullRequestCommentProcessor implements Processor {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ Comment comment = (Comment) in.getBody();
+ LOG.debug("Got Comment " + comment.getId() + " [" + comment.getBody() + "] from User [" + comment.getUser().getLogin() + "]");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java
new file mode 100644
index 0000000..d0b7d40
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestCommentProducerTest.java
@@ -0,0 +1,87 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.egit.github.core.CommitComment;
+import org.eclipse.egit.github.core.PullRequest;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
+public class PullRequestCommentProducerTest extends GitHubComponentTestBase {
+ protected static final Logger LOG = LoggerFactory.getLogger(PullRequestCommentProducerTest.class);
+ private long latestPullRequestId = 0;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ context.addComponent("github", new GitHubComponent());
+ from("direct:validPullRequest")
+ .process(new MockPullRequestCommentProducerProcessor())
+ .to("github://pullRequestComment?" + GITHUB_CREDENTIALS_STRING);
+ } // end of configure
+
+
+ };
+ }
+
+
+ @Test
+ public void testPullRequestCommentProducer() throws Exception {
+ PullRequest pullRequest = pullRequestService.addPullRequest("testPullRequestCommentProducer");
+ latestPullRequestId = pullRequest.getId();
+
+ Endpoint commentProducerEndpoint = getMandatoryEndpoint("direct:validPullRequest");
+ Exchange exchange = commentProducerEndpoint.createExchange();
+ String commentText = "Pushed this comment at " + new Date();
+ exchange.getIn().setBody(commentText);
+ template.send(commentProducerEndpoint, exchange);
+
+ Thread.sleep(1 * 1000);
+
+ // Verify that the mock pull request service received this comment.
+ List<CommitComment> commitComments = pullRequestService.getComments(null, (int) pullRequest.getId());
+ assertEquals(1, commitComments.size());
+ CommitComment commitComment = commitComments.get(0);
+ assertEquals("Commit IDs did not match ", Long.toString(pullRequest.getId()), commitComment.getCommitId());
+ assertEquals("Comment text did not match ", commentText, commitComment.getBodyText());
+ }
+
+
+ public class MockPullRequestCommentProducerProcessor implements Processor {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ Map<String, Object> headers = in.getHeaders();
+ headers.put("GitHubPullRequest", latestPullRequestId);
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestConsumerTest.java b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestConsumerTest.java
new file mode 100644
index 0000000..a2df1d3
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/PullRequestConsumerTest.java
@@ -0,0 +1,72 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.egit.github.core.PullRequest;
+import org.eclipse.egit.github.core.User;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class PullRequestConsumerTest extends GitHubComponentTestBase {
+ protected static final Logger LOG = LoggerFactory.getLogger(PullRequestConsumerTest.class);
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ context.addComponent("github", new GitHubComponent());
+ from("github://pullRequest?" + GITHUB_CREDENTIALS_STRING)
+ .process(new MockPullRequestProcessor())
+ .to(mockResultEndpoint);
+ }
+ };
+ }
+
+
+ @Test
+ public void pullRequestTest() throws Exception {
+ PullRequest pr1 = pullRequestService.addPullRequest("First add");
+ PullRequest pr2 = pullRequestService.addPullRequest("Second");
+ mockResultEndpoint.expectedMessageCount(2);
+ mockResultEndpoint.expectedBodiesReceivedInAnyOrder(pr1, pr2);
+ Thread.sleep(1 * 1000);
+
+ mockResultEndpoint.assertIsSatisfied();
+ }
+
+ public class MockPullRequestProcessor implements Processor {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ PullRequest pullRequest = (PullRequest) in.getBody();
+ User pullRequestUser = pullRequest.getUser();
+
+ pullRequest.getTitle();
+ pullRequest.getHtmlUrl();
+ pullRequest.getUser().getLogin();
+ pullRequest.getUser().getHtmlUrl();
+ LOG.debug("Got PullRequest " + pullRequest.getHtmlUrl() + " [" + pullRequest.getTitle() + "] From " + pullRequestUser.getLogin());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/TagConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/TagConsumerTest.java b/components/camel-github/src/test/java/org/apache/camel/component/github/TagConsumerTest.java
new file mode 100644
index 0000000..6d69954
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/TagConsumerTest.java
@@ -0,0 +1,62 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.eclipse.egit.github.core.RepositoryTag;
+import org.junit.Test;
+
+public class TagConsumerTest extends GitHubComponentTestBase {
+
+ @Override
+ protected RouteBuilder createRouteBuilder() throws Exception {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() throws Exception {
+ context.addComponent("github", new GitHubComponent());
+ from("github://tag?" + GITHUB_CREDENTIALS_STRING)
+ .process(new RepositoryTagProcessor())
+ .to(mockResultEndpoint);
+ }
+ };
+ }
+
+
+ @Test
+ public void tagConsumerTest() throws Exception {
+ RepositoryTag tag1 = repositoryService.addTag("TAG1");
+ RepositoryTag tag2 = repositoryService.addTag("TAG2");
+ RepositoryTag tag3 = repositoryService.addTag("TAG3");
+ mockResultEndpoint.expectedBodiesReceivedInAnyOrder(tag1, tag2, tag3);
+ Thread.sleep(1 * 1000);
+
+ mockResultEndpoint.assertIsSatisfied();
+ }
+
+ public class RepositoryTagProcessor implements Processor {
+ @Override
+ public void process(Exchange exchange) throws Exception {
+ Message in = exchange.getIn();
+ RepositoryTag tag = (RepositoryTag) in.getBody();
+ log.debug("Got TAG [" + tag.getName() + "]");
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java
new file mode 100644
index 0000000..a37f403
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockCommitService.java
@@ -0,0 +1,57 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github.consumer;
+
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
+import org.eclipse.egit.github.core.RepositoryCommit;
+import org.eclipse.egit.github.core.User;
+import org.eclipse.egit.github.core.service.CommitService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicLong;
+
+public class MockCommitService extends CommitService {
+ protected static final Logger LOG = LoggerFactory.getLogger(MockCommitService.class);
+
+ private List<RepositoryCommit> commitsList = new ArrayList<>();
+ private AtomicLong fakeSha = new AtomicLong(System.currentTimeMillis());
+
+ public synchronized RepositoryCommit addRepositoryCommit() {
+ User author = new User();
+ author.setEmail("someguy@gmail.com"); // TODO change
+ author.setHtmlUrl("http://github/someguy");
+ author.setLogin("someguy");
+
+ RepositoryCommit rc = new RepositoryCommit();
+ rc.setAuthor(author);
+ rc.setSha(fakeSha.incrementAndGet() + "");
+ LOG.debug("In MockCommitService added commit with sha " + rc.getSha());
+ commitsList.add(rc);
+
+ return rc;
+ }
+
+ @Override
+ public synchronized List<RepositoryCommit> getCommits(IRepositoryIdProvider repository, String sha, String path) throws IOException {
+ LOG.debug("Returning list of size " + commitsList.size());
+ return commitsList;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java
new file mode 100644
index 0000000..52c2ab1
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockIssueService.java
@@ -0,0 +1,47 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github.consumer;
+
+import org.eclipse.egit.github.core.Comment;
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
+import org.eclipse.egit.github.core.service.IssueService;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MockIssueService extends IssueService {
+
+ private List<Comment> comments = new ArrayList<>();
+ private MockPullRequestService mockPullRequestService;
+
+ public MockIssueService(MockPullRequestService mockPullRequestService) {
+ this.mockPullRequestService = mockPullRequestService;
+
+ }
+
+ @Override
+ public List<Comment> getComments(IRepositoryIdProvider repository, int issueNumber) {
+ return comments;
+ }
+
+ @Override
+ public Comment createComment(IRepositoryIdProvider repository, int issueNumber, String commentText) throws IOException {
+ Comment addedComment = mockPullRequestService.addComment((long) issueNumber, commentText);
+ return addedComment;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java
new file mode 100644
index 0000000..97e9838
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockPullRequestService.java
@@ -0,0 +1,106 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github.consumer;
+
+import org.eclipse.egit.github.core.CommitComment;
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
+import org.eclipse.egit.github.core.PullRequest;
+import org.eclipse.egit.github.core.User;
+import org.eclipse.egit.github.core.service.PullRequestService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class MockPullRequestService extends PullRequestService {
+ protected static final Logger LOG = LoggerFactory.getLogger(MockPullRequestService.class);
+
+ private List<PullRequest> pullRequestsList = new ArrayList<>();
+ private List<CommitComment> emptyComments = new ArrayList<>();
+ private AtomicInteger pullRequestNumber = new AtomicInteger(101);
+ private AtomicInteger commentId = new AtomicInteger(500);
+ private Map<Long, List<CommitComment>> allComments = new HashMap<>();
+
+ public List<CommitComment> getComments(IRepositoryIdProvider repository, int pullRequestId) {
+ Long id = new Long(pullRequestId);
+ if (allComments.containsKey(id)) {
+ List<CommitComment> comments = allComments.get(id);
+ return comments;
+ } else {
+ return emptyComments;
+ }
+ }
+
+ private User createAuthor() {
+ User author = new User();
+ author.setEmail("someguy@gmail.com");
+ author.setHtmlUrl("http://github/someguy");
+ author.setLogin("someguy");
+
+ return author;
+ }
+
+ public CommitComment addComment(Long pullRequestId, String bodyText) {
+ CommitComment commitComment = new CommitComment();
+
+ User author = createAuthor();
+ commitComment.setUser(author);
+ commitComment.setCommitId("" + pullRequestId);
+ commitComment.setId(commentId.getAndIncrement());
+ commitComment.setBody(bodyText);
+ commitComment.setBodyText(bodyText);
+
+
+ List<CommitComment> comments;
+ if (allComments.containsKey(pullRequestId)) {
+ comments = allComments.get(pullRequestId);
+ } else {
+ comments = new ArrayList<CommitComment>();
+ }
+ comments.add(commitComment);
+ allComments.put(pullRequestId, comments);
+
+ return commitComment;
+ }
+
+ public PullRequest addPullRequest(String title) {
+ User author = createAuthor();
+
+ PullRequest pullRequest = new PullRequest();
+ pullRequest.setUser(author);
+ pullRequest.setHtmlUrl("https://github.com/someguy/somerepo/pull" + pullRequestNumber);
+ pullRequest.setTitle(title);
+ pullRequest.setNumber(pullRequestNumber.get());
+ pullRequest.setId(pullRequestNumber.get());
+ pullRequestNumber.incrementAndGet();
+
+ pullRequestsList.add(pullRequest);
+ return pullRequest;
+ }
+
+ @Override
+ public synchronized List<PullRequest> getPullRequests(IRepositoryIdProvider repository, String state) {
+ LOG.debug("Returning list of " + pullRequestsList.size() + " pull requests");
+ return pullRequestsList;
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/f1d4afe1/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java
----------------------------------------------------------------------
diff --git a/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java
new file mode 100644
index 0000000..4b504d7
--- /dev/null
+++ b/components/camel-github/src/test/java/org/apache/camel/component/github/consumer/MockRepositoryService.java
@@ -0,0 +1,55 @@
+/**
+ * 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.
+ */
+package org.apache.camel.component.github.consumer;
+
+import org.eclipse.egit.github.core.IRepositoryIdProvider;
+import org.eclipse.egit.github.core.Repository;
+import org.eclipse.egit.github.core.RepositoryTag;
+import org.eclipse.egit.github.core.service.RepositoryService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+public class MockRepositoryService extends RepositoryService {
+ protected static final Logger LOG = LoggerFactory.getLogger(MockRepositoryService.class);
+
+ private List<RepositoryTag> tags = new ArrayList<>();
+
+ public RepositoryTag addTag(String tagName) {
+ RepositoryTag tag = new RepositoryTag();
+ tag.setName(tagName);
+ tags.add(tag);
+
+ return tag;
+ }
+
+ @Override
+ public Repository getRepository(final String owner, final String name) throws IOException {
+ Repository repository = new Repository();
+ repository.setName(name);
+ return repository;
+ }
+
+ @Override
+ public List<RepositoryTag> getTags(IRepositoryIdProvider repository) throws IOException {
+ LOG.debug("in MockRepositoryService returning " + tags.size() + " tags");
+ return tags;
+ }
+}