public void createFlatpackWithPreferences2() throws Exception{
//
// upload a new widget to test with
//
W3CWidgetFactory fac = getFactory();
fac.setFeatures(Features.getFeatureNames());
File testWidget = new File("build/widgets/simplechat.wgt");
fac.parse(testWidget);
download = fac.getUnzippedWidgetDirectory(); //download is where we unzipped the widget
//
// Create an instance of it
//
IWidgetInstance instance = new WidgetInstanceMock();
ArrayList<IPreference> prefs = new ArrayList<IPreference>();
IPreference pref = new PreferenceMock();
pref.setDkey("moderator");
pref.setDvalue("true");
pref.setReadOnly(false);
prefs.add(pref);
instance.setPreferences(prefs);
//
// Flatpack it
//
FlatpackFactory flatfac = new FlatpackFactory(instance);
flatfac.setParser(fac);
flatfac.setInputWidget(testWidget); // this is the original .wgt
flatfac.setFlatpackFolder(flatpack); // flatpack is our new temp folder. This would probably be "/flatpack" or similar in deployment
File file = flatfac.pack(); // Get the new .wgt file
//
// Test it works!
//
System.out.println(file.getAbsolutePath());
W3CWidget fpWidget = fac.parse(file);
assertEquals("moderator", fpWidget.getPreferences().get(0).getName());
assertEquals("true", fpWidget.getPreferences().get(0).getValue());
assertEquals(1,fpWidget.getPreferences().size());
}