View Javadoc

1   /*
2    * $Id: TcpDispatcherPoolFactoryTestCase.java 19251 2010-08-30 17:53:17Z pablo.kraan $
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.transport.tcp;
12  
13  import org.mule.api.transport.Connector;
14  import org.mule.tck.FunctionalTestCase;
15  import org.mule.transport.ConfigurableKeyedObjectPool;
16  import org.mule.transport.ConfigurableKeyedObjectPoolFactory;
17  import org.mule.transport.DefaultConfigurableKeyedObjectPool;
18  import org.mule.transport.DefaultConfigurableKeyedObjectPoolFactory;
19  
20  public class TcpDispatcherPoolFactoryTestCase extends FunctionalTestCase
21  {
22  
23      @Override
24      protected String getConfigResources()
25      {
26          return "tcp-dispatcher-pool-factory-config.xml";
27      }
28  
29      public static class StubConfigurableKeyedObjectPool extends DefaultConfigurableKeyedObjectPool
30      {
31  
32      }
33  
34      public static class StubDispatcherPoolFactory implements ConfigurableKeyedObjectPoolFactory
35      {
36  
37          public ConfigurableKeyedObjectPool createObjectPool()
38          {
39              return new StubConfigurableKeyedObjectPool();
40          }
41      }
42  
43      public void testConnectorUsingDefaultDispatcherPoolFactory()
44      {
45          Connector connector = muleContext.getRegistry().lookupConnector("tcpConnectorWithDefaultFactory");
46  
47          assertTrue(connector instanceof TcpConnector);
48          TcpConnector tcpConnector = (TcpConnector) connector;
49          assertEquals(DefaultConfigurableKeyedObjectPoolFactory.class, tcpConnector.getDispatcherPoolFactory().getClass());
50          assertEquals(DefaultConfigurableKeyedObjectPool.class, tcpConnector.getDispatchers().getClass());
51      }
52  
53      public void testConnectorUsingOverriddenDispatcherPoolFactory()
54      {
55          Connector connector = muleContext.getRegistry().lookupConnector("tcpConnectorWithOverriddenFactory");
56  
57          assertTrue(connector instanceof TcpConnector);
58          TcpConnector tcpConnector = (TcpConnector) connector;
59          assertEquals(StubDispatcherPoolFactory.class, tcpConnector.getDispatcherPoolFactory().getClass());
60          assertEquals(StubConfigurableKeyedObjectPool.class, tcpConnector.getDispatchers().getClass());
61      }
62  }