1   package com.atlassian.selenium;
2   
3   import com.atlassian.performance.TimeRecorder;
4   import junit.framework.TestCase;
5   
6   import java.util.List;
7   
8   public abstract class SeleniumMultiTest extends TestCase
9   {
10  
11      protected SeleniumAssertions assertThat;
12      protected SeleniumClient client;
13      protected boolean parallel;
14  
15      public abstract List<SeleniumConfiguration> getSeleniumConfigurations();
16  
17      /**
18       * Calls overridden onSetup method before starting
19       * the selenium client and possibly server and initiating
20       * assertThat and interaction variables
21       */
22      public final void setUp() throws Exception
23      {
24          super.setUp();
25          client = SeleniumStarter.getInstance().getSeleniumClient(getSeleniumConfigurations(), parallel);
26  
27          if (SeleniumStarter.getInstance().isManual())
28          {
29              SeleniumStarter.getInstance().start(getSeleniumConfigurations().get(0));
30          }
31  
32          assertThat = new SeleniumAssertions(client, getSeleniumConfigurations().get(0), new TimeRecorder(this.getClass().getName()));
33          onSetUp();
34      }
35  
36      /**
37       * To be overridden in the case of test-specific setup activities
38       */
39      protected void onSetUp() throws Exception
40      {
41      }
42  
43      /**
44       * Calls overridden onTearDown method before shutting down
45       * the selenium client and possibly server
46       */
47      public final void tearDown() throws Exception
48      {
49          super.tearDown();
50          onTearDown();
51  
52          if (SeleniumStarter.getInstance().isManual())
53          {
54              SeleniumStarter.getInstance().stop();
55          }
56      }
57  
58      /**
59       * To be overridden in the case of test-specific tear-down activities
60       */
61      protected  void onTearDown() throws Exception
62      {
63      }
64  
65  }