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.functional;
8   
9   import org.mule.api.endpoint.InboundEndpoint;
10  import org.mule.api.processor.MessageProcessor;
11  import org.mule.api.service.Service;
12  import org.mule.endpoint.DefaultInboundEndpoint;
13  import org.mule.module.cxf.CxfInboundMessageProcessor;
14  import org.mule.module.cxf.config.FlowConfiguringMessageProcessor;
15  import org.mule.service.ServiceCompositeMessageSource;
16  import org.mule.tck.junit4.FunctionalTestCase;
17  import org.mule.tck.junit4.rule.DynamicPort;
18  
19  import java.util.List;
20  
21  import org.apache.cxf.endpoint.Server;
22  import org.apache.cxf.service.model.EndpointInfo;
23  import org.junit.Rule;
24  import org.junit.Test;
25  
26  import static org.junit.Assert.assertEquals;
27  
28  public class EndpointBindsToCorrectWdslPortTestCase extends FunctionalTestCase
29  {
30  
31      @Rule
32      public DynamicPort dynamicPort = new DynamicPort("port1");
33  
34      @Override
35      protected String getConfigResources()
36      {
37          return "org/mule/module/cxf/functional/endpoint-binds-to-correct-wdsl-port.xml";
38      }
39  
40      @Test
41      public void testThatTheCorrectSoapPortIsChosen() throws Exception
42      {
43          final Service service = muleContext.getRegistry().lookupService("CXFProxyService");
44          ServiceCompositeMessageSource messageSource = (ServiceCompositeMessageSource) service.getMessageSource();
45  
46          List<InboundEndpoint> endpoints = messageSource.getEndpoints();
47          DefaultInboundEndpoint inboundEndpoint = (DefaultInboundEndpoint) endpoints.get(0);
48          List<MessageProcessor> processors = inboundEndpoint.getMessageProcessors();
49          FlowConfiguringMessageProcessor wrapper = (FlowConfiguringMessageProcessor) processors.get(0);
50          CxfInboundMessageProcessor cxfProcessor = (CxfInboundMessageProcessor) wrapper.getWrappedMessageProcessor();
51          Server server = cxfProcessor.getServer();
52          EndpointInfo endpointInfo = server.getEndpoint().getEndpointInfo();
53  
54          assertEquals(
55              "The local part of the endpoing name must be the one supplied as the endpointName parameter on the cxf:inbound-endpoint",
56              "ListsSoap", endpointInfo.getName().getLocalPart());
57      }
58  
59  }