use of org.eclipse.wst.xml.ui.internal.wizards.NewXMLGenerator in project webtools.sourceediting by eclipse.
the class TestNewXMLGenerator method runOneTest.
/**
* Runs a generic generate + comparison test.
* @param buildPolicy Integer representing the build policy for this generation.
* @param rootElement Desired root element.
* @param xsdUri URI of the desired XML schema.
*/
private void runOneTest(int buildPolicy, String rootElement, String xsdUriFile) {
try {
// generic setup
PLUGIN_ABSOLUTE_PATH = XMLUITestsPlugin.getInstallURL();
// $NON-NLS-3$
String uri = "file:///" + PLUGIN_ABSOLUTE_PATH + "testresources/" + xsdUriFile + ".xsd";
String[] errorInfo = new String[2];
CMDocument cmd = NewXMLGenerator.createCMDocument(uri, errorInfo);
NewXMLGenerator generator = new NewXMLGenerator(uri, cmd);
String id = xsdUriFile + "-" + rootElement + "-" + buildPolicy;
// $NON-NLS-2$
String fileNameResult = PLUGIN_ABSOLUTE_PATH + "testresources/Tested-" + id + ".xml";
File nFile = new File(fileNameResult);
if (!nFile.exists()) {
nFile.createNewFile();
}
// $NON-NLS-2$
String fileNameCompare = PLUGIN_ABSOLUTE_PATH + "testresources/Compare-" + id + ".xml";
generator.setBuildPolicy(buildPolicy);
generator.setRootElementName(rootElement);
// $NON-NLS-1$
generator.setDefaultSystemId(xsdUriFile + ".xsd");
generator.createNamespaceInfoList();
generator.createXMLDocument(fileNameResult);
XMLDiff differ = new XMLDiff();
// $NON-NLS-2$
assertTrue("The XML files are not identical.", differ.diff(fileNameCompare, fileNameResult, "XML"));
// if we've made it this far, delete the output file
remove(nFile);
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations