View Javadoc

1   /*
2    * $Id: JsonStringTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.module.json.transformers;
12  
13  import org.mule.tck.AbstractMuleTestCase;
14  
15  
16  public class JsonStringTestCase extends AbstractMuleTestCase
17  {
18      public static final String TEST_JSON_MESSAGE = "{\"data\" : {\"value1\" : \"foo\", \"value2\" : \"bar\"}, \"replyTo\" : \"/response\"}";
19  
20      /**
21       * Test that a Json string doesn't get modified in any way
22       */
23      public void testTryConvertJsonStringToJsonString() throws Exception
24      {
25          ObjectToJson transformer = createObject(ObjectToJson.class);
26          Object result = transformer.transform(TEST_JSON_MESSAGE);
27          assertNotNull(result);
28          assertEquals(TEST_JSON_MESSAGE, result);
29      }
30  
31  
32      public void testTryConvertJsonStringToJustString() throws Exception
33      {
34          ObjectToJson transformer = createObject(ObjectToJson.class);
35          //This is still valid json
36          assertEquals("\"Hello\"", transformer.transform("Hello"));
37      }
38  }