View Javadoc

1   /*
2    * $Id: ConnectableTestCase.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.transport;
12  
13  import org.mule.api.context.WorkManager;
14  import org.mule.api.endpoint.ImmutableEndpoint;
15  import org.mule.tck.AbstractMuleTestCase;
16  
17  public class ConnectableTestCase extends AbstractMuleTestCase
18  {
19  
20      /**
21       * MULE-4531
22       */
23      public void testDoNotConnectIfConnected() throws Exception
24      {
25          AbstractConnectable connectable = new TestConnectable(getTestInboundEndpoint("test"), true);
26          connectable.connect();
27      }
28  
29      class TestConnectable extends AbstractConnectable
30      {
31          public TestConnectable(ImmutableEndpoint endpoint, boolean connected)
32          {
33              super(endpoint);
34              this.connected.set(connected);
35          }
36  
37          @Override
38          protected ConnectableLifecycleManager createLifecycleManager()
39          {
40              return new ConnectableLifecycleManager("test", this);
41          }
42  
43          @Override
44          protected WorkManager getWorkManager()
45          {
46              return null;
47          }
48  
49          @Override
50          protected void doConnect() throws Exception
51          {
52              if (connected.get())
53              {
54                  fail("Should not attempt connection");
55              }
56              super.doConnect();
57          }
58  
59      }
60  
61  }