1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.json.transformers;
12
13 import org.mule.tck.junit4.AbstractMuleContextTestCase;
14
15 import org.junit.Test;
16
17 import static org.junit.Assert.assertEquals;
18 import static org.junit.Assert.assertNotNull;
19
20
21 public class JsonStringTestCase extends AbstractMuleContextTestCase
22 {
23 public static final String TEST_JSON_MESSAGE = "{\"data\" : {\"value1\" : \"foo\", \"value2\" : \"bar\"}, \"replyTo\" : \"/response\"}";
24
25
26
27
28 @Test
29 public void testTryConvertJsonStringToJsonString() throws Exception
30 {
31 ObjectToJson transformer = createObject(ObjectToJson.class);
32 Object result = transformer.transform(TEST_JSON_MESSAGE);
33 assertNotNull(result);
34 assertEquals(TEST_JSON_MESSAGE, result);
35 }
36
37
38 @Test
39 public void testTryConvertJsonStringToJustString() throws Exception
40 {
41 ObjectToJson transformer = createObject(ObjectToJson.class);
42
43 assertEquals("\"Hello\"", transformer.transform("Hello"));
44 }
45 }