public void testExplicitFileEntry() throws Exception {
File[] tmp = createTempDirAndFile();
File archive = null;
CpioArchiveOutputStream tos = null;
CpioArchiveInputStream tis = null;
FileInputStream fis = null;
try {
archive = File.createTempFile("test.", ".cpio", tmp[0]);
archive.deleteOnExit();
tos = new CpioArchiveOutputStream(new FileOutputStream(archive));
CpioArchiveEntry in = new CpioArchiveEntry("foo");
in.setTime(tmp[1].lastModified() / 1000);
in.setSize(tmp[1].length());
in.setMode(CpioConstants.C_ISREG);
tos.putArchiveEntry(in);
byte[] b = new byte[(int) tmp[1].length()];
fis = new FileInputStream(tmp[1]);
while (fis.read(b) > 0) {
tos.write(b);
}
fis.close();
fis = null;
tos.closeArchiveEntry();
tos.close();
tos = null;
tis = new CpioArchiveInputStream(new FileInputStream(archive));
CpioArchiveEntry out = tis.getNextCPIOEntry();
tis.close();
tis = 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 (tis != null) {
tis.close();
}
if (tos != null) {
tos.close();
}
if (archive != null) {