mirror of
https://gitee.com/dcren/initializr.git
synced 2026-02-26 05:32:58 +08:00
Polish "Add support for long fine names for tar archives"
See gh-1139
This commit is contained in:
@@ -141,9 +141,9 @@ public abstract class ProjectGenerationController<R extends ProjectRequest> {
|
|||||||
|
|
||||||
private TarArchiveOutputStream createTarArchiveOutputStream(OutputStream output) {
|
private TarArchiveOutputStream createTarArchiveOutputStream(OutputStream output) {
|
||||||
try {
|
try {
|
||||||
final TarArchiveOutputStream taos = new TarArchiveOutputStream(new GzipCompressorOutputStream(output));
|
TarArchiveOutputStream out = new TarArchiveOutputStream(new GzipCompressorOutputStream(output));
|
||||||
taos.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
|
out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
|
||||||
return taos;
|
return out;
|
||||||
}
|
}
|
||||||
catch (IOException ex) {
|
catch (IOException ex) {
|
||||||
throw new IllegalStateException(ex);
|
throw new IllegalStateException(ex);
|
||||||
|
|||||||
@@ -67,11 +67,13 @@ class ProjectGenerationControllerIntegrationTests extends AbstractInitializrCont
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
void tgzProjectWithLongFilenames() {
|
void tgzProjectWithLongFilenames() {
|
||||||
String queryParams = "name=spring-boot-service&dependencies=org.acme:foo&artifactId=spring-boot-service"
|
ResponseEntity<byte[]> entity = downloadArchive(
|
||||||
+ "&groupId=com.spring.boot.service&baseDir=spring-boot-service";
|
"/starter.tgz?name=spring-boot-service&artifactId=spring-boot-service"
|
||||||
|
+ "&groupId=com.spring.boot.service&baseDir=spring-boot-service");
|
||||||
ResponseEntity<byte[]> entity = downloadArchive("/starter.tgz?" + queryParams);
|
|
||||||
assertArchiveResponseHeaders(entity, MediaType.valueOf("application/x-compress"), "spring-boot-service.tar.gz");
|
assertArchiveResponseHeaders(entity, MediaType.valueOf("application/x-compress"), "spring-boot-service.tar.gz");
|
||||||
|
ProjectStructure project = tgzProjectAssert(entity.getBody());
|
||||||
|
assertThat(project).containsFiles(
|
||||||
|
"spring-boot-service/src/test/java/com/spring/boot/service/springbootservice/SpringBootServiceApplicationTests.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertArchiveResponseHeaders(ResponseEntity<byte[]> entity, MediaType contentType, String fileName) {
|
private void assertArchiveResponseHeaders(ResponseEntity<byte[]> entity, MediaType contentType, String fileName) {
|
||||||
|
|||||||
Reference in New Issue
Block a user