View Javadoc

1   /*
2    * $Id: DefaultMuleContextTestCase.java 22377 2011-07-11 12:41:42Z 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.context;
12  
13  import org.mule.api.MuleContext;
14  import org.mule.api.MuleException;
15  import org.mule.tck.junit4.AbstractMuleContextTestCase;
16  
17  import org.junit.Test;
18  
19  import static org.junit.Assert.assertFalse;
20  import static org.junit.Assert.assertTrue;
21  
22  public class DefaultMuleContextTestCase extends AbstractMuleContextTestCase
23  {
24  
25      @Test
26      public void testDisposal() throws MuleException, InterruptedException
27      {
28          int threadsBeforeStart = Thread.activeCount();
29          MuleContext ctx = new DefaultMuleContextFactory().createMuleContext();
30          ctx.start();
31          assertTrue(Thread.activeCount() > threadsBeforeStart);
32          ctx.stop();
33          ctx.dispose();
34          // Check that workManager ("MuleServer") thread no longer exists.
35          assertTrue(Thread.activeCount() == threadsBeforeStart);
36          assertTrue(ctx.isDisposed());
37          assertFalse(ctx.isInitialised());
38          assertFalse(ctx.isStarted());
39      }
40  
41      @Override
42      protected MuleContext createMuleContext() throws Exception
43      {
44          return null;
45      }
46  }