} catch (FileNotFoundException e3) {
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),Messages.ValidationDialog_fileNotFound, e3.toString());
ValidationPlugin.log(e3.toString()); //log the error, but don't throw the exception
return;
}
TestSuiteDTO newDTO;
try {
newDTO = XMLReader.readTestSuite(fileName, reader, processor.getPluginDTOs());
} catch (ValidationException e3) {
String errorMsg = e3.toString();
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),"Exception Occurred", errorMsg); //$NON-NLS-1$
ValidationPlugin.log(errorMsg, e3);
return;
}
try {
reader.close();
} catch (IOException e2) {
MessageDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),"Exception Occurred", e2.toString()); //$NON-NLS-1$
ValidationPlugin.log(e2.toString(), e2);
return;
}
//get the existing testSuites
Map<String, TestSuiteDTO> suites = processor.getTestSuiteDTOs();
//ensure there is at least one test in the new testSuite
if (newDTO.getTests().size() == 0) {
//nothing to see here, move along
return;
}
//if no testSuites exist, just copy the new one directly in
if (suites.size() == 0) {
suites.put(newDTO.getName(), newDTO);
defaultTestSuite = newDTO.getName();
//does the testSuite exist? if so, add the new tests to the existing one
} else if (suites.containsKey(newDTO.getName())) {
//ensure the current testSuite is selected
defaultTestSuite = newDTO.getName();
//get the existing testSuite
TestSuiteDTO testSuite = (TestSuiteDTO) suites.get(defaultTestSuite);
//move the tests to the existing testSuite
testSuite = processor.moveTests(testSuite, newDTO.getTests(), false);
suites.put(defaultTestSuite, testSuite); //overwrite the suite
//a test Suite exists, but it isn't this one; put the new tests into the existing testSuite
} else {
TestSuiteDTO testSuite = (TestSuiteDTO) suites.get(defaultTestSuite);
Map<String, TestDTO> tests = newDTO.getTests();
testSuite = processor.moveTests(testSuite, tests, false);
suites.put(defaultTestSuite, testSuite); //overwrite the suite with new map of tests
}
//do multiple testSuites exist? if so, merge them
while (suites.size() > 1) {
//find the first testSuite which isn't the defaultTestSuite
Object key = null;
for (Iterator i = suites.keySet().iterator(); i.hasNext();) {
Object thisKey = i.next();
if (!(thisKey.equals(defaultTestSuite))) {
key = thisKey;
break;
}
}
if (key != null) {
TestSuiteDTO alphaSuite = (TestSuiteDTO) suites.get(defaultTestSuite);
TestSuiteDTO betaSuite = (TestSuiteDTO) suites.get(key);
alphaSuite = processor.moveTests(alphaSuite, betaSuite.getTests(), false);
suites.remove(key); //bye betaSuite!
suites.put(defaultTestSuite, alphaSuite); //overwrite the suite (alphaSuite has now assimilated betaSuite)
}
}
//all done; save the Map of testSuites and refresh the Tree