@Test
public void loadModifySaveReload() throws Exception{
// Load the widget
W3CWidgetFactory fac = new W3CWidgetFactory();
fac.setLocalPath("/widgets");
fac.setFeatures(new String[]{"feature:a9bb79c1"});
fac.setEncodings(new String[]{"UTF-8", "ISO-8859-1","Windows-1252"});
if (download.exists()) download.delete();
if (output.exists()) output.delete();
output.mkdir();
fac.setOutputDirectory(output.getAbsolutePath());
File widgetFile = WidgetUploader.downloadWidget("http://dev.w3.org/2006/waf/widgets/test-suite/test-cases/ta-RRZxvvTFHx/001/b6.wgt");
W3CWidget widget = fac.parse(widgetFile);
IName name = widget.getNames().get(0);
name.setName("Re-Modified Widget");
WidgetOutputter outputter = new WidgetOutputter();
outputter.setWidgetFolder("/widgets");
// Save the config.xml
File widgetFolder = new File(output.getPath()+"/b6");
File configXml = new File(widgetFolder, "config.xml");
outputter.outputXML(widget, configXml);
// Pack up the widget
File zip = File.createTempFile("wookie-output", ".wgt");
WidgetPackageUtils.repackZip(widgetFolder, zip);
// Reload the widget but using a new path
fac.setLocalPath("/zaphod.bee.ble/brox");
widget = fac.parse(zip);
assertEquals("Re-Modified Widget", widget.getLocalName("en"));
// Check the content is now pointing to the new location
assertEquals("/zaphod.bee.ble/brox/b6/index.html", widget.getContentList().get(0).getSrc());
}