mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 12:19:54 +01:00
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:
@@ -82,7 +82,7 @@ public class StreamDecrypterImplTest extends BriarTestCase {
|
||||
assertEquals(-1, s.readFrame(buffer));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IOException.class)
|
||||
public void testTruncatedFrameThrowsException() throws Exception {
|
||||
byte[] frameHeader = new byte[FRAME_HEADER_LENGTH];
|
||||
int payloadLength = 123, paddingLength = 234;
|
||||
@@ -105,15 +105,10 @@ public class StreamDecrypterImplTest extends BriarTestCase {
|
||||
|
||||
// Try to read the truncated frame
|
||||
byte[] buffer = new byte[MAX_PAYLOAD_LENGTH];
|
||||
try {
|
||||
s.readFrame(buffer);
|
||||
fail();
|
||||
} catch (IOException expected) {
|
||||
// Expected
|
||||
}
|
||||
s.readFrame(buffer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IOException.class)
|
||||
public void testInvalidPayloadAndPaddingLengthThrowsException()
|
||||
throws Exception {
|
||||
byte[] frameHeader = new byte[FRAME_HEADER_LENGTH];
|
||||
@@ -139,15 +134,10 @@ public class StreamDecrypterImplTest extends BriarTestCase {
|
||||
|
||||
// Try to read the invalid frame
|
||||
byte[] buffer = new byte[MAX_PAYLOAD_LENGTH];
|
||||
try {
|
||||
s.readFrame(buffer);
|
||||
fail();
|
||||
} catch (IOException expected) {
|
||||
// Expected
|
||||
}
|
||||
s.readFrame(buffer);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test(expected = IOException.class)
|
||||
public void testNonZeroPaddingThrowsException() throws Exception {
|
||||
byte[] frameHeader = new byte[FRAME_HEADER_LENGTH];
|
||||
int payloadLength = 123, paddingLength = 234;
|
||||
@@ -174,12 +164,7 @@ public class StreamDecrypterImplTest extends BriarTestCase {
|
||||
|
||||
// Try to read the invalid frame
|
||||
byte[] buffer = new byte[MAX_PAYLOAD_LENGTH];
|
||||
try {
|
||||
s.readFrame(buffer);
|
||||
fail();
|
||||
} catch (IOException expected) {
|
||||
// Expected
|
||||
}
|
||||
s.readFrame(buffer);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user