1
2
3
4
5
6
7
8
9
10
11 package org.mule.test.integration.exceptions;
12
13 import org.mule.api.lifecycle.LifecycleException;
14 import org.mule.tck.testmodels.mule.TestConnector;
15
16 import java.util.concurrent.TimeUnit;
17 import org.junit.Test;
18
19 import static org.junit.Assert.assertEquals;
20 import static org.junit.Assert.fail;
21
22 public class SystemExceptionStrategyTestCase extends AbstractExceptionStrategyTestCase
23 {
24
25 @Override
26 protected String getConfigResources()
27 {
28 return "org/mule/test/integration/exceptions/system-exception-strategy.xml";
29 }
30
31 @Test
32 public void testConnectorStartup() throws Exception
33 {
34 try
35 {
36 TestConnector c = (TestConnector) muleContext.getRegistry().lookupConnector("testConnector");
37 c.setInitialStateStopped(false);
38 c.start();
39 fail("Connector should have thrown an exception");
40 }
41 catch (LifecycleException e)
42 {
43
44 }
45 latch.await(1000, TimeUnit.MILLISECONDS);
46 assertEquals(0, serviceExceptionCounter.get());
47 assertEquals(1, systemExceptionCounter.get());
48 }
49
50 @Test
51 public void testConnectorPolling() throws Exception
52 {
53 muleContext.getRegistry().lookupService("Polling").start();
54 Thread.sleep(3000);
55 latch.await(1000, TimeUnit.MILLISECONDS);
56 assertEquals(0, serviceExceptionCounter.get());
57 assertEquals(1, systemExceptionCounter.get());
58 }
59 }
60
61