Skip to content

Commit ef2a23b

Browse files
committed
add more timestamps
1 parent 3b0176d commit ef2a23b

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

src/test/java/org/apache/maven/archiver/MavenArchiverTest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import java.util.stream.Stream;
4646
import java.util.zip.ZipEntry;
4747

48+
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
49+
import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
4850
import org.apache.maven.artifact.Artifact;
4951
import org.apache.maven.artifact.handler.ArtifactHandler;
5052
import org.apache.maven.artifact.handler.DefaultArtifactHandler;
@@ -69,6 +71,8 @@
6971
import static org.assertj.core.api.Assertions.assertThat;
7072
import static org.assertj.core.api.Assertions.assertThatCode;
7173
import static org.assertj.core.api.Assertions.assertThatExceptionOfType;
74+
import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
75+
import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
7276
import static org.mockito.Mockito.mock;
7377
import static org.mockito.Mockito.when;
7478

@@ -1454,6 +1458,29 @@ private void testJar(String name, String timestamp) throws Exception {
14541458
@Test
14551459
void testJar() throws Exception {
14561460
testJar("1970", "10");
1461+
testJar("1970-2h", "1970-01-01T02:00:00Z");
1462+
testJar("1970-1h59", "1970-01-01T01:59:00Z");
1463+
testJar("1970-1h", "1970-01-01T01:00:00Z");
1464+
testJar("1970-0h59", "1970-01-01T00:59:00Z");
14571465
testJar("2000", "2000-01-01T00:00:00Z");
14581466
}
1467+
1468+
@Test
1469+
void testCompress() throws Exception {
1470+
File zipFile = new File("target/test/dummy.zip");
1471+
ZipArchiveOutputStream zipArchiveOutputStream =
1472+
new ZipArchiveOutputStream(bufferedOutputStream(fileOutputStream(zipFile, "zip")));
1473+
zipArchiveOutputStream.setEncoding("UTF-8");
1474+
zipArchiveOutputStream.setCreateUnicodeExtraFields(ZipArchiveOutputStream.UnicodeExtraFieldPolicy.NEVER);
1475+
zipArchiveOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED);
1476+
1477+
ZipArchiveEntry ze = new ZipArchiveEntry("f.txt");
1478+
ze.setTime(0);
1479+
1480+
zipArchiveOutputStream.putArchiveEntry(ze);
1481+
zipArchiveOutputStream.write(1);
1482+
zipArchiveOutputStream.closeArchiveEntry();
1483+
1484+
zipArchiveOutputStream.close();
1485+
}
14591486
}

0 commit comments

Comments
 (0)