Package com.thoughtworks.xstream

Examples of com.thoughtworks.xstream.XStream.toXML()


    log.debug("Session size: " + serialized.length);
   
    if (testXmlSessionPath != null) {
      XStream xstream = new XStream(new DomDriver());
      PrintWriter writer = new PrintWriter(new FileWriter(testXmlSessionPath + "/" + sess.getId() + ".xml"));
      xstream.toXML(child, writer);
      writer.close();
    }
  }
}
View Full Code Here


        return ids;
    }

    private String serialize(Object task) {
        XStream xStream = new XStream();
        return xStream.toXML(task);
    }

    private Object deserialize(String serializedRunnable) {
        XStream xStream = new XStream();
        return xStream.fromXML(serializedRunnable);
View Full Code Here

        String result = null;

        XStream xstream = new XStream();
        xstream.registerConverter(new GuardedStringConverter());
        try {
            result = URLEncoder.encode(xstream.toXML(object), SyncopeConstants.DEFAULT_ENCODING);
        } catch (UnsupportedEncodingException e) {
            LOG.error("During serialization", e);
        }

        return result;
View Full Code Here

      XStream xstream = new XStream();
      xstream.alias("page", Page.class);
      xstream.useAttributeFor(Page.class, "xmlns");
            xstream.aliasField("xmlns", Page.class, "xmlns");
            xstream.ignoreUnknownElements();
      String xml = xstream.toXML(page);
      return xml;
    default:
      return resource.getContent();
    }
  }
View Full Code Here

        XStream xs = new XStream();

        ScenarioType scenarioType = ScenarioType.NORMAL;
        List<Step> subset = foo.collectBeforeOrAfterScenarioSteps(steps, null, Stage.BEFORE, scenarioType);
        String subsetAsXML = xs.toXML(subset);
        assertThat(subsetAsXML.indexOf("<name>a</name>"), greaterThan(-1)); // there
        assertThat(subsetAsXML.indexOf("<name>b</name>"), equalTo(-1)); // not there
        assertThat(subsetAsXML.indexOf("<name>c</name>"), greaterThan(-1)); // there
        assertThat(subsetAsXML.indexOf("<name>d</name>"), equalTo(-1)); // not there
        assertThat(subsetAsXML.indexOf("<name>a</name>"), lessThan(subsetAsXML.indexOf("<name>c</name>"))); // there
View Full Code Here

        assertThat(subsetAsXML.indexOf("<name>a</name>"), lessThan(subsetAsXML.indexOf("<name>c</name>"))); // there

        assertThat(stepsAsString, equalTo(steps.toString())); // steps have not been mutated.

        subset = foo.collectBeforeOrAfterScenarioSteps(steps, null, Stage.AFTER, scenarioType);
        subsetAsXML = xs.toXML(subset);
        assertThat(subsetAsXML.indexOf("<name>a</name>"), equalTo(-1)); // not there
        assertThat(subsetAsXML.indexOf("<name>b</name>"), greaterThan(-1)); // there
        assertThat(subsetAsXML.indexOf("<name>c</name>"), equalTo(-1)); // not there
        assertThat(subsetAsXML.indexOf("<name>d</name>"), greaterThan(-1)); // there
        assertThat(subsetAsXML.indexOf("<name>d</name>"), lessThan(subsetAsXML.indexOf("<name>b</name>"))); // reverse order
View Full Code Here

    assertEqualsNullComparisonReturnsFalse(serializableFactory);
  }

  public void testGetOriginalValueWithArgumentBeingObjectWrapper() {
  XStream xstream = new XStream();
  ObjectWrapper wrapper = new ObjectWrapper(xstream.toXML(puppy));
    assertEquals(puppy, serializableFactory.getOriginalValue(wrapper));
  }

  public void testGetOriginalValueWithArgumentEqualToNull() {
    assertNull(serializableFactory.getOriginalValue(null));
View Full Code Here

  }

  public void testMakeSerializableIfNecessaryWithNotSerializableArgument()
      throws Exception {
    XStream xstream = new XStream();
    ObjectWrapper expected = new ObjectWrapper(xstream.toXML(puppy));

    Object actual = serializableFactory.makeSerializableIfNecessary(puppy);

    assertEquals(expected, actual);
    SerializationAssert.assertIsSerializable(actual);
View Full Code Here

        XStream xstream = new XStream(new DomDriver());
        xstream.registerConverter(ROLEMAPCONVERTER);
        xstream.registerConverter(ROLECONVERTER);
        xstream.registerConverter(DICTCONVERTER);
        xstream.aliasType("roles", Map.class);
        xstream.toXML(m_roles, out);
        try {
            out.close();
        }
        catch (IOException e) {
            m_log.log(LogService.LOG_ERROR, "Error closing XStream output stream.", e);
View Full Code Here

        return configurationData;
    }

    public void writeConfigurationData(ConfigurationData configurationData, OutputStream out) throws IOException {
        XStream xstream = XStreamUtil.createXStream();
        String xml = xstream.toXML(configurationData);

        out.write(("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                "\n" +
                "<!-- ======================================================== -->\n" +
                "<!-- Warning - Modification of this file may cause server     -->\n" +
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.