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.spring;
8   
9   import org.mule.api.endpoint.ImmutableEndpoint;
10  import org.mule.api.service.Service;
11  import org.mule.service.ServiceCompositeMessageSource;
12  import org.mule.tck.junit4.FunctionalTestCase;
13  
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertEquals;
17  import static org.junit.Assert.assertNotNull;
18  
19  public class InheritedPropertiesMule2458TestCase extends FunctionalTestCase
20  {
21  
22      @Override
23      protected String getConfigResources()
24      {
25          return "org/mule/test/spring/inherited-properties-mule-2458-test.xml";
26      }
27  
28      @Test
29      public void testProperties()
30      {
31          Service service = muleContext.getRegistry().lookupService("service");
32          assertNotNull(service);
33          ImmutableEndpoint endpoint = (ImmutableEndpoint) ((ServiceCompositeMessageSource) service.getMessageSource()).getEndpoints().get(0);
34          assertNotNull(endpoint);
35  
36          assertProperty(endpoint, "global-only", "global");
37          assertProperty(endpoint, "local-only", "local");
38          assertProperty(endpoint, "url-only", "url");
39  
40          assertProperty(endpoint, "global-and-local", "local");
41          assertProperty(endpoint, "global-and-url", "global");
42          assertProperty(endpoint, "local-and-url", "local");
43          
44          assertProperty(endpoint, "all", "local");
45      }
46  
47      protected void assertProperty(ImmutableEndpoint endpoint, String name, String value)
48      {
49          Object property = endpoint.getProperty(name);
50          assertNotNull("Property " + name + " is missing", property);
51          String actual = property.toString();
52          assertEquals("Unexpected value for " + name + ": " + actual + ", not " + value, value, actual);
53      }
54  
55  }