View Javadoc

1   /*
2    * $Id: ServiceOverridesMule1770TestCase.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.issues;
12  
13  import org.mule.api.config.MuleProperties;
14  import org.mule.api.transformer.Transformer;
15  import org.mule.tck.FunctionalTestCase;
16  import org.mule.tck.testmodels.mule.TestMessageDispatcherFactory;
17  import org.mule.tck.transformer.NoActionTransformer;
18  import org.mule.transformer.TransformerUtils;
19  import org.mule.transport.AbstractConnector;
20  
21  public class ServiceOverridesMule1770TestCase extends FunctionalTestCase
22  {
23  
24      protected String getConfigResources()
25      {
26          return "issues/service-overrides-mule-1770-test.xml";
27      }
28  
29      public void testServiceOverrides()
30      {
31          AbstractConnector c = (AbstractConnector)muleContext.getRegistry().lookupConnector("test");
32          assertNotNull("Connector should not be null", c);
33          assertNotNull("Service overrides should not be null", c.getServiceOverrides());
34          String temp =  (String)c.getServiceOverrides().get(MuleProperties.CONNECTOR_DISPATCHER_FACTORY);
35          assertNotNull("DispatcherFactory override should not be null", temp);
36          assertEquals(TestMessageDispatcherFactory.class.getName(), temp);
37          Transformer transformer = TransformerUtils.firstOrNull(c.getDefaultInboundTransformers(null));
38          assertNotNull("InboundTransformer should not be null", transformer);
39          assertEquals(NoActionTransformer.class, transformer.getClass());
40      }
41  
42  
43      // MULE-1878
44      public void testDuplicate()
45      {
46          AbstractConnector c1 = (AbstractConnector)muleContext.getRegistry().lookupConnector("test");
47          assertNotNull("Connector should not be null", c1);
48          Transformer t1 = TransformerUtils.firstOrNull(c1.getDefaultInboundTransformers(null));
49          assertNotNull("InboundTransformer should not be null", t1);
50          assertEquals(NoActionTransformer.class, t1.getClass());
51  
52          AbstractConnector c2 = (AbstractConnector)muleContext.getRegistry().lookupConnector("second");
53          assertNotNull("Connector should not be null", c2);
54          Transformer t2 = TransformerUtils.firstOrNull(c2.getDefaultInboundTransformers(null));
55          assertNull("InboundTransformer should be null", t2);
56      }
57  
58  }