this.checkArchiveContent(temp, expected);
}
public void testDeleteFromAndAddToTar() throws Exception {
ArchiveOutputStream out = null;
ArchiveInputStream ais = null;
File temp = null;
try {
ChangeSet changes = new ChangeSet();
changes.delete("test2.xml");
final File file1 = getFile("test.txt");
final TarArchiveEntry entry = new TarArchiveEntry(
"testdata/test.txt");
entry.setModTime(0);
entry.setSize(file1.length());
entry.setUserId(0);
entry.setGroupId(0);
entry.setUserName("avalon");
entry.setGroupName("excalibur");
entry.setMode(0100000);
changes.add(entry, new FileInputStream(file1));
final File input = getFile("bla.tar");
final InputStream is = new FileInputStream(input);
ais = factory.createArchiveInputStream("tar", is);
temp = new File(dir, "bla.tar");
out = factory.createArchiveOutputStream("tar",
new FileOutputStream(temp));
ChangeSetPerformer performer = new ChangeSetPerformer(changes);
performer.perform(ais, out);
} finally {
if (out != null) {
out.close();
}
if (ais != null) {
ais.close();
}
}
List<String> expected = new ArrayList<String>();
expected.add("test1.xml");
expected.add("testdata/test.txt");
final ArchiveInputStream in = factory.createArchiveInputStream("tar", new FileInputStream(temp));
this.checkArchiveContent(in, expected);
}