Last active
August 29, 2015 14:22
-
-
Save punya/39f83a1437515f5a2143 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package gittests; | |
import org.assertj.core.api.Assertions; | |
import org.eclipse.jgit.api.Git; | |
import org.eclipse.jgit.api.errors.GitAPIException; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import org.junit.rules.TemporaryFolder; | |
import java.io.File; | |
import java.io.IOException; | |
public final class GitTests { | |
@Rule | |
public final TemporaryFolder folder = new TemporaryFolder(); | |
@Test | |
public void testSsh() throws GitAPIException, IOException { | |
testClone("git@github.com:palantir/gradle-miniconda-plugin.git"); | |
} | |
@Test | |
public void testHttps() throws GitAPIException, IOException { | |
testClone("https://github.com/palantir/gradle-miniconda-plugin.git"); | |
} | |
private void testClone(String remote) throws GitAPIException, IOException { | |
Git result = null; | |
try { | |
result = Git.cloneRepository() | |
.setURI(remote) | |
.setDirectory(folder.getRoot()) | |
.call(); | |
Assertions.assertThat(new File(folder.getRoot(), ".travis.yml")).exists(); | |
} finally { | |
if (result != null) { | |
result.close(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment