View Javadoc

1   /*
2    * $Id: ConfigurationTestCase.java 19441 2010-09-08 12:34:34Z esteban.robles $
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.cxf;
12  
13  import java.util.Iterator;
14  import java.util.List;
15  
16  import org.apache.cxf.Bus;
17  import org.apache.cxf.interceptor.Interceptor;
18  import org.apache.cxf.interceptor.LoggingInInterceptor;
19  import org.mule.api.endpoint.InboundEndpoint;
20  import org.mule.module.cxf.config.FlowConfiguringMessageProcessor;
21  import org.mule.module.cxf.config.ProxyServiceFactoryBean;
22  import org.mule.tck.FunctionalTestCase;
23  
24  public class ConfigurationTestCase extends FunctionalTestCase
25  {
26      public void testBusConfiguration() throws Exception
27      {
28          CxfConfiguration config = muleContext.getRegistry().get("cxf");
29  
30          Bus cxfBus = ((CxfConfiguration) config).getCxfBus();
31          boolean found = false;
32          for (Iterator itr2 = cxfBus.getInInterceptors().iterator(); itr2.hasNext();)
33          {
34              Interceptor i = (Interceptor) itr2.next();
35              if (i instanceof LoggingInInterceptor)
36              {
37                  found = true;
38                  break;
39              }
40          }
41  
42          assertTrue("Did not find logging interceptor.", found);
43      }
44      
45      public void testSpringRefs() throws Exception
46      {
47          InboundEndpoint endpoint = muleContext.getRegistry().get("clientEndpoint");
48          FlowConfiguringMessageProcessor processor = (FlowConfiguringMessageProcessor) endpoint.getMessageProcessors().get(0);
49          List inInterceptors = ((ProxyServiceFactoryBean) processor.getMessageProcessorBuilder()).getInInterceptors();
50          assertEquals(muleContext.getRegistry().get("foo1"), inInterceptors.get(0));
51          assertEquals(muleContext.getRegistry().get("foo3"), inInterceptors.get(1));
52      }
53  
54      protected String getConfigResources()
55      {
56          return "configuration-conf.xml";
57      }
58  
59  }