|
45 | 45 | import java.util.stream.Stream;
|
46 | 46 | import java.util.zip.ZipEntry;
|
47 | 47 |
|
| 48 | +import org.apache.commons.compress.archivers.zip.ZipArchiveEntry; |
| 49 | +import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; |
48 | 50 | import org.apache.maven.artifact.Artifact;
|
49 | 51 | import org.apache.maven.artifact.handler.ArtifactHandler;
|
50 | 52 | import org.apache.maven.artifact.handler.DefaultArtifactHandler;
|
|
69 | 71 | import static org.assertj.core.api.Assertions.assertThat;
|
70 | 72 | import static org.assertj.core.api.Assertions.assertThatCode;
|
71 | 73 | 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; |
72 | 76 | import static org.mockito.Mockito.mock;
|
73 | 77 | import static org.mockito.Mockito.when;
|
74 | 78 |
|
@@ -1454,6 +1458,29 @@ private void testJar(String name, String timestamp) throws Exception {
|
1454 | 1458 | @Test
|
1455 | 1459 | void testJar() throws Exception {
|
1456 | 1460 | 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"); |
1457 | 1465 | testJar("2000", "2000-01-01T00:00:00Z");
|
1458 | 1466 | }
|
| 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 | + } |
1459 | 1486 | }
|
0 commit comments