Skip to content

Commit

Permalink
test: spell checkers
Browse files Browse the repository at this point in the history
Signed-off-by: Hiroshi Miura <[email protected]>
  • Loading branch information
miurahr committed Nov 21, 2024
1 parent a32ac0a commit fbbeb33
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.Collections;

import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
Expand Down Expand Up @@ -67,8 +67,8 @@ public static void setUpClass() throws IOException {
copyFile("es_MX.dic");
}

@After
public final void tearDown() throws Exception {
@AfterClass
public static void tearDownClass() throws Exception {
FileUtils.forceDeleteOnExit(tmpDir.toFile());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,33 +25,37 @@

package org.omegat.spellchecker.morfologik;

import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;

import org.apache.commons.io.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

import org.omegat.core.Core;
import org.omegat.core.data.NotLoadedProject;
import org.omegat.core.data.ProjectProperties;
import org.omegat.core.spellchecker.ISpellChecker;
import org.omegat.filters2.master.PluginUtils;
import org.omegat.util.Language;
import org.omegat.util.TestPreferencesInitializer;

import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Path;

import static org.assertj.core.api.Assertions.assertThat;


public class MorfologikSpellcheckerTest {
private static final String DICTIONARY_PATH = "/org/omegat/spellchecker/morfologik/";

private Path tmpDir;
private Path configDir;
private static Path tmpDir;
private static Path configDir;

@Before
public final void setUp() throws Exception {
@BeforeClass
public static void setUpClass() throws Exception {
PluginUtils.loadPlugins(Collections.emptyMap());
tmpDir = Files.createTempDirectory("omegat");
assertThat(tmpDir.toFile()).isDirectory();
configDir = Files.createDirectory(tmpDir.resolve(".omegat"));
Expand All @@ -61,8 +65,8 @@ public final void setUp() throws Exception {
copyFile("de_DE.info");
}

@After
public final void tearDown() throws Exception {
@AfterClass
public static void tearDownClass() throws Exception {
FileUtils.forceDeleteOnExit(tmpDir.toFile());
}

Expand Down Expand Up @@ -102,7 +106,7 @@ public ProjectProperties getProjectProperties() {

}

private void copyFile(String target) throws IOException {
private static void copyFile(String target) throws IOException {
try (InputStream is = MorfologikSpellcheckerTest.class.getResourceAsStream(DICTIONARY_PATH + target)) {
if (is == null) {
throw new IOException("Target resource not found");
Expand Down

0 comments on commit fbbeb33

Please sign in to comment.