XmlSerializer { public T fromString(String xml) { return deserialize(new StringReader(xml)); } XmlSerializer();  XmlSerializer(Map<String, String> deserializingClassRenames);  XmlSerializer(ClassLoader loader, Map<String, String> deserializingClassRenames); void serialize(Object object, Writer writer); @SuppressWarnings("unchecked") T deserialize(Reader xml); String toString(T memento); T fromString(String xml);  }
@Test public void testObjectFieldDeserializingStringWhenNoClassSpecified() throws Exception { String tag = "org.apache.brooklyn.util.core.xstream.XmlSerializerTest_-ObjectHolder"; String xml = "<"+tag+"><val>myval</val></"+tag+">"; Object result = serializer.fromString(xml); assertEquals(((ObjectHolder)result).val, "myval"); }
@Test public void testIntFieldDeserializingStringWhenNoClassSpecified() throws Exception { String tag = "org.apache.brooklyn.util.core.xstream.XmlSerializerTest_-IntHolder"; String xml = "<"+tag+"><val>123</val></"+tag+">"; Object result = serializer.fromString(xml); assertEquals(((IntHolder)result).val, 123); }
@Test public void testIntegerFieldDeserializingStringWhenNoClassSpecified() throws Exception { String tag = "org.apache.brooklyn.util.core.xstream.XmlSerializerTest_-IntegerHolder"; String xml = "<"+tag+"><val>123</val></"+tag+">"; Object result = serializer.fromString(xml); assertEquals(((IntegerHolder)result).val, Integer.valueOf(123)); }