### Question:
CGT { public int retrieveInteger() throws IOException { return ((Integer)retrieveEntry(EntryType.UINT16)).intValue(); } CGT(); Entry retrieveEntry(); boolean atEOF(); void close(); boolean isRecordComplete(); int getEntryCount(); int getEntriesRead(); String getHeader(); boolean getNextRecord(); void open(File file); void open(InputStream input); boolean retrieveBoolean(); int retrieveByte(); int retrieveInteger(); String retrieveString(); static final int RECORD_CONTENT_MULTI; }### Answer:
@Test public void testRetrieveInteger() throws Exception { CGT cgt = new CGT(); cgt.open(new ByteArrayInputStream(new byte[] {})); try { cgt.retrieveInteger(); fail("expected IOException"); } catch (IOException e) { assertEquals("wrong msg", "Invalid entry type. Expected UINT16, but got EMPTY", e.getMessage()); } cgt.open(new ByteArrayInputStream(toByteArray(HEADER, SAMPLE_UINT16S))); assertTrue(cgt.getNextRecord()); assertEquals(1, cgt.retrieveInteger()); assertEquals(59266, cgt.retrieveInteger()); assertEquals(771, cgt.retrieveInteger()); validateExpectEMPTY(cgt); }