diff --git a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java index e6d47c8a5..42838e92a 100644 --- a/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java +++ b/tooling/src/test/java/org/opencds/cqf/tooling/operation/RefreshIGOperationTest.java @@ -88,14 +88,29 @@ public void setUp() throws Exception { IOUtils.resourceDirectories = new ArrayList(); IOUtils.clearDevicePaths(); System.setOut(new PrintStream(this.console)); - File dir = new File("target" + separator + "refreshIG"); - if (dir.exists()) { - FileUtils.deleteDirectory(dir); - } + + // Delete directories + deleteDirectory("target" + File.separator + "refreshIG"); + deleteDirectory("target" + File.separator + "NewRefreshIG"); deleteTempINI(); } + /** + * Attempts to delete a directory if it exists. + * @param path The path to the directory to delete. + */ + private void deleteDirectory(String path) { + File dir = new File(path); + if (dir.exists()) { + try { + FileUtils.deleteDirectory(dir); + } catch (IOException e) { + System.err.println("Failed to delete directory: " + path + " - " + e.getMessage()); + } + } + } + @Test public void testNewRefreshOperation() throws IOException { copyResourcesToTargetDir(TARGET_OUTPUT_FOLDER_PATH, "NewRefreshIG"); @@ -173,17 +188,17 @@ private boolean verifyRelatedArtifacts(JsonArray relatedArtifacts) { return false; } - @AfterSuite - public void cleanup() { - // Delete the generated files - File folder = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH); - for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { - File jsonFile = new File(folder, fileName); - if (jsonFile.exists()) { - jsonFile.delete(); - } - } - } +// @AfterSuite +// public void cleanup() { +// // Delete the generated files +// File folder = new File(TARGET_OUTPUT_IG_LIBRARY_FOLDER_PATH); +// for (String fileName : NEW_REFRESH_IG_LIBRARY_FILE_NAMES) { +// File jsonFile = new File(folder, fileName); +// if (jsonFile.exists()) { +// jsonFile.delete(); +// } +// } +// } private void verifyFileContent(File file, String expectedContent) { try (BufferedReader reader = new BufferedReader(new FileReader(file))) {