Skip to content

Commit

Permalink
Improve test stability
Browse files Browse the repository at this point in the history
  • Loading branch information
mekya committed Sep 6, 2024
1 parent 857becc commit 2ac55e4
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ public void testDoHead() throws ServletException, IOException {
MockHttpServletRequest request = new MockHttpServletRequest();
MockHttpServletResponse response = Mockito.spy(new MockHttpServletResponse());

request.setRequestURI("/test.war");
String appName = "test" + RandomStringUtils.randomAlphanumeric(16);
request.setRequestURI("/"+ appName +".war");
warDownloadServlet.doHead(request, response);
verify(response).sendError(HttpServletResponse.SC_NOT_FOUND, "No such war file in the tmp directory");



File f = new File(AdminApplication.getJavaTmpDirectory(), "test.war");
File f = new File(AdminApplication.getJavaTmpDirectory(), appName + ".war");
assertTrue(f.createNewFile());
f.deleteOnExit();

Expand All @@ -59,7 +60,7 @@ public void testDoHead() throws ServletException, IOException {


warDownloadServlet = Mockito.spy(new WarDownloadServlet());
Mockito.doReturn(mock(AntMediaApplicationAdapter.class)).when(warDownloadServlet).getAppAdaptor("test", request);
Mockito.doReturn(mock(AntMediaApplicationAdapter.class)).when(warDownloadServlet).getAppAdaptor(appName, request);
response = Mockito.spy(new MockHttpServletResponse());
verify(response, never()).sendError(anyInt(), anyString());

Expand Down

0 comments on commit 2ac55e4

Please sign in to comment.