<commit_before>package br.com.caelum.brutal.integration.scene;

import org.apache.commons.httpclient.HttpClient;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

import br.com.caelum.brutal.integration.pages.Home;
import br.com.caelum.pagpag.aceitacao.util.ServerInfo;

import com.gargoylesoftware.htmlunit.BrowserVersion;

public abstract class AcceptanceTestBase implements ServerInfo.TesteAceitacao {

	protected static WebDriver driver;

	protected HttpClient client;
	
	protected static String HOMOLOG_ENV = "development";

	@AfterClass
	public static void close() {
		if (driver != null)
			driver.close();
	}

	private static WebDriver htmlUnitDriver() {
		HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
		driver.setJavascriptEnabled(true);
		return driver;
	}

	protected Navigation browser() {
		return driver.navigate();
	}
	
	protected Home home() {
		return new Home(driver);
	}

	@Before
	public void setUpEnv() {
//		waitForFirstBodyPresence();
		client = new HttpClient();
	}
	

	@BeforeClass
	public static void getDriver() {
		if ("firefox".equals(System.getProperty("vraptor.browser"))) {
			driver = new FirefoxDriver();
		} else {
			driver = htmlUnitDriver();
		}
		waitForFirstBodyPresence();
	}

	private static void waitForFirstBodyPresence() {<commit_msg>executando get para a home antes de executar testes de integração para ver se server está mesmo em pé<commit_after>package br.com.caelum.brutal.integration.scene;

import java.io.IOException;

import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.methods.GetMethod;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriver.Navigation;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.WebDriverWait;

import br.com.caelum.brutal.integration.pages.Home;
import br.com.caelum.pagpag.aceitacao.util.ServerInfo;

import com.gargoylesoftware.htmlunit.BrowserVersion;

public abstract class AcceptanceTestBase implements ServerInfo.TesteAceitacao {

	protected static WebDriver driver;

	protected static HttpClient client;
	
	protected static String HOMOLOG_ENV = "development";

	@AfterClass
	public static void close() {
		if (driver != null)
			driver.close();
	}

	private static WebDriver htmlUnitDriver() {
		HtmlUnitDriver driver = new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
		driver.setJavascriptEnabled(true);
		return driver;
	}

	protected Navigation browser() {
		return driver.navigate();
	}
	
	protected Home home() {
		return new Home(driver);
	}

	@Before
	public void setUpEnv() {
//		waitForFirstBodyPresence();
		client = new HttpClient();
	}
	

	@BeforeClass
	public static void getDriver() {
		if ("firefox".equals(System.getProperty("vraptor.browser"))) {
			driver = new FirefoxDriver();
		} else {
			driver = htmlUnitDriver();
		}
		waitForFirstBodyPresence();
	}
	
	@BeforeClass
	public static void getHttpClient() {
	    client = new HttpClient();
	    getHome();
	}

	private static void getHome() {
	    String homeUri = SERVER.urlFor("");
        try {
            HttpMethod method = new GetMethod(homeUri);
            int status = client.executeMethod(method);
            int digit = status % 100;
            if (digit == 5 || digit == 4) {
                throw new RuntimeException("server responded with "+ status + " status for a GET request to uri: " + homeUri + ", is the server ok?");
            }
        } catch (IOException e) {
            throw new RuntimeException("could not execute GET to: " + homeUri + ", is the server up?", e);
        }
    }

    private static void waitForFirstBodyPresence() {
{'fraction_non_alphanumeric': 0.10410456317358405, 'fraction_numerical': 0.0020637468470534283, 'mean_word_length': 4.319512195121951, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1375978', 'n_tokens_mistral': 1431, 'n_tokens_neox': 1333, 'n_words': 306}