Fixing testing on windows 7, test temp and work directory were being reused, which windows can't unlock between tests, such that the use of delete of the directory (to clean up between tests) cannot occur

git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1209 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
Joakim Erdfelt 2010-01-21 18:41:30 +00:00
parent 96044a1d2c
commit d7a8e421e1
2 changed files with 38 additions and 23 deletions

View File

@ -110,10 +110,6 @@ public class MavenTestingUtils
public static File getTargetTestingDir(String testname)
{
File dir = new File(getTargetDir(),"test-" + testname);
if (!dir.exists())
{
dir.mkdirs();
}
return dir;
}
@ -197,23 +193,27 @@ public class MavenTestingUtils
}
}
/*
public static boolean isSurefireExecuting()
public static String getTestID()
{
if (surefireRunning == null)
{
String val = System.getProperty("surefire.test.class.path");
if (val != null)
{
surefireRunning = Boolean.TRUE;
}
else
{
surefireRunning = Boolean.FALSE;
}
StackTraceElement stacked[] = new Throwable().getStackTrace();
String name = null;
for(StackTraceElement stack: stacked) {
if(stack.getClassName().endsWith("Test"))
{
name = stack.getClassName();
if (stack.getMethodName().startsWith("test"))
{
return stack.getClassName() + "#" + stack.getMethodName();
}
}
}
return surefireRunning;
if(name == null)
{
return "Unidentified_Test";
}
return name;
}
*/
}

View File

@ -57,13 +57,23 @@ public class XmlConfiguredJetty
public XmlConfiguredJetty() throws IOException
{
String testname = new Throwable().getStackTrace()[1].getClassName();
this(MavenTestingUtils.getTestID());
}
public XmlConfiguredJetty(String testname) throws IOException
{
xmlConfigurations = new ArrayList<URL>();
properties = new Properties();
jettyHome = MavenTestingUtils.getTargetTestingDir(testname);
deleteContents(jettyHome); // Ensure that we are working with a pristene directory
String jettyHomeBase = MavenTestingUtils.getTargetTestingDir(testname).getAbsolutePath();
// Ensure we have a new (pristene) directory to work with.
int idx = 0;
jettyHome = new File(jettyHomeBase + "#" + idx);
while(jettyHome.exists()) {
idx++;
jettyHome = new File(jettyHomeBase + "#" + idx);
}
deleteContents(jettyHome);
// Prepare Jetty.Home (Test) dir
jettyHome.mkdirs();
@ -228,6 +238,11 @@ public class XmlConfiguredJetty
private void deleteContents(File dir)
{
System.out.printf("Delete (dir) %s/%n",dir);
if(!dir.exists())
{
return;
}
for (File file : dir.listFiles())
{
// Safety measure. only recursively delete within target directory.