View Javadoc

1   /*
2    * $Id: FeaturesTestCase.java 22401 2011-07-13 09:10:18Z dirk.olmes $
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 org.mule.api.endpoint.ImmutableEndpoint;
14  import org.mule.api.processor.MessageProcessor;
15  import org.mule.module.cxf.builder.WebServiceMessageProcessorBuilder;
16  import org.mule.module.cxf.config.FlowConfiguringMessageProcessor;
17  import org.mule.tck.junit4.FunctionalTestCase;
18  
19  import java.util.List;
20  
21  import org.apache.cxf.feature.AbstractFeature;
22  import org.apache.cxf.feature.LoggingFeature;
23  import org.junit.Test;
24  
25  import static org.junit.Assert.assertNotNull;
26  import static org.junit.Assert.assertTrue;
27  
28  public class FeaturesTestCase extends FunctionalTestCase
29  {
30  
31      @Override
32      protected String getConfigResources()
33      {
34          return "features-test.xml";
35      }
36  
37      @Test
38      public void testFeatures() throws Exception
39      {
40          ImmutableEndpoint endpoint = muleContext.getRegistry().lookupEndpointBuilder("endpoint").buildInboundEndpoint();
41          assertNotNull(endpoint);
42          
43          List<MessageProcessor> mps = endpoint.getMessageProcessors();
44          assertTrue(mps.get(0) instanceof FlowConfiguringMessageProcessor);
45          
46          FlowConfiguringMessageProcessor mp = (FlowConfiguringMessageProcessor) mps.get(0);
47          WebServiceMessageProcessorBuilder builder = (WebServiceMessageProcessorBuilder) mp.getMessageProcessorBuilder();
48          
49          List<AbstractFeature> features = builder.getFeatures();
50          assertNotNull(features);
51          boolean found = false;
52          for (AbstractFeature f : features) 
53          {
54              if (f instanceof LoggingFeature)
55              {
56                  found = true;
57                  break;
58              }
59          }
60          assertTrue(found);
61      }
62  
63  }