コード例 #1
0
ファイル: DebAntTaskTestCase.java プロジェクト: urchinly/jdeb
  public void testXZCompression() throws Exception {
    project.executeTarget("xz-compression");

    File deb = new File("target/test-classes/test.deb");
    assertTrue("package not build", deb.exists());

    final AtomicBoolean found = new AtomicBoolean(false);

    ArArchiveInputStream in = new ArArchiveInputStream(new FileInputStream(deb));
    ArchiveWalker.walk(
        in,
        new ArchiveVisitor<ArArchiveEntry>() {
          public void visit(ArArchiveEntry entry, byte[] content) throws IOException {
            if (entry.getName().equals("data.tar.xz")) {
              found.set(true);

              assertEquals("header 0", (byte) 0xFD, content[0]);
              assertEquals("header 1", (byte) '7', content[1]);
              assertEquals("header 2", (byte) 'z', content[2]);
              assertEquals("header 3", (byte) 'X', content[3]);
              assertEquals("header 4", (byte) 'Z', content[4]);
              assertEquals("header 5", (byte) '\0', content[5]);

              TarInputStream tar =
                  new TarInputStream(
                      new XZCompressorInputStream(new ByteArrayInputStream(content)));
              while ((tar.getNextEntry()) != null) ;
              tar.close();
            }
          }
        });

    assertTrue("xz file not found", found.get());
  }
コード例 #2
0
ファイル: DebAntTaskTestCase.java プロジェクト: urchinly/jdeb
  public void testNoCompression() throws Exception {
    project.executeTarget("no-compression");

    File deb = new File("target/test-classes/test.deb");
    assertTrue("package not build", deb.exists());

    boolean found =
        ArchiveWalker.walkData(
            deb,
            new ArchiveVisitor<TarArchiveEntry>() {
              public void visit(TarArchiveEntry entry, byte[] content) throws IOException {}
            },
            Compression.NONE);

    assertTrue("tar file not found", found);
  }
コード例 #3
0
ファイル: DebAntTaskTestCase.java プロジェクト: urchinly/jdeb
  public void testTarFileSet() throws Exception {
    project.executeTarget("tarfileset");

    File deb = new File("target/test-classes/test.deb");
    assertTrue("package not build", deb.exists());

    ArchiveWalker.walkData(
        deb,
        new ArchiveVisitor<TarArchiveEntry>() {
          public void visit(TarArchiveEntry entry, byte[] content) throws IOException {
            assertTrue("prefix: " + entry.getName(), entry.getName().startsWith("./foo/"));
            if (entry.isDirectory()) {
              assertEquals("directory mode (" + entry.getName() + ")", 040700, entry.getMode());
            } else {
              assertEquals("file mode (" + entry.getName() + ")", 0100600, entry.getMode());
            }
            assertEquals("user", "ebourg", entry.getUserName());
            assertEquals("group", "ebourg", entry.getGroupName());
          }
        },
        Compression.GZIP);
  }