<commit_before>/*
Copyright 2011 Opera Software ASA

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.opera.core.systems;

import com.opera.core.systems.arguments.OperaCoreArguments;
import com.opera.core.systems.runner.OperaRunnerException;
import com.opera.core.systems.runner.launcher.OperaLauncherRunnerSettings;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.Platform;

import java.io.File;
import java.util.logging.Level;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class OperaLauncherRunnerSettingsTest {

  private TestOperaLauncherRunnerSettings settings;
  private static
  File
      launcherOnSystem =
      new File(System.getProperty("user.home") + File.separator + ".launcher" + File.separator
               + TestOperaLauncherRunnerSettings.getLauncherNameForOS2());
  private static File fakeBinary;

  @BeforeClass
  public static void beforeAll() {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
      fakeBinary = new File("C:\\WINDOWS\\system32\\find.exe");
    } else {
      fakeBinary = new File("/bin/echo");
    }
  }

  @Before
  public void setUp() {
    settings = new TestOperaLauncherRunnerSettings();
  }

  @Test
  public void testDefaultSettings() {
    OperaLauncherRunnerSettings
        defaultSettings =
        TestOperaLauncherRunnerSettings.getDefaultSettings();
    assertNotNull(defaultSettings);
    assertEquals(OperaProduct.CORE, defaultSettings.getProduct());
    assertTrue("default port should be greater than 0", defaultSettings.getPort() > 0);
    assertTrue(defaultSettings.getArguments() instanceof OperaCoreArguments);
  }

  @Test
  public void testSetLoggingLevel() {
    settings.setLoggingLevel(Level.SEVERE);
    assertEquals(Level.SEVERE, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToAll() {
    settings.setLoggingLevel(Level.ALL);
    assertEquals(Level.FINEST, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToConfig() {
    settings.setLoggingLevel(Level.FINE);
    assertEquals(Level.INFO, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToFiner() {
    settings.setLoggingLevel(Level.FINER);
    assertEquals(Level.FINE, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToOff() {
    settings.setLoggingLevel(Level.OFF);
    assertEquals(Level.OFF, settings.getLoggingLevel());
  }

  @Test
  public void testGetLoggingLevel() {
    assertEquals(Level.INFO, settings.getLoggingLevel());<commit_msg>Correcting test<commit_after>/*
Copyright 2011 Opera Software ASA

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package com.opera.core.systems;

import com.opera.core.systems.arguments.OperaCoreArguments;
import com.opera.core.systems.runner.OperaRunnerException;
import com.opera.core.systems.runner.launcher.OperaLauncherRunnerSettings;

import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.openqa.selenium.Platform;

import java.io.File;
import java.util.logging.Level;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;

public class OperaLauncherRunnerSettingsTest {

  private TestOperaLauncherRunnerSettings settings;
  private static
  File
      launcherOnSystem =
      new File(System.getProperty("user.home") + File.separator + ".launcher" + File.separator
               + TestOperaLauncherRunnerSettings.getLauncherNameForOS2());
  private static File fakeBinary;

  @BeforeClass
  public static void beforeAll() {
    if (Platform.getCurrent().is(Platform.WINDOWS)) {
      fakeBinary = new File("C:\\WINDOWS\\system32\\find.exe");
    } else {
      fakeBinary = new File("/bin/echo");
    }
  }

  @Before
  public void setUp() {
    settings = new TestOperaLauncherRunnerSettings();
  }

  @Test
  public void testDefaultSettings() {
    OperaLauncherRunnerSettings
        defaultSettings =
        TestOperaLauncherRunnerSettings.getDefaultSettings();
    assertNotNull(defaultSettings);
    assertEquals(OperaProduct.CORE, defaultSettings.getProduct());
    assertTrue("default port should be greater than 0", defaultSettings.getPort() > 0);
    assertTrue(defaultSettings.getArguments() instanceof OperaCoreArguments);
  }

  @Test
  public void testSetLoggingLevel() {
    settings.setLoggingLevel(Level.SEVERE);
    assertEquals(Level.SEVERE, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToAll() {
    settings.setLoggingLevel(Level.ALL);
    assertEquals(Level.FINEST, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToConfig() {
    settings.setLoggingLevel(Level.CONFIG);
    assertEquals(Level.FINE, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToFiner() {
    settings.setLoggingLevel(Level.FINER);
    assertEquals(Level.FINE, settings.getLoggingLevel());
  }

  @Test
  public void testSetLoggingLevelToOff() {
    settings.setLoggingLevel(Level.OFF);
    assertEquals(Level.OFF, settings.getLoggingLevel());
  }

  @Test
  public void testGetLoggingLevel() {
    assertEquals(Level.INFO, settings.getLoggingLevel());
{'fraction_non_alphanumeric': 0.09546313799621928, 'fraction_numerical': 0.004095778197857593, 'mean_word_length': 4.511284722222222, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '138061', 'n_tokens_mistral': 1840, 'n_tokens_neox': 1786, 'n_words': 440}