1   /*
2    * $Id: AbstractMuleMessageWireFormatTestCase.java 11433 2008-03-20 03:43:57Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transformer.wire;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.tck.testmodels.fruit.Orange;
16  
17  import java.util.Properties;
18  
19  public abstract class AbstractMuleMessageWireFormatTestCase extends AbstractWireFormatTestCase
20  {
21  
22      public void testWriteReadMessage() throws Exception
23      {
24          // Create message to send over wire
25          Properties messageProerties = new Properties();
26          messageProerties.put("key1", "val1");
27          MuleMessage inMessage = new DefaultMuleMessage("testMessage", messageProerties);
28  
29          Object outMessage = readWrite(inMessage);
30  
31          // Test deserialized message
32          // NOTE: As we are using SerializedMuleMessageWireFormat we get
33          // MuleMessage rather than just the payload
34  
35          assertTrue(outMessage instanceof MuleMessage);
36          assertEquals("testMessage", ((MuleMessage) outMessage).getPayload());
37          assertEquals("val1", ((MuleMessage) outMessage).getProperty("key1"));
38      }
39  
40      public void testWriteReadPayload() throws Exception
41      {
42          // Create orange to send over the wire
43          Properties messageProerties = new Properties();
44          messageProerties.put("key1", "val1");
45          Orange inOrange = new Orange();
46          inOrange.setBrand("Walmart");
47          inOrange.setMapProperties(messageProerties);
48  
49          try
50          {
51              readWrite(inOrange);
52              fail("Expected exception: MuleMessageWireFormat does not support other types");
53          }
54          catch (Exception e)
55          {
56              // Expected
57          }
58      }
59  
60  }