@Test
  public void testCompressionBZip2() throws Exception {
    virtualContent = new VirtualContent(new VirtualContentConfiguration());
    virtualContent.fillRandomly(1, 0, 0, 100, 50, null);

    ByteArrayStream byteArrayStream = new ByteArrayStream(1000000);

    IOutCreateArchiveBZip2 outNewArchiveBZip2 = closeLater(SevenZip.openOutArchiveBZip2());

    outNewArchiveBZip2.setLevel(5);

    assertEquals(ArchiveFormat.BZIP2, outNewArchiveBZip2.getArchiveFormat());

    outNewArchiveBZip2.createArchive(
        byteArrayStream,
        virtualContent.getItemCount(),
        callbackTesterCreateArchive.getProxyInstance());

    assertEquals(
        "Methods called: " + callbackTesterCreateArchive,
        5,
        callbackTesterCreateArchive.getDifferentMethodsCalled());

    byteArrayStream.rewind();

    IInArchive inArchive = closeLater(SevenZip.openInArchive(ArchiveFormat.BZIP2, byteArrayStream));
    virtualContent.verifyInArchive(inArchive);
  }
    public IOutItemBZip2 getItemInformation(int index, OutItemFactory<IOutItemBZip2> outItemFactory)
        throws SevenZipException {
      ByteArrayStream byteArrayStream = virtualContent.getItemStream(index);
      byteArrayStream.rewind();

      IOutItemBZip2 outItem = outItemFactory.createOutItem();

      outItem.setDataSize((long) byteArrayStream.getSize());

      return outItem;
    }
  private VirtualContent doTest(
      int countOfFiles,
      int directoriesDepth,
      int maxSubdirectories,
      int averageFileLength,
      int deltaFileLength)
      throws Exception {
    VirtualContent virtualContent = new VirtualContent(virtualContentConfiguration);
    virtualContent.fillRandomly(
        countOfFiles,
        directoriesDepth,
        maxSubdirectories,
        averageFileLength,
        deltaFileLength,
        null);
    ArchiveFormat archiveFormat = getArchiveFormat();
    IOutCreateArchive<IOutItemAllFormats> outArchive = SevenZip.openOutArchive(archiveFormat);
    ByteArrayStream byteArrayStream;
    boolean ok = false;
    try {
      byteArrayStream = new ByteArrayStream(OUTARCHIVE_MAX_SIZE);

      virtualContent.createOutArchive(outArchive, byteArrayStream);
      ok = true;
    } finally {
      try {
        outArchive.close();
      } catch (Throwable throwable) {
        if (ok) {
          throw new RuntimeException("Error closing archive", throwable);
        }
      }
    }
    byteArrayStream.rewind();
    IInArchive inArchive = SevenZip.openInArchive(archiveFormat, byteArrayStream);
    try {
      virtualContent.verifyInArchive(inArchive);
      // byteArrayStream.writeToOutputStream(new FileOutputStream("test-2.7z"), true);
    } finally {
      inArchive.close();
    }
    return virtualContent;
  }