in java/src/org/apache/qetest/trax/TestMultiTypeThreads.java [362:481]
protected boolean initPropFile(String fName)
{
Properties p = new Properties();
try
{
// Load named file into our properties block
FileInputStream fIS = new FileInputStream(fName);
p.load(fIS);
// Parse out any values that match our internal convenience variables
outputDir = p.getProperty("outputDir", outputDir);
// Validate the outputDir and use it to reset the logFileName
File oDir = new File(outputDir);
if (!oDir.exists())
{
if (!oDir.mkdirs())
{
// Error, we can't create the outputDir, default to current dir
println("<message desc=\"outputDir(" + outputDir
+ ") does not exist, defaulting to .\"/>");
outputDir = ".";
}
}
// Verify inputDir as well
inputDir = p.getProperty("inputDir", inputDir);
File tDir = new File(inputDir);
if (!tDir.exists())
{
if (!tDir.mkdirs())
{
// Error, we can't create the inputDir, abort
println("<message desc=\"inputDir(" + inputDir
+ ") does not exist, terminating test\"/>");
return false;
}
}
// Add on separators
inputDir += File.separator;
outputDir += File.separator;
// Each defaults to variable initializers
logFileName = p.getProperty("logFile", logFileName);
setOneFilenameRoot = p.getProperty("setOneFile",
setOneFilenameRoot);
setTwoFilenameRoot = p.getProperty("setTwoFile",
setTwoFilenameRoot);
setThreeFilenameRoot = p.getProperty("setThreeFile",
setThreeFilenameRoot);
paramName = p.getProperty("paramName", paramName);
paramVal = p.getProperty("paramVal", paramVal);
liaison = p.getProperty("liaison", liaison);
String numb;
numb = p.getProperty("numRunners");
if (numb != null)
{
try
{
numRunners = Integer.parseInt(numb);
}
catch (NumberFormatException numEx)
{
// no-op, leave set as default
println("<message desc=\"numRunners threw: "
+ numEx.toString() + "\"/>");
}
}
numb = p.getProperty("numRunnerCalls");
if (numb != null)
{
try
{
numRunnerCalls = Integer.parseInt(numb);
}
catch (NumberFormatException numEx)
{
// no-op, leave set as default
println("<message desc=\"numRunnerCalls threw: "
+ numEx.toString() + "\"/>");
}
}
}
catch (Exception e)
{
println("<arbitrary=\"initPropFile: " + fName + " threw: "
+ e.toString() + "\">");
if (pWriter != null)
{
e.printStackTrace(pWriter);
}
e.printStackTrace();
println("</arbitrary>");
return false;
}
return true;
}