View Javadoc

1   /*
2    * $Id: SxcFilterTestCase.java 12264 2008-07-09 22:24:04Z dandiep $
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.sxc;
12  
13  import org.mule.api.MuleMessage;
14  import org.mule.module.client.MuleClient;
15  import org.mule.tck.FunctionalTestCase;
16  
17  import java.io.ByteArrayOutputStream;
18  
19  import org.apache.commons.io.IOUtils;
20  
21  public class HttpRoutingTestCase extends FunctionalTestCase
22  {
23      int finished = 0;
24  
25      public void testBasicXPath() throws Exception
26      {
27          final MuleClient client = new MuleClient(muleContext);
28  
29          ByteArrayOutputStream out = new ByteArrayOutputStream();
30          IOUtils.copy(getClass().getResourceAsStream("/purchase-order.xml"), out);
31  
32          MuleMessage res = client.send("http://localhost:63081/proxy", out.toByteArray(), null);
33          System.out.println(res.getPayloadAsString());
34          assertTrue(res.getPayloadAsString().contains("purchaseOrder"));
35          assertTrue(res.getPayloadAsString().contains("Alice"));
36          
37          out = new ByteArrayOutputStream();
38          IOUtils.copy(getClass().getResourceAsStream("/namespace-purchase-order.xml"), out);
39          
40          res = client.send("http://localhost:63081/proxy", out.toByteArray(), null);
41          System.out.println(res.getPayloadAsString());
42          assertTrue(res.getPayloadAsString().contains("purchaseOrder"));
43          assertTrue(res.getPayloadAsString().contains("Alice"));
44      }
45  
46      @Override
47      protected String getConfigResources()
48      {
49          return "http-routing-conf.xml";
50      }
51  
52  }