public void testExplicitFileEntry() throws Exception {
File[] tmp = createTempDirAndFile();
File archive = null;
ArArchiveOutputStream aos = null;
ArArchiveInputStream ais = null;
FileInputStream fis = null;
try {
archive = File.createTempFile("test.", ".ar", tmp[0]);
archive.deleteOnExit();
aos = new ArArchiveOutputStream(new FileOutputStream(archive));
ArArchiveEntry in = new ArArchiveEntry("foo", tmp[1].length(),
0, 0, 0,
tmp[1].lastModified() / 1000);
aos.putArchiveEntry(in);
byte[] b = new byte[(int) tmp[1].length()];
fis = new FileInputStream(tmp[1]);
while (fis.read(b) > 0) {
aos.write(b);
}
fis.close();
fis = null;
aos.closeArchiveEntry();
aos.close();
aos = null;
ais = new ArArchiveInputStream(new FileInputStream(archive));
ArArchiveEntry out = ais.getNextArEntry();
ais.close();
ais = null;
assertNotNull(out);
assertEquals("foo", out.getName());
assertEquals(tmp[1].length(), out.getSize());
assertEquals(tmp[1].lastModified() / 1000,
out.getLastModifiedDate().getTime() / 1000);
assertFalse(out.isDirectory());
} finally {
if (ais != null) {
ais.close();
}
if (aos != null) {
aos.close();
}
if (archive != null) {