public class ContentConcatenationTest extends MockMongoTestCaseSupport {
public void testContentRepetition() throws IOException {
ContentStorage storage = new MongoContentStorage(getMongo().getDB(
"test"));
{
Content doubled = new ContentConcatenation().getContent(storage,
new BasicBSONObject("store", "cat").append("base",
new InlineContent("abcde".getBytes(), 0, 10)
.serialize()));
assertEquals("abcdeabcde", IOUtils.toString(doubled
.getInputStream()));
assertEquals(10l, doubled.getLength());
}
{
ContentSHA one = storage.storeContent(new ByteArrayInputStream(
"abcde".getBytes()));
Content doubled = new ContentConcatenation().getContent(storage,
new BasicBSONObject("store", "cat").append("base",
new BasicBSONObject("store", "cat").append("base",
new StoredContent(one.getSHA(), 10)
.serialize())));
assertEquals("abcdeabcde", IOUtils.toString(doubled
.getInputStream()));
assertEquals(10l, doubled.getLength());
}
{
ContentSHA one = storage.storeContent(new ByteArrayInputStream(
"abcde".getBytes()));
Content doubled = new ContentConcatenation().getContent(storage,
new BasicBSONObject("store", "cat").append("base",
new BasicBSONObject("store", "cat").append("base",