Browse Source

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>
tags/v4.2.0.201601211800-r
David Pursehouse 8 years ago
parent
commit
3b63a242ef
1 changed files with 10 additions and 36 deletions
  1. 10
    36
      org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java

+ 10
- 36
org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/URIishTest.java View File

import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;


import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
private static final String GIT_SCHEME = "git://"; private static final String GIT_SCHEME = "git://";


@SuppressWarnings("unused") @SuppressWarnings("unused")
@Test
@Test(expected = URISyntaxException.class)
public void shouldRaiseErrorOnEmptyURI() throws Exception { public void shouldRaiseErrorOnEmptyURI() throws Exception {
try {
new URIish("");
fail("expecting an exception");
} catch (URISyntaxException e) {
// expected
}
new URIish("");
} }


@SuppressWarnings("unused") @SuppressWarnings("unused")
@Test
@Test(expected = URISyntaxException.class)
public void shouldRaiseErrorOnNullURI() throws Exception { public void shouldRaiseErrorOnNullURI() throws Exception {
try {
new URIish((String) null);
fail("expecting an exception");
} catch (URISyntaxException e) {
// expected
}
new URIish((String) null);
} }


@Test @Test
assertEquals(u, new URIish(str)); assertEquals(u, new URIish(str));
} }


@Test
@Test(expected = IllegalArgumentException.class)
public void testGetNullHumanishName() { 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 { 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() { public void testGetAbsEmptyHumanishName() {
try {
new URIish().getHumanishName();
fail("empty path is useless");
} catch (IllegalArgumentException e) {
// expected
}
new URIish().getHumanishName();
} }


@Test @Test

Loading…
Cancel
Save