View Javadoc

1   /*
2    * $Id: XmlOutboundNamespaceHandlerTestCase.java 20321 2010-11-24 15:21:24Z dfeist $
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.config;
12  
13  import org.mule.api.routing.OutboundRouterCollection;
14  import org.mule.api.service.Service;
15  import org.mule.module.xml.routing.XmlMessageSplitter;
16  import org.mule.routing.CorrelationMode;
17  import org.mule.tck.FunctionalTestCase;
18  
19  import java.util.List;
20  import java.util.Map;
21  
22  public class XmlOutboundNamespaceHandlerTestCase extends FunctionalTestCase
23  {
24      protected String getConfigResources()
25      {
26          return "org/mule/module/xml/xml-outbound-namespace-test.xml";
27      }
28  
29      public void testMessageSplitter()
30      {
31          XmlMessageSplitter splitter =
32                  (XmlMessageSplitter) getRouter("fancy config splitter", XmlMessageSplitter.class);
33  
34          assertEquals(CorrelationMode.ALWAYS, splitter.getEnableCorrelation());
35          assertEquals("external", splitter.getExternalSchemaLocation());
36          assertEquals("/expression", splitter.getSplitExpression());
37          assertTrue(splitter.isDeterministic());
38          assertTrue(splitter.isValidateSchema());
39          Map namespaces = splitter.getNamespaces();
40          assertEquals(1, namespaces.size());
41          assertEquals("foo", namespaces.get("bar"));
42      }
43  
44  
45      protected Object getRouter(String name, Class clazz)
46      {
47          Service service = muleContext.getRegistry().lookupService(name);
48          List routers = ((OutboundRouterCollection) service.getOutboundMessageProcessor()).getRoutes();
49          assertEquals(1, routers.size());
50          assertTrue(routers.get(0).getClass().getName(), clazz.isAssignableFrom(routers.get(0).getClass()));
51          return routers.get(0);
52      }
53  
54  }