1   /*
2    * $Id: XSLTWikiDocsTestCase.java 11757 2008-05-14 19:50:54Z rossmason $
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  package org.mule.test.integration.xml;
11  
12  import org.mule.tck.FunctionalTestCase;
13  import org.mule.util.IOUtils;
14  import org.mule.module.client.MuleClient;
15  import org.mule.api.MuleMessage;
16  
17  import java.util.Map;
18  import java.util.HashMap;
19  
20  import org.custommonkey.xmlunit.XMLUnit;
21  
22  //START SNIPPET: test-code
23  public class XSLTWikiDocsTestCase extends FunctionalTestCase
24  {
25      protected String getConfigResources()
26      {
27          return "org/mule/test/integration/xml/xslt-functional-test.xml";
28      }
29  
30      public void testMessageTransform() throws Exception
31          {
32              //We're using Xml Unit to compare results
33              //Ignore whitespace and comments
34              XMLUnit.setIgnoreWhitespace(true);
35              XMLUnit.setIgnoreComments(true);
36  
37              //Read in src and result data
38              String srcData = IOUtils.getResourceAsString(
39                      "org/mule/test/integration/xml/cd-catalog.xml", getClass());
40              String resultData = IOUtils.getResourceAsString(
41                      "org/mule/test/integration/xml/cd-catalog-result-with-params.xml", getClass());
42  
43              //Create a new Mule Client
44              MuleClient client = new MuleClient();
45  
46              //These are the message roperties that will get passed into the XQuery context
47              Map props = new HashMap();
48              props.put("ListTitle", "MyList");
49              props.put("ListRating", new Integer(6));
50  
51              //Invoke the service
52              MuleMessage message = client.send("vm://test.in", srcData, props);
53              assertNotNull(message);
54              assertNull(message.getExceptionPayload());
55              //Compare results
56              assertTrue(XMLUnit.compareXML(message.getPayloadAsString(), resultData).similar());
57          }
58      }
59  //END SNIPPET: test-code