Beispiel #1
0
  @Test
  public void verifyLength() {
    cont.storeFile(
        file, new BufferedInputStream(new ByteArrayInputStream(data)), FileInContainer.NO_TAIL_ID);

    long length = Container.HEADER_SIZE + File.OVERHEAD_SIZE + data.length;

    assertEquals(length, cont.getCurrentSize());
  }
Beispiel #2
0
  @Test
  public void verifyBytesWritten() throws IOException, WriteFileInContainerException {
    cont.storeFile(
        file, new BufferedInputStream(new ByteArrayInputStream(data)), FileInContainer.NO_TAIL_ID);

    // apache commons' implementation required
    ByteArrayOutputStream bstream = new ByteArrayOutputStream();
    bstream.write(containerHeader);
    bstream.write(fileHeader);
    bstream.write(data);
    bstream.write(checksum);
    byte[] expected = bstream.toByteArray();
    bstream.close();
    byte[] actual = FileUtils.readFileToByteArray(new java.io.File(cont.getFileName()));
    assertArrayEquals(expected, actual);
  }