[Minor] cleaned up test

tests left some state files, which are now cleaned up as well
This commit is contained in:
Robert von Burg 2012-12-01 00:12:00 +01:00
parent e0f0b67f60
commit 717e2de556
1 changed files with 20 additions and 0 deletions

View File

@ -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 {