diff options
author | David Pursehouse <david.pursehouse@sonymobile.com> | 2016-01-14 17:25:56 +0900 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2016-01-19 17:27:46 +0100 |
commit | 3b63a242efff6ee2e3f3d87d40b8fbdd1fddacd3 (patch) | |
tree | 3bd2e0b1252e30616c428c68d561b236a920055c /org.eclipse.jgit.test | |
parent | 75e096c80ad3ad413c4ebb0b5369dc6417db00d9 (diff) | |
download | jgit-3b63a242efff6ee2e3f3d87d40b8fbdd1fddacd3.tar.gz jgit-3b63a242efff6ee2e3f3d87d40b8fbdd1fddacd3.zip |
URIishTest: Use @Test annotation's `expected` argument
Specify the expected exception in the annotation, instead of
catching it and calling `fail()` when it wasn't raised.
Change-Id: I8a640c0e42353533e4e73b85b50c224dc060f2d7
Signed-off-by: David Pursehouse <david.pursehouse@sonymobile.com>
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java index 0fda72cf9d..2078dd337b 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java @@ -51,7 +51,6 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; import java.io.File; import java.io.IOException; @@ -65,25 +64,15 @@ public class URIishTest { private static final String GIT_SCHEME = "git://"; @SuppressWarnings("unused") - @Test + @Test(expected = URISyntaxException.class) public void shouldRaiseErrorOnEmptyURI() throws Exception { - try { - new URIish(""); - fail("expecting an exception"); - } catch (URISyntaxException e) { - // expected - } + new URIish(""); } @SuppressWarnings("unused") - @Test + @Test(expected = URISyntaxException.class) public void shouldRaiseErrorOnNullURI() throws Exception { - try { - new URIish((String) null); - fail("expecting an exception"); - } catch (URISyntaxException e) { - // expected - } + new URIish((String) null); } @Test @@ -594,34 +583,19 @@ public class URIishTest { assertEquals(u, new URIish(str)); } - @Test + @Test(expected = IllegalArgumentException.class) public void testGetNullHumanishName() { - try { - new URIish().getHumanishName(); - fail("path must be not null"); - } catch (IllegalArgumentException e) { - // expected - } + new URIish().getHumanishName(); } - @Test + @Test(expected = IllegalArgumentException.class) public void testGetEmptyHumanishName() throws URISyntaxException { - try { - new URIish(GIT_SCHEME).getHumanishName(); - fail("empty path is useless"); - } catch (IllegalArgumentException e) { - // expected - } + new URIish(GIT_SCHEME).getHumanishName(); } - @Test + @Test(expected = IllegalArgumentException.class) public void testGetAbsEmptyHumanishName() { - try { - new URIish().getHumanishName(); - fail("empty path is useless"); - } catch (IllegalArgumentException e) { - // expected - } + new URIish().getHumanishName(); } @Test |