View Javadoc

1   /*
2    * $Id: XPathNodeExpressionEvaluatorTestCase.java 22419 2011-07-15 03:41:06Z dirk.olmes $
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.xml.functional;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.AbstractServiceAndFlowTestCase;
16  
17  import java.util.Arrays;
18  import java.util.Collection;
19  
20  import org.custommonkey.xmlunit.XMLAssert;
21  import org.junit.Test;
22  import org.junit.runners.Parameterized.Parameters;
23  
24  public class XPathNodeExpressionEvaluatorTestCase extends AbstractServiceAndFlowTestCase
25  {
26      private static final String SAMPLE_REQUEST =
27              "<root>" +
28              "<table>" +
29              "<name>African Coffee Table</name>" +
30              "<width>80</width>" +
31              "<length>120</length>" +
32              "</table>" +
33              "</root>";
34  
35      private static final String EXPECTED_RESPONSE =
36              "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
37              "<name>African Coffee Table</name>";
38  
39      @Parameters
40      public static Collection<Object[]> parameters()
41      {
42          return Arrays.asList(new Object[][]{
43              {ConfigVariant.SERVICE, "org/mule/module/xml/xpath-node-config-service.xml"},
44              {ConfigVariant.FLOW, "org/mule/module/xml/xpath-node-config-flow.xml"}
45          });
46      }
47  
48      public XPathNodeExpressionEvaluatorTestCase(ConfigVariant variant, String configResources)
49      {
50          super(variant, configResources);
51      }
52  
53      @Test
54      public void testExpressionTransformerUsingXpathNode() throws Exception
55      {
56          MuleClient client = new MuleClient(muleContext);
57  
58          MuleMessage message = client.send("vm://testInput", SAMPLE_REQUEST, null);
59  
60          XMLAssert.assertXMLEqual(EXPECTED_RESPONSE, message.getPayloadAsString());
61      }
62  }