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.test.integration.config;
8   
9   import static org.junit.Assert.assertTrue;
10  import org.mule.api.MuleContext;
11  import org.mule.api.client.LocalMuleClient;
12  import org.mule.api.endpoint.EndpointURI;
13  import org.mule.api.endpoint.MalformedEndpointException;
14  import org.mule.endpoint.UrlEndpointURIBuilder;
15  import org.mule.tck.junit4.FunctionalTestCase;
16  
17  import java.net.URI;
18  
19  import org.junit.Test;
20  
21  public class EndpointUriBuilderOverrideTestCase extends FunctionalTestCase
22  {
23      private static boolean invokedOverriddenUriBuilder;
24  
25      @Override
26      protected String getConfigResources()
27      {
28          return "org/mule/test/integration/config/endpoint-uri-builder-service-override-config.xml";
29      }
30  
31      @Test
32      public void usesServiceOverrideInEndpoint() throws Exception
33      {
34          LocalMuleClient client = muleContext.getClient();
35  
36          client.send("vm://testIn", TEST_MESSAGE, null);
37  
38          assertTrue("Connector service overrides were not applied to endpoint", invokedOverriddenUriBuilder);
39      }
40  
41      public static class TestUriBuilder extends UrlEndpointURIBuilder
42      {
43  
44          @Override
45          public EndpointURI build(URI uri, MuleContext muleContext) throws MalformedEndpointException
46          {
47  
48              EndpointURI build = super.build(uri, muleContext);
49              invokedOverriddenUriBuilder = true;
50              return build;
51          }
52      }
53  }