use of org.hl7.fhir.utilities.CSFile in project org.hl7.fhir.core by hapifhir.
the class TestingUtilities method checkXMLIsSame.
public static String checkXMLIsSame(String f1, String f2) throws Exception {
String result = compareXml(f1, f2);
if (result != null && SHOW_DIFF) {
String diff = Utilities.path(System.getenv("ProgramFiles(X86)"), "WinMerge", "WinMergeU.exe");
List<String> command = new ArrayList<String>();
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
ProcessBuilder builder = new ProcessBuilder(command);
builder.directory(new CSFile(Utilities.path("[tmp]")));
builder.start();
}
return result;
}
use of org.hl7.fhir.utilities.CSFile in project org.hl7.fhir.core by hapifhir.
the class TestingUtilities method checkJsonIsSame.
public static String checkJsonIsSame(String f1, String f2) throws JsonSyntaxException, FileNotFoundException, IOException {
String result = compareJson(f1, f2);
if (result != null && SHOW_DIFF) {
String diff = Utilities.path(System.getenv("ProgramFiles(X86)"), "WinMerge", "WinMergeU.exe");
List<String> command = new ArrayList<String>();
command.add("\"" + diff + "\" \"" + f1 + "\" \"" + f2 + "\"");
ProcessBuilder builder = new ProcessBuilder(command);
builder.directory(new CSFile(Utilities.path("[tmp]")));
builder.start();
}
return result;
}
use of org.hl7.fhir.utilities.CSFile in project org.hl7.fhir.core by hapifhir.
the class ToolsHelper method executeFragments.
public void executeFragments(String[] args) throws IOException {
try {
File source = new CSFile(args[1]);
if (!source.exists())
throw new FHIRException("Source File \"" + source.getAbsolutePath() + "\" not found");
XmlPullParser xpp = loadXml(new FileInputStream(source));
nextNoWhitespace(xpp);
if (!xpp.getName().equals("tests"))
throw new FHIRFormatError("Unable to parse file - starts with " + xpp.getName());
xpp.next();
nextNoWhitespace(xpp);
StringBuilder s = new StringBuilder();
s.append("<results>\r\n");
int fail = 0;
while (xpp.getEventType() == XmlPullParser.START_TAG && xpp.getName().equals("test")) {
String id = xpp.getAttributeValue(null, "id");
String type = xpp.getAttributeValue(null, "type");
// test
xpp.next();
nextNoWhitespace(xpp);
// pre
xpp.next();
nextNoWhitespace(xpp);
XmlParser p = new XmlParser();
try {
p.parseFragment(xpp, type);
s.append("<result id=\"" + id + "\" outcome=\"ok\"/>\r\n");
nextNoWhitespace(xpp);
} catch (Exception e) {
s.append("<result id=\"" + id + "\" outcome=\"error\" msg=\"" + Utilities.escapeXml(e.getMessage()) + "\"/>\r\n");
fail++;
}
while (xpp.getEventType() != XmlPullParser.END_TAG || !xpp.getName().equals("pre")) xpp.next();
xpp.next();
nextNoWhitespace(xpp);
xpp.next();
nextNoWhitespace(xpp);
}
s.append("</results>\r\n");
TextFile.stringToFile(s.toString(), args[2]);
} catch (Exception e) {
e.printStackTrace();
TextFile.stringToFile(e.getMessage(), args[2]);
}
}
Aggregations