View Javadoc

1   /*
2    * $Id: ConfigurationTestCase.java 22552 2011-07-25 07:18:19Z claude.mamo $
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 static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertTrue;
15  
16  import org.mule.api.endpoint.InboundEndpoint;
17  import org.mule.module.cxf.config.FlowConfiguringMessageProcessor;
18  import org.mule.module.cxf.config.ProxyServiceFactoryBean;
19  import org.mule.tck.AbstractServiceAndFlowTestCase;
20  
21  import java.util.Arrays;
22  import java.util.Collection;
23  import java.util.List;
24  
25  import org.apache.cxf.Bus;
26  import org.apache.cxf.interceptor.Interceptor;
27  import org.apache.cxf.interceptor.LoggingInInterceptor;
28  import org.apache.cxf.message.Message;
29  import org.junit.Test;
30  import org.junit.runners.Parameterized.Parameters;
31  
32  public class ConfigurationTestCase extends AbstractServiceAndFlowTestCase
33  {
34      public ConfigurationTestCase(ConfigVariant variant, String configResources)
35      {
36          super(variant, configResources);
37      }
38  
39      @Parameters
40      public static Collection<Object[]> parameters()
41      {
42          return Arrays.asList(new Object[][]{
43              {ConfigVariant.SERVICE, "configuration-conf-service.xml"},
44              {ConfigVariant.FLOW, "configuration-conf-flow.xml"}
45          });
46      }      
47      
48      @Test
49      public void testBusConfiguration() throws Exception
50      {
51          CxfConfiguration config = muleContext.getRegistry().get("cxf");
52  
53          Bus cxfBus = config.getCxfBus();
54          boolean found = false;
55          for (Interceptor<? extends Message> i : cxfBus.getInInterceptors())
56          {
57              if (i instanceof LoggingInInterceptor)
58              {
59                  found = true;
60                  break;
61              }
62          }
63  
64          assertTrue("Did not find logging interceptor.", found);
65      }
66  
67      @Test
68      public void testSpringRefs() throws Exception
69      {
70          InboundEndpoint endpoint = muleContext.getRegistry().get("clientEndpoint");
71          FlowConfiguringMessageProcessor processor = (FlowConfiguringMessageProcessor) endpoint.getMessageProcessors().get(0);
72          List<Interceptor<? extends Message>> inInterceptors =
73              ((ProxyServiceFactoryBean) processor.getMessageProcessorBuilder()).getInInterceptors();
74          assertEquals(muleContext.getRegistry().get("foo1"), inInterceptors.get(0));
75          assertEquals(muleContext.getRegistry().get("foo3"), inInterceptors.get(1));
76      }
77  }