|
1 | 1 | package org.labkey.test.tests.assay; |
2 | 2 |
|
3 | 3 | import org.apache.commons.io.FileUtils; |
| 4 | +import org.apache.commons.lang3.SystemUtils; |
4 | 5 | import org.junit.Assert; |
5 | 6 | import org.junit.Test; |
6 | 7 | import org.junit.experimental.categories.Category; |
7 | 8 | import org.labkey.api.util.FileUtil; |
8 | | -import org.labkey.test.BaseWebDriverTest; |
9 | 9 | import org.labkey.test.Locator; |
10 | 10 | import org.labkey.test.TestFileUtils; |
11 | 11 | import org.labkey.test.categories.Assays; |
|
19 | 19 | import java.io.File; |
20 | 20 | import java.nio.file.Files; |
21 | 21 | import java.nio.file.Path; |
| 22 | +import java.nio.file.Paths; |
| 23 | +import java.time.Instant; |
22 | 24 |
|
23 | 25 | /** |
24 | 26 | * Issue 54156: Regression test to ensure a reasonable error message is shown when an assay design references |
@@ -49,18 +51,19 @@ public void testMissingParentDirectoryRegression() throws Exception |
49 | 51 | getArtifactCollector().dumpPageSnapshot("TransformScript_Added"); |
50 | 52 | assayDesignerPage.clickSave(); |
51 | 53 |
|
52 | | - // Now delete the parent dir to ensure we handle it reasonably |
53 | | - TestFileUtils.deleteDir(parentDir.toFile()); |
54 | | - |
55 | | - int count = 1; |
56 | | - while (!FileUtils.isDirectory(parentDir.toFile()) && count <= 5) |
| 54 | + // Now delete, or rename, the parent dir to ensure we handle it reasonably |
| 55 | + if (SystemUtils.IS_OS_WINDOWS) |
| 56 | + { |
| 57 | + // Deleting directories on Windows is not always reliable, try renaming as an alternative. |
| 58 | + String newName = "Not-Here-" + Instant.now().getEpochSecond(); |
| 59 | + TestFileUtils.renameDir(parentDir, newName); |
| 60 | + } |
| 61 | + else |
57 | 62 | { |
58 | | - sleep(1_000); |
59 | 63 | TestFileUtils.deleteDir(parentDir.toFile()); |
60 | | - count++; |
61 | 64 | } |
62 | 65 |
|
63 | | - Assert.assertFalse(String.format("Directory %s not deleted.", parentDir.toString()), |
| 66 | + Assert.assertFalse(String.format("Directory %s is still present.", parentDir), |
64 | 67 | FileUtils.isDirectory(parentDir.toFile())); |
65 | 68 |
|
66 | 69 | // Attempt to import data and verify a reasonable error message is shown |
|
0 commit comments