View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.tck;
8   
9   import org.mule.tck.junit4.FunctionalTestCase;
10  
11  import org.junit.runner.RunWith;
12  import org.junit.runners.Parameterized;
13  
14  @RunWith(Parameterized.class)
15  public abstract class AbstractServiceAndFlowTestCase extends FunctionalTestCase
16  {
17      protected ConfigVariant variant;
18      protected String configResources;
19  
20      public AbstractServiceAndFlowTestCase(ConfigVariant variant, String configResources)
21      {
22          super();
23          this.variant = variant;
24          this.configResources = configResources;
25      }
26  
27      @Override
28      protected void doSetUp() throws Exception
29      {
30          super.doSetUp();
31  
32          switch (variant)
33          {
34              case FLOW:
35                  doSetUpForFlow();
36                  break;
37  
38              case SERVICE:
39                  doSetUpForService();
40                  break;
41          }
42      }
43  
44      protected void doSetUpForFlow()
45      {
46          // subclasses can override this method with setup that is specific for the flow test variant
47      }
48  
49      protected void doSetUpForService()
50      {
51          // subclasses can override this method with setup that is specific for the service test variant
52      }
53  
54      @Override
55      protected String getConfigResources()
56      {
57          return configResources;
58      }
59  
60      @Override
61      protected String getTestHeader()
62      {
63          return "Testing: " + name.getMethodName() + " (" + variant + ")";
64      }
65  
66      public static enum ConfigVariant
67      {
68          FLOW, SERVICE
69      }
70  }