Fix missing resources in GzipResourceResolverTests
This commit is contained in:
parent
4346d15cb5
commit
72e4fac28d
|
@ -16,8 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.web.reactive.resource;
|
package org.springframework.web.reactive.resource;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -74,14 +78,12 @@ public class GzipResourceResolverTests {
|
||||||
private static void createGzFile(String filePath) throws IOException {
|
private static void createGzFile(String filePath) throws IOException {
|
||||||
Resource location = new ClassPathResource("test/", GzipResourceResolverTests.class);
|
Resource location = new ClassPathResource("test/", GzipResourceResolverTests.class);
|
||||||
Resource fileResource = new FileSystemResource(location.createRelative(filePath).getFile());
|
Resource fileResource = new FileSystemResource(location.createRelative(filePath).getFile());
|
||||||
Resource gzFileResource = location.createRelative(filePath + ".gz");
|
Path gzFilePath = Paths.get(fileResource.getFile().getAbsolutePath() + ".gz");
|
||||||
|
Files.deleteIfExists(gzFilePath);
|
||||||
if (gzFileResource.getFile().createNewFile()) {
|
File gzFile = Files.createFile(gzFilePath).toFile();
|
||||||
GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFileResource.getFile()));
|
GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFile));
|
||||||
FileCopyUtils.copy(fileResource.getInputStream(), out);
|
FileCopyUtils.copy(fileResource.getInputStream(), out);
|
||||||
}
|
gzFile.deleteOnExit();
|
||||||
|
|
||||||
assertTrue(gzFileResource.exists());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
|
@ -16,8 +16,12 @@
|
||||||
|
|
||||||
package org.springframework.web.servlet.resource;
|
package org.springframework.web.servlet.resource;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -65,14 +69,12 @@ public class GzipResourceResolverTests {
|
||||||
private static void createGzFile(String filePath) throws IOException {
|
private static void createGzFile(String filePath) throws IOException {
|
||||||
Resource location = new ClassPathResource("test/", GzipResourceResolverTests.class);
|
Resource location = new ClassPathResource("test/", GzipResourceResolverTests.class);
|
||||||
Resource fileResource = new FileSystemResource(location.createRelative(filePath).getFile());
|
Resource fileResource = new FileSystemResource(location.createRelative(filePath).getFile());
|
||||||
Resource gzFileResource = location.createRelative(filePath + ".gz");
|
Path gzFilePath = Paths.get(fileResource.getFile().getAbsolutePath() + ".gz");
|
||||||
|
Files.deleteIfExists(gzFilePath);
|
||||||
if (gzFileResource.getFile().createNewFile()) {
|
File gzFile = Files.createFile(gzFilePath).toFile();
|
||||||
GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFileResource.getFile()));
|
GZIPOutputStream out = new GZIPOutputStream(new FileOutputStream(gzFile));
|
||||||
FileCopyUtils.copy(fileResource.getInputStream(), out);
|
FileCopyUtils.copy(fileResource.getInputStream(), out);
|
||||||
}
|
gzFile.deleteOnExit();
|
||||||
|
|
||||||
assertTrue(gzFileResource.exists());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue