1
2
3
4
5
6
7
8
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
47
48
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
60
61
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
73
74
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 }