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.transport.soap.axis;
8   
9   import org.mule.api.MuleException;
10  import org.mule.tck.junit4.FunctionalTestCase;
11  import org.mule.tck.junit4.rule.DynamicPort;
12  
13  import org.junit.Rule;
14  import org.junit.Test;
15  
16  import static org.junit.Assert.assertFalse;
17  import static org.junit.Assert.assertNull;
18  import static org.junit.Assert.assertTrue;
19  
20  public class AxisConnectorLifecycleTestCase extends FunctionalTestCase
21  {
22  
23      private static String SERVICE_NAME = "mycomponent";
24      private static String PROTOCOL_SERVICE_NAME = AxisConnector.AXIS_SERVICE_PROPERTY + "connector.axis.0";
25  
26      @Rule
27      public DynamicPort dynamicPort1 = new DynamicPort("port1");
28  
29      @Rule
30      public DynamicPort dynamicPort2 = new DynamicPort("port2");
31  
32      @Rule
33      public DynamicPort dynamicPort3 = new DynamicPort("port3");
34  
35      @Override
36      protected String getConfigResources()
37      {
38          return "axis-http-mule-config.xml";
39      }
40  
41      /**
42       * MULE-4570, MULE-4573
43       * 
44       * @throws MuleException
45       */
46      @Test
47      public void testStopService() throws MuleException
48      {
49          muleContext.getRegistry().lookupService(SERVICE_NAME).stop();
50          assertFalse(muleContext.getRegistry().lookupService(SERVICE_NAME).isStarted());
51          assertFalse(muleContext.getRegistry().lookupService(PROTOCOL_SERVICE_NAME).isStarted());
52      }
53  
54      /**
55       * MULE-4570, MULE-4573
56       * 
57       * @throws MuleException
58       */
59      @Test
60      public void testDisposeService() throws MuleException
61      {
62          muleContext.getRegistry().lookupService(SERVICE_NAME).dispose();
63          assertFalse(muleContext.getRegistry().lookupService(SERVICE_NAME).isStarted());
64          assertNull(muleContext.getRegistry().lookupService(PROTOCOL_SERVICE_NAME));
65      }
66  
67      /**
68       * MULE-4569, MULE-4573
69       * 
70       * @throws MuleException
71       */
72      @Test
73      public void testRestartService() throws MuleException
74      {
75          muleContext.getRegistry().lookupService(SERVICE_NAME).stop();
76          assertFalse(muleContext.getRegistry().lookupService(SERVICE_NAME).isStarted());
77          assertFalse(muleContext.getRegistry().lookupService(PROTOCOL_SERVICE_NAME).isStarted());
78          muleContext.getRegistry().lookupService(SERVICE_NAME).start();
79          assertTrue(muleContext.getRegistry().lookupService(SERVICE_NAME).isStarted());
80          assertTrue(muleContext.getRegistry().lookupService(PROTOCOL_SERVICE_NAME).isStarted());
81      }
82  
83  }