int origLength = (int) new File(url.getFile()).length(); int savedLength = out.toString().length(); int diff = Math.abs(origLength - savedLength); assertEquals("Difference between saved and original is " + diff, diff < 4, true);
String inputString = getFileAsString(url.getFile()); String outputString = out.toString();  Diff diff = new Diff(inputString, outputString); diff.overrideElementQualifier(new ElementNameAndTextQualifier()); assertTrue(diff.similar()); assertXMLEqual("But they are equal when an ElementQualifier controls which test element is compared with each control element", diff, true);  assertTrue(diff.similar());
    public void testSave() throws Exception {        URL url = getClass().getClassLoader().getResource("/samples/saved.xml");        WorkflowDescriptor descriptor = DescriptorLoader.getDescriptor(url.toString());        StringWriter out = new StringWriter();        PrintWriter writer = new PrintWriter(out);        writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");        writer.println("<!DOCTYPE workflow PUBLIC \"-//OpenSymphony Group//DTD OSWorkflow 2.5//EN\" \"http://www.opensymphony.com/osworkflow/workflow_2_5.dtd\">");        descriptor.writeXML(new PrintWriter(out), 0);        int origLength = (int) new File(url.getFile()).length();        int savedLength = out.toString().length();        int diff = Math.abs(origLength - savedLength);        assertEquals("Difference between saved and original is " + diff, diff < 4, true);    }