1
2
3
4
5
6
7
8
9
10
11 package org.mule.transformers.xml.wire;
12
13 import org.mule.api.MuleMessage;
14 import org.mule.api.transformer.wire.WireFormat;
15 import org.mule.module.xml.transformer.ObjectToXml;
16 import org.mule.module.xml.transformer.XmlToObject;
17 import org.mule.module.xml.transformer.wire.XStreamWireFormat;
18 import org.mule.tck.testmodels.fruit.Orange;
19 import org.mule.transformer.wire.AbstractMuleMessageWireFormatTestCase;
20
21 import java.util.Properties;
22
23 public class XStreamWireFormatTestCase extends AbstractMuleMessageWireFormatTestCase
24 {
25
26 protected WireFormat getWireFormat() throws IllegalAccessException, InstantiationException, ClassNotFoundException
27 {
28 return new XStreamWireFormat();
29 }
30
31 public void testGetDefaultInboundTransformer()
32 throws IllegalAccessException, InstantiationException, ClassNotFoundException
33 {
34 assertEquals(XmlToObject.class, ((XStreamWireFormat) getWireFormat()).getInboundTransformer().getClass());
35
36 }
37
38 public void testGetDefaultOutboundTransformer()
39 throws IllegalAccessException, InstantiationException, ClassNotFoundException
40 {
41 assertEquals(ObjectToXml.class, ((XStreamWireFormat) getWireFormat()).getOutboundTransformer().getClass());
42 }
43
44 public void testWriteReadPayload() throws Exception
45 {
46
47 Properties messageProerties = new Properties();
48 messageProerties.put("key1", "val1");
49 Orange inOrange = new Orange();
50 inOrange.setBrand("Walmart");
51 inOrange.setMapProperties(messageProerties);
52
53 Object outObject = readWrite(inOrange);
54
55
56
57
58
59 assertTrue(outObject instanceof MuleMessage);
60 assertEquals("Walmart", ((Orange) ((MuleMessage) outObject).getPayload()).getBrand());
61 assertEquals("val1", ((Orange) ((MuleMessage) outObject).getPayload()).getMapProperties().get("key1"));
62 }
63
64 }