@Test public void testRead2() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); String result = fSDMsg.read(is, 0, "2C", null); assertEquals("result", "", result); }
@Test public void testRead1() throws Throwable { byte[] bytes = new byte[2]; FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); String result = fSDMsg.read(new ByteArrayInputStream(bytes), 0, " ", null); assertEquals("result", "", result); }
@Test public void testReadMoreThanInputThrowsEOFException() throws Throwable { byte[] bytes = new byte[2]; FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); InputStream is = new ByteArrayInputStream(bytes); try { fSDMsg.read(is, 100, null, null); fail("Expected EOFException to be thrown"); } catch (EOFException ex) { assertNull("ex.getMessage()", ex.getMessage()); assertEquals("(ByteArrayInputStream) is.available()", 0, is.available()); } }
@Test public void testReadThrowsEOFException() throws Throwable { FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath"); when(is.read(new byte[] {(byte) 00})).thenReturn(Integer.valueOf(1)); when(is.read(new byte[] {(byte) 00})).thenReturn(Integer.valueOf(1)); when(is.read(new byte[] {(byte) 00})).thenReturn(Integer.valueOf(-1)); try { fSDMsg.read(is, 100, " ", null); fail("Expected EOFException to be thrown"); } catch (EOFException ex) { assertEquals("ex.getClass()", EOFException.class, ex.getClass()); } }
@Test public void testReadThrowsRuntimeException() throws Throwable { byte[] bytes = new byte[2]; FSDMsg fSDMsg = new FSDMsg("testFSDMsgBasePath", "testFSDMsgBaseSchema"); InputStream is = new ByteArrayInputStream(bytes); try { fSDMsg.read(is, 100, "3Ch", "Ch"); fail("Expected RuntimeException to be thrown"); } catch (RuntimeException ex) { assertEquals( "ex.getMessage()", "FSDMsg.isSeparated(String) found that Ch has not been defined as a separator!", ex.getMessage()); assertEquals("(ByteArrayInputStream) is.available()", 2, is.available()); } }