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 2016/11/21 11:57:15 UTC

[2/3] camel git commit: Add allowEmpty endpoint option

Add allowEmpty endpoint option


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

Branch: refs/heads/master
Commit: 4034e2a7854a0dc768c8786bf527e7d4474c38f1
Parents: cdd35f0
Author: Olivier Antibi <ol...@crossing-tech.com>
Authored: Sun Nov 20 22:43:15 2016 +0100
Committer: Andrea Cosentino <an...@gmail.com>
Committed: Mon Nov 21 12:54:10 2016 +0100

----------------------------------------------------------------------
 .../camel-git/src/main/docs/git-component.adoc  |   6 +-
 .../camel/component/git/GitConstants.java       |   2 +
 .../apache/camel/component/git/GitEndpoint.java |  15 +
 .../component/git/producer/GitProducer.java     |  34 +-
 .../component/git/producer/GitProducerTest.java | 397 ++++++++++---------
 5 files changed, 261 insertions(+), 193 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/4034e2a7/components/camel-git/src/main/docs/git-component.adoc
----------------------------------------------------------------------
diff --git a/components/camel-git/src/main/docs/git-component.adoc b/components/camel-git/src/main/docs/git-component.adoc
index 3ebe2ad..e7c26cb 100644
--- a/components/camel-git/src/main/docs/git-component.adoc
+++ b/components/camel-git/src/main/docs/git-component.adoc
@@ -40,7 +40,7 @@ The Git component has no options.
 
 
 // endpoint options: START
-The Git component supports 13 endpoint options which are listed below:
+The Git component supports 14 endpoint options which are listed below:
 
 {% raw %}
 [width="100%",cols="2,1,1m,1m,5",options="header"]
@@ -57,6 +57,7 @@ The Git component supports 13 endpoint options which are listed below:
 | type | consumer |  | GitType | The consumer type
 | exceptionHandler | consumer (advanced) |  | ExceptionHandler | To let the consumer use a custom ExceptionHandler. Notice if the option bridgeErrorHandler is enabled then this options is not in use. By default the consumer will deal with exceptions that will be logged at WARN/ERROR level and ignored.
 | exchangePattern | consumer (advanced) |  | ExchangePattern | Sets the exchange pattern when the consumer creates an exchange.
+| allowEmpty | producer | true | boolean | The flag to manage empty git commits
 | operation | producer |  | String | The operation to do on the repository
 | synchronous | advanced | false | boolean | Sets whether synchronous processing should be strictly used or Camel is allowed to use asynchronous processing (if supported).
 |=======================================================================
@@ -85,6 +86,9 @@ Message Headers
 |CamelGitCommitEmail |`null` |String |Producer |The commit email in a commit operation
 
 |CamelGitCommitId |`null` |String |Producer |The commit id
+
+|CamelGitAlowEmpty |`null` |Boolean |Producer |The flag to manage empty git commits
+
 |=======================================================================
 
 [[Git-ProducerExample]]

http://git-wip-us.apache.org/repos/asf/camel/blob/4034e2a7/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 5e575ce..03f54ee 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
@@ -28,4 +28,6 @@ public interface GitConstants {
     String GIT_COMMIT_EMAIL = "CamelGitCommitEmail";
     
     String GIT_COMMIT_ID = "CamelGitCommitId";
+
+    String GIT_ALLOW_EMPTY = "CamelGitAllowEmpty";
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/4034e2a7/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 d25dbb2..44aeb26 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
@@ -61,6 +61,11 @@ public class GitEndpoint extends DefaultEndpoint {
     @UriParam
     private String remoteName;
 
+    @UriParam
+    // Set to true For backward compatibility , better to set to false (native git behavior)
+    @Metadata(defaultValue = "true", label = "producer")
+    private boolean allowEmpty = true;
+
     @UriParam(enums = "clone,init,add,remove,commit,commitAll,createBranch,deleteBranch,createTag,deleteTag,status,log,push,pull,showBranches,cherryPick", label = "producer")
     private String operation;
 
@@ -190,4 +195,14 @@ public class GitEndpoint extends DefaultEndpoint {
         this.remoteName = remoteName;
     }
 
+    /**
+     * The flag to manage empty git commits
+     */
+    public boolean isAllowEmpty() {
+        return allowEmpty;
+    }
+
+    public void setAllowEmpty(boolean allowEmpty) {
+        this.allowEmpty = allowEmpty;
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/4034e2a7/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 be7ef1d..2047aeb 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
@@ -83,7 +83,7 @@ public class GitProducer extends DefaultProducer {
         }
 
         switch (operation) {
-        
+
         case GitOperation.CLONE_OPERATION:
             doClone(exchange, operation);
             break;
@@ -99,7 +99,7 @@ public class GitProducer extends DefaultProducer {
         case GitOperation.CHERRYPICK_OPERATION:
             doCherryPick(exchange, operation);
             break;
-            
+
         case GitOperation.REMOVE_OPERATION:
             doRemove(exchange, operation);
             break;
@@ -143,11 +143,11 @@ public class GitProducer extends DefaultProducer {
         case GitOperation.DELETE_TAG_OPERATION:
             doDeleteTag(exchange, operation);
             break;
-            
+
         case GitOperation.SHOW_BRANCHES:
             doShowBranches(exchange, operation);
             break;
-                
+
         default:
             throw new IllegalArgumentException("Unsupported operation " + operation);
         }
@@ -242,19 +242,24 @@ public class GitProducer extends DefaultProducer {
         } else {
             throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
         }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_USERNAME)) 
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_USERNAME))
                 && ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_EMAIL))) {
             username = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_USERNAME, String.class);
             email = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_EMAIL, String.class);
         }
+        boolean allowEmpty = endpoint.isAllowEmpty();
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_ALLOW_EMPTY))) {
+            allowEmpty = exchange.getIn().getHeader(GitConstants.GIT_ALLOW_EMPTY, Boolean.class);
+        }
+
         try {
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
             }
             if (ObjectHelper.isNotEmpty(username) && ObjectHelper.isNotEmpty(email)) {
-                git.commit().setCommitter(username, email).setMessage(commitMessage).call();
+                git.commit().setAllowEmpty(allowEmpty).setCommitter(username, email).setMessage(commitMessage).call();
             } else {
-                git.commit().setMessage(commitMessage).call();
+                git.commit().setAllowEmpty(allowEmpty).setMessage(commitMessage).call();
             }
         } catch (Exception e) {
             LOG.error("There was an error in Git " + operation + " operation");
@@ -271,19 +276,24 @@ public class GitProducer extends DefaultProducer {
         } else {
             throw new IllegalArgumentException("Commit message must be specified to execute " + operation);
         }
-        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_USERNAME)) 
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_USERNAME))
                 && ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_COMMIT_EMAIL))) {
             username = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_USERNAME, String.class);
             email = exchange.getIn().getHeader(GitConstants.GIT_COMMIT_EMAIL, String.class);
         }
+        boolean allowEmpty = endpoint.isAllowEmpty();
+        if (ObjectHelper.isNotEmpty(exchange.getIn().getHeader(GitConstants.GIT_ALLOW_EMPTY))) {
+            allowEmpty = exchange.getIn().getHeader(GitConstants.GIT_ALLOW_EMPTY, Boolean.class);
+        }
+
         try {
             if (ObjectHelper.isNotEmpty(endpoint.getBranchName())) {
                 git.checkout().setCreateBranch(false).setName(endpoint.getBranchName()).call();
             }
             if (ObjectHelper.isNotEmpty(username) && ObjectHelper.isNotEmpty(email)) {
-                git.commit().setAll(true).setCommitter(username, email).setMessage(commitMessage).call();
+                git.commit().setAllowEmpty(allowEmpty).setAll(true).setCommitter(username, email).setMessage(commitMessage).call();
             } else {
-                git.commit().setAll(true).setMessage(commitMessage).call();
+                git.commit().setAllowEmpty(allowEmpty).setAll(true).setMessage(commitMessage).call();
             }
         } catch (Exception e) {
             LOG.error("There was an error in Git " + operation + " operation");
@@ -410,7 +420,7 @@ public class GitProducer extends DefaultProducer {
             throw e;
         }
     }
-    
+
     protected void doShowBranches(Exchange exchange, String operation) throws Exception {
         List<Ref> result = null;
         try {
@@ -421,7 +431,7 @@ public class GitProducer extends DefaultProducer {
         }
         exchange.getOut().setBody(result);
     }
-    
+
     protected void doCherryPick(Exchange exchange, String operation) throws Exception {
         CherryPickResult result = null;
         String commitId = null;

http://git-wip-us.apache.org/repos/asf/camel/blob/4034e2a7/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 6dc66ed..5491770 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,8 +17,9 @@
 package org.apache.camel.component.git.producer;
 
 import java.io.File;
+import java.util.HashMap;
 import java.util.List;
-
+import java.util.Map;
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -34,22 +35,23 @@ import org.eclipse.jgit.lib.Repository;
 import org.eclipse.jgit.revwalk.RevCommit;
 import org.junit.Test;
 
+
 public class GitProducerTest extends GitTestSupport {
-    
+
     @Test
     public void cloneTest() throws Exception {
         template.sendBody("direct:clone", "");
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
     }
-    
+
     @Test
     public void initTest() throws Exception {
         template.sendBody("direct:init", "");
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
     }
-    
+
     @Test(expected = CamelExecutionException.class)
     public void doubleCloneOperationTest() throws Exception {
         template.sendBody("direct:clone", "");
@@ -57,7 +59,7 @@ public class GitProducerTest extends GitTestSupport {
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
     }
-    
+
     @Test
     public void pullTest() throws Exception {
         template.sendBody("direct:clone", "");
@@ -66,15 +68,15 @@ public class GitProducerTest extends GitTestSupport {
         PullResult pr = template.requestBody("direct:pull", "", PullResult.class);
         assertTrue(pr.isSuccessful());
     }
-    
+
     @Test
     public void addTest() throws Exception {
 
         Repository repository = getTestRepository();
-       
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -83,20 +85,20 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
         repository.close();
     }
-    
+
     @Test
     public void removeTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -105,10 +107,10 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         template.send("direct:remove", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -117,7 +119,7 @@ public class GitProducerTest extends GitTestSupport {
         });
         gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -132,22 +134,22 @@ public class GitProducerTest extends GitTestSupport {
             count++;
         }
         assertEquals(count, 1);
-        
+
         status = new Git(repository).status().call();
 
         assertFalse(status.getAdded().contains(filenameToAdd));
-        
+
         repository.close();
     }
-    
+
     @Test
     public void commitTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -156,10 +158,10 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -176,15 +178,51 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(count, 1);
         repository.close();
     }
-    
+
+    @Test
+    public void commitTestEmpty() throws Exception {
+        Repository repository = getTestRepository();
+        File gitDir = new File(gitLocalRepo, ".git");
+        assertEquals(gitDir.exists(), true);
+        Git git = new Git(repository);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
+        fileToAdd.createNewFile();
+        git.add().addFilepattern(filenameToAdd).call();
+        Status status = git.status().call();
+        assertTrue(status.getAdded().contains(filenameToAdd));
+        git.commit().setMessage(commitMessage).call();
+        template.requestBodyAndHeader("direct:commit", "", GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
+    }
+
+    @Test(expected = CamelExecutionException.class)
+    public void commitTestAllowEmptyFalse() throws Exception {
+        Repository repository = getTestRepository();
+        File gitDir = new File(gitLocalRepo, ".git");
+        assertEquals(gitDir.exists(), true);
+        Git git = new Git(repository);
+        File fileToAdd = new File(gitLocalRepo, filenameToAdd);
+        fileToAdd.createNewFile();
+        git.add().addFilepattern(filenameToAdd).call();
+        Status status = git.status().call();
+        assertTrue(status.getAdded().contains(filenameToAdd));
+        git.commit().setMessage(commitMessage).call();
+        Map<String, Object> headers = new HashMap<>();
+        headers.put(GitConstants.GIT_COMMIT_MESSAGE, commitMessage);
+        headers.put(GitConstants.GIT_ALLOW_EMPTY, true);
+        template.requestBodyAndHeaders("direct:commit", "", headers);
+        headers.remove(GitConstants.GIT_ALLOW_EMPTY);
+        template.requestBodyAndHeaders("direct:commit-not-allow-empty", "", headers);
+    }
+
+
     @Test
     public void commitBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -193,10 +231,10 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -211,11 +249,9 @@ public class GitProducerTest extends GitTestSupport {
             count++;
         }
         assertEquals(count, 1);
-        
         Git git = new Git(repository);
         git.checkout().setCreateBranch(true).setName(branchTest).
-        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
-        
+                setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
         template.send("direct:commit-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -236,24 +272,23 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(count, 2);
         repository.close();
     }
-    
 
-    
+
     @Test
     public void commitAllTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         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, filenameToAdd);
             }
         });
-        
+
         template.send("direct:commit-all", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -270,15 +305,15 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(count, 1);
         repository.close();
     }
-    
+
     @Test
     public void commitAllDifferentBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -287,10 +322,10 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -305,21 +340,21 @@ public class GitProducerTest extends GitTestSupport {
             count++;
         }
         assertEquals(count, 1);
-        
+
         Git git = new Git(repository);
         git.checkout().setCreateBranch(true).setName(branchTest).
-        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
-        
+                setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+
         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, filenameBranchToAdd);
             }
         });
-        
+
         template.send("direct:commit-all-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -340,15 +375,15 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(count, 2);
         repository.close();
     }
-    
+
     @Test
     public void removeFileBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -357,10 +392,10 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -375,21 +410,21 @@ public class GitProducerTest extends GitTestSupport {
             count++;
         }
         assertEquals(count, 1);
-        
+
         Git git = new Git(repository);
         git.checkout().setCreateBranch(true).setName(branchTest).
-        setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
-        
+                setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call();
+
         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, filenameBranchToAdd);
             }
         });
-        
+
         template.send("direct:commit-all-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -408,31 +443,31 @@ public class GitProducerTest extends GitTestSupport {
             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, filenameToAdd);
             }
         });
-        
+
         git = new Git(repository);
         git.checkout().setCreateBranch(false).setName(branchTest).call();
-        
+
         status = git.status().call();
         assertFalse(status.getAdded().contains(filenameToAdd));
-        
+
         repository.close();
     }
-    
+
     @Test
     public void createBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -441,21 +476,21 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         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, commitMessage);
             }
         });
-        
+
         Git git = new Git(repository);
-        
+
         template.sendBody("direct:create-branch", "");
-        
+
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
@@ -466,15 +501,15 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(branchCreated, true);
         repository.close();
     }
-    
+
     @Test
     public void deleteBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -483,21 +518,21 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         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, commitMessage);
             }
         });
-        
+
         Git git = new Git(repository);
-        
+
         template.sendBody("direct:create-branch", "");
-        
+
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
@@ -506,9 +541,9 @@ public class GitProducerTest extends GitTestSupport {
             }
         }
         assertEquals(branchCreated, true);
-        
+
         template.sendBody("direct:delete-branch", "");
-        
+
         ref = git.branchList().call();
         branchCreated = false;
         for (Ref refInternal : ref) {
@@ -519,15 +554,15 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(branchCreated, false);
         repository.close();
     }
-    
+
     @Test
     public void statusTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -536,21 +571,21 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = template.requestBody("direct:status", "", Status.class);
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         repository.close();
     }
-    
+
     @Test
     public void statusBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -559,21 +594,21 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = template.requestBody("direct:status", "", Status.class);
         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, commitMessage);
             }
         });
-        
+
         template.sendBody("direct:create-branch", "");
-        
+
         Git git = new Git(repository);
-        
+
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
@@ -582,31 +617,31 @@ public class GitProducerTest extends GitTestSupport {
             }
         }
         assertEquals(branchCreated, true);
-        
+
         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, filenameBranchToAdd);
             }
         });
-        
+
         status = template.requestBody("direct:status-branch", "", Status.class);
         assertTrue(status.getAdded().contains(filenameBranchToAdd));
-        
+
         repository.close();
     }
-    
+
     @Test
     public void logTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -615,32 +650,32 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = template.requestBody("direct:status", "", Status.class);
         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, commitMessage);
             }
         });
-        
+
         Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
         for (RevCommit rev : revCommits) {
             assertEquals(rev.getShortMessage(), commitMessage);
-        }        
+        }
         repository.close();
     }
-    
+
     @Test
     public void logBranchTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -649,26 +684,26 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = template.requestBody("direct:status", "", Status.class);
         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, commitMessage);
             }
         });
-        
+
         Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class);
         for (RevCommit rev : revCommits) {
             assertEquals(rev.getShortMessage(), commitMessage);
         }
-        
+
         template.sendBody("direct:create-branch", "");
-        
+
         Git git = new Git(repository);
-        
+
         List<Ref> ref = git.branchList().call();
         boolean branchCreated = false;
         for (Ref refInternal : ref) {
@@ -677,24 +712,24 @@ public class GitProducerTest extends GitTestSupport {
             }
         }
         assertEquals(branchCreated, true);
-        
+
         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, filenameBranchToAdd);
             }
         });
-        
+
         template.send("direct:commit-all-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll);
             }
         });
-        
+
         revCommits = template.requestBody("direct:log-branch", "", Iterable.class);
         int count = 0;
         for (RevCommit rev : revCommits) {
@@ -706,18 +741,18 @@ public class GitProducerTest extends GitTestSupport {
             }
             count++;
         }
-        
+
         repository.close();
     }
-    
+
     @Test
     public void createTagTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -726,21 +761,21 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         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, commitMessage);
             }
         });
-        
+
         Git git = new Git(repository);
-        
+
         template.sendBody("direct:create-tag", "");
-        
+
         List<Ref> ref = git.tagList().call();
         boolean tagCreated = false;
         for (Ref refInternal : ref) {
@@ -751,15 +786,15 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(tagCreated, true);
         repository.close();
     }
-    
+
     @Test
     public void deleteTagTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -768,21 +803,21 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         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, commitMessage);
             }
         });
-        
+
         Git git = new Git(repository);
-        
+
         template.sendBody("direct:create-tag", "");
-        
+
         List<Ref> ref = git.tagList().call();
         boolean tagCreated = false;
         for (Ref refInternal : ref) {
@@ -791,9 +826,9 @@ public class GitProducerTest extends GitTestSupport {
             }
         }
         assertEquals(tagCreated, true);
-        
+
         template.sendBody("direct:delete-tag", "");
-        
+
         ref = git.tagList().call();
         boolean tagExists = false;
         for (Ref refInternal : ref) {
@@ -804,15 +839,15 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(tagExists, false);
         repository.close();
     }
-    
+
     @Test
     public void showBranchesTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -821,43 +856,43 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         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, commitMessage);
             }
         });
-        
+
         Git git = new Git(repository);
-        
+
         template.sendBody("direct:create-branch", "");
-        
+
         List<Ref> branches = template.requestBody("direct:show-branches", "", List.class);
-        
+
         Boolean branchExists = false;
-        
+
         for (Ref reference : branches) {
             if (("refs/heads/" + branchTest).equals(reference.getName())) {
                 branchExists = true;
             }
         }
         assertTrue(branchExists);
-        
+
         repository.close();
     }
-    
+
     @Test
     public void cherryPickTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -866,10 +901,10 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -879,39 +914,39 @@ public class GitProducerTest extends GitTestSupport {
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
-        
+
         for (RevCommit rev : logs) {
             assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
-        
+
         template.sendBody("direct:create-branch", "");
-        
+
         List<Ref> branches = template.requestBody("direct:show-branches", "", List.class);
-        
+
         Boolean branchExists = false;
-        
+
         for (Ref reference : branches) {
             if (("refs/heads/" + branchTest).equals(reference.getName())) {
                 branchExists = true;
             }
         }
         assertTrue(branchExists);
-        
+
         File fileToAdd1 = new File(gitLocalRepo, "filetest1test.txt");
         fileToAdd1.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
                 exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, "filetest1test.txt");
             }
         });
-        
+
         status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains("filetest1test.txt"));
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -923,14 +958,14 @@ public class GitProducerTest extends GitTestSupport {
         count = 0;
         String id = "";
         for (RevCommit rev : logs) {
-            if (count == 0) { 
+            if (count == 0) {
                 id = rev.getName();
                 assertEquals(rev.getShortMessage(), "Test second commit");
             }
             count++;
         }
         assertEquals(count, 2);
-        
+
         final String str = id;
         template.send("direct:cherrypick", new Processor() {
             @Override
@@ -938,7 +973,7 @@ public class GitProducerTest extends GitTestSupport {
                 exchange.getIn().setHeader(GitConstants.GIT_COMMIT_ID, str);
             }
         });
-        
+
         Git git = new Git(repository);
         git.checkout().setCreateBranch(false).setName(branchTest).call();
         logs = git.log()
@@ -953,15 +988,15 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(count, 2);
         repository.close();
     }
-    
+
     @Test
     public void cherryPickBranchToMasterTest() throws Exception {
 
         Repository repository = getTestRepository();
-        
+
         File fileToAdd = new File(gitLocalRepo, filenameToAdd);
         fileToAdd.createNewFile();
-        
+
         template.send("direct:add", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -970,10 +1005,10 @@ public class GitProducerTest extends GitTestSupport {
         });
         File gitDir = new File(gitLocalRepo, ".git");
         assertEquals(gitDir.exists(), true);
-        
+
         Status status = new Git(repository).status().call();
         assertTrue(status.getAdded().contains(filenameToAdd));
-        
+
         template.send("direct:commit", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -983,29 +1018,29 @@ public class GitProducerTest extends GitTestSupport {
         Iterable<RevCommit> logs = new Git(repository).log()
                 .call();
         int count = 0;
-        
+
         for (RevCommit rev : logs) {
             assertEquals(rev.getShortMessage(), commitMessage);
             count++;
         }
         assertEquals(count, 1);
-        
+
         template.sendBody("direct:create-branch", "");
-        
+
         List<Ref> branches = template.requestBody("direct:show-branches", "", List.class);
-        
+
         Boolean branchExists = false;
-        
+
         for (Ref reference : branches) {
             if (("refs/heads/" + branchTest).equals(reference.getName())) {
                 branchExists = true;
             }
         }
         assertTrue(branchExists);
-        
+
         File fileToAdd1 = new File(gitLocalRepo, "filetest1test.txt");
         fileToAdd1.createNewFile();
-        
+
         template.send("direct:add-on-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -1016,7 +1051,7 @@ public class GitProducerTest extends GitTestSupport {
         git.checkout().setCreateBranch(false).setName(branchTest).call();
         status = git.status().call();
         assertTrue(status.getAdded().contains("filetest1test.txt"));
-        
+
         template.send("direct:commit-branch", new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -1028,14 +1063,14 @@ public class GitProducerTest extends GitTestSupport {
         count = 0;
         String id = "";
         for (RevCommit rev : logs) {
-            if (count == 0) { 
+            if (count == 0) {
                 id = rev.getName();
                 assertEquals(rev.getShortMessage(), "Test second commit");
             }
             count++;
         }
         assertEquals(count, 2);
-        
+
         final String str = id;
         template.send("direct:cherrypick-master", new Processor() {
             @Override
@@ -1043,7 +1078,7 @@ public class GitProducerTest extends GitTestSupport {
                 exchange.getIn().setHeader(GitConstants.GIT_COMMIT_ID, str);
             }
         });
-        
+
         git = new Git(repository);
         git.checkout().setCreateBranch(false).setName("refs/heads/master").call();
         logs = git.log()
@@ -1058,10 +1093,10 @@ public class GitProducerTest extends GitTestSupport {
         assertEquals(count, 2);
         repository.close();
     }
-    
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
-        return new RouteBuilder() {            
+        return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 from("direct:clone")
@@ -1078,6 +1113,8 @@ public class GitProducerTest extends GitTestSupport {
                         .to("git://" + gitLocalRepo + "?operation=add&branchName=" + branchTest);
                 from("direct:commit")
                         .to("git://" + gitLocalRepo + "?operation=commit");
+                from("direct:commit-not-allow-empty")
+                        .to("git://" + gitLocalRepo + "?operation=commit&allowEmpty=false");
                 from("direct:commit-branch")
                         .to("git://" + gitLocalRepo + "?operation=commit&branchName=" + branchTest);
                 from("direct:commit-all")
@@ -1108,7 +1145,7 @@ public class GitProducerTest extends GitTestSupport {
                         .to("git://" + gitLocalRepo + "?operation=cherryPick&branchName=refs/heads/master");
                 from("direct:pull")
                         .to("git://" + gitLocalRepo + "?remoteName=origin&operation=pull");
-            } 
+            }
         };
     }