public static Collection loadItemsFromXml(Model model, String resourceName) throws Exception { XmlBinding binding = new XmlBinding(model); return binding.unmarshal(SetupDataTestCase.class.getClassLoader().getResourceAsStream(resourceName)); }
public static void main(String[] args) throws Exception { Model testModel = Model.getInstanceByName("testmodel"); if (testModel == null) { throw new Exception("Cannot find testmodel"); } XmlBinding binding = new XmlBinding(testModel); Collection col = setUpDataObjects(); setIds(col); binding.marshal(col, new FileWriter(File.createTempFile("testmodel_data", "xml"))); }
public void testRoundTrip() throws Exception { StringWriter sw = new StringWriter(); InputStream original = getClass().getClassLoader().getResourceAsStream("testmodel_data.xml"); XMLUnit.setIgnoreWhitespace(true); Collection<FastPathObject> unmarshalled = (Collection<FastPathObject>) binding.unmarshal(original); setIds(unmarshalled); binding.marshal(unmarshalled, sw); // System.out.println(sw.toString()); String expected = IOUtils.toString(getClass().getClassLoader().getResourceAsStream("testmodel_data.xml")); Diff diff = new Diff(expected, sw.toString()); DetailedDiff detail = new DetailedDiff(diff); detail.overrideElementQualifier(new ElementNameAndAttributeQualifier()); assertTrue(detail.getAllDifferences().toString() + ": Original: " + expected + ", Generated: " + sw.toString(), detail.similar()); }
public void setUp() throws Exception { binding = new XmlBinding(Model.getInstanceByName("testmodel")); }
private void marshalList(List list, File file) throws Exception { List flat = TypeUtil.flatten(list); System.out.println("flat = " + flat); setIds(flat); System.out.println("setIds: " + flat); binding.marshal(flat, new BufferedWriter(new FileWriter(file))); stripIds(flat); }
public void setUp() throws Exception { writer = ObjectStoreWriterFactory.getObjectStoreWriter("osw.unittest"); iw = IntegrationWriterFactory.getIntegrationWriter("integration.unittestmulti"); loader = new XmlDataLoader(iw); binding = new XmlBinding(writer.getModel()); toDelete = new ArrayList(); }
public static Collection setUpData() throws Exception { XmlBinding binding = new XmlBinding(model); return (List) binding.unmarshal(SetupDataTestCase.class.getClassLoader().getResourceAsStream(alternateDataFile == null ? "testmodel_data.xml" : alternateDataFile)); }
long startTime = time; LOG.info("Starting XmlDataLoader. Loading XML file."); XmlBinding binding = new XmlBinding(getIntegrationWriter().getObjectStore().getModel()); List<FastPathObject> objects = binding.unmarshal(is); LOG.info("Loaded XML file to list of " + objects.size() + " objects");
long startTime = time; LOG.info("Starting XmlDataLoader. Loading XML file."); XmlBinding binding = new XmlBinding(getIntegrationWriter().getObjectStore().getModel()); List<FastPathObject> objects = binding.unmarshal(is); LOG.info("Loaded XML file to list of " + objects.size() + " objects");