|
12 | 12 | import org.junit.jupiter.api.Test; |
13 | 13 | import org.junit.jupiter.api.io.TempDir; |
14 | 14 |
|
| 15 | +import org.ohdsi.usagi.TestUtils; |
| 16 | + |
15 | 17 | import javax.swing.*; |
16 | 18 | import java.io.File; |
17 | 19 | import java.io.FileOutputStream; |
@@ -60,7 +62,7 @@ private void setupEnvironment(boolean createAuthorFile) throws IOException { |
60 | 62 | // Unzip OMOP vocabularies |
61 | 63 | vocabDir = tempDir.resolve("vocab"); |
62 | 64 | Files.createDirectories(vocabDir); |
63 | | - unzipResource("/OMOP-vocabularies-minimal.zip", vocabDir); |
| 65 | + TestUtils.unzipResource("/OMOP-vocabularies-minimal.zip", vocabDir); |
64 | 66 |
|
65 | 67 | // Prepare UsagiMain |
66 | 68 | String[] args = {tempDir.toAbsolutePath().toString()}; |
@@ -163,26 +165,4 @@ private void runBuildIndexTest() { |
163 | 165 | restartPane.okButton().click(); |
164 | 166 | } |
165 | 167 |
|
166 | | - private void unzipResource(String resourceName, Path targetDir) throws IOException { |
167 | | - try (InputStream is = getClass().getResourceAsStream(resourceName); |
168 | | - ZipInputStream zis = new ZipInputStream(is)) { |
169 | | - ZipEntry entry; |
170 | | - while ((entry = zis.getNextEntry()) != null) { |
171 | | - File newFile = new File(targetDir.toFile(), entry.getName()); |
172 | | - if (entry.isDirectory()) { |
173 | | - newFile.mkdirs(); |
174 | | - } else { |
175 | | - newFile.getParentFile().mkdirs(); |
176 | | - try (FileOutputStream fos = new FileOutputStream(newFile)) { |
177 | | - byte[] buffer = new byte[1024]; |
178 | | - int len; |
179 | | - while ((len = zis.read(buffer)) > 0) { |
180 | | - fos.write(buffer, 0, len); |
181 | | - } |
182 | | - } |
183 | | - } |
184 | | - zis.closeEntry(); |
185 | | - } |
186 | | - } |
187 | | - } |
188 | 168 | } |
0 commit comments