|
7 | 7 | import org.jspecify.annotations.NullMarked; |
8 | 8 | import org.junit.jupiter.api.Nested; |
9 | 9 | import org.junit.jupiter.api.Test; |
| 10 | +import org.junit.jupiter.api.io.TempDir; |
10 | 11 |
|
11 | 12 | import java.io.File; |
| 13 | +import java.nio.file.Path; |
12 | 14 | import java.util.List; |
13 | 15 |
|
14 | 16 | import static org.junit.jupiter.api.Assertions.assertEquals; |
@@ -82,38 +84,43 @@ public void logArgumentFile() throws ArgumentParserException { |
82 | 84 | class OutputDirectoryArgumentsTest { |
83 | 85 |
|
84 | 86 | @Test |
85 | | - public void outputArgumentDefaultDefault() throws ArgumentParserException { |
86 | | - Namespace arguments = parseCommandLine("--output-directory C:\\temp -"); |
| 87 | + public void outputArgumentDefaultDefault(@TempDir Path tempDir) throws ArgumentParserException { |
| 88 | + String tempDirPath = tempDir.toAbsolutePath().toString(); |
| 89 | + Namespace arguments = parseCommandLine("--output-directory " + tempDirPath + " -"); |
87 | 90 | File output = resolveOutputFile(arguments, ".msch"); |
88 | 91 | assertEquals(new File("-"), output); |
89 | 92 | } |
90 | 93 |
|
91 | 94 | @Test |
92 | | - public void outputArgumentDefaultFile() throws ArgumentParserException { |
93 | | - Namespace arguments = parseCommandLine("--output-directory C:\\temp input.sdf"); |
| 95 | + public void outputArgumentDefaultFile(@TempDir Path tempDir) throws ArgumentParserException { |
| 96 | + String tempDirPath = tempDir.toAbsolutePath().toString(); |
| 97 | + Namespace arguments = parseCommandLine("--output-directory " + tempDirPath + " input.sdf"); |
94 | 98 | File output = resolveOutputFile(arguments, ".msch"); |
95 | | - assertEquals(new File("C:\\temp\\input.msch"), output); |
| 99 | + assertEquals(new File(tempDirPath, "input.msch"), output); |
96 | 100 | } |
97 | 101 |
|
98 | 102 | @Test |
99 | | - public void outputArgumentFile() throws ArgumentParserException { |
100 | | - Namespace arguments = parseCommandLine("--output-directory C:\\temp input.sdf -o output.msch"); |
| 103 | + public void outputArgumentFile(@TempDir Path tempDir) throws ArgumentParserException { |
| 104 | + String tempDirPath = tempDir.toAbsolutePath().toString(); |
| 105 | + Namespace arguments = parseCommandLine("--output-directory " + tempDirPath + " input.sdf -o output.msch"); |
101 | 106 | File output = resolveOutputFile(arguments, ".msch"); |
102 | | - assertEquals(new File("C:\\temp\\output.msch"), output); |
| 107 | + assertEquals(new File(tempDirPath, "output.msch"), output); |
103 | 108 | } |
104 | 109 |
|
105 | 110 | @Test |
106 | | - public void logArgumentDefault() throws ArgumentParserException { |
107 | | - Namespace arguments = parseCommandLine("--output-directory C:\\temp input.sdf -o output.msch -l"); |
| 111 | + public void logArgumentDefault(@TempDir Path tempDir) throws ArgumentParserException { |
| 112 | + String tempDirPath = tempDir.toAbsolutePath().toString(); |
| 113 | + Namespace arguments = parseCommandLine("--output-directory " + tempDirPath + " input.sdf -o output.msch -l"); |
108 | 114 | File output = resolveLogFile(arguments, ".log"); |
109 | | - assertEquals(new File("C:\\temp\\input.log"), output); |
| 115 | + assertEquals(new File(tempDirPath, "input.log"), output); |
110 | 116 | } |
111 | 117 |
|
112 | 118 | @Test |
113 | | - public void logArgumentFile() throws ArgumentParserException { |
114 | | - Namespace arguments = parseCommandLine("--output-directory C:\\temp input.sdf -o output.msch -l log.log"); |
| 119 | + public void logArgumentFile(@TempDir Path tempDir) throws ArgumentParserException { |
| 120 | + String tempDirPath = tempDir.toAbsolutePath().toString(); |
| 121 | + Namespace arguments = parseCommandLine("--output-directory " + tempDirPath + " input.sdf -o output.msch -l log.log"); |
115 | 122 | File output = resolveLogFile(arguments, ".log"); |
116 | | - assertEquals(new File("C:\\temp\\log.log"), output); |
| 123 | + assertEquals(new File(tempDirPath, "log.log"), output); |
117 | 124 | } |
118 | 125 | } |
119 | 126 |
|
|
0 commit comments