View Javadoc

1   /*
2    * $Id: W3CDocumentXPathNodeEvaluatorTestCase.java 22421 2011-07-15 05:05:06Z dirk.olmes $
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  
11  package org.mule.module.xml.functional;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.client.MuleClient;
16  import org.mule.tck.AbstractServiceAndFlowTestCase;
17  
18  import java.util.Arrays;
19  import java.util.Collection;
20  
21  import org.junit.Test;
22  import org.junit.runners.Parameterized.Parameters;
23  import org.w3c.dom.Node;
24  
25  import static org.junit.Assert.assertNotNull;
26  import static org.junit.Assert.assertTrue;
27  
28  public class W3CDocumentXPathNodeEvaluatorTestCase extends AbstractServiceAndFlowTestCase
29  {
30      private static final String XML_INPUT =
31          "<root>" +
32          "  <table>" +
33          "    <name>African Coffee Table</name>" +
34          "    <width>80</width>" +
35          "    <length>120</length>" +
36          "  </table>" +
37          "</root>";
38  
39      @Parameters
40      public static Collection<Object[]> parameters()
41      {
42          return Arrays.asList(new Object[][]{
43              {ConfigVariant.SERVICE, "org/mule/module/xml/w3c-dom-xpath-node-config-service.xml"},
44              {ConfigVariant.FLOW, "org/mule/module/xml/w3c-dom-xpath-node-config-flow.xml"}
45          });
46      }
47  
48      public W3CDocumentXPathNodeEvaluatorTestCase(ConfigVariant variant, String configResources)
49      {
50          super(variant, configResources);
51      }
52  
53      @Test
54      public void testW3CDocument() throws Exception
55      {
56          MuleClient client = muleContext.getClient();
57  
58          MuleMessage message = new DefaultMuleMessage(XML_INPUT, muleContext);
59          MuleMessage response = client.send("vm://test", message);
60          assertNotNull(response);
61          assertNotNull(response.getPayload());
62          assertTrue(response.getPayload() instanceof Node);
63      }
64  }