private DataHolder createDataHolder(Content content) { DataHolder dataHolder = xstream.newDataHolder(); dataHolder.put("content", content); return dataHolder; }
/** * Read results from JTL file. * * @param reader of the file * @param resultCollectorHelper helper class to enable TestResultWrapperConverter to deliver the samples * @throws IOException if an I/O error occurs */ public static void loadTestResults(InputStream reader, ResultCollectorHelper resultCollectorHelper) throws IOException { // Get the InputReader to use InputStreamReader inputStreamReader = getInputStreamReader(reader); DataHolder dh = JTLSAVER.newDataHolder(); dh.put(RESULTCOLLECTOR_HELPER_OBJECT, resultCollectorHelper); // Allow TestResultWrapper to feed back the samples // This is effectively the same as saver.fromXML(InputStream) except we get to provide the DataHolder // Don't know why there is no method for this in the XStream class JTLSAVER.unmarshal(new XppDriver().createReader(reader), null, dh); inputStreamReader.close(); }
/** * Save a sampleResult to an XML output file using XStream. * * @param evt sampleResult wrapped in a sampleEvent * @param writer output stream which must be created using {@link #getFileEncoding(String)} * @throws IOException when writing data to output fails */ // Used by ResultCollector.sampleOccurred(SampleEvent event) public synchronized static void saveSampleResult(SampleEvent evt, Writer writer) throws IOException { DataHolder dh = JTLSAVER.newDataHolder(); dh.put(SAMPLE_EVENT_OBJECT, evt); // This is effectively the same as saver.toXML(Object, Writer) except we get to provide the DataHolder // Don't know why there is no method for this in the XStream class try { JTLSAVER.marshal(evt.getResult(), new XppDriver().createWriter(writer), dh); } catch(RuntimeException e) { throw new IllegalArgumentException("Failed marshalling:"+(evt.getResult() != null ? showDebuggingInfo(evt.getResult()) : "null"), e); } writer.write('\n'); }