Loading src/test/java/com/inteligr8/git/CommandUnitTest.java +11 −9 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.inteligr8.git; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.UUID; Loading @@ -10,8 +11,6 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ListBranchCommand.ListMode; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.util.FileUtils; import org.junit.AfterClass; import org.junit.Assert; Loading @@ -20,9 +19,6 @@ import org.junit.Test; public class CommandUnitTest { private final static CredentialsProvider gitCreds = new UsernamePasswordCredentialsProvider( System.getProperty("git.username"), System.getProperty("git.token")); private static File tmpdir; private static Git git; Loading @@ -31,8 +27,7 @@ public class CommandUnitTest { tmpdir = new File(System.getProperty("java.io.tmpdir"), "git-" + UUID.randomUUID().toString() + ".tmp"); git = new CloneCommand() .setURI("git@github.com:bmlong137/env-docker-adbp.git") .setCredentialsProvider(gitCreds) .setURI("git@bitbucket.org:inteligr8/git-utils.git") .setDirectory(tmpdir) .call(); } Loading @@ -45,10 +40,17 @@ public class CommandUnitTest { } @Test public void lotsOfBranches() throws GitAPIException { public void listOfBranches() throws GitAPIException, IOException { List<Ref> remoteBranches = git.branchList().setListMode(ListMode.REMOTE).call(); Assert.assertNotNull(remoteBranches); Assert.assertTrue(remoteBranches.size() > 5); Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/develop"))); Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/stable"))); List<Ref> localBranches = git.branchList().call(); Assert.assertNotNull(localBranches); Assert.assertEquals(1, localBranches.size()); Assert.assertTrue(Collections.disjoint(remoteBranches, localBranches)); } } Loading
src/test/java/com/inteligr8/git/CommandUnitTest.java +11 −9 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ package com.inteligr8.git; import java.io.File; import java.io.IOException; import java.util.Collections; import java.util.List; import java.util.UUID; Loading @@ -10,8 +11,6 @@ import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.ListBranchCommand.ListMode; import org.eclipse.jgit.api.errors.GitAPIException; import org.eclipse.jgit.lib.Ref; import org.eclipse.jgit.transport.CredentialsProvider; import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider; import org.eclipse.jgit.util.FileUtils; import org.junit.AfterClass; import org.junit.Assert; Loading @@ -20,9 +19,6 @@ import org.junit.Test; public class CommandUnitTest { private final static CredentialsProvider gitCreds = new UsernamePasswordCredentialsProvider( System.getProperty("git.username"), System.getProperty("git.token")); private static File tmpdir; private static Git git; Loading @@ -31,8 +27,7 @@ public class CommandUnitTest { tmpdir = new File(System.getProperty("java.io.tmpdir"), "git-" + UUID.randomUUID().toString() + ".tmp"); git = new CloneCommand() .setURI("git@github.com:bmlong137/env-docker-adbp.git") .setCredentialsProvider(gitCreds) .setURI("git@bitbucket.org:inteligr8/git-utils.git") .setDirectory(tmpdir) .call(); } Loading @@ -45,10 +40,17 @@ public class CommandUnitTest { } @Test public void lotsOfBranches() throws GitAPIException { public void listOfBranches() throws GitAPIException, IOException { List<Ref> remoteBranches = git.branchList().setListMode(ListMode.REMOTE).call(); Assert.assertNotNull(remoteBranches); Assert.assertTrue(remoteBranches.size() > 5); Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/develop"))); Assert.assertTrue(remoteBranches.contains(git.getRepository().findRef("origin/stable"))); List<Ref> localBranches = git.branchList().call(); Assert.assertNotNull(localBranches); Assert.assertEquals(1, localBranches.size()); Assert.assertTrue(Collections.disjoint(remoteBranches, localBranches)); } }