Skip to content

Commit

Permalink
[JBTM-1816] Clear out object store before running each unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
mmusgrov committed Jul 5, 2013
1 parent 40703cf commit c5ade74
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
2 changes: 0 additions & 2 deletions ArjunaJTS/jts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,6 @@
<skip>false</skip>
<systemProperties combine.children="append" />
<excludes>
<!-- JavaIdlRecoveryUnitTest fails because of unset ID -->
<exclude>**/JavaIdlRecoveryUnitTest.java</exclude>
<exclude>**/JacORBGenericRecoveryCreatorUnitTest.java</exclude>
<exclude>**/JacORBRecoveryUnitTest.java</exclude>
<exclude>**/GenericRecoveryCreatorUnitTest.java</exclude>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

package com.hp.mwtests.ts.jts.resources;

import com.arjuna.ats.arjuna.common.arjPropertyManager;
import org.junit.After;
import org.junit.Before;

Expand All @@ -39,6 +40,8 @@
import com.arjuna.orbportability.ORB;
import com.arjuna.orbportability.RootOA;

import java.io.File;

public class TestBase
{
public void beforeSetupClass() {}
Expand All @@ -47,7 +50,8 @@ public void beforeSetupClass() {}
public void setUp () throws Exception
{
beforeSetupClass();

emptyObjectStore();

myORB = ORB.getInstance("test");
myOA = OA.getRootOA(myORB);

Expand All @@ -63,8 +67,47 @@ public void tearDown () throws Exception
{
myOA.destroy();
myORB.shutdown();
emptyObjectStore();
}


private void emptyObjectStore()
{
String objectStoreDirName = arjPropertyManager.getObjectStoreEnvironmentBean().getObjectStoreDir();

System.out.printf("Emptying %s\n", objectStoreDirName);

File objectStoreDir = new File(objectStoreDirName);

removeContents(objectStoreDir);
}

public void removeContents(File directory)
{
if ((directory != null) &&
directory.isDirectory() &&
(!directory.getName().equals("")) &&
(!directory.getName().equals("/")) &&
(!directory.getName().equals("\\")) &&
(!directory.getName().equals(".")) &&
(!directory.getName().equals("..")))
{
File[] contents = directory.listFiles();

for (int index = 0; index < contents.length; index++)
{
if (contents[index].isDirectory())
{
removeContents(contents[index]);
contents[index].delete();
}
else
{
contents[index].delete();
}
}
}
}

private ORB myORB = null;
private RootOA myOA = null;
}

0 comments on commit c5ade74

Please sign in to comment.