View Javadoc

1   /*
2    * $Id: GlobalPropertiesMule2458TestCase.java 22518 2011-07-22 07:00:22Z claude.mamo $
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 static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  
16  import org.mule.api.endpoint.ImmutableEndpoint;
17  import org.mule.api.service.Service;
18  import org.mule.construct.Flow;
19  import org.mule.service.ServiceCompositeMessageSource;
20  import org.mule.tck.AbstractServiceAndFlowTestCase;
21  
22  import java.util.Arrays;
23  import java.util.Collection;
24  
25  import org.junit.Test;
26  import org.junit.runners.Parameterized.Parameters;
27  
28  public class GlobalPropertiesMule2458TestCase extends AbstractServiceAndFlowTestCase
29  {
30      public GlobalPropertiesMule2458TestCase(ConfigVariant variant, String configResources)
31      {
32          super(variant, configResources);
33      }
34  
35      @Parameters
36      public static Collection<Object[]> parameters()
37      {
38          return Arrays.asList(new Object[][]{
39              {ConfigVariant.SERVICE, "org/mule/test/spring/global-properties-mule-2458-test-service.xml"},
40              {ConfigVariant.FLOW, "org/mule/test/spring/global-properties-mule-2458-test-flow.xml"}
41          });
42      }      
43      
44      @Test
45      public void testProperties()
46      {
47          Object service = muleContext.getRegistry().lookupObject("service");
48          assertNotNull(service);
49          ImmutableEndpoint ep; 
50          if (variant.equals(ConfigVariant.FLOW))
51          {
52              ep = (ImmutableEndpoint) ((Flow) service).getMessageSource();
53          }
54          else
55          {
56              ep = ((ServiceCompositeMessageSource) ((Service) service).getMessageSource()).getEndpoints().get(0);    
57          }
58          
59          
60          assertNotNull(ep);
61          assertEquals("local", ep.getProperties().get("local"));
62          assertEquals("global", ep.getProperties().get("global"));
63          assertEquals("local", ep.getProperties().get("override-me"));
64          assertEquals(3, ep.getProperties().size());
65      }
66  }