]> source.dussan.org Git - jgit.git/commitdiff
Do not catch Exception in test cases 30/3830/2
authorStefan Lay <stefan.lay@sap.com>
Wed, 6 Jul 2011 11:36:57 +0000 (13:36 +0200)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 6 Jul 2011 21:10:52 +0000 (23:10 +0200)
Exception handling is already done by JUnit.

Change-Id: Ia25d768c311d384d728f281aced92f598e5e2041
Signed-off-by: Stefan Lay <stefan.lay@sap.com>
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/CloneCommandTest.java
org.eclipse.jgit.test/tst/org/eclipse/jgit/api/InitCommandTest.java

index 2e3345756d33a70212b629eb341d8ce06cd231fe..ca5260766932c2adc32bfcb9f70035c824e6b9b2 100644 (file)
@@ -44,7 +44,6 @@ package org.eclipse.jgit.api;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
@@ -93,139 +92,111 @@ public class CloneCommandTest extends RepositoryTestCase {
        }
 
        @Test
-       public void testCloneRepository() {
-               try {
-                       File directory = createTempDirectory("testCloneRepository");
-                       CloneCommand command = Git.cloneRepository();
-                       command.setDirectory(directory);
-                       command.setURI("file://"
-                                       + git.getRepository().getWorkTree().getPath());
-                       Git git2 = command.call();
-                       addRepoToClose(git2.getRepository());
-                       assertNotNull(git2);
-                       ObjectId id = git2.getRepository().resolve("tag-for-blob");
-                       assertNotNull(id);
-                       assertEquals(git2.getRepository().getFullBranch(),
-                                       "refs/heads/test");
-                       assertEquals(
-                                       "origin",
-                                       git2.getRepository()
-                                                       .getConfig()
-                                                       .getString(ConfigConstants.CONFIG_BRANCH_SECTION,
-                                                                       "test", ConfigConstants.CONFIG_KEY_REMOTE));
-                       assertEquals(
-                                       "refs/heads/test",
-                                       git2.getRepository()
-                                                       .getConfig()
-                                                       .getString(ConfigConstants.CONFIG_BRANCH_SECTION,
-                                                                       "test", ConfigConstants.CONFIG_KEY_MERGE));
-                       assertEquals(2, git2.branchList().setListMode(ListMode.REMOTE)
-                                       .call().size());
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
+       public void testCloneRepository() throws IOException {
+               File directory = createTempDirectory("testCloneRepository");
+               CloneCommand command = Git.cloneRepository();
+               command.setDirectory(directory);
+               command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+               Git git2 = command.call();
+               addRepoToClose(git2.getRepository());
+               assertNotNull(git2);
+               ObjectId id = git2.getRepository().resolve("tag-for-blob");
+               assertNotNull(id);
+               assertEquals(git2.getRepository().getFullBranch(), "refs/heads/test");
+               assertEquals(
+                               "origin",
+                               git2.getRepository()
+                                               .getConfig()
+                                               .getString(ConfigConstants.CONFIG_BRANCH_SECTION,
+                                                               "test", ConfigConstants.CONFIG_KEY_REMOTE));
+               assertEquals(
+                               "refs/heads/test",
+                               git2.getRepository()
+                                               .getConfig()
+                                               .getString(ConfigConstants.CONFIG_BRANCH_SECTION,
+                                                               "test", ConfigConstants.CONFIG_KEY_MERGE));
+               assertEquals(2, git2.branchList().setListMode(ListMode.REMOTE).call()
+                               .size());
        }
 
        @Test
-       public void testCloneRepositoryWithBranch() {
-               try {
-                       File directory = createTempDirectory("testCloneRepositoryWithBranch");
-                       CloneCommand command = Git.cloneRepository();
-                       command.setBranch("refs/heads/master");
-                       command.setDirectory(directory);
-                       command.setURI("file://"
-                                       + git.getRepository().getWorkTree().getPath());
-                       Git git2 = command.call();
-                       addRepoToClose(git2.getRepository());
-
-                       assertNotNull(git2);
-                       assertEquals(git2.getRepository().getFullBranch(),
-                                       "refs/heads/master");
-                       assertEquals(
-                                       "refs/heads/master, refs/remotes/origin/master, refs/remotes/origin/test",
-                                       allRefNames(git2.branchList().setListMode(ListMode.ALL)
-                                                       .call()));
-
-                       // Same thing, but now without checkout
-                       directory = createTempDirectory("testCloneRepositoryWithBranch_bare");
-                       command = Git.cloneRepository();
-                       command.setBranch("refs/heads/master");
-                       command.setDirectory(directory);
-                       command.setURI("file://"
-                                       + git.getRepository().getWorkTree().getPath());
-                       command.setNoCheckout(true);
-                       git2 = command.call();
-                       addRepoToClose(git2.getRepository());
-
-                       assertNotNull(git2);
-                       assertEquals(git2.getRepository().getFullBranch(),
-                                       "refs/heads/master");
-                       assertEquals(
-                                       "refs/remotes/origin/master, refs/remotes/origin/test",
-                                       allRefNames(git2.branchList().setListMode(ListMode.ALL)
-                                                       .call()));
-
-                       // Same thing, but now test with bare repo
-                       directory = createTempDirectory("testCloneRepositoryWithBranch_bare");
-                       command = Git.cloneRepository();
-                       command.setBranch("refs/heads/master");
-                       command.setDirectory(directory);
-                       command.setURI("file://"
-                                       + git.getRepository().getWorkTree().getPath());
-                       command.setBare(true);
-                       git2 = command.call();
-                       addRepoToClose(git2.getRepository());
-
-                       assertNotNull(git2);
-                       assertEquals(git2.getRepository().getFullBranch(),
-                                       "refs/heads/master");
-                       assertEquals("refs/heads/master, refs/heads/test", allRefNames(git2
-                                       .branchList().setListMode(ListMode.ALL).call()));
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
+       public void testCloneRepositoryWithBranch() throws IOException {
+               File directory = createTempDirectory("testCloneRepositoryWithBranch");
+               CloneCommand command = Git.cloneRepository();
+               command.setBranch("refs/heads/master");
+               command.setDirectory(directory);
+               command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+               Git git2 = command.call();
+               addRepoToClose(git2.getRepository());
+
+               assertNotNull(git2);
+               assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master");
+               assertEquals(
+                               "refs/heads/master, refs/remotes/origin/master, refs/remotes/origin/test",
+                               allRefNames(git2.branchList().setListMode(ListMode.ALL).call()));
+
+               // Same thing, but now without checkout
+               directory = createTempDirectory("testCloneRepositoryWithBranch_bare");
+               command = Git.cloneRepository();
+               command.setBranch("refs/heads/master");
+               command.setDirectory(directory);
+               command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+               command.setNoCheckout(true);
+               git2 = command.call();
+               addRepoToClose(git2.getRepository());
+
+               assertNotNull(git2);
+               assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master");
+               assertEquals("refs/remotes/origin/master, refs/remotes/origin/test",
+                               allRefNames(git2.branchList().setListMode(ListMode.ALL).call()));
+
+               // Same thing, but now test with bare repo
+               directory = createTempDirectory("testCloneRepositoryWithBranch_bare");
+               command = Git.cloneRepository();
+               command.setBranch("refs/heads/master");
+               command.setDirectory(directory);
+               command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+               command.setBare(true);
+               git2 = command.call();
+               addRepoToClose(git2.getRepository());
+
+               assertNotNull(git2);
+               assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master");
+               assertEquals("refs/heads/master, refs/heads/test", allRefNames(git2
+                               .branchList().setListMode(ListMode.ALL).call()));
        }
 
        @Test
-       public void testCloneRepositoryOnlyOneBranch() {
-               try {
-                       File directory = createTempDirectory("testCloneRepositoryWithBranch");
-                       CloneCommand command = Git.cloneRepository();
-                       command.setBranch("refs/heads/master");
-                       command.setBranchesToClone(Collections
-                                       .singletonList("refs/heads/master"));
-                       command.setDirectory(directory);
-                       command.setURI("file://"
-                                       + git.getRepository().getWorkTree().getPath());
-                       Git git2 = command.call();
-                       addRepoToClose(git2.getRepository());
-                       assertNotNull(git2);
-                       assertEquals(git2.getRepository().getFullBranch(),
-                                       "refs/heads/master");
-                       assertEquals("refs/remotes/origin/master",
-                                       allRefNames(git2.branchList()
-                                       .setListMode(ListMode.REMOTE).call()));
-
-                       // Same thing, but now test with bare repo
-                       directory = createTempDirectory("testCloneRepositoryWithBranch_bare");
-                       command = Git.cloneRepository();
-                       command.setBranch("refs/heads/master");
-                       command.setBranchesToClone(Collections
-                                       .singletonList("refs/heads/master"));
-                       command.setDirectory(directory);
-                       command.setURI("file://"
-                                       + git.getRepository().getWorkTree().getPath());
-                       command.setBare(true);
-                       git2 = command.call();
-                       addRepoToClose(git2.getRepository());
-                       assertNotNull(git2);
-                       assertEquals(git2.getRepository().getFullBranch(),
-                                       "refs/heads/master");
-                       assertEquals("refs/heads/master", allRefNames(git2
-                                       .branchList().setListMode(ListMode.ALL).call()));
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
+       public void testCloneRepositoryOnlyOneBranch() throws IOException {
+               File directory = createTempDirectory("testCloneRepositoryWithBranch");
+               CloneCommand command = Git.cloneRepository();
+               command.setBranch("refs/heads/master");
+               command.setBranchesToClone(Collections
+                               .singletonList("refs/heads/master"));
+               command.setDirectory(directory);
+               command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+               Git git2 = command.call();
+               addRepoToClose(git2.getRepository());
+               assertNotNull(git2);
+               assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master");
+               assertEquals("refs/remotes/origin/master", allRefNames(git2
+                               .branchList().setListMode(ListMode.REMOTE).call()));
+
+               // Same thing, but now test with bare repo
+               directory = createTempDirectory("testCloneRepositoryWithBranch_bare");
+               command = Git.cloneRepository();
+               command.setBranch("refs/heads/master");
+               command.setBranchesToClone(Collections
+                               .singletonList("refs/heads/master"));
+               command.setDirectory(directory);
+               command.setURI("file://" + git.getRepository().getWorkTree().getPath());
+               command.setBare(true);
+               git2 = command.call();
+               addRepoToClose(git2.getRepository());
+               assertNotNull(git2);
+               assertEquals(git2.getRepository().getFullBranch(), "refs/heads/master");
+               assertEquals("refs/heads/master", allRefNames(git2.branchList()
+                               .setListMode(ListMode.ALL).call()));
        }
 
        public static String allRefNames(List<Ref> refs) {
index 28c54c269f0e4abf53d64a71d813686c0b639307..7f47295c3f307543e3b75d0f5e7b8da25e9c1f23 100644 (file)
@@ -44,7 +44,6 @@ package org.eclipse.jgit.api;
 
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
 
 import java.io.File;
 import java.io.IOException;
@@ -64,33 +63,25 @@ public class InitCommandTest extends RepositoryTestCase {
        }
 
        @Test
-       public void testInitRepository() {
-               try {
-                       File directory = createTempDirectory("testInitRepository");
-                       InitCommand command = new InitCommand();
-                       command.setDirectory(directory);
-                       Repository repository = command.call().getRepository();
-                       addRepoToClose(repository);
-                       assertNotNull(repository);
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
+       public void testInitRepository() throws IOException {
+               File directory = createTempDirectory("testInitRepository");
+               InitCommand command = new InitCommand();
+               command.setDirectory(directory);
+               Repository repository = command.call().getRepository();
+               addRepoToClose(repository);
+               assertNotNull(repository);
        }
 
        @Test
-       public void testInitBareRepository() {
-               try {
-                       File directory = createTempDirectory("testInitBareRepository");
-                       InitCommand command = new InitCommand();
-                       command.setDirectory(directory);
-                       command.setBare(true);
-                       Repository repository = command.call().getRepository();
-                       addRepoToClose(repository);
-                       assertNotNull(repository);
-                       assertTrue(repository.isBare());
-               } catch (Exception e) {
-                       fail(e.getMessage());
-               }
+       public void testInitBareRepository() throws IOException {
+               File directory = createTempDirectory("testInitBareRepository");
+               InitCommand command = new InitCommand();
+               command.setDirectory(directory);
+               command.setBare(true);
+               Repository repository = command.call().getRepository();
+               addRepoToClose(repository);
+               assertNotNull(repository);
+               assertTrue(repository.isBare());
        }
 
        public static File createTempDirectory(String name) throws IOException {