InMemoryDocument extends CommonDocument { public byte[] getBytes() { return bytes; } InMemoryDocument();  InMemoryDocument(final byte[] bytes);  InMemoryDocument(final byte[] bytes, final String name);  InMemoryDocument(final byte[] bytes, final String name, final MimeType mimeType);  InMemoryDocument(final InputStream inputStream);  InMemoryDocument(final InputStream inputStream, final String name);  InMemoryDocument(final InputStream inputStream, final String name, final MimeType mimeType); @Override InputStream openStream(); byte[] getBytes(); void setBytes(byte[] bytes); String getBase64Encoded();  }
@Test public void test() { InMemoryDocument doc = new InMemoryDocument(getClass().getResourceAsStream("/AdobeCA.p7c")); assertNotNull(doc); assertNull(doc.getAbsolutePath()); assertNull(doc.getMimeType()); assertNull(doc.getName()); assertNotNull(doc.getBytes()); assertNotNull(doc.getDigest(DigestAlgorithm.SHA256)); }
@Test public void testWithName() { InMemoryDocument doc = new InMemoryDocument(getClass().getResourceAsStream("/AdobeCA.p7c"), "AdobeCA.p7c"); assertNotNull(doc); assertNull(doc.getAbsolutePath()); assertEquals(MimeType.BINARY, doc.getMimeType()); assertNotNull(doc.getName()); assertNotNull(doc.getBytes()); assertNotNull(doc.getDigest(DigestAlgorithm.SHA256)); }
@Test public void testBytes() { byte[] bytes = new byte[] { 1, 2, 3 }; InMemoryDocument doc = new InMemoryDocument(bytes, "doc.txt"); assertNotNull(doc); assertEquals(MimeType.TEXT, doc.getMimeType()); assertNotNull(doc.getName()); assertNotNull(doc.getBytes()); assertNotNull(doc.getDigest(DigestAlgorithm.SHA256)); assertNull(doc.getAbsolutePath()); }