View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.cxf;
8   
9   import org.mule.api.endpoint.InboundEndpoint;
10  import org.mule.module.cxf.config.FlowConfiguringMessageProcessor;
11  import org.mule.module.cxf.config.ProxyServiceFactoryBean;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import java.util.Iterator;
15  import java.util.List;
16  
17  import org.apache.cxf.Bus;
18  import org.apache.cxf.interceptor.Interceptor;
19  import org.apache.cxf.interceptor.LoggingInInterceptor;
20  import org.junit.Test;
21  
22  import static org.junit.Assert.assertEquals;
23  import static org.junit.Assert.assertTrue;
24  
25  public class ConfigurationTestCase extends FunctionalTestCase
26  {
27      @Override
28      protected String getConfigResources()
29      {
30          return "configuration-conf.xml";
31      }
32  
33      @Test
34      public void testBusConfiguration() throws Exception
35      {
36          CxfConfiguration config = muleContext.getRegistry().get("cxf");
37  
38          Bus cxfBus = ((CxfConfiguration) config).getCxfBus();
39          boolean found = false;
40          for (Iterator itr2 = cxfBus.getInInterceptors().iterator(); itr2.hasNext();)
41          {
42              Interceptor i = (Interceptor) itr2.next();
43              if (i instanceof LoggingInInterceptor)
44              {
45                  found = true;
46                  break;
47              }
48          }
49  
50          assertTrue("Did not find logging interceptor.", found);
51      }
52  
53      @Test
54      public void testSpringRefs() throws Exception
55      {
56          InboundEndpoint endpoint = muleContext.getRegistry().get("clientEndpoint");
57          FlowConfiguringMessageProcessor processor = (FlowConfiguringMessageProcessor) endpoint.getMessageProcessors().get(0);
58          List inInterceptors = ((ProxyServiceFactoryBean) processor.getMessageProcessorBuilder()).getInInterceptors();
59          assertEquals(muleContext.getRegistry().get("foo1"), inInterceptors.get(0));
60          assertEquals(muleContext.getRegistry().get("foo3"), inInterceptors.get(1));
61      }
62  
63  }