View Javadoc

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