diff --git a/build.gradle.kts b/build.gradle.kts index 442f460d5..363d0799e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -9,6 +9,12 @@ tasks.withType() { options.encoding = "UTF-8" } +tasks.withType() { + // Enforce en-US locale, as many unit tests are locale-dependant. + systemProperty("user.language", "en") + systemProperty("user.country", "US") +} + group = "org.crosswire" version = "2.3" @@ -28,11 +34,8 @@ dependencies { // implementation("org.apache.lucene:lucene-analyzers-common:x") //implementation("org.slf4j:slf4j-api:1.7.6") - if(project.hasProperty("tests")) { - implementation("org.slf4j:slf4j-api:1.7.6") - } else { - implementation("de.psdev.slf4j-android-logger:slf4j-android-logger:1.0.5") - } + implementation("org.slf4j:slf4j-api:1.7.6") + testImplementation("org.slf4j:slf4j-simple:1.7.6") testImplementation("junit:junit:4.13") } diff --git a/src/test/java/org/crosswire/jsword/book/BooksTest.java b/src/test/java/org/crosswire/jsword/book/BooksTest.java index fcc1465ec..05e215849 100644 --- a/src/test/java/org/crosswire/jsword/book/BooksTest.java +++ b/src/test/java/org/crosswire/jsword/book/BooksTest.java @@ -35,6 +35,7 @@ import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; import org.junit.Assert; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; @@ -134,6 +135,7 @@ public void testGetDataPassage() throws Exception { public void testBookList() throws Exception { //part of the pre-requisites AbstractPassageBook esv = (AbstractPassageBook) Books.installed().getBook("ESV2011"); + Assume.assumeTrue("ESV2011 is installed", esv != null); Assert.assertTrue(esv.getBibleBooks().contains(BibleBook.ACTS)); } @@ -147,17 +149,18 @@ public void testBookList() throws Exception { @Test public void testLinkedVersesNotDuplicated() throws Exception { Book turNTB = Books.installed().getBook("TurNTB"); - if (turNTB != null) { - // Eph 2:4,5 are merged/linked in TurNTB - Key eph245 = VerseRangeFactory.fromString(Versifications.instance().getVersification("KJV"), "Eph 2:4-5"); - BookData bookData = new BookData(turNTB, eph245); - final Element osisFragment = bookData.getOsisFragment(); - final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat()); - String xml = xmlOutputter.outputString(osisFragment); + Assume.assumeTrue("TurNTB is installed", turNTB != null); - Assert.assertTrue("Probable duplicate text", xml.length() < 300); - } + // Eph 2:4,5 are merged/linked in TurNTB + Key eph245 = VerseRangeFactory.fromString(Versifications.instance().getVersification("KJV"), "Eph 2:4-5"); + BookData bookData = new BookData(turNTB, eph245); + final Element osisFragment = bookData.getOsisFragment(); + + final XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat()); + String xml = xmlOutputter.outputString(osisFragment); + + Assert.assertTrue("Probable duplicate text", xml.length() < 300); } /** diff --git a/src/test/java/org/crosswire/jsword/book/sword/BackendTest.java b/src/test/java/org/crosswire/jsword/book/sword/BackendTest.java index 95c3bf331..72b5727d8 100644 --- a/src/test/java/org/crosswire/jsword/book/sword/BackendTest.java +++ b/src/test/java/org/crosswire/jsword/book/sword/BackendTest.java @@ -30,6 +30,7 @@ import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; import org.junit.Assert; +import org.junit.Assume; import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -270,9 +271,8 @@ public void testBackendGenevaCommentsZ() throws Exception { public void testBackendStrongsGreekRawLd() throws Exception { String version = "StrongsGreek"; String reference = "G3588"; - String assertion = "3588 ho ho, including the feminine"; - backendTest(version, reference, assertion); + backendTest(version, reference, "3588", "ho"); } /** @@ -331,9 +331,7 @@ public void testBackendOt1Nt2Devotional() throws Exception { private String backendTest(String version, String reference, String... assertion) throws NoSuchKeyException, BookException { final Book currentBook = Books.installed().getBook(version); - if (currentBook == null) { - return null; - } + Assume.assumeTrue("Book " + version + " is installed", currentBook != null); return backendTest(currentBook, currentBook.getKey(reference), assertion); } diff --git a/src/test/java/org/crosswire/jsword/bridge/DwrBridgeMissingAssetsTest.java b/src/test/java/org/crosswire/jsword/bridge/DwrBridgeMissingAssetsTest.java index e5dd8804c..40beaa301 100644 --- a/src/test/java/org/crosswire/jsword/bridge/DwrBridgeMissingAssetsTest.java +++ b/src/test/java/org/crosswire/jsword/bridge/DwrBridgeMissingAssetsTest.java @@ -22,10 +22,7 @@ import org.crosswire.jsword.book.BookException; import org.crosswire.jsword.passage.NoSuchKeyException; import org.crosswire.jsword.versification.BookName; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.*; /** * Test of functionality for use with DWR. This test assumes, at a minimum, that @@ -42,6 +39,10 @@ public class DwrBridgeMissingAssetsTest { @Before public void setUp() { BookName.setFullBookName(true); + + Assume.assumeTrue("KJV must be installed", BookInstaller.getInstalledBook("KJV") != null); + Assume.assumeTrue("StrongsHebrew must be installed", BookInstaller.getInstalledBook("StrongsHebrew") != null); + Assume.assumeTrue("StrongsGreek must be installed", BookInstaller.getInstalledBook("StrongsGreek") != null); } @Test diff --git a/src/test/java/org/crosswire/jsword/prerequisites/BookPreRequisitesTest.java b/src/test/java/org/crosswire/jsword/prerequisites/BookPreRequisitesTest.java index eccbf144f..19cba465a 100644 --- a/src/test/java/org/crosswire/jsword/prerequisites/BookPreRequisitesTest.java +++ b/src/test/java/org/crosswire/jsword/prerequisites/BookPreRequisitesTest.java @@ -67,6 +67,11 @@ public void testInstallBook() { private BookInstaller underTest; private Books installedBooks; - private static final String[] BOOKS = new String[]{"KJV", "ESV2011"}; + /** + * All books referenced in these unit tests that can be retrieved from the Crosswire repository. + * Currently missing : ESV2011, MHCC, ot1nt2 + * Tests that reference a currently missing book are automatically skipped unless the book was installed externally. + */ + private static final String[] BOOKS = new String[]{"KJV", "StrongsHebrew", "StrongsGreek", "Josephus", "Nave", "Geneva", "TurNTB"}; private static final Logger LOGGER = LoggerFactory.getLogger(BookPreRequisitesTest.class); }