InMemoryBinaryValue extends AbstractBinary { @Override public long getSize() { return bytes.length; } InMemoryBinaryValue( BinaryStore store,
                                byte[] bytes );  InMemoryBinaryValue( BinaryStore store,
                                BinaryKey key,
                                byte[] bytes ); @Override long getSize(); byte[] getBytes(); @Override String getMimeType(); @Override String getMimeType( String name );  }
@Test public void shouldConstructFromByteArray() { binary = new InMemoryBinaryValue(store, validByteArrayContent); assertThat(binary.getSize(), is((long)validByteArrayContent.length)); assertThat(binary, hasContent(validByteArrayContent)); }
@Test public void shouldConstructFromEmptyByteArray() { validByteArrayContent = new byte[0]; binary = new InMemoryBinaryValue(store, validByteArrayContent); assertThat(binary.getSize(), is(0l)); assertThat(binary, hasNoContent()); }
@Test public void shouldHaveSizeThatMatchesContentLength() { assertThat(binary.getSize(), is((long)validByteArrayContent.length)); }
@Test public void shouldComputeSha1HashOfEmptyContent() throws Exception { validByteArrayContent = new byte[0]; binary = new InMemoryBinaryValue(store, validByteArrayContent); assertThat(binary.getSize(), is(0l)); assertThat(binary, hasNoContent()); byte[] hash = binary.getHash(); assertThat(hash.length, is(20)); assertThat(StringUtil.getHexString(hash), is("da39a3ee5e6b4b0d3255bfef95601890afd80709")); }
@Test public void shouldComputeSha1HashOfNonEmptyContent() throws Exception { binary = new InMemoryBinaryValue(store, validByteArrayContent); assertThat(binary.getSize(), is((long)validByteArrayContent.length)); byte[] hash = binary.getHash(); assertThat(hash.length, is(20)); assertThat(StringUtil.getHexString(hash), is("14abe696257e85ba18b7c784d6c7855f46ce50ea")); }