KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > thoughtworks > xstream > mapper > FieldAliasingMapperTest


1 package com.thoughtworks.xstream.mapper;
2
3 import com.thoughtworks.acceptance.AbstractAcceptanceTest;
4 import com.thoughtworks.acceptance.objects.Software;
5 import com.thoughtworks.xstream.XStream;
6
7 public class FieldAliasingMapperTest extends AbstractAcceptanceTest {
8
9     public void testAllowsIndividualFieldsToBeAliased() {
10         Software in = new Software("ms", "word");
11         xstream.alias("software", Software.class);
12         xstream.aliasField("CUSTOM-VENDOR", Software.class, "vendor");
13         xstream.aliasField("CUSTOM-NAME", Software.class, "name");
14
15         String JavaDoc expectedXml = "" +
16                 "<software>\n" +
17                 " <CUSTOM-VENDOR>ms</CUSTOM-VENDOR>\n" +
18                 " <CUSTOM-NAME>word</CUSTOM-NAME>\n" +
19                 "</software>";
20
21         assertBothWays(in, expectedXml);
22     }
23 }
24
Popular Tags