### Question:
CGT { public boolean retrieveBoolean() throws IOException { return ((Boolean)retrieveEntry(EntryType.BOOLEAN)).booleanValue(); } 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 testRetrieveBoolean() throws Exception { CGT cgt = new CGT(); cgt.open(new ByteArrayInputStream(new byte[] {})); try { cgt.retrieveBoolean(); fail("expected IOException"); } catch (IOException e) { assertEquals("wrong msg", "Invalid entry type. Expected BOOLEAN, but got EMPTY", e.getMessage()); } cgt.open(new ByteArrayInputStream(toByteArray(HEADER, SAMPLE_BOOLEANS))); assertTrue(cgt.getNextRecord()); assertEquals(true, cgt.retrieveBoolean()); assertEquals(false, cgt.retrieveBoolean()); assertEquals(true, cgt.retrieveBoolean()); assertEquals(false, cgt.retrieveBoolean()); validateExpectEMPTY(cgt); }