Refactor unit tests using Jgit instead of camel-git to initialise the context
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e396f77d Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e396f77d Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e396f77d Branch: refs/heads/master Commit: e396f77d3ba24e8271fc8d6169c68a9af0e23afb Parents: 0be70c5 Author: Olivier Antibi <[email protected]> Authored: Mon Nov 21 22:34:03 2016 +0100 Committer: Olivier Antibi <[email protected]> Committed: Tue Nov 22 10:34:41 2016 +0100 ---------------------------------------------------------------------- .../camel/component/git/GitTestSupport.java | 4 + .../component/git/consumer/GitConsumerTest.java | 215 ++---- .../component/git/producer/GitProducerTest.java | 774 ++++++------------- 3 files changed, 309 insertions(+), 684 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/e396f77d/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 ce0cc01..15bd8ce 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 @@ -74,4 +74,8 @@ public class GitTestSupport extends CamelTestSupport { .build(); return repo; } + + protected Git getGitTestRepository() throws IOException, IllegalStateException, GitAPIException { + return new Git(getTestRepository()); + } } http://git-wip-us.apache.org/repos/asf/camel/blob/e396f77d/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 a36c746..f2b5db1 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 @@ -18,124 +18,79 @@ package org.apache.camel.component.git.consumer; import java.io.File; import java.util.List; +import java.util.concurrent.TimeUnit; import org.apache.camel.Exchange; import org.apache.camel.Processor; +import org.apache.camel.builder.NotifyBuilder; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.git.GitConstants; 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.internal.storage.file.RefDirectory; +import org.eclipse.jgit.lib.ObjectIdRef; 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-commit"); - - 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); - } - }); + // Init + MockEndpoint mockResultCommit = getMockEndpoint("mock:result-commit"); + mockResultCommit.expectedMessageCount(2); + Git git = getGitTestRepository(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + File fileToAdd = new File(gitLocalRepo, filenameToAdd); + fileToAdd.createNewFile(); + git.add().addFilepattern(filenameToAdd).call(); + Status status = git.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); - } - }); - Iterable<RevCommit> logs = new Git(repository).log() - .call(); - int count = 0; - for (RevCommit rev : logs) { - assertEquals(rev.getShortMessage(), commitMessage); - count++; - } - assertEquals(count, 1); - + git.commit().setMessage(commitMessage).call(); 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, filenameBranchToAdd); - } - }); - - status = new Git(repository).status().call(); + git.add().addFilepattern(filenameBranchToAdd).call(); + status = git.status().call(); assertTrue(status.getAdded().contains(filenameBranchToAdd)); - - 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; + git.commit().setMessage("Test test Commit").call(); + Iterable<RevCommit> logs = git.log().call(); + int 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); + + // Test + mockResultCommit.assertIsSatisfied(); + + // Check + Exchange ex1 = mockResultCommit.getExchanges().get(0); + Exchange ex2 = mockResultCommit.getExchanges().get(1); assertEquals(commitMessage, ex2.getOut().getBody(RevCommit.class).getShortMessage()); assertEquals("Test test Commit", ex1.getOut().getBody(RevCommit.class).getShortMessage()); - repository.close(); + git.close(); } - + @Test public void tagConsumerTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + MockEndpoint mockResultTag = getMockEndpoint("mock:result-tag"); + mockResultTag.expectedMessageCount(1); + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.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", ""); - + git.commit().setMessage(commitMessage).call(); + git.tag().setName(tagTest).call(); List<Ref> ref = git.tagList().call(); boolean tagCreated = false; for (Ref refInternal : ref) { @@ -144,45 +99,32 @@ public class GitConsumerTest extends GitTestSupport { } } assertEquals(tagCreated, true); - - MockEndpoint added = getMockEndpoint("mock:result-tag"); - - Thread.sleep(1 * 5000); - assertEquals(added.getExchanges().size(), 1); - repository.close(); + + // Test + mockResultTag.assertIsSatisfied(); + + // Check + Exchange exchange = mockResultTag.getExchanges().get(0); + assertEquals("refs/tags/" + tagTest, exchange.getOut().getBody(ObjectIdRef.Unpeeled.class).getName()); + git.close(); } - + @Test public void branchConsumerTest() throws Exception { - Repository repository = getTestRepository(); - + // Init + MockEndpoint mockResultBranch = getMockEndpoint("mock:result-branch"); + mockResultBranch.expectedMessageCount(2); + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.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", ""); - + git.commit().setMessage(commitMessage).call(); + git.branchCreate().setName(branchTest).call(); List<Ref> ref = git.branchList().call(); boolean branchCreated = false; for (Ref refInternal : ref) { @@ -191,40 +133,35 @@ public class GitConsumerTest extends GitTestSupport { } } assertEquals(branchCreated, true); - - MockEndpoint added = getMockEndpoint("mock:result-branch"); - - Thread.sleep(1 * 5000); - assertEquals(added.getExchanges().size(), 2); - repository.close(); + + + // Test + mockResultBranch.assertIsSatisfied(); + + // Check + List<Exchange> exchanges = mockResultBranch.getExchanges(); + assertEquals("refs/heads/master", exchanges.get(0).getOut().getBody(ObjectIdRef.Unpeeled.class).getName()); + assertEquals("refs/heads/" + branchTest, exchanges.get(1).getOut().getBody(ObjectIdRef.Unpeeled.class).getName()); + + git.close(); } - + @Override protected RouteBuilder createRouteBuilder() throws Exception { - return new RouteBuilder() { + return new RouteBuilder() { @Override public void configure() throws Exception { - from("direct:clone") - .to("git://" + gitLocalRepo + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone"); - from("direct:init") - .to("git://" + gitLocalRepo + "?operation=init"); - from("direct:add") - .to("git://" + gitLocalRepo + "?operation=add"); - from("direct:commit") - .to("git://" + gitLocalRepo + "?operation=commit"); - from("direct:create-branch") - .to("git://" + gitLocalRepo + "?operation=createBranch&branchName=" + branchTest); - from("direct:create-tag") - .to("git://" + gitLocalRepo + "?operation=createTag&tagName=" + tagTest); - from("git://" + gitLocalRepo + "?type=commit") - .to("mock:result-commit"); - from("git://" + gitLocalRepo + "?type=tag") - .to("mock:result-tag"); - from("git://" + gitLocalRepo + "?type=branch") - .to("mock:result-branch"); - } + from("direct:clone").to("git://" + gitLocalRepo + "?remotePath=https://github.com/oscerd/json-webserver-example.git&operation=clone"); + from("direct:init").to("git://" + gitLocalRepo + "?operation=init"); + from("direct:add").to("git://" + gitLocalRepo + "?operation=add"); + from("direct:commit").to("git://" + gitLocalRepo + "?operation=commit"); + from("direct:create-branch").to("git://" + gitLocalRepo + "?operation=createBranch&branchName=" + branchTest); + from("direct:create-tag").to("git://" + gitLocalRepo + "?operation=createTag&tagName=" + tagTest); + from("git://" + gitLocalRepo + "?type=commit").to("mock:result-commit"); + from("git://" + gitLocalRepo + "?type=tag").to("mock:result-tag"); + from("git://" + gitLocalRepo + "?type=branch").to("mock:result-branch"); + } }; } } - http://git-wip-us.apache.org/repos/asf/camel/blob/e396f77d/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 3d8674d..94edb9c 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 @@ -18,6 +18,7 @@ package org.apache.camel.component.git.producer; import java.io.File; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Map; import org.apache.camel.CamelExecutionException; @@ -74,139 +75,121 @@ public class GitProducerTest extends GitTestSupport { @Test public void addTest() throws Exception { - - Repository repository = getTestRepository(); - + Git git = getGitTestRepository(); 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); - } - }); + // Test camel-git add + template.sendBodyAndHeader("direct:add", "", GitConstants.GIT_FILE_NAME, filenameToAdd); + File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.status().call(); assertTrue(status.getAdded().contains(filenameToAdd)); - repository.close(); + git.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 { - exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd); - } - }); + // Init + Git git = getGitTestRepository(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + File fileToAdd = new File(gitLocalRepo, filenameToAdd); + fileToAdd.createNewFile(); + git.add().addFilepattern(filenameToAdd).call(); + Status status = git.status().call(); 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, filenameToAdd); - } - }); + // Test camel-git remove + template.sendBodyAndHeader("direct:remove", "", GitConstants.GIT_FILE_NAME, filenameToAdd); + + // Check 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, commitMessage); - } - }); - Iterable<RevCommit> logs = new Git(repository).log().call(); + git.commit().setMessage(commitMessage).call(); + Iterable<RevCommit> logs = git.log().call(); int count = 0; for (RevCommit rev : logs) { assertEquals(rev.getShortMessage(), commitMessage); count++; } assertEquals(count, 1); - - status = new Git(repository).status().call(); - + status = git.status().call(); assertFalse(status.getAdded().contains(filenameToAdd)); - - repository.close(); + git.close(); } @Test public void commitTest() throws Exception { - - Repository repository = getTestRepository(); - Git git = new Git(repository); + // Init + Git git = getGitTestRepository(); 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); - } - }); - File gitDir = new File(gitLocalRepo, ".git"); - assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + git.add().addFilepattern(filenameToAdd).call(); + Status status = git.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); - } - }); - validateGitLogs(git, commitMessage); - repository.close(); + // Test camel-git commit + template.sendBodyAndHeader("direct:commit", "", GitConstants.GIT_COMMIT_MESSAGE, commitMessage); + + // Check + Iterable<RevCommit> logs = git.log().call(); + int count = 0; + for (RevCommit rev : logs) { + assertEquals(rev.getShortMessage(), commitMessage); + count++; + } + assertEquals(count, 1); + git.close(); } @Test public void commitTestEmpty() throws Exception { - Repository repository = getTestRepository(); + // Init + Git git = getGitTestRepository(); 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(); + + // Test camel-git commit (with no changes) template.requestBodyAndHeader("direct:commit", "", GitConstants.GIT_COMMIT_MESSAGE, commitMessage); + + // Check that it has been commited twice + Iterable<RevCommit> logs = git.log().call(); + int count = 0; + for (RevCommit rev : logs) { + assertEquals(rev.getShortMessage(), commitMessage); + count++; + } + assertEquals(count, 2); + git.close(); } @Test(expected = CamelExecutionException.class) public void commitTestAllowEmptyFalse() throws Exception { - Repository repository = getTestRepository(); + // Init + Git git = getGitTestRepository(); 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(); + + // Test camel-git commit (with allowEmpty set to false) 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); + + // Check : An exception should have been raised } @Test @@ -229,39 +212,26 @@ public class GitProducerTest extends GitTestSupport { @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 { - exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd); - } - }); + // Init + Git git = getGitTestRepository(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + File fileToAdd = new File(gitLocalRepo, filenameToAdd); + fileToAdd.createNewFile(); + git.add().addFilepattern(filenameToAdd).call(); + Status status = git.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); - } - }); - Iterable<RevCommit> logs = new Git(repository).log().call(); + git.commit().setMessage(commitMessage).call(); + Iterable<RevCommit> logs = git.log().call(); int count = 0; for (RevCommit rev : logs) { assertEquals(rev.getShortMessage(), commitMessage); count++; } assertEquals(count, 1); - Git git = new Git(repository); git.checkout().setCreateBranch(true).setName(branchTest).setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call(); + + // Test camel-git commit (with branch) template.send("direct:commit-branch", new Processor() { @Override public void process(Exchange exchange) throws Exception { @@ -280,23 +250,15 @@ public class GitProducerTest extends GitTestSupport { count++; } assertEquals(count, 2); - repository.close(); + git.close(); } @Test public void commitAllTest() throws Exception { - - Repository repository = getTestRepository(); - + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); template.send("direct:commit-all", new Processor() { @Override @@ -304,43 +266,29 @@ public class GitProducerTest extends GitTestSupport { exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll); } }); - Iterable<RevCommit> logs = new Git(repository).log().call(); + Iterable<RevCommit> logs = git.log().call(); int count = 0; for (RevCommit rev : logs) { assertEquals(rev.getShortMessage(), commitMessageAll); count++; } assertEquals(count, 1); - repository.close(); + git.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 { - exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd); - } - }); + // Init + Git git = getGitTestRepository(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + File fileToAdd = new File(gitLocalRepo, filenameToAdd); + fileToAdd.createNewFile(); + git.add().addFilepattern(filenameToAdd).call(); + Status status = git.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); - } - }); - Iterable<RevCommit> logs = new Git(repository).log().call(); + git.commit().setMessage(commitMessage).call(); + Iterable<RevCommit> logs = git.log().call(); int count = 0; for (RevCommit rev : logs) { assertEquals(rev.getShortMessage(), commitMessage); @@ -348,12 +296,12 @@ public class GitProducerTest extends GitTestSupport { } assertEquals(count, 1); - Git git = new Git(repository); git.checkout().setCreateBranch(true).setName(branchTest).setUpstreamMode(SetupUpstreamMode.SET_UPSTREAM).call(); File fileToAdd1 = new File(gitLocalRepo, filenameBranchToAdd); fileToAdd1.createNewFile(); + // Test camel-git add and commit (different branches) template.send("direct:add-on-branch", new Processor() { @Override public void process(Exchange exchange) throws Exception { @@ -367,6 +315,8 @@ public class GitProducerTest extends GitTestSupport { exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll); } }); + + // Check logs = git.log().call(); count = 0; for (RevCommit rev : logs) { @@ -379,62 +329,33 @@ public class GitProducerTest extends GitTestSupport { count++; } assertEquals(count, 2); - repository.close(); + git.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 { - exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd); - } - }); + // Init + Git git = getGitTestRepository(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + File fileToAdd = new File(gitLocalRepo, filenameToAdd); + fileToAdd.createNewFile(); + git.add().addFilepattern(filenameToAdd).call(); + Status status = git.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); - } - }); - Iterable<RevCommit> logs = new Git(repository).log().call(); + git.commit().setMessage(commitMessage).call(); + Iterable<RevCommit> logs = git.log().call(); int count = 0; for (RevCommit rev : logs) { assertEquals(rev.getShortMessage(), commitMessage); count++; } assertEquals(count, 1); - - Git git = new Git(repository); git.checkout().setCreateBranch(true).setName(branchTest).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 { - exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessageAll); - } - }); + git.add().addFilepattern(filenameBranchToAdd).call(); + git.commit().setMessage(commitMessageAll).call(); logs = git.log().call(); count = 0; for (RevCommit rev : logs) { @@ -448,6 +369,7 @@ public class GitProducerTest extends GitTestSupport { } assertEquals(count, 2); + // Test camel-git remove template.send("direct:remove-on-branch", new Processor() { @Override public void process(Exchange exchange) throws Exception { @@ -455,46 +377,30 @@ public class GitProducerTest extends GitTestSupport { } }); - git = new Git(repository); + // Check git.checkout().setCreateBranch(false).setName(branchTest).call(); - status = git.status().call(); assertFalse(status.getAdded().contains(filenameToAdd)); - - repository.close(); + git.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 { - exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameToAdd); - } - }); + // Init + Git git = getGitTestRepository(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + 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.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); - + // Test camel-git create-branch template.sendBody("direct:create-branch", ""); + // Check List<Ref> ref = git.branchList().call(); boolean branchCreated = false; for (Ref refInternal : ref) { @@ -503,40 +409,22 @@ public class GitProducerTest extends GitTestSupport { } } assertEquals(branchCreated, true); - repository.close(); + git.close(); } @Test public void deleteBranchTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.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", ""); - + git.commit().setMessage(commitMessage).call(); + git.branchCreate().setName(branchTest).call(); List<Ref> ref = git.branchList().call(); boolean branchCreated = false; for (Ref refInternal : ref) { @@ -546,6 +434,7 @@ public class GitProducerTest extends GitTestSupport { } assertEquals(branchCreated, true); + // Test camel-git delete-branch template.sendBody("direct:delete-branch", ""); ref = git.branchList().call(); @@ -556,63 +445,42 @@ public class GitProducerTest extends GitTestSupport { } } assertEquals(branchCreated, false); - repository.close(); + git.close(); } @Test public void statusTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); + // Test camel-git status Status status = template.requestBody("direct:status", "", Status.class); - assertTrue(status.getAdded().contains(filenameToAdd)); - repository.close(); + // Check + assertTrue(status.getAdded().contains(filenameToAdd)); + Status gitStatus = git.status().call(); + assertEquals(gitStatus.getAdded(), status.getAdded()); + git.close(); } @Test public void statusBranchTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = template.requestBody("direct:status", "", Status.class); + Status status = git.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); - } - }); - - template.sendBody("direct:create-branch", ""); - - Git git = new Git(repository); - + git.commit().setMessage(commitMessage).call(); + git.branchCreate().setName(branchTest).call(); List<Ref> ref = git.branchList().call(); boolean branchCreated = false; for (Ref refInternal : ref) { @@ -621,93 +489,60 @@ public class GitProducerTest extends GitTestSupport { } } assertEquals(branchCreated, true); - File fileToAddDifferent = new File(gitLocalRepo, filenameBranchToAdd); fileToAddDifferent.createNewFile(); + git.add().addFilepattern(filenameBranchToAdd).call(); - template.send("direct:add-on-branch", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(GitConstants.GIT_FILE_NAME, filenameBranchToAdd); - } - }); - + // Test camel-git status branch status = template.requestBody("direct:status-branch", "", Status.class); + + // Check assertTrue(status.getAdded().contains(filenameBranchToAdd)); + Status gitStatus = git.status().call(); + assertEquals(gitStatus.getAdded(), status.getAdded()); - repository.close(); + git.close(); } @Test public void logTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = template.requestBody("direct:status", "", Status.class); + Status status = git.status().call(); assertTrue(status.getAdded().contains(filenameToAdd)); + git.commit().setMessage(commitMessage).call(); - template.send("direct:commit", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, commitMessage); - } - }); - + // Test camel-git log Iterable<RevCommit> revCommits = template.requestBody("direct:log", "", Iterable.class); + + // Check + Iterator<RevCommit> gitLogs = git.log().call().iterator(); for (RevCommit rev : revCommits) { - assertEquals(rev.getShortMessage(), commitMessage); + RevCommit gitRevCommit = gitLogs.next(); + assertEquals(gitRevCommit.getName(), rev.getName()); } - repository.close(); + + git.close(); } @Test public void logBranchTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = template.requestBody("direct:status", "", Status.class); + Status status = git.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); - } - }); - - 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); - + git.commit().setMessage(commitMessage).call(); + git.branchCreate().setName(branchTest).call(); List<Ref> ref = git.branchList().call(); boolean branchCreated = false; for (Ref refInternal : ref) { @@ -716,70 +551,41 @@ public class GitProducerTest extends GitTestSupport { } } assertEquals(branchCreated, true); - File fileToAddDifferent = new File(gitLocalRepo, filenameBranchToAdd); fileToAddDifferent.createNewFile(); + git.add().addFilepattern(filenameBranchToAdd).call(); + git.commit().setMessage(commitMessageAll).call(); - 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); - } - }); + // Test camel-git log (with branches) + Iterable<RevCommit> revCommits = template.requestBody("direct:log-branch", "", Iterable.class); - revCommits = template.requestBody("direct:log-branch", "", Iterable.class); - int count = 0; + // Check + Iterator<RevCommit> gitLogs = git.log().call().iterator(); for (RevCommit rev : revCommits) { - if (count == 0) { - assertEquals(rev.getShortMessage(), commitMessageAll); - } - if (count == 1) { - assertEquals(rev.getShortMessage(), commitMessage); - } - count++; + RevCommit gitRevCommit = gitLogs.next(); + assertEquals(gitRevCommit.getName(), rev.getName()); + assertEquals(gitRevCommit.getShortMessage(), rev.getShortMessage()); } - - repository.close(); + git.close(); } @Test public void createTagTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.status().call(); assertTrue(status.getAdded().contains(filenameToAdd)); + git.commit().setMessage(commitMessage).call(); - 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); - + // Test camel-git create tag template.sendBody("direct:create-tag", ""); + // Check List<Ref> ref = git.tagList().call(); boolean tagCreated = false; for (Ref refInternal : ref) { @@ -788,40 +594,22 @@ public class GitProducerTest extends GitTestSupport { } } assertEquals(tagCreated, true); - repository.close(); + git.close(); } @Test public void deleteTagTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.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", ""); - + git.commit().setMessage(commitMessage).call(); + git.tag().setName(tagTest).call(); List<Ref> ref = git.tagList().call(); boolean tagCreated = false; for (Ref refInternal : ref) { @@ -831,8 +619,10 @@ public class GitProducerTest extends GitTestSupport { } assertEquals(tagCreated, true); + // Test camel-git delete-tag template.sendBody("direct:delete-tag", ""); + // Check ref = git.tagList().call(); boolean tagExists = false; for (Ref refInternal : ref) { @@ -841,123 +631,67 @@ public class GitProducerTest extends GitTestSupport { } } assertEquals(tagExists, false); - repository.close(); + git.close(); } @Test public void showBranchesTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.status().call(); assertTrue(status.getAdded().contains(filenameToAdd)); + git.commit().setMessage(commitMessage).call(); + git.branchCreate().setName(branchTest).call(); - 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", ""); - + // Test camel-git show-branches List<Ref> branches = template.requestBody("direct:show-branches", "", List.class); + // Check Boolean branchExists = false; - for (Ref reference : branches) { if (("refs/heads/" + branchTest).equals(reference.getName())) { branchExists = true; } } assertTrue(branchExists); - - repository.close(); + git.close(); } @Test public void cherryPickTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.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); - } - }); - 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); - + git.commit().setMessage(commitMessage).call(); + git.branchCreate().setName(branchTest).call(); + List<Ref> branches = git.branchList().call(); 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"); + String fileToAdd1Name = "filetest1test.txt"; + File fileToAdd1 = new File(gitLocalRepo, fileToAdd1Name); 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 { - exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, "Test second commit"); - } - }); - logs = new Git(repository).log().call(); - count = 0; + git.add().addFilepattern(fileToAdd1Name).call(); + status = git.status().call(); + assertTrue(status.getAdded().contains(fileToAdd1Name)); + git.commit().setMessage("Test second commit").call(); + Iterable<RevCommit> logs = git.log().call(); + int count = 0; String id = ""; for (RevCommit rev : logs) { if (count == 0) { @@ -968,15 +702,10 @@ public class GitProducerTest extends GitTestSupport { } assertEquals(count, 2); - final String str = id; - template.send("direct:cherrypick", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(GitConstants.GIT_COMMIT_ID, str); - } - }); + // Test camel-git cherry-pick + template.sendBodyAndHeader("direct:cherrypick", "", GitConstants.GIT_COMMIT_ID, id); - Git git = new Git(repository); + // Check git.checkout().setCreateBranch(false).setName(branchTest).call(); logs = git.log().call(); count = 0; @@ -987,79 +716,39 @@ public class GitProducerTest extends GitTestSupport { count++; } assertEquals(count, 2); - repository.close(); + git.close(); } @Test public void cherryPickBranchToMasterTest() throws Exception { - - Repository repository = getTestRepository(); - + // Init + Git git = getGitTestRepository(); 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); - } - }); + git.add().addFilepattern(filenameToAdd).call(); File gitDir = new File(gitLocalRepo, ".git"); assertEquals(gitDir.exists(), true); - - Status status = new Git(repository).status().call(); + Status status = git.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); - } - }); - 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); - + git.commit().setMessage(commitMessage).call(); + git.branchCreate().setName(branchTest).call(); + List<Ref> branches = git.branchList().call(); 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"); + String fileToAdd1Name = "filetest1test.txt"; + File fileToAdd1 = new File(gitLocalRepo, fileToAdd1Name); 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, "filetest1test.txt"); - } - }); - Git git = new Git(repository); - git.checkout().setCreateBranch(false).setName(branchTest).call(); + git.add().addFilepattern(fileToAdd1Name).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 { - exchange.getIn().setHeader(GitConstants.GIT_COMMIT_MESSAGE, "Test second commit"); - } - }); - logs = git.log().call(); - count = 0; + assertTrue(status.getAdded().contains(fileToAdd1Name)); + git.commit().setMessage("Test second commit").call(); + Iterable<RevCommit> logs = git.log().call(); + int count = 0; String id = ""; for (RevCommit rev : logs) { if (count == 0) { @@ -1070,15 +759,10 @@ public class GitProducerTest extends GitTestSupport { } assertEquals(count, 2); - final String str = id; - template.send("direct:cherrypick-master", new Processor() { - @Override - public void process(Exchange exchange) throws Exception { - exchange.getIn().setHeader(GitConstants.GIT_COMMIT_ID, str); - } - }); + // Test camel-git cherry-pick (on master) + template.sendBodyAndHeader("direct:cherrypick-master", "", GitConstants.GIT_COMMIT_ID, id); - git = new Git(repository); + // Check git.checkout().setCreateBranch(false).setName("refs/heads/master").call(); logs = git.log().call(); count = 0; @@ -1089,7 +773,7 @@ public class GitProducerTest extends GitTestSupport { count++; } assertEquals(count, 2); - repository.close(); + git.close(); } @Test
