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