From 717e2de556ae32c8baf09683f2fd7abc452ec4f8 Mon Sep 17 00:00:00 2001 From: Robert von Burg Date: Sat, 1 Dec 2012 00:12:00 +0100 Subject: [PATCH] [Minor] cleaned up test tests left some state files, which are now cleaned up as well --- .../privilege/test/PrivilegeTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/test/java/ch/eitchnet/privilege/test/PrivilegeTest.java b/src/test/java/ch/eitchnet/privilege/test/PrivilegeTest.java index 5357faaa7..47e2c69e7 100644 --- a/src/test/java/ch/eitchnet/privilege/test/PrivilegeTest.java +++ b/src/test/java/ch/eitchnet/privilege/test/PrivilegeTest.java @@ -26,6 +26,7 @@ import java.util.Map; import junit.framework.Assert; +import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; @@ -106,6 +107,25 @@ public class PrivilegeTest { } } + @AfterClass + public static void destroy() throws Exception { + + // delete temporary file + String pwd = System.getProperty("user.dir"); + + File tmpPrivilegeModelFile = new File(pwd + "/target/test/PrivilegeModel.xml"); + if (tmpPrivilegeModelFile.exists() && !tmpPrivilegeModelFile.delete()) { + throw new RuntimeException("Tmp configuration still exists and can not be deleted at " + + tmpPrivilegeModelFile.getAbsolutePath()); + } + + // and temporary parent + File parentFile = tmpPrivilegeModelFile.getParentFile(); + if (parentFile.exists() && !parentFile.delete()) { + throw new RuntimeException("Could not remove temporary parent for tmp " + tmpPrivilegeModelFile); + } + } + @Before public void setup() throws Exception { try {