|
1 | 1 | /*
|
2 |
| - * Copyright 2012-2017 the original author or authors. |
| 2 | + * Copyright 2012-2018 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
18 | 18 |
|
19 | 19 | import java.io.ByteArrayInputStream;
|
20 | 20 | import java.io.File;
|
| 21 | +import java.io.FileOutputStream; |
21 | 22 | import java.io.IOException;
|
22 | 23 | import java.nio.file.Files;
|
23 | 24 | import java.nio.file.attribute.PosixFilePermission;
|
24 | 25 | import java.util.Calendar;
|
| 26 | +import java.util.Random; |
25 | 27 | import java.util.jar.Attributes;
|
26 | 28 | import java.util.jar.JarEntry;
|
27 | 29 | import java.util.jar.JarFile;
|
28 | 30 | import java.util.jar.Manifest;
|
| 31 | +import java.util.zip.Deflater; |
29 | 32 | import java.util.zip.ZipEntry;
|
| 33 | +import java.util.zip.ZipOutputStream; |
30 | 34 |
|
31 | 35 | import org.junit.Before;
|
32 | 36 | import org.junit.Rule;
|
@@ -613,6 +617,28 @@ public void metaInfAopXmlIsMovedBeneathBootInfClassesWhenRepackaged()
|
613 | 617 | }
|
614 | 618 | }
|
615 | 619 |
|
| 620 | + @Test |
| 621 | + public void jarThatUsesCustomCompressionConfigurationCanBeRepackaged() |
| 622 | + throws IOException { |
| 623 | + File source = this.temporaryFolder.newFile("source.jar"); |
| 624 | + ZipOutputStream output = new ZipOutputStream(new FileOutputStream(source)) { |
| 625 | + { |
| 626 | + this.def = new Deflater(Deflater.NO_COMPRESSION, true); |
| 627 | + } |
| 628 | + }; |
| 629 | + byte[] data = new byte[1024 * 1024]; |
| 630 | + new Random().nextBytes(data); |
| 631 | + ZipEntry entry = new ZipEntry("entry.dat"); |
| 632 | + output.putNextEntry(entry); |
| 633 | + output.write(data); |
| 634 | + output.closeEntry(); |
| 635 | + output.close(); |
| 636 | + File dest = this.temporaryFolder.newFile("dest.jar"); |
| 637 | + Repackager repackager = new Repackager(source); |
| 638 | + repackager.setMainClass("com.example.Main"); |
| 639 | + repackager.repackage(dest, NO_LIBRARIES); |
| 640 | + } |
| 641 | + |
616 | 642 | private boolean hasLauncherClasses(File file) throws IOException {
|
617 | 643 | return hasEntry(file, "org/springframework/boot/")
|
618 | 644 | && hasEntry(file, "org/springframework/boot/loader/JarLauncher.class");
|
|
0 commit comments