TarEntryIdentificationRequest implements IdentificationRequest<InputStream> { @Override public byte getByte(long position) throws IOException { final int result = reader.readByte(position); if (result < 0) { throw new IOException("No byte at position " + position); } return (byte) result; } TarEntryIdentificationRequest(final RequestMetaData metaData, final RequestIdentifier identifier,
            final Path tempDir); @Override final void open(InputStream in); @Override final void close(); @Override final String getExtension(); @Override final String getFileName(); @Override final long size(); @Override final InputStream getSourceInputStream(); @Override final RequestMetaData getRequestMetaData(); @Override final RequestIdentifier getIdentifier(); @Override byte getByte(long position); @Override WindowReader getWindowReader();  }
@Test public void testGetByte3FollowedByByte42() throws IOException { String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><profiles/>"; assertEquals(expected.getBytes()[3], tarResource.getByte(3)); assertEquals(expected.getBytes()[42], tarResource.getByte(42)); }
@Test public void testGetByte42FollowedByByte3() throws IOException { String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><profiles/>"; assertEquals(expected.getBytes()[42], tarResource.getByte(42)); assertEquals(expected.getBytes()[3], tarResource.getByte(3)); }
@Test public void testGetByte42FollowedByByte49() throws IOException { String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><profiles/>"; assertEquals(expected.getBytes()[42], tarResource.getByte(42)); try { tarResource.getByte(49); fail("Expected IOException"); } catch (IOException e) { } }
@Test public void testGetByte42FollowedByByte10000() throws IOException { String expected = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><profiles/>"; assertEquals(expected.getBytes()[42], tarResource.getByte(42)); try { tarResource.getByte(10000); fail("Expected IOException."); } catch (IOException e) { } }