View Javadoc

1   /*
2    * $Id: JaxenFilterTestCase.java 22431 2011-07-18 07:40:35Z 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.test.integration.xml;
12  
13  import org.mule.DefaultMuleMessage;
14  import org.mule.api.MuleMessage;
15  import org.mule.module.client.MuleClient;
16  import org.mule.tck.AbstractServiceAndFlowTestCase;
17  
18  import java.io.InputStream;
19  import java.util.Arrays;
20  import java.util.Collection;
21  
22  import org.junit.Test;
23  import org.junit.runners.Parameterized.Parameters;
24  import org.w3c.dom.Document;
25  
26  import static org.junit.Assert.assertNotNull;
27  import static org.junit.Assert.assertTrue;
28  
29  public class JaxenFilterTestCase extends AbstractServiceAndFlowTestCase
30  {
31      @Parameters
32      public static Collection<Object[]> parameters()
33      {
34          return Arrays.asList(new Object[][]{
35              {ConfigVariant.SERVICE, "org/mule/test/integration/xml/jaxen-routing-conf-service.xml"},
36              {ConfigVariant.FLOW, "org/mule/test/integration/xml/jaxen-routing-conf-flow.xml"}});
37      }
38  
39      public JaxenFilterTestCase(ConfigVariant variant, String configResources)
40      {
41          super(variant, configResources);
42      }
43  
44      @Test
45      public void testJaxen() throws Exception
46      {
47          MuleClient client = new MuleClient(muleContext);
48          InputStream po = getClass().getResourceAsStream("/org/mule/test/integration/xml/purchase-order.xml");
49  
50          assertNotNull(po);
51  
52          MuleMessage msg = new DefaultMuleMessage(po, muleContext);
53          MuleMessage res = client.send("vm://in", msg);
54  
55          Object payload = res.getPayload();
56          assertTrue("payload is of type " + payload.getClass(), payload instanceof Document);
57      }
58  }