Use @Test annotation to test for exceptions being thrown

Please note that this commit only uses the @Test annotation
where exceptions are thrown at the end of the test,
because otherwise the test would not be executed completely.

Examples for this are in DatabaseComponentImplTest where many exceptions
are thrown in close succession or in ConnectionRegistryImplTest where an
exception is thrown in the middle of the test.
This commit is contained in:
Torsten Grote
2016-01-12 15:16:34 -02:00
parent aa1b9328c4
commit b837e8b035
5 changed files with 48 additions and 140 deletions

View File

@@ -20,20 +20,14 @@ public class ByteUtilsTest extends BriarTestCase {
assertEquals(65535, ByteUtils.readUint16(b, 1));
}
@Test
public void testReadUint16ValidatesArguments() {
try {
ByteUtils.readUint16(new byte[1], 0);
fail();
} catch (IllegalArgumentException expected) {
// Expected
}
try {
ByteUtils.readUint16(new byte[2], 1);
fail();
} catch (IllegalArgumentException expected) {
// Expected
}
@Test(expected = IllegalArgumentException.class)
public void testReadUint16ValidatesArguments1() {
ByteUtils.readUint16(new byte[1], 0);
}
@Test(expected = IllegalArgumentException.class)
public void testReadUint16ValidatesArguments2() {
ByteUtils.readUint16(new byte[2], 1);
}
@Test
@@ -46,20 +40,14 @@ public class ByteUtilsTest extends BriarTestCase {
assertEquals(4294967295L, ByteUtils.readUint32(b, 1));
}
@Test
public void testReadUint32ValidatesArguments() {
try {
ByteUtils.readUint32(new byte[3], 0);
fail();
} catch (IllegalArgumentException expected) {
// Expected
}
try {
ByteUtils.readUint32(new byte[4], 1);
fail();
} catch (IllegalArgumentException expected) {
// Expected
}
@Test(expected = IllegalArgumentException.class)
public void testReadUint32ValidatesArguments1() {
ByteUtils.readUint32(new byte[3], 0);
}
@Test(expected = IllegalArgumentException.class)
public void testReadUint32ValidatesArguments2() {
ByteUtils.readUint32(new byte[4], 1);
}
@Test