<commit_before>package tests;

import org.junit.Test;
import play.Play;
import play.test.TestBrowser;
import play.libs.F.Callback;
import tests.pages.IndexPage;
import tests.pages.LoginPage;
import tests.pages.ManageSurferPage;
import tests.pages.NameTheSurferPage;
import tests.pages.NewSurferPage;
import tests.pages.SearchResultsPage;
import tests.pages.ShowSurferPage;
import tests.pages.UpdatesPage;
import static play.test.Helpers.HTMLUNIT;
import static play.test.Helpers.inMemoryDatabase;
import static play.test.Helpers.fakeApplication;
import static play.test.Helpers.testServer;
import static play.test.Helpers.running;
import static org.fest.assertions.Assertions.assertThat;

/**
 * Integration tests running on an instance of the application.
 */
public class IntegrationTest {
  /** The port number for the integration test. */
  private static final int PORT = 3333;

  /**
   * Ensure a user can login and logout of the system.
   */
  @Test
  public void testLoginLogout() {
    running(testServer(PORT, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
      public void invoke(TestBrowser browser) {
        
        IndexPage indexPage = new IndexPage(browser.getDriver(), PORT);
        browser.goTo(indexPage);
        indexPage.isAt();
                
        indexPage.goToLogin();
        LoginPage loginPage = new LoginPage(browser.getDriver(), PORT);
        loginPage.isAt();
        
        String adminEmail = Play.application().configuration().getString("surferpedia.admin.email");
        String adminPassword = Play.application().configuration().getString("surferpedia.admin.password");
        loginPage.login(adminEmail, adminPassword);
        assertThat(indexPage.isLoggedIn()).isTrue();

        indexPage.logout();
        assertThat(indexPage.isLoggedIn()).isFalse();
      }
    });
  }
  
  /**
   * Ensure a user can register for an account.
   */
  @Test
  public void testRegistration() {
    running(testServer(PORT, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
      public void invoke(TestBrowser browser) {
        
        IndexPage indexPage = new IndexPage(browser.getDriver(), PORT);
        browser.goTo(indexPage);
        indexPage.isAt();
        
        indexPage.goToLogin();
        LoginPage loginPage = new LoginPage(browser.getDriver(), PORT);
        loginPage.isAt();
        
        loginPage.register("<NAME>", "<EMAIL>", "password");
        assertThat(indexPage.isLoggedIn()).isTrue();
        
        indexPage.logout();
        assertThat(indexPage.isLoggedIn()).isFalse();
        
        indexPage.goToLogin();
        loginPage.isAt();<commit_msg>adding tests<commit_after>package tests;

import org.junit.Test;
import play.Play;
import play.test.TestBrowser;
import play.libs.F.Callback;
import tests.pages.IndexPage;
import tests.pages.LoginPage;
import tests.pages.ManageSurferPage;
import tests.pages.NameTheSurferPage;
import tests.pages.NewSurferPage;
import tests.pages.SearchResultsPage;
import tests.pages.ShowSurferPage;
import tests.pages.UpdatesPage;
import static play.test.Helpers.HTMLUNIT;
import static play.test.Helpers.inMemoryDatabase;
import static play.test.Helpers.fakeApplication;
import static play.test.Helpers.testServer;
import static play.test.Helpers.running;
import static org.fest.assertions.Assertions.assertThat;

/**
 * Integration tests running on an instance of the application.
 */
public class IntegrationTest {
  /** The port number for the integration test. */
  private static final int PORT = 3333;

  /**
   * Ensure a user can login and logout of the system.
   */
  @Test
  public void testLoginLogout() {
    running(testServer(PORT, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
      public void invoke(TestBrowser browser) {
        
        IndexPage indexPage = new IndexPage(browser.getDriver(), PORT);
        browser.goTo(indexPage);
        indexPage.isAt();
                
        indexPage.goToLogin();
        LoginPage loginPage = new LoginPage(browser.getDriver(), PORT);
        loginPage.isAt();
        
        String adminEmail = Play.application().configuration().getString("surferpedia.admin.email");
        String adminPassword = Play.application().configuration().getString("surferpedia.admin.password");
        loginPage.login(adminEmail, adminPassword);
        assertThat(indexPage.isLoggedIn()).isTrue();

         System.out.println("Logout");
        indexPage.logout();
        assertThat(indexPage.isLoggedIn()).isFalse();
      }
    });
  }
  
  /**
   * Ensure a user can register for an account.
   */
  @Test
  public void testRegistration() {
    running(testServer(PORT, fakeApplication(inMemoryDatabase())), HTMLUNIT, new Callback<TestBrowser>() {
      public void invoke(TestBrowser browser) {
        
        IndexPage indexPage = new IndexPage(browser.getDriver(), PORT);
        browser.goTo(indexPage);
        indexPage.isAt();
        
        indexPage.goToLogin();
        LoginPage loginPage = new LoginPage(browser.getDriver(), PORT);
        loginPage.isAt();
        
        loginPage.register("<NAME>", "<EMAIL>", "password");
        assertThat(indexPage.isLoggedIn()).isTrue();
        
        indexPage.logout();
        assertThat(indexPage.isLoggedIn()).isFalse();
        
        indexPage.goToLogin();
        loginPage.isAt();
{'fraction_non_alphanumeric': 0.11613737075332349, 'fraction_numerical': 0.0014771048744460858, 'mean_word_length': 3.32667731629393, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '6623339', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1496, 'n_words': 321}