View Javadoc

1   /*
2    * $Id: ServiceOverridesMule1770TestCase.java 22431 2011-07-18 07:40:35Z dirk.olmes $
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.junit4.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  import org.junit.Test;
22  
23  import static org.junit.Assert.assertEquals;
24  import static org.junit.Assert.assertNotNull;
25  import static org.junit.Assert.assertNull;
26  
27  public class ServiceOverridesMule1770TestCase extends FunctionalTestCase
28  {
29  
30      @Override
31      protected String getConfigResources()
32      {
33          return "issues/service-overrides-mule-1770-test.xml";
34      }
35  
36      @Test
37      public void testServiceOverrides()
38      {
39          AbstractConnector c = (AbstractConnector)muleContext.getRegistry().lookupConnector("test");
40          assertNotNull("Connector should not be null", c);
41          assertNotNull("Service overrides should not be null", c.getServiceOverrides());
42          String temp =  (String)c.getServiceOverrides().get(MuleProperties.CONNECTOR_DISPATCHER_FACTORY);
43          assertNotNull("DispatcherFactory override should not be null", temp);
44          assertEquals(TestMessageDispatcherFactory.class.getName(), temp);
45          Transformer transformer = TransformerUtils.firstOrNull(c.getDefaultInboundTransformers(null));
46          assertNotNull("InboundTransformer should not be null", transformer);
47          assertEquals(NoActionTransformer.class, transformer.getClass());
48      }
49  
50      // MULE-1878
51      @Test
52      public void testDuplicate()
53      {
54          AbstractConnector c1 = (AbstractConnector)muleContext.getRegistry().lookupConnector("test");
55          assertNotNull("Connector should not be null", c1);
56          Transformer t1 = TransformerUtils.firstOrNull(c1.getDefaultInboundTransformers(null));
57          assertNotNull("InboundTransformer should not be null", t1);
58          assertEquals(NoActionTransformer.class, t1.getClass());
59  
60          AbstractConnector c2 = (AbstractConnector)muleContext.getRegistry().lookupConnector("second");
61          assertNotNull("Connector should not be null", c2);
62          Transformer t2 = TransformerUtils.firstOrNull(c2.getDefaultInboundTransformers(null));
63          assertNull("InboundTransformer should be null", t2);
64      }
65  
66  }