From 7a172d1c6922851e7008d1ce2afdf673193699d3 Mon Sep 17 00:00:00 2001 From: uj426b Date: Wed, 13 May 2020 18:41:47 -0400 Subject: Fix Junit to clean up file/directory Change-Id: Ib29b3b708bd28e333822d4c2b9db44e33f8e395f Issue-ID: POLICY-2496 Signed-off-by: uj426b --- .../policy/pap/xacml/rest/service/ImportServiceTest.java | 14 +++++++++++++- .../org/onap/policy/admin/PolicyManagerServletTest.java | 11 +++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/ImportServiceTest.java b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/ImportServiceTest.java index b7d6bacbd..cee67dd51 100644 --- a/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/ImportServiceTest.java +++ b/ONAP-PAP-REST/src/test/java/org/onap/policy/pap/xacml/rest/service/ImportServiceTest.java @@ -23,11 +23,14 @@ package org.onap.policy.pap.xacml.rest.service; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.junit.Assert.assertEquals; - import com.mockrunner.mock.web.MockHttpServletRequest; import com.mockrunner.mock.web.MockHttpServletResponse; +import java.io.File; +import java.io.IOException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.io.FileUtils; +import org.junit.AfterClass; import org.junit.Test; public class ImportServiceTest { @@ -74,4 +77,13 @@ public class ImportServiceTest { HttpServletResponse response = new MockHttpServletResponse(); assertThatThrownBy(() -> service.doImportMicroServicePut(request, response)).isInstanceOf(Exception.class); } + + @AfterClass + public static void tearDown(){ + try { + FileUtils.deleteDirectory(new File("ExtractDir")); + } catch (IOException e) { + e.printStackTrace(); + } + } } diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java index e349d53ac..c3b98f525 100644 --- a/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java +++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/admin/PolicyManagerServletTest.java @@ -50,6 +50,7 @@ import org.apache.commons.fileupload.FileItem; import org.apache.commons.io.IOUtils; import org.json.JSONArray; import org.json.JSONObject; +import org.junit.AfterClass; import org.junit.Before; import org.junit.FixMethodOrder; import org.junit.Test; @@ -89,6 +90,16 @@ public class PolicyManagerServletTest extends Mockito { private HttpServletRequest request; private MockHttpServletResponse response; + /** + * Delete test File. + * + */ + @AfterClass + public static void tearDown() { + File destroyFile = new File("testFileName.xls"); + destroyFile.deleteOnExit(); + } + /** * setUp. * -- cgit 1.2.3-korg