View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.xml.functional;
8   
9   import org.mule.api.MuleMessage;
10  import org.mule.module.client.MuleClient;
11  import org.mule.tck.junit4.FunctionalTestCase;
12  
13  import org.custommonkey.xmlunit.XMLAssert;
14  import org.junit.Test;
15  
16  public class XPathNodeExpressionEvaluatorTestCase extends FunctionalTestCase
17  {
18  
19      private static final String SAMPLE_REQUEST =
20              "<root>" +
21              "<table>" +
22              "<name>African Coffee Table</name>" +
23              "<width>80</width>" +
24              "<length>120</length>" +
25              "</table>" +
26              "</root>";
27  
28      private static final String EXPECTED_RESPONSE =
29              "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
30              "<name>African Coffee Table</name>";
31  
32      @Override
33      protected String getConfigResources()
34      {
35          return "org/mule/module/xml/xpath-node-config.xml";
36      }
37  
38      @Test
39      public void testExpressionTransformerUsingXpathNode() throws Exception
40      {
41          MuleClient client = new MuleClient(muleContext);
42  
43          MuleMessage message = client.send("vm://testInput", SAMPLE_REQUEST, null);
44  
45          XMLAssert.assertXMLEqual(EXPECTED_RESPONSE, message.getPayloadAsString());
46      }
47  }