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 {