Polish "Add support for long fine names for tar archives"

See gh-1139
This commit is contained in:
Stephane Nicoll
2020-10-14 11:27:26 +02:00
parent 249b260774
commit 6447249c54
2 changed files with 9 additions and 7 deletions

View File

@@ -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);

View File

@@ -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) {