### Question:
CGT { public String retrieveString() throws IOException { return (String)retrieveEntry(EntryType.STRING); } 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 testRetrieveString() throws Exception { CGT cgt = new CGT(); cgt.open(new ByteArrayInputStream(new byte[] {})); try { cgt.retrieveString(); fail("expected IOException"); } catch (IOException e) { assertEquals("wrong msg", "Invalid entry type. Expected STRING, but got EMPTY", e.getMessage()); } cgt.open(new ByteArrayInputStream(toByteArray(HEADER, SAMPLE_STRINGS))); assertTrue(cgt.getNextRecord()); assertEquals("wrong value", "Abc", cgt.retrieveString()); assertEquals("wrong value", "D\u0117F", cgt.retrieveString()); validateExpectEMPTY(cgt); }