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