InMemoryDataRecord implements DataRecord { static InMemoryDataRecord getInstance(byte[] data) { if (data.length == 0) { return EMPTY; } else { return new InMemoryDataRecord(data); } } private  InMemoryDataRecord(byte[] data); static boolean isInstance(String id); static InMemoryDataRecord getInstance(String id); @Override DataIdentifier getIdentifier(); @Override String getReference(); @Override long getLength(); InputStream getStream(); @Override long getLastModified(); String toString(); boolean equals(Object obj); int hashCode();  }
@Test public void testGetInstance() throws Exception { int length = 400; byte[] data = new byte[length]; new Random().nextBytes(data); DataRecord dr = InMemoryDataRecord.getInstance(data); assertTrue(InMemoryDataRecord.isInstance(dr.getIdentifier().toString())); DataRecord dr2 = InMemoryDataRecord.getInstance(dr.getIdentifier().toString()); assertTrue(IOUtils.contentEquals(dr.getStream(), dr2.getStream())); assertTrue(IOUtils.contentEquals(dr.getStream(), new ByteArrayInputStream(data))); assertEquals(length, dr.getLength()); assertEquals(dr2.getLength(), dr.getLength()); assertEquals(dr, dr2); }