View Javadoc

1   /*
2    * $Id: DynamicPortTestCase.java 20230 2010-11-17 21:58:16Z dzapata $
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.tck;
12  
13  
14  /**
15   * Extend this class instead of FunctionalTestCase to add dynamic port support to
16   * your tests. The test will need to only implement 'getNumPortsToFind' to tell this
17   * class how many free test ports to find.
18   */
19  public abstract class DynamicPortTestCase extends FunctionalTestCase
20  {
21      protected abstract int getNumPortsToFind();
22  
23      public DynamicPortTestCase()
24      {
25          super();
26  
27          // each test class sets the number of free ports to find
28          numPorts = getNumPortsToFind();
29      }
30  
31      @Override
32      protected void doSetUp() throws Exception
33      {
34          super.doSetUp();
35      }
36  
37      @Override
38      protected void doTearDown() throws Exception
39      {
40          super.doTearDown();
41          // make sure that the ports have been freed. It's not a fatal error, but we
42          // want to track down why it's not being released
43          checkPorts(false, "TEARDOWN");
44      }
45  }