View Javadoc

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