View Javadoc

1   /*
2    * $Id: SystemExceptionStrategyTestCase.java 19264 2010-08-31 22:21:33Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.test.integration.exceptions;
12  
13  import org.mule.api.lifecycle.LifecycleException;
14  import org.mule.tck.testmodels.mule.TestConnector;
15  
16  import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
17  
18  public class SystemExceptionStrategyTestCase extends AbstractExceptionStrategyTestCase
19  {
20      @Override
21      protected String getConfigResources()
22      {
23          return "org/mule/test/integration/exceptions/system-exception-strategy.xml";
24      }
25  
26      public void testConnectorStartup() throws Exception
27      {
28          try
29          {
30              TestConnector c = (TestConnector) muleContext.getRegistry().lookupConnector("testConnector");
31              c.setInitialStateStopped(false);
32              c.start();
33              fail("Connector should have thrown an exception");
34          }
35          catch (LifecycleException e)
36          {
37              // expected
38          }
39          latch.await(1000, TimeUnit.MILLISECONDS); 
40          assertEquals(0, serviceExceptionCounter.get());
41          assertEquals(1, systemExceptionCounter.get());
42      }
43  
44      public void testConnectorPolling() throws Exception
45      {
46          muleContext.getRegistry().lookupService("Polling").start();
47          Thread.sleep(3000);
48          latch.await(1000, TimeUnit.MILLISECONDS); 
49          assertEquals(0, serviceExceptionCounter.get());
50          assertEquals(1, systemExceptionCounter.get());
51      }
52  }
53  
54