public void testAddArchivedFileSet() throws Exception {
    File toBeAdded = new File("src/test/resources/test.zip");
    DefaultArchivedFileSet sfd = DefaultArchivedFileSet.archivedFileSet(toBeAdded);
    File zipFIle = getTestFile("target/output/withZip.zip");
    final ZipArchiver zipArchiver = getZipArchiver(zipFIle);
    InputStreamTransformer is =
        new InputStreamTransformer() {
          @Nonnull
          public InputStream transform(
              @Nonnull PlexusIoResource resource, @Nonnull InputStream inputStream)
              throws IOException {
            return new BoundedInputStream(inputStream, 3);
          }
        };
    sfd.setStreamTransformer(is);
    zipArchiver.addArchivedFileSet(sfd);
    zipArchiver.createArchive();

    final ZipUnArchiver zipUnArchiver = getZipUnArchiver(zipFIle);
    File destFile = new File("target/output/withZip");
    destFile.mkdirs();
    zipUnArchiver.setDestFile(destFile);
    zipUnArchiver.extract();
    File a3byteFile =
        new File(
            destFile,
            "Users/kristian/lsrc/plexus/plexus-archiver/src/main/java/org/codehaus/plexus/archiver/zip/ZipArchiver.java");
    assertTrue(a3byteFile.exists());
    assertTrue(a3byteFile.length() == 3);
  }
 @SuppressWarnings("ResultOfMethodCallIgnored")
 public void testSymlinkFileSet() throws Exception {
   final File zipFile = getTestFile("target/output/pasymlinks-fileset.zip");
   final ZipArchiver zipArchiver = getZipArchiver(zipFile);
   final DefaultFileSet fs = new DefaultFileSet();
   fs.setPrefix("bzz/");
   fs.setDirectory(new File("src/test/resources/symlinks/src"));
   zipArchiver.addFileSet(fs);
   zipArchiver.createArchive();
   final File output = getTestFile("target/output/unzipped/symlFs");
   output.mkdirs();
   final ZipUnArchiver zipUnArchiver = getZipUnArchiver(zipFile);
   zipUnArchiver.setDestFile(output);
   zipUnArchiver.extract();
   File symDir = new File(output, "bzz/symDir");
   PlexusIoResourceAttributes fa = Java7FileAttributes.uncached(symDir);
   assertTrue(fa.isSymbolicLink());
 }
 public void testSymlinkZip() throws Exception {
   final File zipFile = getTestFile("target/output/pasymlinks.zip");
   final ZipArchiver zipArchiver = getZipArchiver(zipFile);
   PlexusIoFileResourceCollection files = new PlexusIoFileResourceCollection();
   files.setFollowingSymLinks(false);
   files.setBaseDir(new File("src/test/resources/symlinks"));
   files.setPrefix("plexus/");
   zipArchiver.addResources(files);
   zipArchiver.createArchive();
   final File output = getTestFile("target/output/unzipped");
   output.mkdirs();
   final ZipUnArchiver zipUnArchiver = getZipUnArchiver(zipFile);
   zipUnArchiver.setDestFile(output);
   zipUnArchiver.extract();
   File symDir = new File("target/output/unzipped/plexus/src/symDir");
   PlexusIoResourceAttributes fa = Java7FileAttributes.uncached(symDir);
   assertTrue(fa.isSymbolicLink());
 }
 private ZipUnArchiver getZipUnArchiver(File testJar) throws Exception {
   ZipUnArchiver zu = (ZipUnArchiver) lookup(UnArchiver.ROLE, "zip");
   zu.setSourceFile(testJar);
   return zu;
 }