|
10 | 10 | import static org.hamcrest.Matchers.is; |
11 | 11 | import static org.hamcrest.Matchers.not; |
12 | 12 |
|
| 13 | +import java.io.File; |
13 | 14 | import java.io.IOException; |
14 | 15 | import java.net.URISyntaxException; |
15 | 16 | import java.nio.file.Files; |
16 | 17 | import java.nio.file.Path; |
17 | 18 | import java.nio.file.Paths; |
| 19 | +import java.util.Comparator; |
| 20 | +import org.junit.jupiter.api.AfterEach; |
18 | 21 | import org.junit.jupiter.api.Assertions; |
| 22 | +import org.junit.jupiter.api.BeforeEach; |
19 | 23 | import org.junit.jupiter.api.Test; |
20 | | -import org.junit.jupiter.api.io.TempDir; |
21 | 24 | import software.amazon.smithy.build.MockManifest; |
22 | 25 | import software.amazon.smithy.build.PluginContext; |
23 | 26 | import software.amazon.smithy.build.SmithyBuild; |
|
30 | 33 | import software.amazon.smithy.utils.ListUtils; |
31 | 34 |
|
32 | 35 | public class SourcesPluginTest { |
| 36 | + |
| 37 | + private Path tempDirectory; |
| 38 | + |
| 39 | + @BeforeEach |
| 40 | + public void before() throws IOException { |
| 41 | + tempDirectory = Files.createTempDirectory(getClass().getSimpleName()); |
| 42 | + } |
| 43 | + |
| 44 | + @AfterEach |
| 45 | + public void after() throws IOException { |
| 46 | + Files.walk(tempDirectory).sorted(Comparator.reverseOrder()).map(Path::toFile).forEach(File::delete); |
| 47 | + } |
| 48 | + |
33 | 49 | @Test |
34 | 50 | public void copiesFilesForSourceProjection() throws URISyntaxException { |
35 | 51 | Model model = Model.assembler() |
@@ -242,10 +258,10 @@ public void omitsUnsupportedFilesFromManifest() throws URISyntaxException { |
242 | 258 | } |
243 | 259 |
|
244 | 260 | @Test |
245 | | - public void copiesModelFromJarWithEncodedPathWithSourceProjection(@TempDir Path tempDir) |
| 261 | + public void copiesModelFromJarWithEncodedPathWithSourceProjection() |
246 | 262 | throws IOException, URISyntaxException { |
247 | 263 | Path source = Paths.get(getClass().getResource("sources/jar-import.jar").toURI()); |
248 | | - Path jarPath = tempDir.resolve(Paths.get("special%45path", "special.jar")); |
| 264 | + Path jarPath = tempDirectory.resolve(Paths.get("special%45path", "special.jar")); |
249 | 265 |
|
250 | 266 | Files.createDirectories(jarPath.getParent()); |
251 | 267 | Files.copy(source, jarPath); |
@@ -275,10 +291,10 @@ public void copiesModelFromJarWithEncodedPathWithSourceProjection(@TempDir Path |
275 | 291 | } |
276 | 292 |
|
277 | 293 | @Test |
278 | | - public void copiesModelFromJarWithEncodedPathWithNonSourceProjection(@TempDir Path tempDir) |
| 294 | + public void copiesModelFromJarWithEncodedPathWithNonSourceProjection() |
279 | 295 | throws IOException, URISyntaxException { |
280 | 296 | Path source = Paths.get(getClass().getResource("sources/jar-import.jar").toURI()); |
281 | | - Path jarPath = tempDir.resolve(Paths.get("special%45path", "special.jar")); |
| 297 | + Path jarPath = tempDirectory.resolve(Paths.get("special%45path", "special.jar")); |
282 | 298 |
|
283 | 299 | Files.createDirectories(jarPath.getParent()); |
284 | 300 | Files.copy(source, jarPath); |
|
0 commit comments