package org.openqa.selenium.testing;

import org.junit.AfterClass;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.openqa.selenium.Pages;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.environment.GlobalTestEnvironment;
import org.openqa.selenium.environment.InProcessTestEnvironment;
import org.openqa.selenium.environment.TestEnvironment;
import org.openqa.selenium.environment.webserver.AppServer;
import org.openqa.selenium.testing.drivers.WebDriverBuilder;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.core.IsNot.not;

@RunWith(SeleniumTestRunner.class)
public abstract class JUnit4TestBase {
  protected TestEnvironment environment;
  protected AppServer appServer;
  protected Pages pages;
  protected static WebDriver driver;

  @Before
  public void setUp() throws Exception {
    environment = GlobalTestEnvironment.get();
    appServer = environment.getAppServer();

    pages = new Pages(appServer);

    String hostName = environment.getAppServer().getHostName();
    String alternateHostName = environment.getAppServer().getAlternateHostName();

    assertThat(hostName, is(not(equalTo(alternateHostName))));
  }

  @Before
  public void createDriver() throws Exception {
    if (driver != null) {
      return;
    }

    driver = new WebDriverBuilder().get();
  }

  @Before
  public void createEnvironment() {
    environment = GlobalTestEnvironment.get(InProcessTestEnvironment.class);
  }

  @AfterClass
  public static void removeDriver() {
    if (driver == null) {
      return;
    }

    try {
      driver.quit();
    } catch (RuntimeException ignored) {
      // Fall through
    }
    driver = null;
  }

  protected boolean isIeDriverTimedOutException(IllegalStateException e) {
    // The IE driver may throw a timed out exception
    return e.getClass().getName().contains("TimedOutException");
  }
}

@@ -916,13 +916,26 @@
 oid 
-setUp
+prepareEnvironment
 () t

Rename a method to prevent subclasses accidentally overriding it