View Javadoc

1   /*
2    * $Id: AbstractServiceAndFlowTestCase.java 22421 2011-07-15 05:05:06Z 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.tck;
12  
13  import org.mule.tck.junit4.FunctionalTestCase;
14  
15  import org.junit.runner.RunWith;
16  import org.junit.runners.Parameterized;
17  
18  @RunWith(Parameterized.class)
19  public abstract class AbstractServiceAndFlowTestCase extends FunctionalTestCase
20  {
21      protected ConfigVariant variant;
22      protected String configResources;
23  
24      public AbstractServiceAndFlowTestCase(ConfigVariant variant, String configResources)
25      {
26          super();
27          this.variant = variant;
28          this.configResources = configResources;
29      }
30  
31      @Override
32      protected void doSetUp() throws Exception
33      {
34          super.doSetUp();
35  
36          switch (variant)
37          {
38              case FLOW:
39                  doSetUpForFlow();
40                  break;
41  
42              case SERVICE:
43                  doSetUpForService();
44                  break;
45          }
46      }
47  
48      protected void doSetUpForFlow()
49      {
50          // subclasses can override this method with setup that is specific for the flow test variant
51      }
52  
53      protected void doSetUpForService()
54      {
55          // subclasses can override this method with setup that is specific for the service test variant
56      }
57  
58      @Override
59      protected String getConfigResources()
60      {
61          return configResources;
62      }
63  
64      @Override
65      protected String getTestHeader()
66      {
67          return "Testing: " + name.getMethodName() + " (" + variant + ")";
68      }
69  
70      public static enum ConfigVariant
71      {
72          FLOW, SERVICE
73      }
74  }