Skip to content

Commit

Permalink
[fix][test] Fix flaky test AdditionalServletsTest.testEmptyStringAsEx…
Browse files Browse the repository at this point in the history
…tractionDirectory (apache#18607)
  • Loading branch information
Andras Beni authored and lifepuzzlefun committed Dec 9, 2022
1 parent f8b0bd0 commit 7680767
Showing 1 changed file with 1 addition and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,8 @@ public void testEmptyStringAsExtractionDirectory() throws IOException {
AdditionalServletWithClassLoader as1 = mock(AdditionalServletWithClassLoader.class);
AdditionalServletWithClassLoader as2 = mock(AdditionalServletWithClassLoader.class);

String originalTmpDirectory = System.getProperty("java.io.tmpdir");
try (MockedStatic<AdditionalServletUtils> utils = mockStatic(AdditionalServletUtils.class)) {
String tmpDirectory = "/my/tmp/directory";
System.setProperty("java.io.tmpdir", tmpDirectory);
String tmpDirectory = System.getProperty("java.io.tmpdir");
utils.when(() -> AdditionalServletUtils.searchForServlets(
"/additionalServletDirectory", tmpDirectory)).thenReturn(definitions);
utils.when(() -> AdditionalServletUtils.load(asm1, tmpDirectory)).thenReturn(as1);
Expand All @@ -65,8 +63,6 @@ public void testEmptyStringAsExtractionDirectory() throws IOException {

Assert.assertEquals(servlets.getServlets().get("AS1"), as1);
Assert.assertEquals(servlets.getServlets().get("AS2"), as2);
} finally {
System.setProperty("java.io.tmpdir", originalTmpDirectory);
}
}

Expand Down

0 comments on commit 7680767

Please sign in to comment.