You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2015/07/18 11:09:18 UTC

[01/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add operation

Repository: camel
Updated Branches:
  refs/heads/master ebf05e07c -> 46d61b8c5


CAMEL-7982: camel-git - A generic git component, add operation


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

Branch: refs/heads/master
Commit: 13b7373f42fc5c0feea70ee5422b72d44e9e55cf
Parents: 91b8b57
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:05:54 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:13 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitConstants.java       |  1 +
 .../camel/component/git/GitOperation.java       |  1 +
 .../apache/camel/component/git/GitProducer.java | 27 +++++++++++-
 .../github/producer/GitProducerTest.java        | 46 ++++++++++++++++++++
 4 files changed, 73 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/13b7373f/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
index 88331c7..c96959b 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
@@ -18,4 +18,5 @@ package org.apache.camel.component.git;
 
 public interface GitConstants {
 	public static final String GIT_OPERATION = "CamelGitOperation";
+	public static final String GIT_FILE_NAME = "CamelGitFilename";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/13b7373f/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index 2b951c0..62b19a4 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -20,4 +20,5 @@ public interface GitOperation {
 
     public final static String CLONE_OPERATION = "clone";
     public final static String INIT_OPERATION = "init";
+    public final static String ADD_OPERATION = "add";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/13b7373f/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index e0fa4fe..1ccbac7 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -6,6 +6,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.lib.Repository;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -36,13 +37,17 @@ public class GitProducer extends DefaultProducer{
 	    case GitOperation.INIT_OPERATION:
 	    	doInit(exchange, operation);
 	    	break;
+
+	    case GitOperation.ADD_OPERATION:
+	    	doAdd(exchange, operation);
+	    	break;	    	
 	    }
 	}
 	
     protected void doClone(Exchange exchange, String operation) {
     	Git result = null;
     	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute" + operation);
+    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
     	}
     	try {
     		File localRepo = new File(endpoint.getLocalPath(), "");
@@ -62,7 +67,7 @@ public class GitProducer extends DefaultProducer{
     protected void doInit(Exchange exchange, String operation) {
     	Git result = null;
     	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute" + operation);
+    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
     	}
     	try {
 			result = Git.init().setDirectory(new File(endpoint.getLocalPath(),"")).call();
@@ -73,4 +78,22 @@ public class GitProducer extends DefaultProducer{
 			result.close();
 		}
     }
+    
+    protected void doAdd(Exchange exchange, String operation) {
+    	String fileName = null;
+    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
+    	}
+    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
+    		fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
+    	} else {
+    		throw new IllegalArgumentException("File name must be specified to execute " + operation);
+    	}
+    	try {
+			Git.open(new File(endpoint.getLocalPath())).add().addFilepattern(fileName).call();
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			e.printStackTrace();
+		}
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/13b7373f/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index 22e66b6..18965c8 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -17,14 +17,24 @@
 package org.apache.camel.component.github.producer;
 
 import java.io.File;
+import java.io.IOException;
 
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.git.GitConstants;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.junit.Test;
 
 public class GitProducerTest extends CamelTestSupport{
 
 	private final static String GIT_LOCAL_REPO = "pippo";
+	private final static String FILENAME_TO_ADD = "filetest.txt";
 	
     @Override
     public void setUp() throws Exception {
@@ -56,6 +66,28 @@ public class GitProducerTest extends CamelTestSupport{
         assertEquals(gitDir.exists(), true);
     }
     
+    @Test
+    public void addTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
@@ -65,10 +97,24 @@ public class GitProducerTest extends CamelTestSupport{
                         .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=clone");
                 from("direct:init")
                         .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=init");
+                from("direct:add")
+                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=add");
             } 
         };
     }
     
+    private Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
+        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
+        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).call();
+        // now open the resulting repository with a FileRepositoryBuilder
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = builder.setGitDir(gitRepo)
+                .readEnvironment() // scan environment GIT_* variables
+                .findGitDir() // scan up the file system tree
+                .build();
+        return repo;
+    }
+    
     static public boolean deleteDirectory(File path) {
         if( path.exists() ) {
           File[] files = path.listFiles();


[16/23] camel git commit: Fixed CS

Posted by ac...@apache.org.
Fixed CS


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

Branch: refs/heads/master
Commit: 69fdbd1569544ee339bf1ef063c047662814f492
Parents: 2cbeee7
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:19 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:16 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitTestSupport.java     |  41 +--
 .../component/git/consumer/GitConsumerTest.java |  62 ++---
 .../component/git/producer/GitProducerTest.java | 274 +++++++++----------
 .../git/producer/GitRemoteProducerTest.java     |  16 +-
 4 files changed, 189 insertions(+), 204 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/69fdbd15/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java
index ae763b3..d93b527 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java
@@ -29,41 +29,41 @@ import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 
 public class GitTestSupport extends CamelTestSupport {
 
-    public final static String GIT_LOCAL_REPO = "testRepo";
+    public final String gitLocalRepo = "testRepo";
 
-    public final static String FILENAME_TO_ADD = "filetest.txt";
+    public final String filenameToAdd = "filetest.txt";
 
-    public final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
+    public final String filenameBranchToAdd = "filetest1.txt";
 
-    public final static String COMMIT_MESSAGE = "Test commit";
+    public final String commitMessage = "Test commit";
 
-    public final static String COMMIT_MESSAGE_ALL = "Test commit all";
+    public final String commitMessageAll = "Test commit all";
 
-    public final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
+    public final String commitMessageBranch = "Test commit on a branch";
 
-    public final static String BRANCH_TEST = "testBranch";
+    public final String branchTest = "testBranch";
     
-    public final static String TAG_TEST = "testTag";
+    public final String tagTest = "testTag";
 
     @Override
     public void setUp() throws Exception {
         super.setUp();
-        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
+        File localPath = File.createTempFile(gitLocalRepo, "");
         localPath.delete();
-        File path = new File(GIT_LOCAL_REPO);
+        File path = new File(gitLocalRepo);
         path.deleteOnExit();
     }
 
     @Override
     public void tearDown() throws Exception {
         super.tearDown();
-        File path = new File(GIT_LOCAL_REPO);
+        File path = new File(gitLocalRepo);
         deleteDirectory(path);
     }
       
     protected Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
-        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
-        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
+        File gitRepo = new File(gitLocalRepo, ".git");
+        Git.init().setDirectory(new File(gitLocalRepo, "")).setBare(false).call();
         // now open the resulting repository with a FileRepositoryBuilder
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = builder.setGitDir(gitRepo)
@@ -72,19 +72,4 @@ public class GitTestSupport extends CamelTestSupport {
                 .build();
         return repo;
     }
-    
-    static public boolean deleteDirectory(File path) {
-        if( path.exists() ) {
-          File[] files = path.listFiles();
-          for(int i=0; i<files.length; i++) {
-             if(files[i].isDirectory()) {
-               deleteDirectory(files[i]);
-             }
-             else {
-               files[i].delete();
-             }
-          }
-        }
-        return( path.delete() );
-      }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/69fdbd15/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
index a080e23..2bde385 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
@@ -40,48 +40,48 @@ public class GitConsumerTest extends GitTestSupport {
     	Repository repository = getTestRepository();
         MockEndpoint added = getMockEndpoint("mock:result-commit");
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
         for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
         
-        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        File fileToAdd1 = new File(gitLocalRepo, filenameBranchToAdd);
         fileToAdd1.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameBranchToAdd);
             }
         });
         
         status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameBranchToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
@@ -100,7 +100,7 @@ public class GitConsumerTest extends GitTestSupport {
         Thread.sleep(1 * 5000);
         Exchange ex1 = added.getExchanges().get(0);
         Exchange ex2 = added.getExchanges().get(1);
-        assertEquals(COMMIT_MESSAGE, ex2.getOut().getBody(RevCommit.class).getShortMessage());
+        assertEquals(commitMessage, ex2.getOut().getBody(RevCommit.class).getShortMessage());
         assertEquals("Test test Commit", ex1.getOut().getBody(RevCommit.class).getShortMessage());
         repository.close();
     }
@@ -110,25 +110,25 @@ public class GitConsumerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
@@ -139,7 +139,7 @@ public class GitConsumerTest extends GitTestSupport {
         List<Ref> ref = git.tagList().call();
         boolean tagCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+            if (refInternal.getName().equals("refs/tags/" + tagTest)) {
                 tagCreated = true;
             }
         }
@@ -157,25 +157,25 @@ public class GitConsumerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
@@ -186,7 +186,7 @@ public class GitConsumerTest extends GitTestSupport {
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+            if (refInternal.getName().equals("refs/heads/" + branchTest)) {
                 branchCreated = true;
             }
         }
@@ -205,22 +205,22 @@ public class GitConsumerTest extends GitTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:clone")
-                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
+                        .to("git://" + gitLocalRepo + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
                 from("direct:init")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
+                        .to("git://" + gitLocalRepo + "?operation=init");
                 from("direct:add")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                        .to("git://" + gitLocalRepo + "?operation=add");
                 from("direct:commit")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                        .to("git://" + gitLocalRepo + "?operation=commit");
                 from("direct:create-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=createBranch&branchName=" + branchTest);
                 from("direct:create-tag")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=createTag&tagName=" + TAG_TEST);
-                from("git://" + GIT_LOCAL_REPO + "?type=commit")
+                        .to("git://" + gitLocalRepo + "?operation=createTag&tagName=" + tagTest);
+                from("git://" + gitLocalRepo + "?type=commit")
                         .to("mock:result-commit");
-                from("git://" + GIT_LOCAL_REPO + "?type=tag")
+                from("git://" + gitLocalRepo + "?type=tag")
                         .to("mock:result-tag");
-                from("git://" + GIT_LOCAL_REPO + "?type=branch")
+                from("git://" + gitLocalRepo + "?type=branch")
                         .to("mock:result-branch");
             } 
         };

http://git-wip-us.apache.org/repos/asf/camel/blob/69fdbd15/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
index cb6bee8..212be8f 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
@@ -37,14 +37,14 @@ public class GitProducerTest extends GitTestSupport {
     @Test
     public void cloneTest() throws Exception {
         template.sendBody("direct:clone","");
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
     }
     
     @Test
     public void initTest() throws Exception {
         template.sendBody("direct:init","");
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
     }
     
@@ -53,20 +53,20 @@ public class GitProducerTest extends GitTestSupport {
 
     	Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         repository.close();
     }
     
@@ -75,48 +75,48 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:remove", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        gitDir = new File(GIT_LOCAL_REPO, ".git");
+        gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
         for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
         
         status = new Git(repository).status().call();
 
-        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
+        assertFalse(status.getAdded().contains(filenameToAdd));
         
         repository.close();
     }
@@ -126,32 +126,32 @@ public class GitProducerTest extends GitTestSupport {
 
     	Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
         for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
@@ -163,51 +163,51 @@ public class GitProducerTest extends GitTestSupport {
 
     	Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
         for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
         
         Git git = new Git(repository);
-        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        git.checkout().setCreateBranch(true).setName(branchTest).
         setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
         
         template.send("direct:commit-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_BRANCH);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageBranch);
             }
         });
         logs = git.log().call();
         count = 0;
         for (RevCommit rev : logs) {
-        	if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_BRANCH);
-        	if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+        	if (count == 0) assertEquals(rev.getShortMessage(), commitMessageBranch);
+        	if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 2);
@@ -221,27 +221,27 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
         
         template.send("direct:commit-all", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll);
             }
         });
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
         for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            assertEquals(rev.getShortMessage(), commitMessageAll);
             count++;
         }
         assertEquals(count, 1);
@@ -253,61 +253,61 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
         for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
         
         Git git = new Git(repository);
-        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        git.checkout().setCreateBranch(true).setName(branchTest).
         setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
         
-        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        File fileToAdd1 = new File(gitLocalRepo, filenameBranchToAdd);
         fileToAdd1.createNewFile();
         
         template.send("direct:add-on-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameBranchToAdd);
             }
         });
         
         template.send("direct:commit-all-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll);
             }
         });
         logs = git.log().call();
         count = 0;
         for (RevCommit rev : logs) {
-            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
-            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            if (count == 0) assertEquals(rev.getShortMessage(), commitMessageAll);
+            if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 2);
@@ -319,61 +319,61 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
         for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
         
         Git git = new Git(repository);
-        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        git.checkout().setCreateBranch(true).setName(branchTest).
         setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
         
-        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        File fileToAdd1 = new File(gitLocalRepo, filenameBranchToAdd);
         fileToAdd1.createNewFile();
         
         template.send("direct:add-on-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameBranchToAdd);
             }
         });
         
         template.send("direct:commit-all-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll);
             }
         });
         logs = git.log().call();
         count = 0;
         for (RevCommit rev : logs) {
-            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
-            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            if (count == 0) assertEquals(rev.getShortMessage(), commitMessageAll);
+            if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 2);
@@ -381,15 +381,15 @@ public class GitProducerTest extends GitTestSupport {
         template.send("direct:remove-on-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
         
         git = new Git(repository);
-        git.checkout().setCreateBranch(false).setName(BRANCH_TEST).call();
+        git.checkout().setCreateBranch(false).setName(branchTest).call();
         
         status = git.status().call();
-        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
+        assertFalse(status.getAdded().contains(filenameToAdd));
         
         repository.close();
     }
@@ -399,25 +399,25 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
@@ -428,7 +428,7 @@ public class GitProducerTest extends GitTestSupport {
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+            if (refInternal.getName().equals("refs/heads/" + branchTest)) {
                 branchCreated = true;
             }
         }
@@ -441,25 +441,25 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
@@ -470,7 +470,7 @@ public class GitProducerTest extends GitTestSupport {
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+            if (refInternal.getName().equals("refs/heads/" + branchTest)) {
                 branchCreated = true;
             }
         }
@@ -481,7 +481,7 @@ public class GitProducerTest extends GitTestSupport {
         ref = git.branchList().call();
         branchCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+            if (refInternal.getName().equals("refs/heads/" + branchTest)) {
                 branchCreated = true;
             }
         }
@@ -494,20 +494,20 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         repository.close();
     }
@@ -517,25 +517,25 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
@@ -546,24 +546,24 @@ public class GitProducerTest extends GitTestSupport {
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+            if (refInternal.getName().equals("refs/heads/" + branchTest)) {
                 branchCreated = true;
             }
         }
         assertEquals(branchCreated, true);
         
-        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        File fileToAddDifferent = new File(gitLocalRepo, filenameBranchToAdd);
         fileToAddDifferent.createNewFile();
         
         template.send("direct:add-on-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameBranchToAdd);
             }
         });
         
         status = template.requestBody("direct:status-branch", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameBranchToAdd));
         
         repository.close();
     }
@@ -573,31 +573,31 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
         Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
         for (RevCommit rev : revCommits) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
         }        
         repository.close();
     }
@@ -607,31 +607,31 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
         Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
         for (RevCommit rev : revCommits) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            assertEquals(rev.getShortMessage(), commitMessage);
         }
         
         template.sendBody("direct:create-branch", "");
@@ -641,34 +641,34 @@ public class GitProducerTest extends GitTestSupport {
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+            if (refInternal.getName().equals("refs/heads/" + branchTest)) {
                 branchCreated = true;
             }
         }
         assertEquals(branchCreated, true);
         
-        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        File fileToAddDifferent = new File(gitLocalRepo, filenameBranchToAdd);
         fileToAddDifferent.createNewFile();
         
         template.send("direct:add-on-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameBranchToAdd);
             }
         });
         
         template.send("direct:commit-all-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll);
             }
         });
         
         revCommits = template.requestBody("direct:log-branch", "", Iterable.class);
         int count = 0;
         for (RevCommit rev : revCommits) {
-            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
-            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            if (count == 0) assertEquals(rev.getShortMessage(), commitMessageAll);
+            if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         
@@ -680,25 +680,25 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
@@ -709,7 +709,7 @@ public class GitProducerTest extends GitTestSupport {
         List<Ref> ref = git.tagList().call();
         boolean tagCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+            if (refInternal.getName().equals("refs/tags/" + tagTest)) {
                 tagCreated = true;
             }
         }
@@ -722,25 +722,25 @@ public class GitProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
         
@@ -751,7 +751,7 @@ public class GitProducerTest extends GitTestSupport {
         List<Ref> ref = git.tagList().call();
         boolean tagCreated = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+            if (refInternal.getName().equals("refs/tags/" + tagTest)) {
                 tagCreated = true;
             }
         }
@@ -762,7 +762,7 @@ public class GitProducerTest extends GitTestSupport {
         ref = git.tagList().call();
         boolean tagExists = false;
         for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+            if (refInternal.getName().equals("refs/tags/" + tagTest)) {
                 tagExists = true;
             }
         }
@@ -776,41 +776,41 @@ public class GitProducerTest extends GitTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:clone")
-                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
+                        .to("git://" + gitLocalRepo + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
                 from("direct:init")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
+                        .to("git://" + gitLocalRepo + "?operation=init");
                 from("direct:add")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                        .to("git://" + gitLocalRepo + "?operation=add");
                 from("direct:remove")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=rm");
+                        .to("git://" + gitLocalRepo + "?operation=rm");
                 from("direct:add-on-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=add&branchName=" + branchTest);
                 from("direct:remove-on-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=add&branchName=" + branchTest);
                 from("direct:commit")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                        .to("git://" + gitLocalRepo + "?operation=commit");
                 from("direct:commit-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=commit&branchName=" + branchTest);
                 from("direct:commit-all")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                        .to("git://" + gitLocalRepo + "?operation=commit");
                 from("direct:commit-all-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=commit&branchName=" + branchTest);
                 from("direct:create-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=createBranch&branchName=" + branchTest);
                 from("direct:delete-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=deleteBranch&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=deleteBranch&branchName=" + branchTest);
                 from("direct:status")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=status");
+                        .to("git://" + gitLocalRepo + "?operation=status");
                 from("direct:status-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=status&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=status&branchName=" + branchTest);
                 from("direct:log")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=log");
+                        .to("git://" + gitLocalRepo + "?operation=log");
                 from("direct:log-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=log&branchName=" + BRANCH_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=log&branchName=" + branchTest);
                 from("direct:create-tag")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=createTag&tagName=" + TAG_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=createTag&tagName=" + tagTest);
                 from("direct:delete-tag")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=deleteTag&tagName=" + TAG_TEST);
+                        .to("git://" + gitLocalRepo + "?operation=deleteTag&tagName=" + tagTest);
             } 
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/69fdbd15/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
index 81ba158..36c33bd 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
@@ -38,25 +38,25 @@ public class GitRemoteProducerTest extends GitTestSupport {
 
         Repository repository = getTestRepository();
         
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd);
             }
         });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
         
         Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        assertTrue(status.getAdded().contains(filenameToAdd));
         
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
             }
         });
 
@@ -71,11 +71,11 @@ public class GitRemoteProducerTest extends GitTestSupport {
             @Override
             public void configure() throws Exception {
                 from("direct:add")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                        .to("git://" + gitLocalRepo + "?operation=add");
                 from("direct:commit")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                        .to("git://" + gitLocalRepo + "?operation=commit");
                 from("direct:push")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx" );
+                        .to("git://" + gitLocalRepo + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx" );
             } 
         };
     }


[21/23] camel git commit: CAMEL-7982: camel-git, define a jgit-version property in parent

Posted by ac...@apache.org.
CAMEL-7982: camel-git, define a jgit-version property in parent


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

Branch: refs/heads/master
Commit: c9192f68f393b3be58dcefeebcc0a44a9d58cc4c
Parents: 382f756
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:41 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:17 2015 +0200

----------------------------------------------------------------------
 components/camel-git/pom.xml | 2 +-
 parent/pom.xml               | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/c9192f68/components/camel-git/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-git/pom.xml b/components/camel-git/pom.xml
index a6a673b..8d547d0 100644
--- a/components/camel-git/pom.xml
+++ b/components/camel-git/pom.xml
@@ -36,7 +36,7 @@
     <dependency>
       <groupId>org.eclipse.jgit</groupId>
       <artifactId>org.eclipse.jgit</artifactId>
-      <version>4.0.1.201506240215-r</version>
+      <version>${jgit-version}</version>
     </dependency>
 
     <!-- testing -->

http://git-wip-us.apache.org/repos/asf/camel/blob/c9192f68/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 08354d0..18068eb 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -273,6 +273,7 @@
     <jettison-version>1.3.7</jettison-version>
     <jexcelapi-bundle-version>2.4.2_4</jexcelapi-bundle-version>
     <jexcelapi-version>2.4.2</jexcelapi-version>
+    <jgit-version>4.0.1.201506240215-r</jgit-version>
     <jgroups-version>3.6.4.Final</jgroups-version>
     <jibx-version>1.2.6</jibx-version>
     <jing-bundle-version>20030619_5</jing-bundle-version>


[10/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add Status operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add Status operation


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

Branch: refs/heads/master
Commit: 903e88f8e86d95ea99a7ebc3b9fd36e1d4d8bba4
Parents: db6f6e1
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:26 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:15 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitOperation.java       |  1 +
 .../apache/camel/component/git/GitProducer.java | 21 +++++
 .../github/producer/GitProducerTest.java        | 83 ++++++++++++++++++++
 3 files changed, 105 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/903e88f8/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index 431540a..88e03de 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -26,4 +26,5 @@ public interface GitOperation {
     public final static String COMMIT_ALL_OPERATION = "commitAll";
     public final static String CREATE_BRANCH_OPERATION = "createBranch";
     public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
+    public final static String STATUS_OPERATION = "status";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/903e88f8/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index c134475..e7c2fbe 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -7,6 +7,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.slf4j.Logger;
@@ -68,6 +69,10 @@ public class GitProducer extends DefaultProducer{
             case GitOperation.DELETE_BRANCH_OPERATION:
                 doDeleteBranch(exchange, operation, repo);
                 break;
+                
+            case GitOperation.STATUS_OPERATION:
+                doStatus(exchange, operation, repo);
+                break;
 	    }
 	    repo.close();
 	}
@@ -215,6 +220,22 @@ public class GitProducer extends DefaultProducer{
         }
     }
     
+    protected void doStatus(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        Status status = null;
+        try {
+            git = new Git(repo);
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+                status = git.status().call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        e.printStackTrace();
+                }
+        exchange.getOut().setBody(status);
+    }
+    
     private Repository getLocalRepository(){
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/903e88f8/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index 791e2aa..73693cc 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -516,6 +516,85 @@ public class GitProducerTest extends CamelTestSupport {
         repository.close();
     }
     
+    @Test
+    public void statusTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        repository.close();
+    }
+    
+    @Test
+    public void statusBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        template.sendBody("direct:create-branch", "");
+        
+        Git git = new Git(repository);
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        
+        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAddDifferent.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        status = template.requestBody("direct:status-branch", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
+        
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
@@ -545,6 +624,10 @@ public class GitProducerTest extends CamelTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
                 from("direct:delete-branch")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=deleteBranch&branchName=" + BRANCH_TEST);
+                from("direct:status")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=status");
+                from("direct:status-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=status&branchName=" + BRANCH_TEST);
             } 
         };
     }


[15/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add branches consumer

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add branches consumer


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

Branch: refs/heads/master
Commit: 2cbeee721769e385743b4595ff796d0c293869ae
Parents: d38b525
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:15 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:16 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/git/GitEndpoint.java |   2 +
 .../git/consumer/GitBranchConsumer.java         |  52 ++++++++++
 .../camel/component/git/consumer/GitType.java   |   2 +-
 .../component/git/consumer/GitConsumerTest.java | 101 ++++++++++++++++++-
 4 files changed, 151 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/2cbeee72/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index 79673e8..ce1a325 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.git;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.component.git.consumer.GitBranchConsumer;
 import org.apache.camel.component.git.consumer.GitCommitConsumer;
 import org.apache.camel.component.git.consumer.GitTagConsumer;
 import org.apache.camel.component.git.consumer.GitType;
@@ -62,6 +63,7 @@ public class GitEndpoint extends DefaultEndpoint {
 	public Consumer createConsumer(Processor processor) throws Exception {
 	    if (type == GitType.COMMIT) return new GitCommitConsumer(this, processor);
 	    else if (type == GitType.TAG) return new GitTagConsumer(this, processor);
+	    else if (type == GitType.BRANCH) return new GitBranchConsumer(this, processor);
 	    else throw new IllegalArgumentException("Cannot create producer with type " + type);
 	}
 

http://git-wip-us.apache.org/repos/asf/camel/blob/2cbeee72/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
new file mode 100644
index 0000000..d906d7a
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
@@ -0,0 +1,52 @@
+/**
+ * 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.git.consumer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.git.GitEndpoint;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+public class GitBranchConsumer extends AbstractGitConsumer {
+	
+	private List used = new ArrayList();
+
+	public GitBranchConsumer(GitEndpoint endpoint, Processor processor) {
+		super(endpoint, processor);
+	}
+
+	@Override
+	protected int poll() throws Exception {
+		int count = 0;
+		List<Ref> call = getGit().branchList().call();
+        for (Ref ref : call) {
+        	if (!used.contains(ref.getName())) {
+            Exchange e = getEndpoint().createExchange();
+            e.getOut().setBody(ref);
+            getProcessor().process(e);
+            used.add(ref.getName());
+            count++;
+        	}
+        }
+        return count;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/2cbeee72/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
index 4015445..ecc9774 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
@@ -18,6 +18,6 @@ package org.apache.camel.component.git.consumer;
 
 public enum GitType {
 
-    COMMIT, TAG
+    COMMIT, TAG, BRANCH
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/2cbeee72/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
index b61286d0..a080e23 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.git.consumer;
 
 import java.io.File;
+import java.util.List;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -26,6 +27,7 @@ import org.apache.camel.component.git.GitTestSupport;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.junit.Test;
@@ -36,7 +38,7 @@ public class GitConsumerTest extends GitTestSupport {
     public void commitConsumerTest() throws Exception {
 
     	Repository repository = getTestRepository();
-        MockEndpoint added = getMockEndpoint("mock:result");
+        MockEndpoint added = getMockEndpoint("mock:result-commit");
         
         File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
         fileToAdd.createNewFile();
@@ -107,10 +109,93 @@ public class GitConsumerTest extends GitTestSupport {
     public void tagConsumerTest() throws Exception {
 
         Repository repository = getTestRepository();
-        MockEndpoint added = getMockEndpoint("mock:result");
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-tag", "");
+        
+        List<Ref> ref = git.tagList().call();
+        boolean tagCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+                tagCreated = true;
+            }
+        }
+        assertEquals(tagCreated, true);
+        
+        MockEndpoint added = getMockEndpoint("mock:result-tag");
+        
+        Thread.sleep(1 * 5000);
+        assertEquals(added.getExchanges().size(), 1);
+        repository.close();
+    }
+    
+    @Test
+    public void branchConsumerTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-branch", "");
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        
+        MockEndpoint added = getMockEndpoint("mock:result-branch");
         
         Thread.sleep(1 * 5000);
-        assertEquals(added.getExchanges().size(), 0);
+        assertEquals(added.getExchanges().size(), 2);
         repository.close();
     }
     
@@ -127,10 +212,16 @@ public class GitConsumerTest extends GitTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=add");
                 from("direct:commit")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("direct:create-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
+                from("direct:create-tag")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=createTag&tagName=" + TAG_TEST);
                 from("git://" + GIT_LOCAL_REPO + "?type=commit")
-                        .to("mock:result");
+                        .to("mock:result-commit");
                 from("git://" + GIT_LOCAL_REPO + "?type=tag")
-                        .to("mock:result");
+                        .to("mock:result-tag");
+                from("git://" + GIT_LOCAL_REPO + "?type=branch")
+                        .to("mock:result-branch");
             } 
         };
     }


[23/23] camel git commit: Camel-7982: camel-git, latest change to code

Posted by ac...@apache.org.
Camel-7982: camel-git, latest change to code


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

Branch: refs/heads/master
Commit: 46d61b8c562d03a8c9039f26963eee6e2d4c2d6a
Parents: c9192f6
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:47 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:17 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/git/consumer/GitBranchConsumer.java | 6 +++---
 .../apache/camel/component/git/consumer/GitCommitConsumer.java | 6 +++---
 .../apache/camel/component/git/consumer/GitTagConsumer.java    | 6 +++---
 3 files changed, 9 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/46d61b8c/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
index dc64012..2ef41f0 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
@@ -26,7 +26,7 @@ import org.eclipse.jgit.lib.Ref;
 
 public class GitBranchConsumer extends AbstractGitConsumer {
 
-    private List used = new ArrayList();
+    private List branchesConsumed = new ArrayList();
 
     public GitBranchConsumer(GitEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
@@ -37,11 +37,11 @@ public class GitBranchConsumer extends AbstractGitConsumer {
         int count = 0;
         List<Ref> call = getGit().branchList().call();
         for (Ref ref : call) {
-            if (!used.contains(ref.getName())) {
+            if (!branchesConsumed.contains(ref.getName())) {
                 Exchange e = getEndpoint().createExchange();
                 e.getOut().setBody(ref);
                 getProcessor().process(e);
-                used.add(ref.getName());
+                branchesConsumed.add(ref.getName());
                 count++;
             }
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/46d61b8c/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
index 6a4600e..882e343 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
@@ -26,7 +26,7 @@ import org.eclipse.jgit.revwalk.RevCommit;
 
 public class GitCommitConsumer extends AbstractGitConsumer {
 
-    private List used = new ArrayList();
+    private List commitsConsumed = new ArrayList();
 
     public GitCommitConsumer(GitEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
@@ -37,11 +37,11 @@ public class GitCommitConsumer extends AbstractGitConsumer {
         int count = 0;
         Iterable<RevCommit> commits = getGit().log().all().call();
         for (RevCommit commit : commits) {
-            if (!used.contains(commit.getId())) {
+            if (!commitsConsumed.contains(commit.getId())) {
                 Exchange e = getEndpoint().createExchange();
                 e.getOut().setBody(commit);
                 getProcessor().process(e);
-                used.add(commit.getId());
+                commitsConsumed.add(commit.getId());
                 count++;
             }
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/46d61b8c/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
index 88832b7..ce8fec9 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
@@ -26,7 +26,7 @@ import org.eclipse.jgit.lib.Ref;
 
 public class GitTagConsumer extends AbstractGitConsumer {
 
-    private List used = new ArrayList();
+    private List tagsConsumed = new ArrayList();
 
     public GitTagConsumer(GitEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
@@ -37,11 +37,11 @@ public class GitTagConsumer extends AbstractGitConsumer {
         int count = 0;
         List<Ref> call = getGit().tagList().call();
         for (Ref ref : call) {
-            if (!used.contains(ref.getName())) {
+            if (!tagsConsumed.contains(ref.getName())) {
                 Exchange e = getEndpoint().createExchange();
                 e.getOut().setBody(ref);
                 getProcessor().process(e);
-                used.add(ref.getName());
+                tagsConsumed.add(ref.getName());
                 count++;
             }
         }


[18/23] camel git commit: Fixed CS

Posted by ac...@apache.org.
Fixed CS


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

Branch: refs/heads/master
Commit: 465352619d40f9bc35c3a3cd8fa087eb221124ba
Parents: 69fdbd1
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:24 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:16 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitConstants.java       |   8 +-
 .../apache/camel/component/git/GitEndpoint.java | 176 ++++---
 .../git/consumer/AbstractGitConsumer.java       |  40 +-
 .../git/consumer/GitBranchConsumer.java         |  35 +-
 .../git/consumer/GitCommitConsumer.java         |  34 +-
 .../component/git/consumer/GitTagConsumer.java  |  35 +-
 .../component/git/producer/GitOperation.java    |  28 +-
 .../component/git/producer/GitProducer.java     | 453 ++++++++++---------
 .../component/git/consumer/GitConsumerTest.java |   2 +-
 .../component/git/producer/GitProducerTest.java |  44 +-
 .../git/producer/GitRemoteProducerTest.java     |   2 +-
 11 files changed, 463 insertions(+), 394 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
index 0ec6856..ce90b82 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
@@ -17,7 +17,9 @@
 package org.apache.camel.component.git;
 
 public interface GitConstants {
-	public static final String GIT_OPERATION = "CamelGitOperation";
-	public static final String GIT_FILE_NAME = "CamelGitFilename";
-	public static final String GIT_COMMIT_MESSAGE = "CamelGitCommitMessage";
+    String GIT_OPERATION = "CamelGitOperation";
+
+    String GIT_FILE_NAME = "CamelGitFilename";
+
+    String GIT_COMMIT_MESSAGE = "CamelGitCommitMessage";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index ce1a325..261c6ce 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -33,94 +33,127 @@ import org.apache.camel.spi.UriPath;
 @UriEndpoint(scheme = "git", title = "Git", syntax = "git://localpath", label = "api,file")
 public class GitEndpoint extends DefaultEndpoint {
 
-    @UriPath @Metadata(required = "true")
+    @UriPath
+    @Metadata(required = "true")
     private String localPath;
+
     @UriPath
     private String branchName;
+
     @UriPath
     private String tagName;
+
     @UriPath(label = "consumer")
     private GitType type;
+
     @UriParam
     private String username;
+
     @UriParam
     private String password;
+
     @UriParam
     private String remotePath;
-    @UriParam
+
+    @UriParam(label = "producer")
     private String operation;
 
     public GitEndpoint(String uri, GitComponent component) {
         super(uri, component);
     }
-    
-	@Override
-	public Producer createProducer() throws Exception {
-		return new GitProducer(this);
-	}
-
-	@Override
-	public Consumer createConsumer(Processor processor) throws Exception {
-	    if (type == GitType.COMMIT) return new GitCommitConsumer(this, processor);
-	    else if (type == GitType.TAG) return new GitTagConsumer(this, processor);
-	    else if (type == GitType.BRANCH) return new GitBranchConsumer(this, processor);
-	    else throw new IllegalArgumentException("Cannot create producer with type " + type);
-	}
-
-	@Override
-	public boolean isSingleton() {
-		// TODO Auto-generated method stub
-		return false;
-	} 
-
-	public String getRemotePath() {
-		return remotePath;
-	}
-
-	public void setRemotePath(String remotePath) {
-		this.remotePath = remotePath;
-	}
-
-	public String getBranchName() {
-		return branchName;
-	}
-
-	public void setBranchName(String branchName) {
-		this.branchName = branchName;
-	}
-
-	public String getUsername() {
-		return username;
-	}
-
-	public void setUsername(String username) {
-		this.username = username;
-	}
-
-	public String getPassword() {
-		return password;
-	}
-
-	public void setPassword(String password) {
-		this.password = password;
-	}
-
-	public String getLocalPath() {
-		return localPath;
-	}
-
-	public void setLocalPath(String localPath) {
-		this.localPath = localPath;
-	}
-
-	public String getOperation() {
-		return operation;
-	}
-
-	public void setOperation(String operation) {
-		this.operation = operation;
-	}
 
+    @Override
+    public Producer createProducer() throws Exception {
+        return new GitProducer(this);
+    }
+
+    @Override
+    public Consumer createConsumer(Processor processor) throws Exception {
+        if (type == GitType.COMMIT) {
+            return new GitCommitConsumer(this, processor);
+        } else if (type == GitType.TAG) {
+            return new GitTagConsumer(this, processor);
+        } else if (type == GitType.BRANCH) {
+            return new GitBranchConsumer(this, processor);
+        } else {
+            throw new IllegalArgumentException("Cannot create producer with type " + type);
+        }
+    }
+
+    @Override
+    public boolean isSingleton() {
+        return false;
+    }
+
+    /**
+     * The remote repository path
+     */
+    public String getRemotePath() {
+        return remotePath;
+    }
+
+    public void setRemotePath(String remotePath) {
+        this.remotePath = remotePath;
+    }
+
+    /**
+     * The branch name to work on
+     */
+    public String getBranchName() {
+        return branchName;
+    }
+
+    public void setBranchName(String branchName) {
+        this.branchName = branchName;
+    }
+
+    /**
+     * Remote repository username
+     */
+    public String getUsername() {
+        return username;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    /**
+     * Remote repository password
+     */
+    public String getPassword() {
+        return password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password;
+    }
+
+    /**
+     * Local repository path
+     */
+    public String getLocalPath() {
+        return localPath;
+    }
+
+    public void setLocalPath(String localPath) {
+        this.localPath = localPath;
+    }
+
+    /**
+     * The operation to do on the repository
+     */
+    public String getOperation() {
+        return operation;
+    }
+
+    public void setOperation(String operation) {
+        this.operation = operation;
+    }
+
+    /**
+     * The consumer type
+     */
     public GitType getType() {
         return type;
     }
@@ -129,6 +162,9 @@ public class GitEndpoint extends DefaultEndpoint {
         this.type = type;
     }
 
+    /**
+     * The tag name to work on
+     */
     public String getTagName() {
         return tagName;
     }
@@ -136,5 +172,5 @@ public class GitEndpoint extends DefaultEndpoint {
     public void setTagName(String tagName) {
         this.tagName = tagName;
     }
-   
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
index ca58dcf..60b98f6 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
@@ -21,7 +21,6 @@ import java.io.IOException;
 
 import org.apache.camel.Processor;
 import org.apache.camel.component.git.GitEndpoint;
-import org.apache.camel.component.git.producer.GitProducer;
 import org.apache.camel.impl.ScheduledPollConsumer;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.lib.Repository;
@@ -30,20 +29,20 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
-    
+
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractGitConsumer.class);
+
     private final GitEndpoint endpoint;
-    
+
     private Repository repo;
-    
+
     private Git git;
-    
-    private static final Logger LOG = LoggerFactory.getLogger(AbstractGitConsumer.class);
 
     public AbstractGitConsumer(GitEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
         this.endpoint = endpoint;
     }
-    
+
     @Override
     protected void doStart() throws Exception {
         super.doStart();
@@ -58,28 +57,27 @@ public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
         git.close();
     }
 
-    private Repository getLocalRepository() throws IOException{
+    private Repository getLocalRepository() throws IOException {
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;
-                try {
-                        repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
-                                .readEnvironment() // scan environment GIT_* variables
-                                .findGitDir() // scan up the file system tree
-                                .build();
-                } catch (IOException e) {
-                        LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
-                        throw e;
-                }
-                return repo;
+        try {
+            repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment() // scan environment GIT_* variables
+                    .findGitDir() // scan up the file system tree
+                    .build();
+        } catch (IOException e) {
+            LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
+            throw e;
+        }
+        return repo;
     }
-    
+
     protected Repository getRepository() {
         return repo;
     }
-    
+
     protected Git getGit() {
         return git;
     }
-    
+
     protected abstract int poll() throws Exception;
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
index d906d7a..dc64012 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitBranchConsumer.java
@@ -23,30 +23,29 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.git.GitEndpoint;
 import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.revwalk.RevCommit;
 
 public class GitBranchConsumer extends AbstractGitConsumer {
-	
-	private List used = new ArrayList();
 
-	public GitBranchConsumer(GitEndpoint endpoint, Processor processor) {
-		super(endpoint, processor);
-	}
+    private List used = new ArrayList();
 
-	@Override
-	protected int poll() throws Exception {
-		int count = 0;
-		List<Ref> call = getGit().branchList().call();
+    public GitBranchConsumer(GitEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        int count = 0;
+        List<Ref> call = getGit().branchList().call();
         for (Ref ref : call) {
-        	if (!used.contains(ref.getName())) {
-            Exchange e = getEndpoint().createExchange();
-            e.getOut().setBody(ref);
-            getProcessor().process(e);
-            used.add(ref.getName());
-            count++;
-        	}
+            if (!used.contains(ref.getName())) {
+                Exchange e = getEndpoint().createExchange();
+                e.getOut().setBody(ref);
+                getProcessor().process(e);
+                used.add(ref.getName());
+                count++;
+            }
         }
         return count;
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
index c837adc..6a4600e 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
@@ -25,27 +25,27 @@ import org.apache.camel.component.git.GitEndpoint;
 import org.eclipse.jgit.revwalk.RevCommit;
 
 public class GitCommitConsumer extends AbstractGitConsumer {
-	
-	private List used = new ArrayList();
 
-	public GitCommitConsumer(GitEndpoint endpoint, Processor processor) {
-		super(endpoint, processor);
-	}
+    private List used = new ArrayList();
 
-	@Override
-	protected int poll() throws Exception {
-		int count = 0;
-		Iterable<RevCommit> commits = getGit().log().all().call();
+    public GitCommitConsumer(GitEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        int count = 0;
+        Iterable<RevCommit> commits = getGit().log().all().call();
         for (RevCommit commit : commits) {
-        	if (!used.contains(commit.getId())) {
-            Exchange e = getEndpoint().createExchange();
-            e.getOut().setBody(commit);
-            getProcessor().process(e);
-            used.add(commit.getId());
-            count++;
-        	}
+            if (!used.contains(commit.getId())) {
+                Exchange e = getEndpoint().createExchange();
+                e.getOut().setBody(commit);
+                getProcessor().process(e);
+                used.add(commit.getId());
+                count++;
+            }
         }
         return count;
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
index ca063f3..88832b7 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
@@ -23,30 +23,29 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.component.git.GitEndpoint;
 import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.revwalk.RevCommit;
 
 public class GitTagConsumer extends AbstractGitConsumer {
-	
-	private List used = new ArrayList();
 
-	public GitTagConsumer(GitEndpoint endpoint, Processor processor) {
-		super(endpoint, processor);
-	}
+    private List used = new ArrayList();
 
-	@Override
-	protected int poll() throws Exception {
-		int count = 0;
-		List<Ref> call = getGit().tagList().call();
+    public GitTagConsumer(GitEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        int count = 0;
+        List<Ref> call = getGit().tagList().call();
         for (Ref ref : call) {
-        	if (!used.contains(ref.getName())) {
-            Exchange e = getEndpoint().createExchange();
-            e.getOut().setBody(ref);
-            getProcessor().process(e);
-            used.add(ref.getName());
-            count++;
-        	}
+            if (!used.contains(ref.getName())) {
+                Exchange e = getEndpoint().createExchange();
+                e.getOut().setBody(ref);
+                getProcessor().process(e);
+                used.add(ref.getName());
+                count++;
+            }
         }
         return count;
-	}
+    }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
index dbd9813..f5f07f2 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
@@ -18,18 +18,18 @@ package org.apache.camel.component.git.producer;
 
 public interface GitOperation {
 
-    public final static String CLONE_OPERATION = "clone";
-    public final static String INIT_OPERATION = "init";
-    public final static String ADD_OPERATION = "add";
-    public final static String REMOVE_OPERATION = "remove";
-    public final static String COMMIT_OPERATION = "commit";
-    public final static String COMMIT_ALL_OPERATION = "commitAll";
-    public final static String CREATE_BRANCH_OPERATION = "createBranch";
-    public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
-    public final static String CREATE_TAG_OPERATION = "createTag";
-    public final static String DELETE_TAG_OPERATION = "deleteTag";
-    public final static String STATUS_OPERATION = "status";
-    public final static String LOG_OPERATION = "log";
-    public final static String PUSH_OPERATION = "push";
-    public final static String PULL_OPERATION = "pull";
+    String CLONE_OPERATION = "clone";
+    String INIT_OPERATION = "init";
+    String ADD_OPERATION = "add";
+    String REMOVE_OPERATION = "remove";
+    String COMMIT_OPERATION = "commit";
+    String COMMIT_ALL_OPERATION = "commitAll";
+    String CREATE_BRANCH_OPERATION = "createBranch";
+    String DELETE_BRANCH_OPERATION = "deleteBranch";
+    String CREATE_TAG_OPERATION = "createTag";
+    String DELETE_TAG_OPERATION = "deleteTag";
+    String STATUS_OPERATION = "status";
+    String LOG_OPERATION = "log";
+    String PUSH_OPERATION = "push";
+    String PULL_OPERATION = "pull";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
index a397801..57a6e01 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -1,3 +1,19 @@
+/**
+ * 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.git.producer;
 
 import java.io.File;
@@ -15,221 +31,225 @@ import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.eclipse.jgit.transport.PushResult;
-import org.eclipse.jgit.transport.RefSpec;
 import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class GitProducer extends DefaultProducer{
+public class GitProducer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(GitProducer.class);
+
     private final GitEndpoint endpoint;
-    
+
     private Repository repo;
-    
+
     private Git git;
-    
-	public GitProducer(GitEndpoint endpoint) {
-		super(endpoint);
-		this.endpoint = endpoint;
-	}
-	
-	    @Override
-	    protected void doStart() throws Exception {
-	        super.doStart();
-	        this.repo = getLocalRepository();
-	        this.git = new Git(repo);
-	    }
-
-	    @Override
-	    protected void doStop() throws Exception {
-	        super.doStop();
-	        repo.close();
-	        git.close();
-	    }
-
-	@Override
-	public void process(Exchange exchange) throws Exception {
-        String operation;	
-	    if (ObjectHelper.isEmpty(endpoint.getOperation())) {
-	        operation = exchange.getIn().getHeader(GitConstants.GIT_OPERATION, String.class);
-	    } else {
-	    	operation = endpoint.getOperation();
-	    }
-    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
-    	}
-	    
-	    switch (operation) {
-	    case GitOperation.CLONE_OPERATION:
-	    	doClone(exchange, operation);
-	    	break;
-	    	
-	    case GitOperation.INIT_OPERATION:
-	    	doInit(exchange, operation);
-	    	break;
-
-	    case GitOperation.ADD_OPERATION:
-	    	doAdd(exchange, operation);
-	    	break;
-	    	
-            case GitOperation.REMOVE_OPERATION:
-                doRemove(exchange, operation);
-                break;
-	    	
-	    case GitOperation.COMMIT_OPERATION:
-	    	doCommit(exchange, operation);
-	    	break;
-	    
-            case GitOperation.COMMIT_ALL_OPERATION:
-                doCommitAll(exchange, operation);
-                break;
-                
-            case GitOperation.CREATE_BRANCH_OPERATION:
-                doCreateBranch(exchange, operation);
-                break;
-                
-            case GitOperation.DELETE_BRANCH_OPERATION:
-                doDeleteBranch(exchange, operation);
-                break;
-                
-            case GitOperation.STATUS_OPERATION:
-                doStatus(exchange, operation);
-                break;
-                
-            case GitOperation.LOG_OPERATION:
-                doLog(exchange, operation);
-                break;
-                
-            case GitOperation.PUSH_OPERATION:
-                doPush(exchange, operation);
-                break;
-                            
-            case GitOperation.PULL_OPERATION:
-                doPull(exchange, operation);
-                break;
-                
-            case GitOperation.CREATE_TAG_OPERATION:
-                doCreateTag(exchange, operation);
-                break;
+
+    public GitProducer(GitEndpoint endpoint) {
+        super(endpoint);
+        this.endpoint = endpoint;
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.repo = getLocalRepository();
+        this.git = new Git(repo);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        repo.close();
+        git.close();
+    }
+
+    @Override
+    public void process(Exchange exchange) throws Exception {
+        String operation;
+        if (ObjectHelper.isEmpty(endpoint.getOperation())) {
+            operation = exchange.getIn().getHeader(GitConstants.GIT_OPERATION, String.class);
+        } else {
+            operation = endpoint.getOperation();
+        }
+        if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+            throw new IllegalArgumentException("Local path must specified to execute " + operation);
+        }
+
+        switch (operation) {
+        
+        case GitOperation.CLONE_OPERATION:
+            doClone(exchange, operation);
+            break;
+
+        case GitOperation.INIT_OPERATION:
+            doInit(exchange, operation);
+            break;
+
+        case GitOperation.ADD_OPERATION:
+            doAdd(exchange, operation);
+            break;
+
+        case GitOperation.REMOVE_OPERATION:
+            doRemove(exchange, operation);
+            break;
+
+        case GitOperation.COMMIT_OPERATION:
+            doCommit(exchange, operation);
+            break;
+
+        case GitOperation.COMMIT_ALL_OPERATION:
+            doCommitAll(exchange, operation);
+            break;
+
+        case GitOperation.CREATE_BRANCH_OPERATION:
+            doCreateBranch(exchange, operation);
+            break;
+
+        case GitOperation.DELETE_BRANCH_OPERATION:
+            doDeleteBranch(exchange, operation);
+            break;
+
+        case GitOperation.STATUS_OPERATION:
+            doStatus(exchange, operation);
+            break;
+
+        case GitOperation.LOG_OPERATION:
+            doLog(exchange, operation);
+            break;
+
+        case GitOperation.PUSH_OPERATION:
+            doPush(exchange, operation);
+            break;
+
+        case GitOperation.PULL_OPERATION:
+            doPull(exchange, operation);
+            break;
+
+        case GitOperation.CREATE_TAG_OPERATION:
+            doCreateTag(exchange, operation);
+            break;
+
+        case GitOperation.DELETE_TAG_OPERATION:
+            doDeleteTag(exchange, operation);
+            break;
                 
-            case GitOperation.DELETE_TAG_OPERATION:
-                doDeleteTag(exchange, operation);
-                break;
-	    }
-	}
-	
+        default:
+            throw new IllegalArgumentException("Local path must specified to execute " + operation);
+        }
+    }
+
     protected void doClone(Exchange exchange, String operation) throws Exception {
-    	Git result = null;
-    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
-    	}
-    	try {
-    		File localRepo = new File(endpoint.getLocalPath(), "");
-    		if (!localRepo.exists()) {
-			   result = Git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(),"")).call();
-    		} else {
-               throw new IllegalArgumentException("The local repository directory already exists");
-    		}
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			throw e;
-		} finally {
-			result.close();
-		}
+        Git result = null;
+        if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+            throw new IllegalArgumentException("Local path must specified to execute " + operation);
+        }
+        try {
+            File localRepo = new File(endpoint.getLocalPath(), "");
+            if (!localRepo.exists()) {
+                result = Git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(), "")).call();
+            } else {
+                throw new IllegalArgumentException("The local repository directory already exists");
+            }
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        } finally {
+            result.close();
+        }
     }
 
     protected void doInit(Exchange exchange, String operation) throws Exception {
-    	Git result = null;
-    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
-    	}
-    	try {
-			result = Git.init().setDirectory(new File(endpoint.getLocalPath(),"")).setBare(false).call();
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			throw e;
-		} finally {
-			result.close();
-		}
+        Git result = null;
+        if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+            throw new IllegalArgumentException("Local path must specified to execute " + operation);
+        }
+        try {
+            result = Git.init().setDirectory(new File(endpoint.getLocalPath(), "")).setBare(false).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        } finally {
+            result.close();
+        }
     }
-    
+
     protected void doAdd(Exchange exchange, String operation) throws Exception {
-    	String fileName = null;
-    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
-    		fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
-    	} else {
-    		throw new IllegalArgumentException("File name must be specified to execute " + operation);
-    	}
-    	try {
-                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-                }
-			git.add().addFilepattern(fileName).call();
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			throw e;
-		}
+        String fileName = null;
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
+            fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
+        } else {
+            throw new IllegalArgumentException("File name must be specified to execute " + operation);
+        }
+        try {
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+            git.add().addFilepattern(fileName).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
     }
-    
+
     protected void doRemove(Exchange exchange, String operation) throws Exception {
         String fileName = null;
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
-                fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
+            fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
         } else {
-                throw new IllegalArgumentException("File name must be specified to execute " + operation);
+            throw new IllegalArgumentException("File name must be specified to execute " + operation);
         }
         try {
-                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-                }
-                        git.rm().addFilepattern(fileName).call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        throw e;
-                }
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+            git.rm().addFilepattern(fileName).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
     }
-    
+
     protected void doCommit(Exchange exchange, String operation) throws Exception {
-    	String commitMessage = null;
-    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
-    		commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
-    	} else {
-    		throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
-    	}
-    	try {
+        String commitMessage = null;
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
+            commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
+        } else {
+            throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
+        }
+        try {
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
             }
-    		git.commit().setMessage(commitMessage).call();
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			throw e;
-		}
+            git.commit().setMessage(commitMessage).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
     }
-    
+
     protected void doCommitAll(Exchange exchange, String operation) throws Exception {
         String commitMessage = null;
         if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
-                commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
+            commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
         } else {
-                throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
+            throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
         }
         try {
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
             }
-                git.commit().setAll(true).setMessage(commitMessage).call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        throw e;
-                }
+            git.commit().setAll(true).setMessage(commitMessage).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
     }
-    
+
     protected void doCreateBranch(Exchange exchange, String operation) throws Exception {
         if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
             throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
-        } 
+        }
         try {
             git.branchCreate().setName(endpoint.getBranchName()).call();
         } catch (Exception e) {
@@ -237,11 +257,11 @@ public class GitProducer extends DefaultProducer{
             throw e;
         }
     }
-    
+
     protected void doDeleteBranch(Exchange exchange, String operation) throws Exception {
         if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
             throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
-        } 
+        }
         try {
             git.branchDelete().setBranchNames(endpoint.getBranchName()).call();
         } catch (Exception e) {
@@ -249,83 +269,83 @@ public class GitProducer extends DefaultProducer{
             throw e;
         }
     }
-    
+
     protected void doStatus(Exchange exchange, String operation) throws Exception {
         Status status = null;
         try {
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
             }
-                status = git.status().call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        throw e;
-                }
+            status = git.status().call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
         exchange.getOut().setBody(status);
     }
-    
+
     protected void doLog(Exchange exchange, String operation) throws Exception {
         Iterable<RevCommit> revCommit = null;
         try {
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
             }
-                revCommit = git.log().call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        throw e;
-                }
+            revCommit = git.log().call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
         exchange.getOut().setBody(revCommit);
     }
-    
+
     protected void doPush(Exchange exchange, String operation) throws Exception {
         Iterable<PushResult> result = null;
         try {
             if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
                 throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
-            } 
+            }
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            } 
+            }
             if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
                 UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
                 result = git.push().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
             } else {
                 result = git.push().setRemote(endpoint.getRemotePath()).call();
             }
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        throw e;
-                }
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
         exchange.getOut().setBody(result);
     }
-    
+
     protected void doPull(Exchange exchange, String operation) throws Exception {
         PullResult result = null;
         try {
             if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
                 throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
-            } 
+            }
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            } 
+            }
             if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
                 UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
                 result = git.pull().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
             } else {
                 result = git.pull().setRemote(endpoint.getRemotePath()).call();
             }
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        throw e;
-                }
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
         exchange.getOut().setBody(result);
     }
-    
+
     protected void doCreateTag(Exchange exchange, String operation) throws Exception {
         if (ObjectHelper.isEmpty(endpoint.getTagName())) {
             throw new IllegalArgumentException("Tag Name must be specified to execute " + operation);
-        } 
+        }
         try {
             git.tag().setName(endpoint.getTagName()).call();
         } catch (Exception e) {
@@ -333,11 +353,11 @@ public class GitProducer extends DefaultProducer{
             throw e;
         }
     }
-    
+
     protected void doDeleteTag(Exchange exchange, String operation) throws Exception {
         if (ObjectHelper.isEmpty(endpoint.getTagName())) {
             throw new IllegalArgumentException("Tag Name must be specified to execute " + operation);
-        } 
+        }
         try {
             git.tagDelete().setTags(endpoint.getTagName()).call();
         } catch (Exception e) {
@@ -345,19 +365,18 @@ public class GitProducer extends DefaultProducer{
             throw e;
         }
     }
-    
-    private Repository getLocalRepository() throws IOException{
+
+    private Repository getLocalRepository() throws IOException {
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;
-		try {
-			repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
-			        .readEnvironment() // scan environment GIT_* variables
-			        .findGitDir() // scan up the file system tree
-			        .build();
-		} catch (IOException e) {
-			LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
-			throw e;
-		}
-		return repo;
+        try {
+            repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git")).readEnvironment() // scan environment GIT_* variables
+                    .findGitDir() // scan up the file system tree
+                    .build();
+        } catch (IOException e) {
+            LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
+            throw e;
+        }
+        return repo;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
index 2bde385..a36c746 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
@@ -37,7 +37,7 @@ public class GitConsumerTest extends GitTestSupport {
     @Test
     public void commitConsumerTest() throws Exception {
 
-    	Repository repository = getTestRepository();
+        Repository repository = getTestRepository();
         MockEndpoint added = getMockEndpoint("mock:result-commit");
         
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
index 212be8f..f45d503 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
@@ -36,14 +36,14 @@ public class GitProducerTest extends GitTestSupport {
     
     @Test
     public void cloneTest() throws Exception {
-        template.sendBody("direct:clone","");
+        template.sendBody("direct:clone", "");
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
     }
     
     @Test
     public void initTest() throws Exception {
-        template.sendBody("direct:init","");
+        template.sendBody("direct:init", "");
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
     }
@@ -51,8 +51,8 @@ public class GitProducerTest extends GitTestSupport {
     @Test
     public void addTest() throws Exception {
 
-    	Repository repository = getTestRepository();
-        
+        Repository repository = getTestRepository();
+       
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
         
@@ -124,7 +124,7 @@ public class GitProducerTest extends GitTestSupport {
     @Test
     public void commitTest() throws Exception {
 
-    	Repository repository = getTestRepository();
+        Repository repository = getTestRepository();
         
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
@@ -161,7 +161,7 @@ public class GitProducerTest extends GitTestSupport {
     @Test
     public void commitBranchTest() throws Exception {
 
-    	Repository repository = getTestRepository();
+        Repository repository = getTestRepository();
         
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
@@ -206,8 +206,12 @@ public class GitProducerTest extends GitTestSupport {
         logs = git.log().call();
         count = 0;
         for (RevCommit rev : logs) {
-        	if (count == 0) assertEquals(rev.getShortMessage(), commitMessageBranch);
-        	if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
+            if (count == 0) {
+                assertEquals(rev.getShortMessage(), commitMessageBranch);
+            }
+            if (count == 1) {
+                assertEquals(rev.getShortMessage(), commitMessage);
+            }
             count++;
         }
         assertEquals(count, 2);
@@ -306,8 +310,12 @@ public class GitProducerTest extends GitTestSupport {
         logs = git.log().call();
         count = 0;
         for (RevCommit rev : logs) {
-            if (count == 0) assertEquals(rev.getShortMessage(), commitMessageAll);
-            if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
+            if (count == 0) {
+                assertEquals(rev.getShortMessage(), commitMessageAll);
+            }
+            if (count == 1) {
+                assertEquals(rev.getShortMessage(), commitMessage);
+            }
             count++;
         }
         assertEquals(count, 2);
@@ -372,8 +380,12 @@ public class GitProducerTest extends GitTestSupport {
         logs = git.log().call();
         count = 0;
         for (RevCommit rev : logs) {
-            if (count == 0) assertEquals(rev.getShortMessage(), commitMessageAll);
-            if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
+            if (count == 0) {
+                assertEquals(rev.getShortMessage(), commitMessageAll);
+            }
+            if (count == 1) {
+                assertEquals(rev.getShortMessage(), commitMessage);
+            }
             count++;
         }
         assertEquals(count, 2);
@@ -667,8 +679,12 @@ public class GitProducerTest extends GitTestSupport {
         revCommits = template.requestBody("direct:log-branch", "", Iterable.class);
         int count = 0;
         for (RevCommit rev : revCommits) {
-            if (count == 0) assertEquals(rev.getShortMessage(), commitMessageAll);
-            if (count == 1) assertEquals(rev.getShortMessage(), commitMessage);
+            if (count == 0) {
+                assertEquals(rev.getShortMessage(), commitMessageAll);
+            }
+            if (count == 1) {
+                assertEquals(rev.getShortMessage(), commitMessage);
+            }
             count++;
         }
         

http://git-wip-us.apache.org/repos/asf/camel/blob/46535261/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
index 36c33bd..abdd7c9 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
@@ -75,7 +75,7 @@ public class GitRemoteProducerTest extends GitTestSupport {
                 from("direct:commit")
                         .to("git://" + gitLocalRepo + "?operation=commit");
                 from("direct:push")
-                        .to("git://" + gitLocalRepo + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx" );
+                        .to("git://" + gitLocalRepo + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx");
             } 
         };
     }


[09/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add Log operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add Log operation


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

Branch: refs/heads/master
Commit: e224e8eb5e118c041f6e7f35835e60f71b27198f
Parents: 903e88f
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:32 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:15 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitOperation.java       |   1 +
 .../apache/camel/component/git/GitProducer.java |  21 ++++
 .../github/producer/GitProducerTest.java        | 111 +++++++++++++++++++
 3 files changed, 133 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e224e8eb/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index 88e03de..df7bb0f 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -27,4 +27,5 @@ public interface GitOperation {
     public final static String CREATE_BRANCH_OPERATION = "createBranch";
     public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
     public final static String STATUS_OPERATION = "status";
+    public final static String LOG_OPERATION = "log";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e224e8eb/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index e7c2fbe..e931d54 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -9,6 +9,7 @@ import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.Status;
 import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -73,6 +74,10 @@ public class GitProducer extends DefaultProducer{
             case GitOperation.STATUS_OPERATION:
                 doStatus(exchange, operation, repo);
                 break;
+                
+            case GitOperation.LOG_OPERATION:
+                doLog(exchange, operation, repo);
+                break;
 	    }
 	    repo.close();
 	}
@@ -236,6 +241,22 @@ public class GitProducer extends DefaultProducer{
         exchange.getOut().setBody(status);
     }
     
+    protected void doLog(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        Iterable<RevCommit> revCommit = null;
+        try {
+            git = new Git(repo);
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+                revCommit = git.log().call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        e.printStackTrace();
+                }
+        exchange.getOut().setBody(revCommit);
+    }
+    
     private Repository getLocalRepository(){
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/e224e8eb/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index 73693cc..8ad0cb6 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -595,6 +595,113 @@ public class GitProducerTest extends CamelTestSupport {
         repository.close();
     }
     
+    @Test
+    public void logTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
+        for (RevCommit rev : revCommits) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+        }        
+        repository.close();
+    }
+    
+    @Test
+    public void logBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
+        for (RevCommit rev : revCommits) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+        }
+        
+        template.sendBody("direct:create-branch", "");
+        
+        Git git = new Git(repository);
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        
+        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAddDifferent.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        
+        revCommits = template.requestBody("direct:log-branch", "", Iterable.class);
+        int count = 0;
+        for (RevCommit rev : revCommits) {
+            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
@@ -628,6 +735,10 @@ public class GitProducerTest extends CamelTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=status");
                 from("direct:status-branch")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=status&branchName=" + BRANCH_TEST);
+                from("direct:log")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=log");
+                from("direct:log-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=log&branchName=" + BRANCH_TEST);
             } 
         };
     }


[07/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add commitAll operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add commitAll operation


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

Branch: refs/heads/master
Commit: d246776386ef65acb49bdf81d1e1f1688a80e587
Parents: 288d3bd
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:04 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:14 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitComponent.java       |   2 +-
 .../apache/camel/component/git/GitEndpoint.java |   7 +-
 .../camel/component/git/GitOperation.java       |   1 +
 .../apache/camel/component/git/GitProducer.java |  29 ++++-
 .../github/producer/GitProducerTest.java        | 116 ++++++++++++++++++-
 5 files changed, 142 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d2467763/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java
index 349e020..81a759c 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java
@@ -29,7 +29,7 @@ public class GitComponent extends DefaultComponent {
     protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
         GitEndpoint endpoint = new GitEndpoint(uri, this);
         setProperties(endpoint, parameters);
-        endpoint.setRemotePath(remaining);
+        endpoint.setLocalPath(remaining);
         return endpoint;
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d2467763/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index 3dd6cbb..612ee00 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -16,8 +16,6 @@
  */
 package org.apache.camel.component.git;
 
-import java.io.File;
-
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
@@ -26,11 +24,8 @@ import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.internal.storage.file.FileRepository;
-import org.eclipse.jgit.lib.Repository;
 
-@UriEndpoint(scheme = "git", title = "Git", syntax = "git:remotepath/branchname", label = "api,file")
+@UriEndpoint(scheme = "git", title = "Git", syntax = "git:localpath", label = "api,file")
 public class GitEndpoint extends DefaultEndpoint {
 
     @UriPath @Metadata(required = "true")

http://git-wip-us.apache.org/repos/asf/camel/blob/d2467763/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index 49109c6..4f588dd 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -22,4 +22,5 @@ public interface GitOperation {
     public final static String INIT_OPERATION = "init";
     public final static String ADD_OPERATION = "add";
     public final static String COMMIT_OPERATION = "commit";
+    public final static String COMMIT_ALL_OPERATION = "commitAll";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d2467763/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index 5ee7ee3..81e0d37 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -51,7 +51,11 @@ public class GitProducer extends DefaultProducer{
 	    	
 	    case GitOperation.COMMIT_OPERATION:
 	    	doCommit(exchange, operation, repo);
-	    	break;	
+	    	break;
+	    
+            case GitOperation.COMMIT_ALL_OPERATION:
+                doCommitAll(exchange, operation, repo);
+                break;
 	    }
 	    repo.close();
 	}
@@ -101,6 +105,9 @@ public class GitProducer extends DefaultProducer{
     	}
     	try {
     		git = new Git(repo);
+                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+                }
 			git.add().addFilepattern(fileName).call();
 		} catch (Exception e) {
 			LOG.error("There was an error in Git " + operation + " operation");
@@ -128,6 +135,26 @@ public class GitProducer extends DefaultProducer{
 		}
     }
     
+    protected void doCommitAll(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        String commitMessage = null;
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
+                commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
+        } else {
+                throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
+        }
+        try {
+            git = new Git(repo);
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+                git.commit().setAll(true).setMessage(commitMessage).call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        e.printStackTrace();
+                }
+    }
+    
     private Repository getLocalRepository(){
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/d2467763/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index f911648..1965f61 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -37,7 +37,9 @@ public class GitProducerTest extends CamelTestSupport {
 
 	private final static String GIT_LOCAL_REPO = "testRepo";
 	private final static String FILENAME_TO_ADD = "filetest.txt";
+	private final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
 	private final static String COMMIT_MESSAGE = "Test commit";
+        private final static String COMMIT_MESSAGE_ALL = "Test commit all";
 	private final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
 	private final static String BRANCH_TEST = "testBranch";
 	
@@ -186,21 +188,125 @@ public class GitProducerTest extends CamelTestSupport {
         repository.close();
     }
     
+    @Test
+    public void commitAllTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            count++;
+        }
+        assertEquals(count, 1);
+        repository.close();
+    }
+    
+    @Test
+    public void commitAllDifferentBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        Git git = new Git(repository);
+        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+        
+        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAdd1.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        logs = git.log().call();
+        count = 0;
+        for (RevCommit rev : logs) {
+            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 2);
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
             @Override
             public void configure() throws Exception {
                 from("direct:clone")
-                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=clone");
+                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
                 from("direct:init")
-                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=init");
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
                 from("direct:add")
-                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=add");
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                from("direct:add-on-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
                 from("direct:commit")
-                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=commit");
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
                 from("direct:commit-branch")
-                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=commit&branchName=" + BRANCH_TEST);
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
+                from("direct:commit-all")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("direct:commit-all-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
             } 
         };
     }


[06/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add createBranch operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add createBranch operation


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

Branch: refs/heads/master
Commit: a6057b59dd149ea3bc73c16ec9f34b1f14144a78
Parents: d246776
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:09 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:14 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitOperation.java       |  1 +
 .../apache/camel/component/git/GitProducer.java | 18 +++++++
 .../github/producer/GitProducerTest.java        | 50 +++++++++++++++++++-
 3 files changed, 67 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/a6057b59/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index 4f588dd..c12c33d 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -23,4 +23,5 @@ public interface GitOperation {
     public final static String ADD_OPERATION = "add";
     public final static String COMMIT_OPERATION = "commit";
     public final static String COMMIT_ALL_OPERATION = "commitAll";
+    public final static String CREATE_BRANCH_OPERATION = "createBranch";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/a6057b59/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index 81e0d37..1bd407a 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -56,6 +56,10 @@ public class GitProducer extends DefaultProducer{
             case GitOperation.COMMIT_ALL_OPERATION:
                 doCommitAll(exchange, operation, repo);
                 break;
+                
+            case GitOperation.CREATE_BRANCH_OPERATION:
+                doCreateBranch(exchange, operation, repo);
+                break;
 	    }
 	    repo.close();
 	}
@@ -155,6 +159,20 @@ public class GitProducer extends DefaultProducer{
                 }
     }
     
+    protected void doCreateBranch(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
+            throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
+        } 
+        try {
+            git = new Git(repo);
+            git.branchCreate().setName(endpoint.getBranchName()).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            e.printStackTrace();
+        }
+    }
+    
     private Repository getLocalRepository(){
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/a6057b59/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index 1965f61..c27139c 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -18,6 +18,7 @@ package org.apache.camel.component.github.producer;
 
 import java.io.File;
 import java.io.IOException;
+import java.util.List;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -28,6 +29,7 @@ import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.Status;
 import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
@@ -55,8 +57,8 @@ public class GitProducerTest extends CamelTestSupport {
     @Override
     public void tearDown() throws Exception {
     	super.tearDown();
-        File path = new File(GIT_LOCAL_REPO);
-        deleteDirectory(path);
+//        File path = new File(GIT_LOCAL_REPO);
+//        deleteDirectory(path);
     }
     
     @Test
@@ -286,6 +288,48 @@ public class GitProducerTest extends CamelTestSupport {
         repository.close();
     }
     
+    @Test
+    public void createBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-branch", "");
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
@@ -307,6 +351,8 @@ public class GitProducerTest extends CamelTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
                 from("direct:commit-all-branch")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
+                from("direct:create-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
             } 
         };
     }


[08/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add commit consumer example

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add commit consumer example


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

Branch: refs/heads/master
Commit: 8205bbef8defa20e1be90dd8ce5c9bab1b88b1b2
Parents: f3731ed
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:45 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:15 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/git/GitConsumer.java |  65 ++++++++++
 .../apache/camel/component/git/GitEndpoint.java |   5 +-
 .../github/consumer/GitConsumerTest.java        | 126 +++++++++++++++++++
 .../github/producer/GitTestSupport.java         |   2 +
 4 files changed, 195 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8205bbef/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java
new file mode 100644
index 0000000..ac3a5f4
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java
@@ -0,0 +1,65 @@
+package org.apache.camel.component.git;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+
+public class GitConsumer extends ScheduledPollConsumer {
+	
+	private GitEndpoint endpoint;
+	
+	private Repository repository;
+	
+	private Git git;
+	
+	private List used;
+
+	public GitConsumer(GitEndpoint endpoint, Processor processor) {
+		super(endpoint, processor);
+		this.endpoint = endpoint;
+		this.repository = getLocalRepository();
+		this.git = new Git(repository);
+		this.used = new ArrayList();
+	}
+
+	@Override
+	protected int poll() throws Exception {
+		int count = 0;
+		Iterable<RevCommit> commits = git.log().all().call();
+        for (RevCommit commit : commits) {
+        	if (!used.contains(commit.getId())) {
+            Exchange e = getEndpoint().createExchange();
+            e.getOut().setBody(commit.getShortMessage());
+            getProcessor().process(e);
+            used.add(commit.getId());
+            count++;
+        	}
+        }
+        return count;
+	}
+	
+    private Repository getLocalRepository(){
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = null;
+		try {
+			repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
+			        .readEnvironment() // scan environment GIT_* variables
+			        .findGitDir() // scan up the file system tree
+			        .build();
+		} catch (IOException e) {
+			//LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
+			e.printStackTrace();
+		}
+		return repo;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8205bbef/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index cbaed51..de09f95 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -25,7 +25,7 @@ import org.apache.camel.spi.UriEndpoint;
 import org.apache.camel.spi.UriParam;
 import org.apache.camel.spi.UriPath;
 
-@UriEndpoint(scheme = "git", title = "Git", syntax = "git:localpath", label = "api,file")
+@UriEndpoint(scheme = "git", title = "Git", syntax = "git://localpath", label = "api,file")
 public class GitEndpoint extends DefaultEndpoint {
 
     @UriPath @Metadata(required = "true")
@@ -52,8 +52,7 @@ public class GitEndpoint extends DefaultEndpoint {
 
 	@Override
 	public Consumer createConsumer(Processor processor) throws Exception {
-		// TODO Auto-generated method stub
-		return null;
+        return new GitConsumer(this, processor);
 	}
 
 	@Override

http://git-wip-us.apache.org/repos/asf/camel/blob/8205bbef/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
new file mode 100644
index 0000000..6071d23
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
@@ -0,0 +1,126 @@
+/**
+ * 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 java.io.File;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.git.GitConstants;
+import org.apache.camel.component.github.producer.GitTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.junit.Test;
+
+public class GitConsumerTest extends GitTestSupport {
+    
+    @Test
+    public void commitTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        MockEndpoint added = getMockEndpoint("mock:result");
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAdd1.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, "Test test Commit");
+            }
+        });
+        logs  = new Git(repository).log()
+                .call();
+        count = 0;
+        for (RevCommit rev : logs) {
+            count++;
+        }
+        assertEquals(count, 2);
+        
+        Thread.sleep(1 * 5000);
+        Exchange ex1 = added.getExchanges().get(0);
+        Exchange ex2 = added.getExchanges().get(1);
+        assertEquals(COMMIT_MESSAGE, ex2.getOut().getBody());
+        assertEquals("Test test Commit", ex1.getOut().getBody());
+        repository.close();
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {            
+            @Override
+            public void configure() throws Exception {
+                from("direct:clone")
+                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
+                from("direct:init")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
+                from("direct:add")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                from("direct:commit")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("git://" + GIT_LOCAL_REPO)
+                        .to("mock:result");
+            } 
+        };
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/camel/blob/8205bbef/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
index 0aa3946..7c15386 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
@@ -19,6 +19,8 @@ package org.apache.camel.component.github.producer;
 import java.io.File;
 import java.io.IOException;
 
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.errors.GitAPIException;


[13/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add tag consumer

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add tag consumer


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

Branch: refs/heads/master
Commit: 828dc8b3bd49352398310fa8a42c9420e28102cf
Parents: 8239d6f
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:56 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:15 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/git/GitEndpoint.java |   2 +
 .../git/consumer/AbstractGitConsumer.java       |  16 +
 .../git/consumer/GitCommitConsumer.java         |  21 +-
 .../component/git/consumer/GitTagConsumer.java  |  52 ++
 .../camel/component/git/consumer/GitType.java   |   2 +-
 .../component/git/consumer/GitConsumerTest.java | 140 ++++
 .../component/git/producer/GitProducerTest.java | 724 +++++++++++++++++++
 .../git/producer/GitRemoteProducerTest.java     |  91 +++
 .../component/git/producer/GitTestSupport.java  |  88 +++
 .../github/consumer/GitConsumerTest.java        | 126 ----
 .../github/producer/GitProducerTest.java        | 724 -------------------
 .../github/producer/GitRemoteProducerTest.java  |  91 ---
 .../github/producer/GitTestSupport.java         |  88 ---
 13 files changed, 1132 insertions(+), 1033 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index 247b60d..1b06092 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -20,6 +20,7 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.component.git.consumer.GitCommitConsumer;
+import org.apache.camel.component.git.consumer.GitTagConsumer;
 import org.apache.camel.component.git.consumer.GitType;
 import org.apache.camel.component.git.producer.GitProducer;
 import org.apache.camel.impl.DefaultEndpoint;
@@ -58,6 +59,7 @@ public class GitEndpoint extends DefaultEndpoint {
 	@Override
 	public Consumer createConsumer(Processor processor) throws Exception {
 	    if (type == GitType.COMMIT) return new GitCommitConsumer(this, processor);
+	    else if (type == GitType.TAG) return new GitTagConsumer(this, processor);
 	    else throw new IllegalArgumentException("Cannot create producer with type " + type);
 	}
 

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
index 5ceec5d..6e93849 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
@@ -1,3 +1,19 @@
+/**
+ * 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.git.consumer;
 
 import java.io.File;

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
index d289c26..c837adc 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
@@ -1,3 +1,19 @@
+/**
+ * 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.git.consumer;
 
 import java.util.ArrayList;
@@ -10,11 +26,10 @@ import org.eclipse.jgit.revwalk.RevCommit;
 
 public class GitCommitConsumer extends AbstractGitConsumer {
 	
-	private List used;
+	private List used = new ArrayList();
 
 	public GitCommitConsumer(GitEndpoint endpoint, Processor processor) {
 		super(endpoint, processor);
-		this.used = new ArrayList();
 	}
 
 	@Override
@@ -24,7 +39,7 @@ public class GitCommitConsumer extends AbstractGitConsumer {
         for (RevCommit commit : commits) {
         	if (!used.contains(commit.getId())) {
             Exchange e = getEndpoint().createExchange();
-            e.getOut().setBody(commit.getShortMessage());
+            e.getOut().setBody(commit);
             getProcessor().process(e);
             used.add(commit.getId());
             count++;

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
new file mode 100644
index 0000000..ca063f3
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitTagConsumer.java
@@ -0,0 +1,52 @@
+/**
+ * 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.git.consumer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.git.GitEndpoint;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+public class GitTagConsumer extends AbstractGitConsumer {
+	
+	private List used = new ArrayList();
+
+	public GitTagConsumer(GitEndpoint endpoint, Processor processor) {
+		super(endpoint, processor);
+	}
+
+	@Override
+	protected int poll() throws Exception {
+		int count = 0;
+		List<Ref> call = getGit().tagList().call();
+        for (Ref ref : call) {
+        	if (!used.contains(ref.getName())) {
+            Exchange e = getEndpoint().createExchange();
+            e.getOut().setBody(ref);
+            getProcessor().process(e);
+            used.add(ref.getName());
+            count++;
+        	}
+        }
+        return count;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
index af3729e..4015445 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
@@ -18,6 +18,6 @@ package org.apache.camel.component.git.consumer;
 
 public enum GitType {
 
-    COMMIT
+    COMMIT, TAG
 
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
new file mode 100644
index 0000000..21273e2
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
@@ -0,0 +1,140 @@
+/**
+ * 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.git.consumer;
+
+import java.io.File;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.git.GitConstants;
+import org.apache.camel.component.git.producer.GitTestSupport;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.junit.Test;
+
+public class GitConsumerTest extends GitTestSupport {
+    
+    @Test
+    public void commitConsumerTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        MockEndpoint added = getMockEndpoint("mock:result");
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAdd1.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, "Test test Commit");
+            }
+        });
+        logs  = new Git(repository).log()
+                .call();
+        count = 0;
+        for (RevCommit rev : logs) {
+            count++;
+        }
+        assertEquals(count, 2);
+        
+        Thread.sleep(1 * 5000);
+        Exchange ex1 = added.getExchanges().get(0);
+        Exchange ex2 = added.getExchanges().get(1);
+        assertEquals(COMMIT_MESSAGE, ex2.getOut().getBody(RevCommit.class).getShortMessage());
+        assertEquals("Test test Commit", ex1.getOut().getBody(RevCommit.class).getShortMessage());
+        repository.close();
+    }
+    
+    @Test
+    public void tagConsumerTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        MockEndpoint added = getMockEndpoint("mock:result");
+        
+        Thread.sleep(1 * 5000);
+        assertEquals(added.getExchanges().size(), 0);
+        repository.close();
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {            
+            @Override
+            public void configure() throws Exception {
+                from("direct:clone")
+                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
+                from("direct:init")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
+                from("direct:add")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                from("direct:commit")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("git://" + GIT_LOCAL_REPO + "?type=commit")
+                        .to("mock:result");
+                from("git://" + GIT_LOCAL_REPO + "?type=tag")
+                        .to("mock:result");
+            } 
+        };
+    }
+
+}
+

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
new file mode 100755
index 0000000..5a9c7f3
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
@@ -0,0 +1,724 @@
+/**
+ * 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.git.producer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.git.GitConstants;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.PushResult;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class GitProducerTest extends GitTestSupport {
+    
+    @Test
+    public void cloneTest() throws Exception {
+        template.sendBody("direct:clone","");
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+    }
+    
+    @Test
+    public void initTest() throws Exception {
+        template.sendBody("direct:init","");
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+    }
+    
+    @Test
+    public void addTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        repository.close();
+    }
+    
+    @Test
+    public void removeTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:remove", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        status = new Git(repository).status().call();
+
+        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        repository.close();
+    }
+    
+    @Test
+    public void commitTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        repository.close();
+    }
+    
+    @Test
+    public void commitBranchTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        Git git = new Git(repository);
+        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+        
+        template.send("direct:commit-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_BRANCH);
+            }
+        });
+        logs = git.log().call();
+        count = 0;
+        for (RevCommit rev : logs) {
+        	if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_BRANCH);
+        	if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 2);
+        repository.close();
+    }
+    
+
+    
+    @Test
+    public void commitAllTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            count++;
+        }
+        assertEquals(count, 1);
+        repository.close();
+    }
+    
+    @Test
+    public void commitAllDifferentBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        Git git = new Git(repository);
+        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+        
+        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAdd1.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        logs = git.log().call();
+        count = 0;
+        for (RevCommit rev : logs) {
+            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 2);
+        repository.close();
+    }
+    
+    @Test
+    public void removeFileBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        Git git = new Git(repository);
+        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+        
+        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAdd1.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        logs = git.log().call();
+        count = 0;
+        for (RevCommit rev : logs) {
+            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 2);
+        
+        template.send("direct:remove-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        
+        git = new Git(repository);
+        git.checkout().setCreateBranch(false).setName(BRANCH_TEST).call();
+        
+        status = git.status().call();
+        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        repository.close();
+    }
+    
+    @Test
+    public void createBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-branch", "");
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        repository.close();
+    }
+    
+    @Test
+    public void deleteBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-branch", "");
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        
+        template.sendBody("direct:delete-branch", "");
+        
+        ref = git.branchList().call();
+        branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, false);
+        repository.close();
+    }
+    
+    @Test
+    public void statusTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        repository.close();
+    }
+    
+    @Test
+    public void statusBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        template.sendBody("direct:create-branch", "");
+        
+        Git git = new Git(repository);
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        
+        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAddDifferent.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        status = template.requestBody("direct:status-branch", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
+        
+        repository.close();
+    }
+    
+    @Test
+    public void logTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
+        for (RevCommit rev : revCommits) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+        }        
+        repository.close();
+    }
+    
+    @Test
+    public void logBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = template.requestBody("direct:status", "", Status.class);
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
+        for (RevCommit rev : revCommits) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+        }
+        
+        template.sendBody("direct:create-branch", "");
+        
+        Git git = new Git(repository);
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        
+        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAddDifferent.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        
+        revCommits = template.requestBody("direct:log-branch", "", Iterable.class);
+        int count = 0;
+        for (RevCommit rev : revCommits) {
+            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        
+        repository.close();
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {            
+            @Override
+            public void configure() throws Exception {
+                from("direct:clone")
+                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
+                from("direct:init")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
+                from("direct:add")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                from("direct:remove")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=rm");
+                from("direct:add-on-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
+                from("direct:remove-on-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
+                from("direct:commit")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("direct:commit-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
+                from("direct:commit-all")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("direct:commit-all-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
+                from("direct:create-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
+                from("direct:delete-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=deleteBranch&branchName=" + BRANCH_TEST);
+                from("direct:status")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=status");
+                from("direct:status-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=status&branchName=" + BRANCH_TEST);
+                from("direct:log")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=log");
+                from("direct:log-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=log&branchName=" + BRANCH_TEST);
+            } 
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
new file mode 100644
index 0000000..a82eba7
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
@@ -0,0 +1,91 @@
+/**
+ * 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.git.producer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.git.GitConstants;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.PullResult;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.PushResult;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class GitRemoteProducerTest extends GitTestSupport {
+    
+    @Ignore("Require a remote git repository")
+    @Test
+    public void pushTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+
+        Iterable<PushResult> result = template.requestBody("direct:push", "", Iterable.class);
+        
+        repository.close();
+    }
+   
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {            
+            @Override
+            public void configure() throws Exception {
+                from("direct:add")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                from("direct:commit")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("direct:push")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx" );
+            } 
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java
new file mode 100644
index 0000000..f0cfacb
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java
@@ -0,0 +1,88 @@
+/**
+ * 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.git.producer;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+
+public class GitTestSupport extends CamelTestSupport {
+
+    public final static String GIT_LOCAL_REPO = "testRepo";
+
+    public final static String FILENAME_TO_ADD = "filetest.txt";
+
+    public final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
+
+    public final static String COMMIT_MESSAGE = "Test commit";
+
+    public final static String COMMIT_MESSAGE_ALL = "Test commit all";
+
+    public final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
+
+    public final static String BRANCH_TEST = "testBranch";
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
+        localPath.delete();
+        File path = new File(GIT_LOCAL_REPO);
+        path.deleteOnExit();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        File path = new File(GIT_LOCAL_REPO);
+        deleteDirectory(path);
+    }
+      
+    protected Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
+        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
+        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
+        // now open the resulting repository with a FileRepositoryBuilder
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = builder.setGitDir(gitRepo)
+                .readEnvironment() // scan environment GIT_* variables
+                .findGitDir() // scan up the file system tree
+                .build();
+        return repo;
+    }
+    
+    static public boolean deleteDirectory(File path) {
+        if( path.exists() ) {
+          File[] files = path.listFiles();
+          for(int i=0; i<files.length; i++) {
+             if(files[i].isDirectory()) {
+               deleteDirectory(files[i]);
+             }
+             else {
+               files[i].delete();
+             }
+          }
+        }
+        return( path.delete() );
+      }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
deleted file mode 100644
index d45591b..0000000
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/**
- * 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 java.io.File;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.git.GitConstants;
-import org.apache.camel.component.github.producer.GitTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.junit.Test;
-
-public class GitConsumerTest extends GitTestSupport {
-    
-    @Test
-    public void commitConsumerTest() throws Exception {
-
-    	Repository repository = getTestRepository();
-        MockEndpoint added = getMockEndpoint("mock:result");
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        Iterable<RevCommit> logs = new Git(repository).log()
-                .call();
-        int count = 0;
-        for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 1);
-        
-        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
-        fileToAdd1.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
-            }
-        });
-        
-        status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, "Test test Commit");
-            }
-        });
-        logs  = new Git(repository).log()
-                .call();
-        count = 0;
-        for (RevCommit rev : logs) {
-            count++;
-        }
-        assertEquals(count, 2);
-        
-        Thread.sleep(1 * 5000);
-        Exchange ex1 = added.getExchanges().get(0);
-        Exchange ex2 = added.getExchanges().get(1);
-        assertEquals(COMMIT_MESSAGE, ex2.getOut().getBody());
-        assertEquals("Test test Commit", ex1.getOut().getBody());
-        repository.close();
-    }
-    
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {            
-            @Override
-            public void configure() throws Exception {
-                from("direct:clone")
-                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
-                from("direct:init")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
-                from("direct:add")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
-                from("direct:commit")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
-                from("git://" + GIT_LOCAL_REPO + "?type=commit")
-                        .to("mock:result");
-            } 
-        };
-    }
-
-}
-

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
deleted file mode 100755
index cee4011..0000000
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ /dev/null
@@ -1,724 +0,0 @@
-/**
- * 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.producer;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.git.GitConstants;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-import org.eclipse.jgit.transport.PushResult;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class GitProducerTest extends GitTestSupport {
-    
-    @Test
-    public void cloneTest() throws Exception {
-        template.sendBody("direct:clone","");
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-    }
-    
-    @Test
-    public void initTest() throws Exception {
-        template.sendBody("direct:init","");
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-    }
-    
-    @Test
-    public void addTest() throws Exception {
-
-    	Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        repository.close();
-    }
-    
-    @Test
-    public void removeTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:remove", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        Iterable<RevCommit> logs = new Git(repository).log()
-                .call();
-        int count = 0;
-        for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 1);
-        
-        status = new Git(repository).status().call();
-
-        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        repository.close();
-    }
-    
-    @Test
-    public void commitTest() throws Exception {
-
-    	Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        Iterable<RevCommit> logs = new Git(repository).log()
-                .call();
-        int count = 0;
-        for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 1);
-        repository.close();
-    }
-    
-    @Test
-    public void commitBranchTest() throws Exception {
-
-    	Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        Iterable<RevCommit> logs = new Git(repository).log()
-                .call();
-        int count = 0;
-        for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 1);
-        
-        Git git = new Git(repository);
-        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
-        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
-        
-        template.send("direct:commit-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_BRANCH);
-            }
-        });
-        logs = git.log().call();
-        count = 0;
-        for (RevCommit rev : logs) {
-        	if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_BRANCH);
-        	if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 2);
-        repository.close();
-    }
-    
-
-    
-    @Test
-    public void commitAllTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        
-        template.send("direct:commit-all", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
-            }
-        });
-        Iterable<RevCommit> logs = new Git(repository).log()
-                .call();
-        int count = 0;
-        for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
-            count++;
-        }
-        assertEquals(count, 1);
-        repository.close();
-    }
-    
-    @Test
-    public void commitAllDifferentBranchTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        Iterable<RevCommit> logs = new Git(repository).log()
-                .call();
-        int count = 0;
-        for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 1);
-        
-        Git git = new Git(repository);
-        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
-        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
-        
-        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
-        fileToAdd1.createNewFile();
-        
-        template.send("direct:add-on-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
-            }
-        });
-        
-        template.send("direct:commit-all-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
-            }
-        });
-        logs = git.log().call();
-        count = 0;
-        for (RevCommit rev : logs) {
-            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
-            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 2);
-        repository.close();
-    }
-    
-    @Test
-    public void removeFileBranchTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        Iterable<RevCommit> logs = new Git(repository).log()
-                .call();
-        int count = 0;
-        for (RevCommit rev : logs) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 1);
-        
-        Git git = new Git(repository);
-        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
-        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
-        
-        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
-        fileToAdd1.createNewFile();
-        
-        template.send("direct:add-on-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
-            }
-        });
-        
-        template.send("direct:commit-all-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
-            }
-        });
-        logs = git.log().call();
-        count = 0;
-        for (RevCommit rev : logs) {
-            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
-            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        assertEquals(count, 2);
-        
-        template.send("direct:remove-on-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        
-        git = new Git(repository);
-        git.checkout().setCreateBranch(false).setName(BRANCH_TEST).call();
-        
-        status = git.status().call();
-        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        repository.close();
-    }
-    
-    @Test
-    public void createBranchTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        
-        Git git = new Git(repository);
-        
-        template.sendBody("direct:create-branch", "");
-        
-        List<Ref> ref = git.branchList().call();
-        boolean branchCreated = false;
-        for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
-                branchCreated = true;
-            }
-        }
-        assertEquals(branchCreated, true);
-        repository.close();
-    }
-    
-    @Test
-    public void deleteBranchTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        
-        Git git = new Git(repository);
-        
-        template.sendBody("direct:create-branch", "");
-        
-        List<Ref> ref = git.branchList().call();
-        boolean branchCreated = false;
-        for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
-                branchCreated = true;
-            }
-        }
-        assertEquals(branchCreated, true);
-        
-        template.sendBody("direct:delete-branch", "");
-        
-        ref = git.branchList().call();
-        branchCreated = false;
-        for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
-                branchCreated = true;
-            }
-        }
-        assertEquals(branchCreated, false);
-        repository.close();
-    }
-    
-    @Test
-    public void statusTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        repository.close();
-    }
-    
-    @Test
-    public void statusBranchTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        
-        template.sendBody("direct:create-branch", "");
-        
-        Git git = new Git(repository);
-        
-        List<Ref> ref = git.branchList().call();
-        boolean branchCreated = false;
-        for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
-                branchCreated = true;
-            }
-        }
-        assertEquals(branchCreated, true);
-        
-        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
-        fileToAddDifferent.createNewFile();
-        
-        template.send("direct:add-on-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
-            }
-        });
-        
-        status = template.requestBody("direct:status-branch", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_BRANCH_TO_ADD));
-        
-        repository.close();
-    }
-    
-    @Test
-    public void logTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        
-        Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
-        for (RevCommit rev : revCommits) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-        }        
-        repository.close();
-    }
-    
-    @Test
-    public void logBranchTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = template.requestBody("direct:status", "", Status.class);
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-        
-        Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
-        for (RevCommit rev : revCommits) {
-            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-        }
-        
-        template.sendBody("direct:create-branch", "");
-        
-        Git git = new Git(repository);
-        
-        List<Ref> ref = git.branchList().call();
-        boolean branchCreated = false;
-        for (Ref refInternal : ref) {
-            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
-                branchCreated = true;
-            }
-        }
-        assertEquals(branchCreated, true);
-        
-        File fileToAddDifferent = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
-        fileToAddDifferent.createNewFile();
-        
-        template.send("direct:add-on-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
-            }
-        });
-        
-        template.send("direct:commit-all-branch", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
-            }
-        });
-        
-        revCommits = template.requestBody("direct:log-branch", "", Iterable.class);
-        int count = 0;
-        for (RevCommit rev : revCommits) {
-            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
-            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
-            count++;
-        }
-        
-        repository.close();
-    }
-    
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {            
-            @Override
-            public void configure() throws Exception {
-                from("direct:clone")
-                        .to("git://" + GIT_LOCAL_REPO + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone");
-                from("direct:init")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=init");
-                from("direct:add")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
-                from("direct:remove")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=rm");
-                from("direct:add-on-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
-                from("direct:remove-on-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
-                from("direct:commit")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
-                from("direct:commit-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
-                from("direct:commit-all")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
-                from("direct:commit-all-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
-                from("direct:create-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
-                from("direct:delete-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=deleteBranch&branchName=" + BRANCH_TEST);
-                from("direct:status")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=status");
-                from("direct:status-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=status&branchName=" + BRANCH_TEST);
-                from("direct:log")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=log");
-                from("direct:log-branch")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=log&branchName=" + BRANCH_TEST);
-            } 
-        };
-    }
-
-}


[22/23] camel git commit: CAMEL-7982: Add camel-git to kit

Posted by ac...@apache.org.
CAMEL-7982: Add camel-git to kit


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

Branch: refs/heads/master
Commit: 382f75654322b34ef05ad60a08af2144be17230d
Parents: 3d15443
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:34 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:17 2015 +0200

----------------------------------------------------------------------
 apache-camel/pom.xml                             | 6 +++++-
 apache-camel/src/main/descriptors/common-bin.xml | 1 +
 components/pom.xml                               | 1 +
 parent/pom.xml                                   | 5 +++++
 4 files changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/382f7565/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index 3b4ef6b..7dc0bb4 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -251,7 +251,11 @@
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-geocoder</artifactId>
     </dependency>
-     <dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-git</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-github</artifactId>
     </dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/382f7565/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index 0a37060..b2eb8db 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -76,6 +76,7 @@
         <include>org.apache.camel:camel-gae</include>
         <include>org.apache.camel:camel-ganglia</include>
         <include>org.apache.camel:camel-geocoder</include>
+        <include>org.apache.camel:camel-git</include>
         <include>org.apache.camel:camel-github</include>
         <include>org.apache.camel:camel-google-calendar</include>
         <include>org.apache.camel:camel-google-drive</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/382f7565/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 298381d..ad84bdf 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -104,6 +104,7 @@
     <module>camel-gae</module>
     <module>camel-ganglia</module>
     <module>camel-geocoder</module>
+    <module>camel-git</module>
     <module>camel-github</module>
     <module>camel-google-calendar</module>
     <module>camel-google-drive</module>

http://git-wip-us.apache.org/repos/asf/camel/blob/382f7565/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 44dce47..08354d0 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -869,6 +869,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-git</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-github</artifactId>
         <version>${project.version}</version>
       </dependency>


[04/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add deleteBranch operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add deleteBranch operation


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

Branch: refs/heads/master
Commit: 9df0710dff3e4a928bd42a23ee54ea05beb17625
Parents: a6057b5
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:15 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:14 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/git/GitEndpoint.java |  4 +-
 .../camel/component/git/GitOperation.java       |  1 +
 .../apache/camel/component/git/GitProducer.java | 18 ++++++
 .../github/producer/GitProducerTest.java        | 59 +++++++++++++++++++-
 4 files changed, 78 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9df0710d/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index 612ee00..cbaed51 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -29,7 +29,7 @@ import org.apache.camel.spi.UriPath;
 public class GitEndpoint extends DefaultEndpoint {
 
     @UriPath @Metadata(required = "true")
-    private String remotePath;
+    private String localPath;
     @UriPath(label = "consumer")
     private String branchName;
     @UriParam
@@ -37,7 +37,7 @@ public class GitEndpoint extends DefaultEndpoint {
     @UriParam
     private String password;
     @UriParam
-    private String localPath;
+    private String remotePath;
     @UriParam
     private String operation;
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9df0710d/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index c12c33d..f70728b 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -24,4 +24,5 @@ public interface GitOperation {
     public final static String COMMIT_OPERATION = "commit";
     public final static String COMMIT_ALL_OPERATION = "commitAll";
     public final static String CREATE_BRANCH_OPERATION = "createBranch";
+    public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/9df0710d/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index 1bd407a..1e0d3f5 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -60,6 +60,10 @@ public class GitProducer extends DefaultProducer{
             case GitOperation.CREATE_BRANCH_OPERATION:
                 doCreateBranch(exchange, operation, repo);
                 break;
+                
+            case GitOperation.DELETE_BRANCH_OPERATION:
+                doDeleteBranch(exchange, operation, repo);
+                break;
 	    }
 	    repo.close();
 	}
@@ -173,6 +177,20 @@ public class GitProducer extends DefaultProducer{
         }
     }
     
+    protected void doDeleteBranch(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
+            throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
+        } 
+        try {
+            git = new Git(repo);
+            git.branchDelete().setBranchNames(endpoint.getBranchName()).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            e.printStackTrace();
+        }
+    }
+    
     private Repository getLocalRepository(){
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/9df0710d/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index c27139c..7122846 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -57,8 +57,8 @@ public class GitProducerTest extends CamelTestSupport {
     @Override
     public void tearDown() throws Exception {
     	super.tearDown();
-//        File path = new File(GIT_LOCAL_REPO);
-//        deleteDirectory(path);
+        File path = new File(GIT_LOCAL_REPO);
+        deleteDirectory(path);
     }
     
     @Test
@@ -330,6 +330,59 @@ public class GitProducerTest extends CamelTestSupport {
         repository.close();
     }
     
+    @Test
+    public void deleteBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-branch", "");
+        
+        List<Ref> ref = git.branchList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        
+        template.sendBody("direct:delete-branch", "");
+        
+        ref = git.branchList().call();
+        branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/heads/" + BRANCH_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, false);
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
@@ -353,6 +406,8 @@ public class GitProducerTest extends CamelTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=commit&branchName=" + BRANCH_TEST);
                 from("direct:create-branch")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=createBranch&branchName=" + BRANCH_TEST);
+                from("direct:delete-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=deleteBranch&branchName=" + BRANCH_TEST);
             } 
         };
     }


[19/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add createTag operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add createTag operation


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

Branch: refs/heads/master
Commit: bc9580640cb2a15709041f49ea105d28a3968387
Parents: 828dc8b
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:02 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:16 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/git/GitEndpoint.java | 11 +++
 .../component/git/producer/GitOperation.java    |  1 +
 .../component/git/producer/GitProducer.java     | 16 ++++
 .../camel/component/git/GitTestSupport.java     | 90 ++++++++++++++++++++
 .../component/git/consumer/GitConsumerTest.java |  3 +-
 .../component/git/producer/GitProducerTest.java | 51 +++++++++--
 .../git/producer/GitRemoteProducerTest.java     | 10 +--
 .../component/git/producer/GitTestSupport.java  | 88 -------------------
 8 files changed, 165 insertions(+), 105 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index 1b06092..79673e8 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -36,6 +36,8 @@ public class GitEndpoint extends DefaultEndpoint {
     private String localPath;
     @UriPath
     private String branchName;
+    @UriPath
+    private String tagName;
     @UriPath(label = "consumer")
     private GitType type;
     @UriParam
@@ -124,4 +126,13 @@ public class GitEndpoint extends DefaultEndpoint {
     public void setType(GitType type) {
         this.type = type;
     }
+
+    public String getTagName() {
+        return tagName;
+    }
+
+    public void setTagName(String tagName) {
+        this.tagName = tagName;
+    }
+   
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
index de03fc7..d45c743 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
@@ -26,6 +26,7 @@ public interface GitOperation {
     public final static String COMMIT_ALL_OPERATION = "commitAll";
     public final static String CREATE_BRANCH_OPERATION = "createBranch";
     public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
+    public final static String CREATE_TAG_OPERATION = "createTag";
     public final static String STATUS_OPERATION = "status";
     public final static String LOG_OPERATION = "log";
     public final static String PUSH_OPERATION = "push";

http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
index b9d88fe..f6eccf4 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -108,6 +108,10 @@ public class GitProducer extends DefaultProducer{
             case GitOperation.PULL_OPERATION:
                 doPull(exchange, operation);
                 break;
+                
+            case GitOperation.CREATE_TAG_OPERATION:
+                doCreateTag(exchange, operation);
+                break;
 	    }
 	}
 	
@@ -314,6 +318,18 @@ public class GitProducer extends DefaultProducer{
         exchange.getOut().setBody(result);
     }
     
+    protected void doCreateTag(Exchange exchange, String operation) throws Exception {
+        if (ObjectHelper.isEmpty(endpoint.getTagName())) {
+            throw new IllegalArgumentException("Tag Name must be specified to execute " + operation);
+        } 
+        try {
+            git.tag().setName(endpoint.getTagName()).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
+    }
+    
     private Repository getLocalRepository(){
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java
new file mode 100644
index 0000000..ae763b3
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/GitTestSupport.java
@@ -0,0 +1,90 @@
+/**
+ * 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.git;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+
+public class GitTestSupport extends CamelTestSupport {
+
+    public final static String GIT_LOCAL_REPO = "testRepo";
+
+    public final static String FILENAME_TO_ADD = "filetest.txt";
+
+    public final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
+
+    public final static String COMMIT_MESSAGE = "Test commit";
+
+    public final static String COMMIT_MESSAGE_ALL = "Test commit all";
+
+    public final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
+
+    public final static String BRANCH_TEST = "testBranch";
+    
+    public final static String TAG_TEST = "testTag";
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
+        localPath.delete();
+        File path = new File(GIT_LOCAL_REPO);
+        path.deleteOnExit();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        File path = new File(GIT_LOCAL_REPO);
+        deleteDirectory(path);
+    }
+      
+    protected Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
+        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
+        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
+        // now open the resulting repository with a FileRepositoryBuilder
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = builder.setGitDir(gitRepo)
+                .readEnvironment() // scan environment GIT_* variables
+                .findGitDir() // scan up the file system tree
+                .build();
+        return repo;
+    }
+    
+    static public boolean deleteDirectory(File path) {
+        if( path.exists() ) {
+          File[] files = path.listFiles();
+          for(int i=0; i<files.length; i++) {
+             if(files[i].isDirectory()) {
+               deleteDirectory(files[i]);
+             }
+             else {
+               files[i].delete();
+             }
+          }
+        }
+        return( path.delete() );
+      }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
index 21273e2..b61286d0 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/consumer/GitConsumerTest.java
@@ -22,11 +22,10 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.git.GitConstants;
-import org.apache.camel.component.git.producer.GitTestSupport;
+import org.apache.camel.component.git.GitTestSupport;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
index 5a9c7f3..910d942 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
@@ -17,24 +17,19 @@
 package org.apache.camel.component.git.producer;
 
 import java.io.File;
-import java.io.IOException;
 import java.util.List;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.git.GitConstants;
-import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.component.git.GitTestSupport;
 import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.api.errors.GitAPIException;
 import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-import org.eclipse.jgit.transport.PushResult;
-import org.junit.Ignore;
 import org.junit.Test;
 
 public class GitProducerTest extends GitTestSupport {
@@ -680,6 +675,48 @@ public class GitProducerTest extends GitTestSupport {
         repository.close();
     }
     
+    @Test
+    public void createTagTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-tag", "");
+        
+        List<Ref> ref = git.tagList().call();
+        boolean branchCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+                branchCreated = true;
+            }
+        }
+        assertEquals(branchCreated, true);
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
@@ -717,6 +754,8 @@ public class GitProducerTest extends GitTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=log");
                 from("direct:log-branch")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=log&branchName=" + BRANCH_TEST);
+                from("direct:create-tag")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=createTag&tagName=" + TAG_TEST);
             } 
         };
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
index a82eba7..81ba158 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitRemoteProducerTest.java
@@ -17,23 +17,15 @@
 package org.apache.camel.component.git.producer;
 
 import java.io.File;
-import java.io.IOException;
-import java.util.List;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.git.GitConstants;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
+import org.apache.camel.component.git.GitTestSupport;
 import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.PullResult;
 import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.eclipse.jgit.transport.PushResult;
 import org.junit.Ignore;
 import org.junit.Test;

http://git-wip-us.apache.org/repos/asf/camel/blob/bc958064/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java
deleted file mode 100644
index f0cfacb..0000000
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitTestSupport.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.git.producer;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-
-public class GitTestSupport extends CamelTestSupport {
-
-    public final static String GIT_LOCAL_REPO = "testRepo";
-
-    public final static String FILENAME_TO_ADD = "filetest.txt";
-
-    public final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
-
-    public final static String COMMIT_MESSAGE = "Test commit";
-
-    public final static String COMMIT_MESSAGE_ALL = "Test commit all";
-
-    public final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
-
-    public final static String BRANCH_TEST = "testBranch";
-
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
-        localPath.delete();
-        File path = new File(GIT_LOCAL_REPO);
-        path.deleteOnExit();
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-        File path = new File(GIT_LOCAL_REPO);
-        deleteDirectory(path);
-    }
-      
-    protected Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
-        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
-        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
-        // now open the resulting repository with a FileRepositoryBuilder
-        FileRepositoryBuilder builder = new FileRepositoryBuilder();
-        Repository repo = builder.setGitDir(gitRepo)
-                .readEnvironment() // scan environment GIT_* variables
-                .findGitDir() // scan up the file system tree
-                .build();
-        return repo;
-    }
-    
-    static public boolean deleteDirectory(File path) {
-        if( path.exists() ) {
-          File[] files = path.listFiles();
-          for(int i=0; i<files.length; i++) {
-             if(files[i].isDirectory()) {
-               deleteDirectory(files[i]);
-             }
-             else {
-               files[i].delete();
-             }
-          }
-        }
-        return( path.delete() );
-      }
-}


[05/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add commit operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add commit operation


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

Branch: refs/heads/master
Commit: 288d3bded33dd180af5c7c7390bbbc2515b89ec5
Parents: 13b7373
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:05:59 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:14 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitConstants.java       |   1 +
 .../camel/component/git/GitOperation.java       |   1 +
 .../apache/camel/component/git/GitProducer.java |  64 +++++++++--
 .../github/producer/GitProducerTest.java        | 108 ++++++++++++++++++-
 4 files changed, 162 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/288d3bde/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
index c96959b..0ec6856 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
@@ -19,4 +19,5 @@ package org.apache.camel.component.git;
 public interface GitConstants {
 	public static final String GIT_OPERATION = "CamelGitOperation";
 	public static final String GIT_FILE_NAME = "CamelGitFilename";
+	public static final String GIT_COMMIT_MESSAGE = "CamelGitCommitMessage";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/288d3bde/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index 62b19a4..49109c6 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -21,4 +21,5 @@ public interface GitOperation {
     public final static String CLONE_OPERATION = "clone";
     public final static String INIT_OPERATION = "init";
     public final static String ADD_OPERATION = "add";
+    public final static String COMMIT_OPERATION = "commit";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/288d3bde/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index 1ccbac7..5ee7ee3 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -1,12 +1,14 @@
 package org.apache.camel.component.git;
 
 import java.io.File;
+import java.io.IOException;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -22,12 +24,17 @@ public class GitProducer extends DefaultProducer{
 
 	@Override
 	public void process(Exchange exchange) throws Exception {
-        String operation;		
+        String operation;	
+        Repository repo;
 	    if (ObjectHelper.isEmpty(endpoint.getOperation())) {
 	        operation = exchange.getIn().getHeader(GitConstants.GIT_OPERATION, String.class);
 	    } else {
 	    	operation = endpoint.getOperation();
 	    }
+    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
+    	}
+    	repo = getLocalRepository();
 	    
 	    switch (operation) {
 	    case GitOperation.CLONE_OPERATION:
@@ -39,9 +46,14 @@ public class GitProducer extends DefaultProducer{
 	    	break;
 
 	    case GitOperation.ADD_OPERATION:
-	    	doAdd(exchange, operation);
-	    	break;	    	
+	    	doAdd(exchange, operation, repo);
+	    	break;
+	    	
+	    case GitOperation.COMMIT_OPERATION:
+	    	doCommit(exchange, operation, repo);
+	    	break;	
 	    }
+	    repo.close();
 	}
 	
     protected void doClone(Exchange exchange, String operation) {
@@ -70,7 +82,7 @@ public class GitProducer extends DefaultProducer{
     		throw new IllegalArgumentException("Local path must specified to execute " + operation);
     	}
     	try {
-			result = Git.init().setDirectory(new File(endpoint.getLocalPath(),"")).call();
+			result = Git.init().setDirectory(new File(endpoint.getLocalPath(),"")).setBare(false).call();
 		} catch (Exception e) {
 			LOG.error("There was an error in Git " + operation + " operation");
 			e.printStackTrace();
@@ -79,21 +91,55 @@ public class GitProducer extends DefaultProducer{
 		}
     }
     
-    protected void doAdd(Exchange exchange, String operation) {
+    protected void doAdd(Exchange exchange, String operation, Repository repo) {
+    	Git git = null;
     	String fileName = null;
-    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
-    	}
     	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
     		fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
     	} else {
     		throw new IllegalArgumentException("File name must be specified to execute " + operation);
     	}
     	try {
-			Git.open(new File(endpoint.getLocalPath())).add().addFilepattern(fileName).call();
+    		git = new Git(repo);
+			git.add().addFilepattern(fileName).call();
 		} catch (Exception e) {
 			LOG.error("There was an error in Git " + operation + " operation");
 			e.printStackTrace();
 		}
     }
+    
+    protected void doCommit(Exchange exchange, String operation, Repository repo) {
+    	Git git = null;
+    	String commitMessage = null;
+    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
+    		commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
+    	} else {
+    		throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
+    	}
+    	try {
+            git = new Git(repo);
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+    		git.commit().setMessage(commitMessage).call();
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			e.printStackTrace();
+		}
+    }
+    
+    private Repository getLocalRepository(){
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = null;
+		try {
+			repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
+			        .readEnvironment() // scan environment GIT_* variables
+			        .findGitDir() // scan up the file system tree
+			        .build();
+		} catch (IOException e) {
+			LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
+			e.printStackTrace();
+		}
+		return repo;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/288d3bde/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index 18965c8..f911648 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -24,17 +24,22 @@ import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.git.GitConstants;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.api.Status;
 import org.eclipse.jgit.api.errors.GitAPIException;
 import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
 import org.junit.Test;
 
-public class GitProducerTest extends CamelTestSupport{
+public class GitProducerTest extends CamelTestSupport {
 
-	private final static String GIT_LOCAL_REPO = "pippo";
+	private final static String GIT_LOCAL_REPO = "testRepo";
 	private final static String FILENAME_TO_ADD = "filetest.txt";
+	private final static String COMMIT_MESSAGE = "Test commit";
+	private final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
+	private final static String BRANCH_TEST = "testBranch";
 	
     @Override
     public void setUp() throws Exception {
@@ -88,6 +93,99 @@ public class GitProducerTest extends CamelTestSupport{
         repository.close();
     }
     
+    @Test
+    public void commitTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        repository.close();
+    }
+    
+    @Test
+    public void commitBranchTest() throws Exception {
+
+    	Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        Git git = new Git(repository);
+        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+        
+        template.send("direct:commit-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_BRANCH);
+            }
+        });
+        logs = git.log().call();
+        count = 0;
+        for (RevCommit rev : logs) {
+        	if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_BRANCH);
+        	if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 2);
+        repository.close();
+    }
+    
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {            
@@ -99,13 +197,17 @@ public class GitProducerTest extends CamelTestSupport{
                         .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=init");
                 from("direct:add")
                         .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=add");
+                from("direct:commit")
+                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=commit");
+                from("direct:commit-branch")
+                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=commit&branchName=" + BRANCH_TEST);
             } 
         };
     }
     
     private Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
         File gitRepo = new File(GIT_LOCAL_REPO, ".git");
-        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).call();
+        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
         // now open the resulting repository with a FileRepositoryBuilder
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = builder.setGitDir(gitRepo)


[14/23] camel git commit: CAMEL-7982: camel-git - A generic git component, make git Consumer abstract

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, make git Consumer abstract


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

Branch: refs/heads/master
Commit: 8239d6f7cd21eea3763fad80024e8f7799244035
Parents: 8205bbe
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:50 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:15 2015 +0200

----------------------------------------------------------------------
 .../apache/camel/component/git/GitConsumer.java |  65 ----
 .../apache/camel/component/git/GitEndpoint.java |  18 +-
 .../camel/component/git/GitOperation.java       |  33 --
 .../apache/camel/component/git/GitProducer.java | 334 -------------------
 .../git/consumer/AbstractGitConsumer.java       |  66 ++++
 .../git/consumer/GitCommitConsumer.java         |  36 ++
 .../camel/component/git/consumer/GitType.java   |  23 ++
 .../component/git/producer/GitOperation.java    |  33 ++
 .../component/git/producer/GitProducer.java     | 331 ++++++++++++++++++
 .../github/consumer/GitConsumerTest.java        |   4 +-
 10 files changed, 507 insertions(+), 436 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java
deleted file mode 100644
index ac3a5f4..0000000
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConsumer.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package org.apache.camel.component.git;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.impl.ScheduledPollConsumer;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-
-public class GitConsumer extends ScheduledPollConsumer {
-	
-	private GitEndpoint endpoint;
-	
-	private Repository repository;
-	
-	private Git git;
-	
-	private List used;
-
-	public GitConsumer(GitEndpoint endpoint, Processor processor) {
-		super(endpoint, processor);
-		this.endpoint = endpoint;
-		this.repository = getLocalRepository();
-		this.git = new Git(repository);
-		this.used = new ArrayList();
-	}
-
-	@Override
-	protected int poll() throws Exception {
-		int count = 0;
-		Iterable<RevCommit> commits = git.log().all().call();
-        for (RevCommit commit : commits) {
-        	if (!used.contains(commit.getId())) {
-            Exchange e = getEndpoint().createExchange();
-            e.getOut().setBody(commit.getShortMessage());
-            getProcessor().process(e);
-            used.add(commit.getId());
-            count++;
-        	}
-        }
-        return count;
-	}
-	
-    private Repository getLocalRepository(){
-        FileRepositoryBuilder builder = new FileRepositoryBuilder();
-        Repository repo = null;
-		try {
-			repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
-			        .readEnvironment() // scan environment GIT_* variables
-			        .findGitDir() // scan up the file system tree
-			        .build();
-		} catch (IOException e) {
-			//LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
-			e.printStackTrace();
-		}
-		return repo;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
index de09f95..247b60d 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -19,6 +19,9 @@ package org.apache.camel.component.git;
 import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
+import org.apache.camel.component.git.consumer.GitCommitConsumer;
+import org.apache.camel.component.git.consumer.GitType;
+import org.apache.camel.component.git.producer.GitProducer;
 import org.apache.camel.impl.DefaultEndpoint;
 import org.apache.camel.spi.Metadata;
 import org.apache.camel.spi.UriEndpoint;
@@ -30,8 +33,10 @@ public class GitEndpoint extends DefaultEndpoint {
 
     @UriPath @Metadata(required = "true")
     private String localPath;
-    @UriPath(label = "consumer")
+    @UriPath
     private String branchName;
+    @UriPath(label = "consumer")
+    private GitType type;
     @UriParam
     private String username;
     @UriParam
@@ -52,7 +57,8 @@ public class GitEndpoint extends DefaultEndpoint {
 
 	@Override
 	public Consumer createConsumer(Processor processor) throws Exception {
-        return new GitConsumer(this, processor);
+	    if (type == GitType.COMMIT) return new GitCommitConsumer(this, processor);
+	    else throw new IllegalArgumentException("Cannot create producer with type " + type);
 	}
 
 	@Override
@@ -108,4 +114,12 @@ public class GitEndpoint extends DefaultEndpoint {
 	public void setOperation(String operation) {
 		this.operation = operation;
 	}
+
+    public GitType getType() {
+        return type;
+    }
+
+    public void setType(GitType type) {
+        this.type = type;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
deleted file mode 100644
index 8d7b69a..0000000
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/**
- * 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.git;
-
-public interface GitOperation {
-
-    public final static String CLONE_OPERATION = "clone";
-    public final static String INIT_OPERATION = "init";
-    public final static String ADD_OPERATION = "add";
-    public final static String REMOVE_OPERATION = "remove";
-    public final static String COMMIT_OPERATION = "commit";
-    public final static String COMMIT_ALL_OPERATION = "commitAll";
-    public final static String CREATE_BRANCH_OPERATION = "createBranch";
-    public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
-    public final static String STATUS_OPERATION = "status";
-    public final static String LOG_OPERATION = "log";
-    public final static String PUSH_OPERATION = "push";
-    public final static String PULL_OPERATION = "pull";
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
deleted file mode 100644
index 42a55e6..0000000
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ /dev/null
@@ -1,334 +0,0 @@
-package org.apache.camel.component.git;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.impl.DefaultProducer;
-import org.apache.camel.util.ObjectHelper;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.PullResult;
-import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-import org.eclipse.jgit.transport.PushResult;
-import org.eclipse.jgit.transport.RefSpec;
-import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class GitProducer extends DefaultProducer{
-
-    private static final Logger LOG = LoggerFactory.getLogger(GitProducer.class);
-    private final GitEndpoint endpoint;
-    
-	public GitProducer(GitEndpoint endpoint) {
-		super(endpoint);
-		this.endpoint = endpoint;
-	}
-
-	@Override
-	public void process(Exchange exchange) throws Exception {
-        String operation;	
-        Repository repo;
-	    if (ObjectHelper.isEmpty(endpoint.getOperation())) {
-	        operation = exchange.getIn().getHeader(GitConstants.GIT_OPERATION, String.class);
-	    } else {
-	    	operation = endpoint.getOperation();
-	    }
-    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
-    	}
-    	repo = getLocalRepository();
-	    
-	    switch (operation) {
-	    case GitOperation.CLONE_OPERATION:
-	    	doClone(exchange, operation);
-	    	break;
-	    	
-	    case GitOperation.INIT_OPERATION:
-	    	doInit(exchange, operation);
-	    	break;
-
-	    case GitOperation.ADD_OPERATION:
-	    	doAdd(exchange, operation, repo);
-	    	break;
-	    	
-            case GitOperation.REMOVE_OPERATION:
-                doRemove(exchange, operation, repo);
-                break;
-	    	
-	    case GitOperation.COMMIT_OPERATION:
-	    	doCommit(exchange, operation, repo);
-	    	break;
-	    
-            case GitOperation.COMMIT_ALL_OPERATION:
-                doCommitAll(exchange, operation, repo);
-                break;
-                
-            case GitOperation.CREATE_BRANCH_OPERATION:
-                doCreateBranch(exchange, operation, repo);
-                break;
-                
-            case GitOperation.DELETE_BRANCH_OPERATION:
-                doDeleteBranch(exchange, operation, repo);
-                break;
-                
-            case GitOperation.STATUS_OPERATION:
-                doStatus(exchange, operation, repo);
-                break;
-                
-            case GitOperation.LOG_OPERATION:
-                doLog(exchange, operation, repo);
-                break;
-                
-            case GitOperation.PUSH_OPERATION:
-                doPush(exchange, operation, repo);
-                break;
-                            
-            case GitOperation.PULL_OPERATION:
-                doPull(exchange, operation, repo);
-                break;
-	    }
-	    repo.close();
-	}
-	
-    protected void doClone(Exchange exchange, String operation) {
-    	Git result = null;
-    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
-    	}
-    	try {
-    		File localRepo = new File(endpoint.getLocalPath(), "");
-    		if (!localRepo.exists()) {
-			   result = Git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(),"")).call();
-    		} else {
-               throw new IllegalArgumentException("The local repository directory already exists");
-    		}
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			e.printStackTrace();
-		} finally {
-			result.close();
-		}
-    }
-
-    protected void doInit(Exchange exchange, String operation) {
-    	Git result = null;
-    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
-    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
-    	}
-    	try {
-			result = Git.init().setDirectory(new File(endpoint.getLocalPath(),"")).setBare(false).call();
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			e.printStackTrace();
-		} finally {
-			result.close();
-		}
-    }
-    
-    protected void doAdd(Exchange exchange, String operation, Repository repo) {
-    	Git git = null;
-    	String fileName = null;
-    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
-    		fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
-    	} else {
-    		throw new IllegalArgumentException("File name must be specified to execute " + operation);
-    	}
-    	try {
-    		git = new Git(repo);
-                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-                }
-			git.add().addFilepattern(fileName).call();
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			e.printStackTrace();
-		}
-    }
-    
-    protected void doRemove(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        String fileName = null;
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
-                fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
-        } else {
-                throw new IllegalArgumentException("File name must be specified to execute " + operation);
-        }
-        try {
-                git = new Git(repo);
-                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-                }
-                        git.rm().addFilepattern(fileName).call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        e.printStackTrace();
-                }
-    }
-    
-    protected void doCommit(Exchange exchange, String operation, Repository repo) {
-    	Git git = null;
-    	String commitMessage = null;
-    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
-    		commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
-    	} else {
-    		throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
-    	}
-    	try {
-            git = new Git(repo);
-            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            }
-    		git.commit().setMessage(commitMessage).call();
-		} catch (Exception e) {
-			LOG.error("There was an error in Git " + operation + " operation");
-			e.printStackTrace();
-		}
-    }
-    
-    protected void doCommitAll(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        String commitMessage = null;
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
-                commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
-        } else {
-                throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
-        }
-        try {
-            git = new Git(repo);
-            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            }
-                git.commit().setAll(true).setMessage(commitMessage).call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        e.printStackTrace();
-                }
-    }
-    
-    protected void doCreateBranch(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
-            throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
-        } 
-        try {
-            git = new Git(repo);
-            git.branchCreate().setName(endpoint.getBranchName()).call();
-        } catch (Exception e) {
-            LOG.error("There was an error in Git " + operation + " operation");
-            e.printStackTrace();
-        }
-    }
-    
-    protected void doDeleteBranch(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
-            throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
-        } 
-        try {
-            git = new Git(repo);
-            git.branchDelete().setBranchNames(endpoint.getBranchName()).call();
-        } catch (Exception e) {
-            LOG.error("There was an error in Git " + operation + " operation");
-            e.printStackTrace();
-        }
-    }
-    
-    protected void doStatus(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        Status status = null;
-        try {
-            git = new Git(repo);
-            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            }
-                status = git.status().call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        e.printStackTrace();
-                }
-        exchange.getOut().setBody(status);
-    }
-    
-    protected void doLog(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        Iterable<RevCommit> revCommit = null;
-        try {
-            git = new Git(repo);
-            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            }
-                revCommit = git.log().call();
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        e.printStackTrace();
-                }
-        exchange.getOut().setBody(revCommit);
-    }
-    
-    protected void doPush(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        Iterable<PushResult> result = null;
-        try {
-            git = new Git(repo);
-            if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
-                throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
-            } 
-            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            } 
-            if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
-                UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
-                result = git.push().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
-            } else {
-                result = git.push().setRemote(endpoint.getRemotePath()).call();
-            }
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        e.printStackTrace();
-                }
-        exchange.getOut().setBody(result);
-    }
-    
-    protected void doPull(Exchange exchange, String operation, Repository repo) {
-        Git git = null;
-        PullResult result = null;
-        try {
-            git = new Git(repo);
-            if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
-                throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
-            } 
-            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
-                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
-            } 
-            if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
-                UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
-                result = git.pull().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
-            } else {
-                result = git.pull().setRemote(endpoint.getRemotePath()).call();
-            }
-                } catch (Exception e) {
-                        LOG.error("There was an error in Git " + operation + " operation");
-                        e.printStackTrace();
-                }
-        exchange.getOut().setBody(result);
-    }
-    
-    private Repository getLocalRepository(){
-        FileRepositoryBuilder builder = new FileRepositoryBuilder();
-        Repository repo = null;
-		try {
-			repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
-			        .readEnvironment() // scan environment GIT_* variables
-			        .findGitDir() // scan up the file system tree
-			        .build();
-		} catch (IOException e) {
-			LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
-			e.printStackTrace();
-		}
-		return repo;
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
new file mode 100644
index 0000000..5ceec5d
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
@@ -0,0 +1,66 @@
+package org.apache.camel.component.git.consumer;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.Processor;
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+
+public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
+    
+    private final GitEndpoint endpoint;
+    
+    private Repository repo;
+    
+    private Git git;
+
+    public AbstractGitConsumer(GitEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+        this.endpoint = endpoint;
+        this.repo = getLocalRepository();
+        this.git = new Git(repo);
+    }
+    
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        this.repo = getLocalRepository();
+        this.git = new Git(repo);
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        super.doStop();
+        repo.close();
+        git.close();
+    }
+
+    private Repository getLocalRepository(){
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = null;
+                try {
+                        repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
+                                .readEnvironment() // scan environment GIT_* variables
+                                .findGitDir() // scan up the file system tree
+                                .build();
+                } catch (IOException e) {
+                        //LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
+                        e.printStackTrace();
+                }
+                return repo;
+    }
+    
+    protected Repository getRepository() {
+        return repo;
+    }
+    
+    protected Git getGit() {
+        return git;
+    }
+    
+    protected abstract int poll() throws Exception;
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
new file mode 100644
index 0000000..d289c26
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitCommitConsumer.java
@@ -0,0 +1,36 @@
+package org.apache.camel.component.git.consumer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.git.GitEndpoint;
+import org.eclipse.jgit.revwalk.RevCommit;
+
+public class GitCommitConsumer extends AbstractGitConsumer {
+	
+	private List used;
+
+	public GitCommitConsumer(GitEndpoint endpoint, Processor processor) {
+		super(endpoint, processor);
+		this.used = new ArrayList();
+	}
+
+	@Override
+	protected int poll() throws Exception {
+		int count = 0;
+		Iterable<RevCommit> commits = getGit().log().all().call();
+        for (RevCommit commit : commits) {
+        	if (!used.contains(commit.getId())) {
+            Exchange e = getEndpoint().createExchange();
+            e.getOut().setBody(commit.getShortMessage());
+            getProcessor().process(e);
+            used.add(commit.getId());
+            count++;
+        	}
+        }
+        return count;
+	}
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
new file mode 100644
index 0000000..af3729e
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/GitType.java
@@ -0,0 +1,23 @@
+/**
+ * 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.git.consumer;
+
+public enum GitType {
+
+    COMMIT
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
new file mode 100644
index 0000000..de03fc7
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
@@ -0,0 +1,33 @@
+/**
+ * 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.git.producer;
+
+public interface GitOperation {
+
+    public final static String CLONE_OPERATION = "clone";
+    public final static String INIT_OPERATION = "init";
+    public final static String ADD_OPERATION = "add";
+    public final static String REMOVE_OPERATION = "remove";
+    public final static String COMMIT_OPERATION = "commit";
+    public final static String COMMIT_ALL_OPERATION = "commitAll";
+    public final static String CREATE_BRANCH_OPERATION = "createBranch";
+    public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
+    public final static String STATUS_OPERATION = "status";
+    public final static String LOG_OPERATION = "log";
+    public final static String PUSH_OPERATION = "push";
+    public final static String PULL_OPERATION = "pull";
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
new file mode 100644
index 0000000..b9d88fe
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -0,0 +1,331 @@
+package org.apache.camel.component.git.producer;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.git.GitConstants;
+import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.PullResult;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.PushResult;
+import org.eclipse.jgit.transport.RefSpec;
+import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GitProducer extends DefaultProducer{
+
+    private static final Logger LOG = LoggerFactory.getLogger(GitProducer.class);
+    private final GitEndpoint endpoint;
+    
+    private Repository repo;
+    
+    private Git git;
+    
+	public GitProducer(GitEndpoint endpoint) {
+		super(endpoint);
+		this.endpoint = endpoint;
+	}
+	
+	    @Override
+	    protected void doStart() throws Exception {
+	        super.doStart();
+	        this.repo = getLocalRepository();
+	        this.git = new Git(repo);
+	    }
+
+	    @Override
+	    protected void doStop() throws Exception {
+	        super.doStop();
+	        repo.close();
+	        git.close();
+	    }
+
+	@Override
+	public void process(Exchange exchange) throws Exception {
+        String operation;	
+	    if (ObjectHelper.isEmpty(endpoint.getOperation())) {
+	        operation = exchange.getIn().getHeader(GitConstants.GIT_OPERATION, String.class);
+	    } else {
+	    	operation = endpoint.getOperation();
+	    }
+    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
+    	}
+	    
+	    switch (operation) {
+	    case GitOperation.CLONE_OPERATION:
+	    	doClone(exchange, operation);
+	    	break;
+	    	
+	    case GitOperation.INIT_OPERATION:
+	    	doInit(exchange, operation);
+	    	break;
+
+	    case GitOperation.ADD_OPERATION:
+	    	doAdd(exchange, operation);
+	    	break;
+	    	
+            case GitOperation.REMOVE_OPERATION:
+                doRemove(exchange, operation);
+                break;
+	    	
+	    case GitOperation.COMMIT_OPERATION:
+	    	doCommit(exchange, operation);
+	    	break;
+	    
+            case GitOperation.COMMIT_ALL_OPERATION:
+                doCommitAll(exchange, operation);
+                break;
+                
+            case GitOperation.CREATE_BRANCH_OPERATION:
+                doCreateBranch(exchange, operation);
+                break;
+                
+            case GitOperation.DELETE_BRANCH_OPERATION:
+                doDeleteBranch(exchange, operation);
+                break;
+                
+            case GitOperation.STATUS_OPERATION:
+                doStatus(exchange, operation);
+                break;
+                
+            case GitOperation.LOG_OPERATION:
+                doLog(exchange, operation);
+                break;
+                
+            case GitOperation.PUSH_OPERATION:
+                doPush(exchange, operation);
+                break;
+                            
+            case GitOperation.PULL_OPERATION:
+                doPull(exchange, operation);
+                break;
+	    }
+	}
+	
+    protected void doClone(Exchange exchange, String operation) throws Exception {
+    	Git result = null;
+    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
+    	}
+    	try {
+    		File localRepo = new File(endpoint.getLocalPath(), "");
+    		if (!localRepo.exists()) {
+			   result = Git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(),"")).call();
+    		} else {
+               throw new IllegalArgumentException("The local repository directory already exists");
+    		}
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			throw e;
+		} finally {
+			result.close();
+		}
+    }
+
+    protected void doInit(Exchange exchange, String operation) throws Exception {
+    	Git result = null;
+    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+    		throw new IllegalArgumentException("Local path must specified to execute " + operation);
+    	}
+    	try {
+			result = Git.init().setDirectory(new File(endpoint.getLocalPath(),"")).setBare(false).call();
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			throw e;
+		} finally {
+			result.close();
+		}
+    }
+    
+    protected void doAdd(Exchange exchange, String operation) throws Exception {
+    	String fileName = null;
+    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
+    		fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
+    	} else {
+    		throw new IllegalArgumentException("File name must be specified to execute " + operation);
+    	}
+    	try {
+                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+                }
+			git.add().addFilepattern(fileName).call();
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			throw e;
+		}
+    }
+    
+    protected void doRemove(Exchange exchange, String operation) throws Exception {
+        String fileName = null;
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
+                fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
+        } else {
+                throw new IllegalArgumentException("File name must be specified to execute " + operation);
+        }
+        try {
+                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+                }
+                        git.rm().addFilepattern(fileName).call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        throw e;
+                }
+    }
+    
+    protected void doCommit(Exchange exchange, String operation) throws Exception {
+    	String commitMessage = null;
+    	if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
+    		commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
+    	} else {
+    		throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
+    	}
+    	try {
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+    		git.commit().setMessage(commitMessage).call();
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			throw e;
+		}
+    }
+    
+    protected void doCommitAll(Exchange exchange, String operation) throws Exception {
+        String commitMessage = null;
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE))) {
+                commitMessage = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_MESSAGE, String.class);
+        } else {
+                throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
+        }
+        try {
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+                git.commit().setAll(true).setMessage(commitMessage).call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        throw e;
+                }
+    }
+    
+    protected void doCreateBranch(Exchange exchange, String operation) throws Exception {
+        if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
+            throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
+        } 
+        try {
+            git.branchCreate().setName(endpoint.getBranchName()).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
+    }
+    
+    protected void doDeleteBranch(Exchange exchange, String operation) throws Exception {
+        if (ObjectHelper.isEmpty(endpoint.getBranchName())) {
+            throw new IllegalArgumentException("Branch Name must be specified to execute " + operation);
+        } 
+        try {
+            git.branchDelete().setBranchNames(endpoint.getBranchName()).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
+    }
+    
+    protected void doStatus(Exchange exchange, String operation) throws Exception {
+        Status status = null;
+        try {
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+                status = git.status().call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        throw e;
+                }
+        exchange.getOut().setBody(status);
+    }
+    
+    protected void doLog(Exchange exchange, String operation) throws Exception {
+        Iterable<RevCommit> revCommit = null;
+        try {
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            }
+                revCommit = git.log().call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        throw e;
+                }
+        exchange.getOut().setBody(revCommit);
+    }
+    
+    protected void doPush(Exchange exchange, String operation) throws Exception {
+        Iterable<PushResult> result = null;
+        try {
+            if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
+                throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
+                UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
+                result = git.push().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
+            } else {
+                result = git.push().setRemote(endpoint.getRemotePath()).call();
+            }
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        throw e;
+                }
+        exchange.getOut().setBody(result);
+    }
+    
+    protected void doPull(Exchange exchange, String operation) throws Exception {
+        PullResult result = null;
+        try {
+            if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
+                throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
+                UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
+                result = git.pull().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
+            } else {
+                result = git.pull().setRemote(endpoint.getRemotePath()).call();
+            }
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        throw e;
+                }
+        exchange.getOut().setBody(result);
+    }
+    
+    private Repository getLocalRepository(){
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = null;
+		try {
+			repo = builder.setGitDir(new File(endpoint.getLocalPath(), ".git"))
+			        .readEnvironment() // scan environment GIT_* variables
+			        .findGitDir() // scan up the file system tree
+			        .build();
+		} catch (IOException e) {
+			LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
+			e.printStackTrace();
+		}
+		return repo;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/8239d6f7/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
index 6071d23..d45591b 100644
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/consumer/GitConsumerTest.java
@@ -33,7 +33,7 @@ import org.junit.Test;
 public class GitConsumerTest extends GitTestSupport {
     
     @Test
-    public void commitTest() throws Exception {
+    public void commitConsumerTest() throws Exception {
 
     	Repository repository = getTestRepository();
         MockEndpoint added = getMockEndpoint("mock:result");
@@ -116,7 +116,7 @@ public class GitConsumerTest extends GitTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=add");
                 from("direct:commit")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
-                from("git://" + GIT_LOCAL_REPO)
+                from("git://" + GIT_LOCAL_REPO + "?type=commit")
                         .to("mock:result");
             } 
         };


[03/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add remove operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add remove operation


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

Branch: refs/heads/master
Commit: db6f6e123136e05460aaa721228d326237b413be
Parents: 9df0710
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:20 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:14 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitOperation.java       |   1 +
 .../apache/camel/component/git/GitProducer.java |  24 ++++
 .../github/producer/GitProducerTest.java        | 137 +++++++++++++++++++
 3 files changed, 162 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/db6f6e12/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index f70728b..431540a 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -21,6 +21,7 @@ public interface GitOperation {
     public final static String CLONE_OPERATION = "clone";
     public final static String INIT_OPERATION = "init";
     public final static String ADD_OPERATION = "add";
+    public final static String REMOVE_OPERATION = "remove";
     public final static String COMMIT_OPERATION = "commit";
     public final static String COMMIT_ALL_OPERATION = "commitAll";
     public final static String CREATE_BRANCH_OPERATION = "createBranch";

http://git-wip-us.apache.org/repos/asf/camel/blob/db6f6e12/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index 1e0d3f5..c134475 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -49,6 +49,10 @@ public class GitProducer extends DefaultProducer{
 	    	doAdd(exchange, operation, repo);
 	    	break;
 	    	
+            case GitOperation.REMOVE_OPERATION:
+                doRemove(exchange, operation, repo);
+                break;
+	    	
 	    case GitOperation.COMMIT_OPERATION:
 	    	doCommit(exchange, operation, repo);
 	    	break;
@@ -123,6 +127,26 @@ public class GitProducer extends DefaultProducer{
 		}
     }
     
+    protected void doRemove(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        String fileName = null;
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME))) {
+                fileName = exchange.getIn().getHeader(GitConstants.GIT_FILE_NAME, String.class);
+        } else {
+                throw new IllegalArgumentException("File name must be specified to execute " + operation);
+        }
+        try {
+                git = new Git(repo);
+                if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                    git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+                }
+                        git.rm().addFilepattern(fileName).call();
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        e.printStackTrace();
+                }
+    }
+    
     protected void doCommit(Exchange exchange, String operation, Repository repo) {
     	Git git = null;
     	String commitMessage = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/db6f6e12/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index 7122846..791e2aa 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -98,6 +98,57 @@ public class GitProducerTest extends CamelTestSupport {
     }
     
     @Test
+    public void removeTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:remove", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        status = new Git(repository).status().call();
+
+        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        repository.close();
+    }
+    
+    @Test
     public void commitTest() throws Exception {
 
     	Repository repository = getTestRepository();
@@ -190,6 +241,8 @@ public class GitProducerTest extends CamelTestSupport {
         repository.close();
     }
     
+
+    
     @Test
     public void commitAllTest() throws Exception {
 
@@ -289,6 +342,86 @@ public class GitProducerTest extends CamelTestSupport {
     }
     
     @Test
+    public void removeFileBranchTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        Iterable<RevCommit> logs = new Git(repository).log()
+                .call();
+        int count = 0;
+        for (RevCommit rev : logs) {
+            assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 1);
+        
+        Git git = new Git(repository);
+        git.checkout().setCreateBranch(true).setName(BRANCH_TEST).
+        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+        
+        File fileToAdd1 = new File(GIT_LOCAL_REPO, FILENAME_BRANCH_TO_ADD);
+        fileToAdd1.createNewFile();
+        
+        template.send("direct:add-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_BRANCH_TO_ADD);
+            }
+        });
+        
+        template.send("direct:commit-all-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE_ALL);
+            }
+        });
+        logs = git.log().call();
+        count = 0;
+        for (RevCommit rev : logs) {
+            if (count == 0) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE_ALL);
+            if (count == 1) assertEquals(rev.getShortMessage(), COMMIT_MESSAGE);
+            count++;
+        }
+        assertEquals(count, 2);
+        
+        template.send("direct:remove-on-branch", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        
+        git = new Git(repository);
+        git.checkout().setCreateBranch(false).setName(BRANCH_TEST).call();
+        
+        status = git.status().call();
+        assertFalse(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        repository.close();
+    }
+    
+    @Test
     public void createBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
@@ -394,8 +527,12 @@ public class GitProducerTest extends CamelTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=init");
                 from("direct:add")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                from("direct:remove")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=rm");
                 from("direct:add-on-branch")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
+                from("direct:remove-on-branch")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add&branchName=" + BRANCH_TEST);
                 from("direct:commit")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
                 from("direct:commit-branch")


[17/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add deleteTag operation

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add deleteTag operation


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

Branch: refs/heads/master
Commit: d38b525a31120965b127ce55c63fe6dd558da997
Parents: bc95806
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:09 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:16 2015 +0200

----------------------------------------------------------------------
 .../git/consumer/AbstractGitConsumer.java       | 13 +++--
 .../component/git/producer/GitOperation.java    |  1 +
 .../component/git/producer/GitProducer.java     | 20 ++++++-
 .../component/git/producer/GitProducerTest.java | 61 +++++++++++++++++++-
 4 files changed, 85 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d38b525a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
index 6e93849..ca58dcf 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/consumer/AbstractGitConsumer.java
@@ -21,10 +21,13 @@ import java.io.IOException;
 
 import org.apache.camel.Processor;
 import org.apache.camel.component.git.GitEndpoint;
+import org.apache.camel.component.git.producer.GitProducer;
 import org.apache.camel.impl.ScheduledPollConsumer;
 import org.eclipse.jgit.api.Git;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
     
@@ -33,12 +36,12 @@ public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
     private Repository repo;
     
     private Git git;
+    
+    private static final Logger LOG = LoggerFactory.getLogger(AbstractGitConsumer.class);
 
     public AbstractGitConsumer(GitEndpoint endpoint, Processor processor) {
         super(endpoint, processor);
         this.endpoint = endpoint;
-        this.repo = getLocalRepository();
-        this.git = new Git(repo);
     }
     
     @Override
@@ -55,7 +58,7 @@ public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
         git.close();
     }
 
-    private Repository getLocalRepository(){
+    private Repository getLocalRepository() throws IOException{
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;
                 try {
@@ -64,8 +67,8 @@ public abstract class AbstractGitConsumer extends ScheduledPollConsumer {
                                 .findGitDir() // scan up the file system tree
                                 .build();
                 } catch (IOException e) {
-                        //LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
-                        e.printStackTrace();
+                        LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
+                        throw e;
                 }
                 return repo;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/d38b525a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
index d45c743..dbd9813 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitOperation.java
@@ -27,6 +27,7 @@ public interface GitOperation {
     public final static String CREATE_BRANCH_OPERATION = "createBranch";
     public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
     public final static String CREATE_TAG_OPERATION = "createTag";
+    public final static String DELETE_TAG_OPERATION = "deleteTag";
     public final static String STATUS_OPERATION = "status";
     public final static String LOG_OPERATION = "log";
     public final static String PUSH_OPERATION = "push";

http://git-wip-us.apache.org/repos/asf/camel/blob/d38b525a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
index f6eccf4..a397801 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -112,6 +112,10 @@ public class GitProducer extends DefaultProducer{
             case GitOperation.CREATE_TAG_OPERATION:
                 doCreateTag(exchange, operation);
                 break;
+                
+            case GitOperation.DELETE_TAG_OPERATION:
+                doDeleteTag(exchange, operation);
+                break;
 	    }
 	}
 	
@@ -330,7 +334,19 @@ public class GitProducer extends DefaultProducer{
         }
     }
     
-    private Repository getLocalRepository(){
+    protected void doDeleteTag(Exchange exchange, String operation) throws Exception {
+        if (ObjectHelper.isEmpty(endpoint.getTagName())) {
+            throw new IllegalArgumentException("Tag Name must be specified to execute " + operation);
+        } 
+        try {
+            git.tagDelete().setTags(endpoint.getTagName()).call();
+        } catch (Exception e) {
+            LOG.error("There was an error in Git " + operation + " operation");
+            throw e;
+        }
+    }
+    
+    private Repository getLocalRepository() throws IOException{
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;
 		try {
@@ -340,7 +356,7 @@ public class GitProducer extends DefaultProducer{
 			        .build();
 		} catch (IOException e) {
 			LOG.error("There was an error, cannot open " + endpoint.getLocalPath() + " repository");
-			e.printStackTrace();
+			throw e;
 		}
 		return repo;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/d38b525a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
index 910d942..cb6bee8 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/git/producer/GitProducerTest.java
@@ -707,13 +707,66 @@ public class GitProducerTest extends GitTestSupport {
         template.sendBody("direct:create-tag", "");
         
         List<Ref> ref = git.tagList().call();
-        boolean branchCreated = false;
+        boolean tagCreated = false;
         for (Ref refInternal : ref) {
             if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
-                branchCreated = true;
+                tagCreated = true;
             }
         }
-        assertEquals(branchCreated, true);
+        assertEquals(tagCreated, true);
+        repository.close();
+    }
+    
+    @Test
+    public void deleteTagTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+        
+        Git git = new Git(repository);
+        
+        template.sendBody("direct:create-tag", "");
+        
+        List<Ref> ref = git.tagList().call();
+        boolean tagCreated = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+                tagCreated = true;
+            }
+        }
+        assertEquals(tagCreated, true);
+        
+        template.sendBody("direct:delete-tag", "");
+        
+        ref = git.tagList().call();
+        boolean tagExists = false;
+        for (Ref refInternal : ref) {
+            if (refInternal.getName().equals("refs/tags/" + TAG_TEST)) {
+                tagExists = true;
+            }
+        }
+        assertEquals(tagExists, false);
         repository.close();
     }
     
@@ -756,6 +809,8 @@ public class GitProducerTest extends GitTestSupport {
                         .to("git://" + GIT_LOCAL_REPO + "?operation=log&branchName=" + BRANCH_TEST);
                 from("direct:create-tag")
                         .to("git://" + GIT_LOCAL_REPO + "?operation=createTag&tagName=" + TAG_TEST);
+                from("direct:delete-tag")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=deleteTag&tagName=" + TAG_TEST);
             } 
         };
     }


[02/23] camel git commit: CAMEL-7982: camel-git - A generic git component, first commit

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, first commit


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

Branch: refs/heads/master
Commit: 91b8b57572a7bfd990cf1efd790c41785dc4d5cf
Parents: ebf05e0
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:05:45 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:13 2015 +0200

----------------------------------------------------------------------
 components/camel-git/pom.xml                    |  65 ++++++
 .../camel/component/git/GitComponent.java       |  35 ++++
 .../camel/component/git/GitConstants.java       |  21 ++
 .../apache/camel/component/git/GitEndpoint.java | 117 +++++++++++
 .../camel/component/git/GitOperation.java       |  23 +++
 .../apache/camel/component/git/GitProducer.java |  76 +++++++
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../services/org/apache/camel/component/git     |  18 ++
 .../github/producer/GitProducerTest.java        |  86 ++++++++
 .../src/test/resources/log4j.properties         |  36 ++++
 11 files changed, 691 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-git/pom.xml b/components/camel-git/pom.xml
new file mode 100644
index 0000000..a6a673b
--- /dev/null
+++ b/components/camel-git/pom.xml
@@ -0,0 +1,65 @@
+<?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/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.16-SNAPSHOT</version>
+  </parent>
+
+  <artifactId>camel-git</artifactId>
+  <packaging>bundle</packaging>
+  <name>Camel :: Git</name>
+
+   <properties>
+      <camel.osgi.export.pkg>org.apache.camel.component.git.*</camel.osgi.export.pkg>
+      <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=git</camel.osgi.export.service>
+   </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse.jgit</groupId>
+      <artifactId>org.eclipse.jgit</artifactId>
+      <version>4.0.1.201506240215-r</version>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java
new file mode 100644
index 0000000..349e020
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitComponent.java
@@ -0,0 +1,35 @@
+/**
+ * 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.git;
+
+import java.util.Map;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+/**
+ * Represents the component that manages {@link GitEndpoint}.
+ */
+public class GitComponent extends DefaultComponent {
+
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        GitEndpoint endpoint = new GitEndpoint(uri, this);
+        setProperties(endpoint, parameters);
+        endpoint.setRemotePath(remaining);
+        return endpoint;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
new file mode 100644
index 0000000..88331c7
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitConstants.java
@@ -0,0 +1,21 @@
+/**
+ * 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.git;
+
+public interface GitConstants {
+	public static final String GIT_OPERATION = "CamelGitOperation";
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
new file mode 100644
index 0000000..3dd6cbb
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitEndpoint.java
@@ -0,0 +1,117 @@
+/**
+ * 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.git;
+
+import java.io.File;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.Metadata;
+import org.apache.camel.spi.UriEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.spi.UriPath;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.internal.storage.file.FileRepository;
+import org.eclipse.jgit.lib.Repository;
+
+@UriEndpoint(scheme = "git", title = "Git", syntax = "git:remotepath/branchname", label = "api,file")
+public class GitEndpoint extends DefaultEndpoint {
+
+    @UriPath @Metadata(required = "true")
+    private String remotePath;
+    @UriPath(label = "consumer")
+    private String branchName;
+    @UriParam
+    private String username;
+    @UriParam
+    private String password;
+    @UriParam
+    private String localPath;
+    @UriParam
+    private String operation;
+
+    public GitEndpoint(String uri, GitComponent component) {
+        super(uri, component);
+    }
+    
+	@Override
+	public Producer createProducer() throws Exception {
+		return new GitProducer(this);
+	}
+
+	@Override
+	public Consumer createConsumer(Processor processor) throws Exception {
+		// TODO Auto-generated method stub
+		return null;
+	}
+
+	@Override
+	public boolean isSingleton() {
+		// TODO Auto-generated method stub
+		return false;
+	} 
+
+	public String getRemotePath() {
+		return remotePath;
+	}
+
+	public void setRemotePath(String remotePath) {
+		this.remotePath = remotePath;
+	}
+
+	public String getBranchName() {
+		return branchName;
+	}
+
+	public void setBranchName(String branchName) {
+		this.branchName = branchName;
+	}
+
+	public String getUsername() {
+		return username;
+	}
+
+	public void setUsername(String username) {
+		this.username = username;
+	}
+
+	public String getPassword() {
+		return password;
+	}
+
+	public void setPassword(String password) {
+		this.password = password;
+	}
+
+	public String getLocalPath() {
+		return localPath;
+	}
+
+	public void setLocalPath(String localPath) {
+		this.localPath = localPath;
+	}
+
+	public String getOperation() {
+		return operation;
+	}
+
+	public void setOperation(String operation) {
+		this.operation = operation;
+	}
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
new file mode 100644
index 0000000..2b951c0
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -0,0 +1,23 @@
+/**
+ * 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.git;
+
+public interface GitOperation {
+
+    public final static String CLONE_OPERATION = "clone";
+    public final static String INIT_OPERATION = "init";
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
new file mode 100644
index 0000000..e0fa4fe
--- /dev/null
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -0,0 +1,76 @@
+package org.apache.camel.component.git;
+
+import java.io.File;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jgit.api.Git;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class GitProducer extends DefaultProducer{
+
+    private static final Logger LOG = LoggerFactory.getLogger(GitProducer.class);
+    private final GitEndpoint endpoint;
+    
+	public GitProducer(GitEndpoint endpoint) {
+		super(endpoint);
+		this.endpoint = endpoint;
+	}
+
+	@Override
+	public void process(Exchange exchange) throws Exception {
+        String operation;		
+	    if (ObjectHelper.isEmpty(endpoint.getOperation())) {
+	        operation = exchange.getIn().getHeader(GitConstants.GIT_OPERATION, String.class);
+	    } else {
+	    	operation = endpoint.getOperation();
+	    }
+	    
+	    switch (operation) {
+	    case GitOperation.CLONE_OPERATION:
+	    	doClone(exchange, operation);
+	    	break;
+	    	
+	    case GitOperation.INIT_OPERATION:
+	    	doInit(exchange, operation);
+	    	break;
+	    }
+	}
+	
+    protected void doClone(Exchange exchange, String operation) {
+    	Git result = null;
+    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+    		throw new IllegalArgumentException("Local path must specified to execute" + operation);
+    	}
+    	try {
+    		File localRepo = new File(endpoint.getLocalPath(), "");
+    		if (!localRepo.exists()) {
+			   result = Git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(),"")).call();
+    		} else {
+               throw new IllegalArgumentException("The local repository directory already exists");
+    		}
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			e.printStackTrace();
+		} finally {
+			result.close();
+		}
+    }
+
+    protected void doInit(Exchange exchange, String operation) {
+    	Git result = null;
+    	if (ObjectHelper.isEmpty(endpoint.getLocalPath())) {
+    		throw new IllegalArgumentException("Local path must specified to execute" + operation);
+    	}
+    	try {
+			result = Git.init().setDirectory(new File(endpoint.getLocalPath(),"")).call();
+		} catch (Exception e) {
+			LOG.error("There was an error in Git " + operation + " operation");
+			e.printStackTrace();
+		} finally {
+			result.close();
+		}
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/resources/META-INF/LICENSE.txt b/components/camel-git/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-git/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/resources/META-INF/NOTICE.txt b/components/camel-git/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-git/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/main/resources/META-INF/services/org/apache/camel/component/git
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/resources/META-INF/services/org/apache/camel/component/git b/components/camel-git/src/main/resources/META-INF/services/org/apache/camel/component/git
new file mode 100644
index 0000000..05f799b
--- /dev/null
+++ b/components/camel-git/src/main/resources/META-INF/services/org/apache/camel/component/git
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+class=org.apache.camel.component.git.GitComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
new file mode 100755
index 0000000..22e66b6
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -0,0 +1,86 @@
+/**
+ * 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.producer;
+
+import java.io.File;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class GitProducerTest extends CamelTestSupport{
+
+	private final static String GIT_LOCAL_REPO = "pippo";
+	
+    @Override
+    public void setUp() throws Exception {
+    	super.setUp();
+        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
+        localPath.delete();
+        File path = new File(GIT_LOCAL_REPO);
+        path.deleteOnExit();
+    }
+    
+    @Override
+    public void tearDown() throws Exception {
+    	super.tearDown();
+        File path = new File(GIT_LOCAL_REPO);
+        deleteDirectory(path);
+    }
+    
+    @Test
+    public void cloneTest() throws Exception {
+        template.sendBody("direct:clone","");
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+    }
+    
+    @Test
+    public void initTest() throws Exception {
+        template.sendBody("direct:init","");
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+    }
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {            
+            @Override
+            public void configure() throws Exception {
+                from("direct:clone")
+                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=clone");
+                from("direct:init")
+                        .to("git://https://github.com/oscerd/json-webserver-example.git?localPath=" + GIT_LOCAL_REPO + "&operation=init");
+            } 
+        };
+    }
+    
+    static public boolean deleteDirectory(File path) {
+        if( path.exists() ) {
+          File[] files = path.listFiles();
+          for(int i=0; i<files.length; i++) {
+             if(files[i].isDirectory()) {
+               deleteDirectory(files[i]);
+             }
+             else {
+               files[i].delete();
+             }
+          }
+        }
+        return( path.delete() );
+      }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/91b8b575/components/camel-git/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/resources/log4j.properties b/components/camel-git/src/test/resources/log4j.properties
new file mode 100644
index 0000000..6d77cde
--- /dev/null
+++ b/components/camel-git/src/test/resources/log4j.properties
@@ -0,0 +1,36 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, file
+
+#log4j.logger.org.apache.camel=DEBUG
+
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-git-test.log
+log4j.appender.file.append=true
+


[20/23] camel git commit: CAMEL-7982: Use instantiated git also in init and clone producer operation

Posted by ac...@apache.org.
CAMEL-7982: Use instantiated git also in init and clone producer operation


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

Branch: refs/heads/master
Commit: 3d154430015fd925d8e192005f59b73197124554
Parents: 4653526
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:07:29 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:17 2015 +0200

----------------------------------------------------------------------
 .../org/apache/camel/component/git/producer/GitProducer.java     | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/3d154430/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
index 57a6e01..6e6a783 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/producer/GitProducer.java
@@ -147,7 +147,7 @@ public class GitProducer extends DefaultProducer {
         try {
             File localRepo = new File(endpoint.getLocalPath(), "");
             if (!localRepo.exists()) {
-                result = Git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(), "")).call();
+                result = git.cloneRepository().setURI(endpoint.getRemotePath()).setDirectory(new File(endpoint.getLocalPath(), "")).call();
             } else {
                 throw new IllegalArgumentException("The local repository directory already exists");
             }
@@ -165,7 +165,7 @@ public class GitProducer extends DefaultProducer {
             throw new IllegalArgumentException("Local path must specified to execute " + operation);
         }
         try {
-            result = Git.init().setDirectory(new File(endpoint.getLocalPath(), "")).setBare(false).call();
+            result = git.init().setDirectory(new File(endpoint.getLocalPath(), "")).setBare(false).call();
         } catch (Exception e) {
             LOG.error("There was an error in Git " + operation + " operation");
             throw e;


[12/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add tag consumer

Posted by ac...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
deleted file mode 100644
index 085fa1c..0000000
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/**
- * 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.producer;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.git.GitConstants;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.PullResult;
-import org.eclipse.jgit.api.Status;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.lib.Ref;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.revwalk.RevCommit;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-import org.eclipse.jgit.transport.PushResult;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class GitRemoteProducerTest extends GitTestSupport {
-    
-    @Ignore("Require a remote git repository")
-    @Test
-    public void pushTest() throws Exception {
-
-        Repository repository = getTestRepository();
-        
-        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
-        fileToAdd.createNewFile();
-        
-        template.send("direct:add", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
-            }
-        });
-        File gitDir = new File(GIT_LOCAL_REPO, ".git");
-        assertEquals(gitDir.exists(), true);
-        
-        Status status = new Git(repository).status().call();
-        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
-        
-        template.send("direct:commit", new Processor() {
-            @Override
-            public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
-            }
-        });
-
-        Iterable<PushResult> result = template.requestBody("direct:push", "", Iterable.class);
-        
-        repository.close();
-    }
-   
-    @Override
-    protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {            
-            @Override
-            public void configure() throws Exception {
-                from("direct:add")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
-                from("direct:commit")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
-                from("direct:push")
-                        .to("git://" + GIT_LOCAL_REPO + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx" );
-            } 
-        };
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/828dc8b3/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
deleted file mode 100644
index 7c15386..0000000
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/**
- * 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.producer;
-
-import java.io.File;
-import java.io.IOException;
-
-import org.apache.camel.EndpointInject;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.test.junit4.CamelTestSupport;
-import org.eclipse.jgit.api.Git;
-import org.eclipse.jgit.api.errors.GitAPIException;
-import org.eclipse.jgit.lib.Repository;
-import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
-
-public class GitTestSupport extends CamelTestSupport {
-
-    public final static String GIT_LOCAL_REPO = "testRepo";
-
-    public final static String FILENAME_TO_ADD = "filetest.txt";
-
-    public final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
-
-    public final static String COMMIT_MESSAGE = "Test commit";
-
-    public final static String COMMIT_MESSAGE_ALL = "Test commit all";
-
-    public final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
-
-    public final static String BRANCH_TEST = "testBranch";
-
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
-        localPath.delete();
-        File path = new File(GIT_LOCAL_REPO);
-        path.deleteOnExit();
-    }
-
-    @Override
-    public void tearDown() throws Exception {
-        super.tearDown();
-        File path = new File(GIT_LOCAL_REPO);
-        deleteDirectory(path);
-    }
-      
-    protected Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
-        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
-        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
-        // now open the resulting repository with a FileRepositoryBuilder
-        FileRepositoryBuilder builder = new FileRepositoryBuilder();
-        Repository repo = builder.setGitDir(gitRepo)
-                .readEnvironment() // scan environment GIT_* variables
-                .findGitDir() // scan up the file system tree
-                .build();
-        return repo;
-    }
-    
-    static public boolean deleteDirectory(File path) {
-        if( path.exists() ) {
-          File[] files = path.listFiles();
-          for(int i=0; i<files.length; i++) {
-             if(files[i].isDirectory()) {
-               deleteDirectory(files[i]);
-             }
-             else {
-               files[i].delete();
-             }
-          }
-        }
-        return( path.delete() );
-      }
-}


[11/23] camel git commit: CAMEL-7982: camel-git - A generic git component, add Push and Pull operations

Posted by ac...@apache.org.
CAMEL-7982: camel-git - A generic git component, add Push and Pull operations


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

Branch: refs/heads/master
Commit: f3731ed4c1058c97f6471114715e737d5b1d1028
Parents: e224e8e
Author: Andrea Cosentino <an...@gmail.com>
Authored: Sat Jul 18 11:06:38 2015 +0200
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Sat Jul 18 11:08:15 2015 +0200

----------------------------------------------------------------------
 .../camel/component/git/GitOperation.java       |  2 +
 .../apache/camel/component/git/GitProducer.java | 60 +++++++++++++
 .../github/producer/GitProducerTest.java        | 56 +-----------
 .../github/producer/GitRemoteProducerTest.java  | 91 ++++++++++++++++++++
 .../github/producer/GitTestSupport.java         | 86 ++++++++++++++++++
 5 files changed, 243 insertions(+), 52 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/f3731ed4/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
index df7bb0f..8d7b69a 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitOperation.java
@@ -28,4 +28,6 @@ public interface GitOperation {
     public final static String DELETE_BRANCH_OPERATION = "deleteBranch";
     public final static String STATUS_OPERATION = "status";
     public final static String LOG_OPERATION = "log";
+    public final static String PUSH_OPERATION = "push";
+    public final static String PULL_OPERATION = "pull";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f3731ed4/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
index e931d54..42a55e6 100644
--- a/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
+++ b/components/camel-git/src/main/java/org/apache/camel/component/git/GitProducer.java
@@ -7,10 +7,14 @@ import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultProducer;
 import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.PullResult;
 import org.eclipse.jgit.api.Status;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.PushResult;
+import org.eclipse.jgit.transport.RefSpec;
+import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -78,6 +82,14 @@ public class GitProducer extends DefaultProducer{
             case GitOperation.LOG_OPERATION:
                 doLog(exchange, operation, repo);
                 break;
+                
+            case GitOperation.PUSH_OPERATION:
+                doPush(exchange, operation, repo);
+                break;
+                            
+            case GitOperation.PULL_OPERATION:
+                doPull(exchange, operation, repo);
+                break;
 	    }
 	    repo.close();
 	}
@@ -257,6 +269,54 @@ public class GitProducer extends DefaultProducer{
         exchange.getOut().setBody(revCommit);
     }
     
+    protected void doPush(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        Iterable<PushResult> result = null;
+        try {
+            git = new Git(repo);
+            if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
+                throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
+                UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
+                result = git.push().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
+            } else {
+                result = git.push().setRemote(endpoint.getRemotePath()).call();
+            }
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        e.printStackTrace();
+                }
+        exchange.getOut().setBody(result);
+    }
+    
+    protected void doPull(Exchange exchange, String operation, Repository repo) {
+        Git git = null;
+        PullResult result = null;
+        try {
+            git = new Git(repo);
+            if (ObjectHelper.isEmpty(endpoint.getRemotePath())) {
+                throw new IllegalArgumentException("Remote path must be specified to execute " + operation);
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
+                git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
+            } 
+            if (ObjectHelper.isNotEmpty(endpoint.getUsername()) && ObjectHelper.isNotEmpty(endpoint.getPassword())) {
+                UsernamePasswordCredentialsProvider credentials = new UsernamePasswordCredentialsProvider(endpoint.getUsername(), endpoint.getPassword());
+                result = git.pull().setCredentialsProvider(credentials).setRemote(endpoint.getRemotePath()).call();
+            } else {
+                result = git.pull().setRemote(endpoint.getRemotePath()).call();
+            }
+                } catch (Exception e) {
+                        LOG.error("There was an error in Git " + operation + " operation");
+                        e.printStackTrace();
+                }
+        exchange.getOut().setBody(result);
+    }
+    
     private Repository getLocalRepository(){
         FileRepositoryBuilder builder = new FileRepositoryBuilder();
         Repository repo = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/f3731ed4/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
index 8ad0cb6..cee4011 100755
--- a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitProducerTest.java
@@ -33,33 +33,11 @@ import org.eclipse.jgit.lib.Ref;
 import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.PushResult;
+import org.junit.Ignore;
 import org.junit.Test;
 
-public class GitProducerTest extends CamelTestSupport {
-
-	private final static String GIT_LOCAL_REPO = "testRepo";
-	private final static String FILENAME_TO_ADD = "filetest.txt";
-	private final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
-	private final static String COMMIT_MESSAGE = "Test commit";
-        private final static String COMMIT_MESSAGE_ALL = "Test commit all";
-	private final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
-	private final static String BRANCH_TEST = "testBranch";
-	
-    @Override
-    public void setUp() throws Exception {
-    	super.setUp();
-        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
-        localPath.delete();
-        File path = new File(GIT_LOCAL_REPO);
-        path.deleteOnExit();
-    }
-    
-    @Override
-    public void tearDown() throws Exception {
-    	super.tearDown();
-        File path = new File(GIT_LOCAL_REPO);
-        deleteDirectory(path);
-    }
+public class GitProducerTest extends GitTestSupport {
     
     @Test
     public void cloneTest() throws Exception {
@@ -742,31 +720,5 @@ public class GitProducerTest extends CamelTestSupport {
             } 
         };
     }
-    
-    private Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
-        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
-        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
-        // now open the resulting repository with a FileRepositoryBuilder
-        FileRepositoryBuilder builder = new FileRepositoryBuilder();
-        Repository repo = builder.setGitDir(gitRepo)
-                .readEnvironment() // scan environment GIT_* variables
-                .findGitDir() // scan up the file system tree
-                .build();
-        return repo;
-    }
-    
-    static public boolean deleteDirectory(File path) {
-        if( path.exists() ) {
-          File[] files = path.listFiles();
-          for(int i=0; i<files.length; i++) {
-             if(files[i].isDirectory()) {
-               deleteDirectory(files[i]);
-             }
-             else {
-               files[i].delete();
-             }
-          }
-        }
-        return( path.delete() );
-      }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/f3731ed4/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
new file mode 100644
index 0000000..085fa1c
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitRemoteProducerTest.java
@@ -0,0 +1,91 @@
+/**
+ * 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.producer;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.git.GitConstants;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.PullResult;
+import org.eclipse.jgit.api.Status;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Ref;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+import org.eclipse.jgit.transport.PushResult;
+import org.junit.Ignore;
+import org.junit.Test;
+
+public class GitRemoteProducerTest extends GitTestSupport {
+    
+    @Ignore("Require a remote git repository")
+    @Test
+    public void pushTest() throws Exception {
+
+        Repository repository = getTestRepository();
+        
+        File fileToAdd = new File(GIT_LOCAL_REPO, FILENAME_TO_ADD);
+        fileToAdd.createNewFile();
+        
+        template.send("direct:add", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, FILENAME_TO_ADD);
+            }
+        });
+        File gitDir = new File(GIT_LOCAL_REPO, ".git");
+        assertEquals(gitDir.exists(), true);
+        
+        Status status = new Git(repository).status().call();
+        assertTrue(status.getAdded().contains(FILENAME_TO_ADD));
+        
+        template.send("direct:commit", new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, COMMIT_MESSAGE);
+            }
+        });
+
+        Iterable<PushResult> result = template.requestBody("direct:push", "", Iterable.class);
+        
+        repository.close();
+    }
+   
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {            
+            @Override
+            public void configure() throws Exception {
+                from("direct:add")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=add");
+                from("direct:commit")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=commit");
+                from("direct:push")
+                        .to("git://" + GIT_LOCAL_REPO + "?operation=push&remotePath=remoteURL&username=xxx&password=xxx" );
+            } 
+        };
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/f3731ed4/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
new file mode 100644
index 0000000..0aa3946
--- /dev/null
+++ b/components/camel-git/src/test/java/org/apache/camel/component/github/producer/GitTestSupport.java
@@ -0,0 +1,86 @@
+/**
+ * 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.producer;
+
+import java.io.File;
+import java.io.IOException;
+
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.eclipse.jgit.api.Git;
+import org.eclipse.jgit.api.errors.GitAPIException;
+import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.storage.file.FileRepositoryBuilder;
+
+public class GitTestSupport extends CamelTestSupport {
+
+    public final static String GIT_LOCAL_REPO = "testRepo";
+
+    public final static String FILENAME_TO_ADD = "filetest.txt";
+
+    public final static String FILENAME_BRANCH_TO_ADD = "filetest1.txt";
+
+    public final static String COMMIT_MESSAGE = "Test commit";
+
+    public final static String COMMIT_MESSAGE_ALL = "Test commit all";
+
+    public final static String COMMIT_MESSAGE_BRANCH = "Test commit on a branch";
+
+    public final static String BRANCH_TEST = "testBranch";
+
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        File localPath = File.createTempFile(GIT_LOCAL_REPO, "");
+        localPath.delete();
+        File path = new File(GIT_LOCAL_REPO);
+        path.deleteOnExit();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        File path = new File(GIT_LOCAL_REPO);
+        deleteDirectory(path);
+    }
+      
+    protected Repository getTestRepository() throws IOException, IllegalStateException, GitAPIException {
+        File gitRepo = new File(GIT_LOCAL_REPO, ".git");
+        Git.init().setDirectory(new File(GIT_LOCAL_REPO,"")).setBare(false).call();
+        // now open the resulting repository with a FileRepositoryBuilder
+        FileRepositoryBuilder builder = new FileRepositoryBuilder();
+        Repository repo = builder.setGitDir(gitRepo)
+                .readEnvironment() // scan environment GIT_* variables
+                .findGitDir() // scan up the file system tree
+                .build();
+        return repo;
+    }
+    
+    static public boolean deleteDirectory(File path) {
+        if( path.exists() ) {
+          File[] files = path.listFiles();
+          for(int i=0; i<files.length; i++) {
+             if(files[i].isDirectory()) {
+               deleteDirectory(files[i]);
+             }
+             else {
+               files[i].delete();
+             }
+          }
+        }
+        return( path.delete() );
+      }
+}