View Javadoc

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