<commit_before>package com.opera.core.systems;

import junit.framework.Assert;
import org.junit.Test;

import java.io.File;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Map;

import static org.junit.Assert.*;

public class OperaPathsTest {
  private static OperaPaths paths = new OperaPaths();
  private static String knownDir = System.getProperty("user.home");

  @Test
  public void testOperaPath() throws Exception {
    assertNotNull(paths.operaPath());
  }

  @Test
  public void testLauncherPath() throws Exception {
    assertNotNull(paths.launcherPath());
  }

  /**
   * Test that the launcher is extracted correctly
   */
  @Test
  public void testNoLauncher() throws Exception {
    File launcher = new File(paths.launcherPath());
    launcher.delete();

    Assert.assertFalse(launcher.exists());

    paths.launcherPath();

    Assert.assertTrue(launcher.exists());
  }

  /**
   * Test that the launcher is re-extracted when the hashes differ
   */
  @Test
  public void testNoMatch() throws Exception {
    File launcher = new File(paths.launcherPath());
    launcher.delete();

    Assert.assertFalse(launcher.exists());
    launcher.createNewFile();
    Assert.assertEquals(0, launcher.length());

    paths.launcherPath();

    Assert.assertNotSame(0, launcher.length());
  }

  /**
   * Test that the launcher isn't extracted when it is the same
   */
  @Test
  public void testExists() throws Exception {
    File launcher = new File(paths.launcherPath());
    long modified = launcher.lastModified();

    paths.launcherPath();
    Assert.assertEquals(modified, launcher.lastModified());
  }

  @Test
  public void testStart() throws Exception {
    OperaDriver driver = new OperaDriver();

    driver.get("http://t/core/README");

    assertEquals("http://t/core/README", driver.getCurrentUrl());

    driver.quit();
  }

  /* These tests mess with the environment variables. So they're at the end */

  @Test
  public void testOperaEnvVar() throws Exception {
    assertNotSame(knownDir, paths.operaPath());

    setEnvVar("OPERA_PATH", knownDir);

    assertEquals(knownDir, paths.operaPath());
  }

  @Test
  public void testLauncherEnvVar() throws Exception {
    assertNotSame(knownDir, paths.launcherPath());<commit_msg>Disable a couple of tests on Windows<commit_after>package com.opera.core.systems;

import junit.framework.Assert;
import org.junit.Test;
import org.openqa.selenium.Platform;

import java.io.File;
import java.lang.reflect.Field;
import java.util.Collections;
import java.util.Map;

import static org.junit.Assert.*;

public class OperaPathsTest {
  private static OperaPaths paths = new OperaPaths();
  private static String knownDir = System.getProperty("user.home");

  @Test
  public void testOperaPath() throws Exception {
    assertNotNull(paths.operaPath());
  }

  @Test
  public void testLauncherPath() throws Exception {
    assertNotNull(paths.launcherPath());
  }

  /**
   * Test that the launcher is extracted correctly
   */
  @Test
  public void testNoLauncher() throws Exception {
    File launcher = new File(paths.launcherPath());
    launcher.delete();

    Assert.assertFalse(launcher.exists());

    paths.launcherPath();

    Assert.assertTrue(launcher.exists());
  }

  /**
   * Test that the launcher is re-extracted when the hashes differ
   */
  @Test
  public void testNoMatch() throws Exception {
    File launcher = new File(paths.launcherPath());
    launcher.delete();

    Assert.assertFalse(launcher.exists());
    launcher.createNewFile();
    Assert.assertEquals(0, launcher.length());

    paths.launcherPath();

    Assert.assertNotSame(0, launcher.length());
  }

  /**
   * Test that the launcher isn't extracted when it is the same
   */
  @Test
  public void testExists() throws Exception {
    File launcher = new File(paths.launcherPath());
    long modified = launcher.lastModified();

    paths.launcherPath();
    Assert.assertEquals(modified, launcher.lastModified());
  }

  @Test
  public void testStart() throws Exception {
    OperaDriver driver = new OperaDriver();

    driver.get("http://t/core/README");

    assertEquals("http://t/core/README", driver.getCurrentUrl());

    driver.quit();
  }

  /* These tests mess with the environment variables. So they're at the end */

  @Test
  public void testOperaEnvVar() throws Exception {
    // Doesn't work on Windows
    if (Platform.getCurrent() == Platform.WINDOWS) return;

    assertNotSame(knownDir, paths.operaPath());

    setEnvVar("OPERA_PATH", knownDir);

    assertEquals(knownDir, paths.operaPath());
  }

  @Test
  public void testLauncherEnvVar() throws Exception {
    // Doesn't work on Windows
    if (Platform.getCurrent() == Platform.WINDOWS) return;

    assertNotSame(knownDir, paths.launcherPath());
{'fraction_non_alphanumeric': 0.12068248023304202, 'fraction_numerical': 0.0008322929671244278, 'mean_word_length': 3.7783300198807157, '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': '407267', 'n_tokens_mistral': 1450, 'n_tokens_neox': 1380, 'n_words': 357}