public class BGPHexFileParserTest {
- public static final String hexDumpFileName = "bgp_hex.txt";
- private final String fileNameInvalid = "BgpMessage_Hex_InvalidLength.bin";
- private final int expectedSize = 25;
-
- @Test
- public void testCleanWhiteSpace() {
- final String input = "abc def\r\nghi\nj";
- assertEquals("ABCDEFGHIJ", HexDumpBGPFileParser.clearWhiteSpaceToUpper(input));
- }
-
- @Test
- public void testParsing() throws Exception {
- final List<byte[]> result = HexDumpBGPFileParser.parseMessages(getClass().getClassLoader().getResourceAsStream(BGPHexFileParserTest.hexDumpFileName));
- assertEquals(this.expectedSize, result.size());
- }
-
- @Test
- public void testParsingInvalidMessage() throws Exception {
- try {
- HexDumpBGPFileParser.parseMessages(getClass().getClassLoader().getResourceAsStream(this.fileNameInvalid));
- fail("Exception should have occured.");
- } catch (final IllegalArgumentException e) {
- assertThat(e.getMessage(), containsString("Invalid message at index 0, length atribute is lower than 19"));
- }
- }
-
- @Test
- public void testParsingInvalidFile() throws Exception {
- try {
- HexDumpBGPFileParser.parseMessages(new File("bad file name"));
- fail("Exception should have occured.");
- } catch (final FileNotFoundException e) {
- assertThat(e.getMessage(), containsString("bad file name"));
- }
- }
+ public static final String hexDumpFileName = "bgp_hex.txt";
+ private final String fileNameInvalid = "BgpMessage_Hex_InvalidLength.bin";
+ private final int expectedSize = 25;
+
+ @Test
+ public void testCleanWhiteSpace() {
+ final String input = "abc def\r\nghi\nj";
+ assertEquals("ABCDEFGHIJ", HexDumpBGPFileParser.clearWhiteSpaceToUpper(input));
+ }
+
+ @Test
+ public void testParsing() throws Exception {
+ final List<byte[]> result = HexDumpBGPFileParser.parseMessages(getClass().getClassLoader().getResourceAsStream(
+ BGPHexFileParserTest.hexDumpFileName));
+ assertEquals(this.expectedSize, result.size());
+ }
+
+ @Test
+ public void testParsingInvalidMessage() throws Exception {
+ try {
+ HexDumpBGPFileParser.parseMessages(getClass().getClassLoader().getResourceAsStream(this.fileNameInvalid));
+ fail("Exception should have occured.");
+ } catch (final IllegalArgumentException e) {
+ assertThat(e.getMessage(), containsString("Invalid message at index 0, length atribute is lower than 19"));
+ }
+ }
+
+ @Test
+ public void testParsingInvalidFile() throws Exception {
+ try {
+ HexDumpBGPFileParser.parseMessages(new File("bad file name"));
+ fail("Exception should have occured.");
+ } catch (final FileNotFoundException e) {
+ assertThat(e.getMessage(), containsString("bad file name"));
+ }
+ }
}