mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-07 23:49:08 +00:00
SPR-5838 - XstreamMarshaller does not support field aliasing
git-svn-id: https://src.springframework.org/svn/spring-framework/trunk@1404 50f2f4bb-b051-0410-bef5-90022cba6387
This commit is contained in:
+10
-2
@@ -68,8 +68,8 @@ public class XStreamMarshallerTests {
|
||||
@Before
|
||||
public void createMarshaller() throws Exception {
|
||||
marshaller = new XStreamMarshaller();
|
||||
Map<String, Class> aliases = new HashMap<String, Class>();
|
||||
aliases.put("flight", Flight.class);
|
||||
Map<String, String> aliases = new HashMap<String, String>();
|
||||
aliases.put("flight", Flight.class.getName());
|
||||
marshaller.setAliases(aliases);
|
||||
flight = new Flight();
|
||||
flight.setFlightNumber(42L);
|
||||
@@ -214,6 +214,14 @@ public class XStreamMarshallerTests {
|
||||
assertXMLEqual("Marshaller does not use attributes", expected, writer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fieldAliases() throws Exception {
|
||||
marshaller.setFieldAliases(Collections.singletonMap("org.springframework.oxm.xstream.Flight.flightNumber", "flightNo"));
|
||||
Writer writer = new StringWriter();
|
||||
marshaller.marshal(flight, new StreamResult(writer));
|
||||
String expected = "<flight><flightNo>42</flightNo></flight>";
|
||||
assertXMLEqual("Marshaller does not use aliases", expected, writer.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
|
||||
Reference in New Issue
Block a user