Skip to content

Commit

Permalink
Merge pull request #33 from charvolant/master
Browse files Browse the repository at this point in the history
Fix test cases in travis
  • Loading branch information
charvolant authored Feb 9, 2021
2 parents fd37804 + 412034c commit b2b8157
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 22 deletions.
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@
<groupId>au.org.ala</groupId>
<artifactId>ala-name-matching</artifactId>
<version>3.5</version>
<exclusions>
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
</exclusion>
</exclusions>
<scope>compile</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/au/org/ala/sds/ExoticBiologicalControlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import au.org.ala.names.search.ALANameSearcher;
import au.org.ala.sds.model.SensitiveTaxon;
import au.org.ala.sds.util.Configuration;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.*;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -34,8 +35,7 @@ public class ExoticBiologicalControlTest {

@BeforeClass
public static void runOnce() throws Exception {

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
System.out.println(Configuration.getInstance().getNameMatchingIndex());
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//The URI to the test list - only contains entries that are used in one or more the the tests
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/au/org/ala/sds/GeneraliseTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.Map;

import au.org.ala.sds.util.TestUtils;
import org.junit.BeforeClass;
import org.junit.Test;

Expand Down Expand Up @@ -51,7 +52,7 @@ public static void runOnce() throws Exception {
// ((BasicDataSource) dataSource).setUsername("root");
// ((BasicDataSource) dataSource).setPassword("password");

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//finder = SensitiveSpeciesFinderFactory.getSensitiveSpeciesFinder(cbIndexSearch);
String uri = nameSearcher.getClass().getClassLoader().getResource("sensitive-species.xml").toURI().toString();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/au/org/ala/sds/PlantPestCategory5Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import au.org.ala.sds.model.SensitiveTaxon;
import au.org.ala.sds.util.Configuration;
import au.org.ala.sds.util.PlantPestUtils;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.MessageFactory;
import au.org.ala.sds.validation.ServiceFactory;
import au.org.ala.sds.validation.ValidationOutcome;
Expand Down Expand Up @@ -46,7 +47,7 @@ public class PlantPestCategory5Test {
@BeforeClass
public static void runOnce() throws Exception {

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
System.out.println(Configuration.getInstance().getNameMatchingIndex());
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//The URI to the test list - only contains entries that are used in one or more the the tests
Expand Down
5 changes: 4 additions & 1 deletion src/test/java/au/org/ala/sds/PlantPestEradicatedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import au.org.ala.sds.model.Message;
import au.org.ala.sds.util.AUWorkarounds;
import au.org.ala.sds.util.GeoLocationHelper;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.*;
import org.junit.BeforeClass;
import org.junit.Ignore;
Expand Down Expand Up @@ -50,7 +51,9 @@ public static void runOnce() throws Exception {
// ((BasicDataSource) dataSource).setUsername("root");
// ((BasicDataSource) dataSource).setPassword("password");

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
Configuration.getInstance().setZoneUrl(PlantPestEradicatedTest.class.getResource("/sensitivity-zones.xml").toExternalForm());
Configuration.getInstance().setCategoriesUrl(PlantPestEradicatedTest.class.getResource("/sensitivity-categories.xml").toExternalForm());
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//finder = SensitiveSpeciesFinderFactory.getSensitiveSpeciesFinder("file:///data/sds/sensitive-species-new.xml", cbIndexSearch);
String uri = nameSearcher.getClass().getClassLoader().getResource("sensitive-species.xml").toURI().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import au.org.ala.sds.model.SensitiveTaxon;
import au.org.ala.sds.util.Configuration;
import au.org.ala.sds.util.PlantPestUtils;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.*;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -39,7 +40,7 @@ public class PlantPestIdentifiedToHigherTaxonTest {
@BeforeClass
public static void runOnce() throws Exception {

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
System.out.println(Configuration.getInstance().getNameMatchingIndex());
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//The URI to the test list - only contains entries that are used in one or more the the tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.util.Map;

import au.org.ala.sds.model.Message;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.*;
import org.junit.BeforeClass;
import org.junit.Ignore;
Expand All @@ -45,7 +46,7 @@ public class PlantPestNotKnownInAustraliaTest {
@BeforeClass
public static void runOnce() throws Exception {

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//use test versions
// Configuration.getInstance().setZoneUrl(nameSearcher.getClass().getClassLoader().getResource("sensitivity-zones.xml").toURI().toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import au.org.ala.sds.model.Message;
import au.org.ala.sds.util.AUWorkarounds;
import au.org.ala.sds.util.GeoLocationHelper;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.*;
import org.junit.BeforeClass;
import org.junit.Ignore;
Expand Down Expand Up @@ -51,7 +52,7 @@ public static void runOnce() throws Exception {
// ((BasicDataSource) dataSource).setUsername("root");
// ((BasicDataSource) dataSource).setPassword("password");

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//finder = SensitiveSpeciesFinderFactory.getSensitiveSpeciesFinder("file:///data/sds/sensitive-species-test.xml", cbIndexSearch);
String uri = nameSearcher.getClass().getClassLoader().getResource("sensitive-species.xml").toURI().toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import au.org.ala.sds.model.SensitiveTaxon;
import au.org.ala.sds.util.AUWorkarounds;
import au.org.ala.sds.util.GeoLocationHelper;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.*;
import org.junit.BeforeClass;
import org.junit.Test;
Expand Down Expand Up @@ -51,7 +52,7 @@ public static void runOnce() throws Exception {
// ((BasicDataSource) dataSource).setUsername("root");
// ((BasicDataSource) dataSource).setPassword("password");

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//finder = SensitiveSpeciesFinderFactory.getSensitiveSpeciesFinder("file:///data/sds/sensitive-species-new.xml", cbIndexSearch);
String uri = nameSearcher.getClass().getClassLoader().getResource("sensitive-species.xml").toURI().toString();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/au/org/ala/sds/ProblematicFileInputTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.Map;

import au.org.ala.sds.util.TestUtils;
import org.apache.commons.lang.StringUtils;
import org.junit.BeforeClass;
import org.junit.Test;
Expand All @@ -26,7 +27,7 @@ public class ProblematicFileInputTest {

//@BeforeClass
public static void runOnce() throws Exception {
System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
finder = SensitiveSpeciesFinderFactory.getSensitiveSpeciesFinder("file:///data/sds/sensitive-species.xml", nameSearcher);
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/au/org/ala/sds/ScotlandTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import au.org.ala.sds.model.SensitiveTaxon;
import au.org.ala.sds.model.SensitivityZoneFactory;
import au.org.ala.sds.util.Configuration;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.ValidationOutcome;
import org.junit.AfterClass;
import org.junit.BeforeClass;
Expand All @@ -25,7 +26,7 @@ public class ScotlandTests {
@BeforeClass
public static void runOnce() throws Exception {

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
SensitivityZoneFactory.reset(); //FIXME this isnt pleasant
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
String uri = nameSearcher.getClass().getClassLoader().getResource("sensitive-species-scotland.xml").toURI().toString();
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/au/org/ala/sds/SearchTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import au.org.ala.names.search.ALANameSearcher;
import au.org.ala.sds.model.SensitiveTaxon;
import au.org.ala.sds.util.Configuration;
import au.org.ala.sds.util.TestUtils;
import org.junit.BeforeClass;
import org.junit.Test;

Expand All @@ -33,7 +34,7 @@ public class SearchTest {

@BeforeClass
public static void runOnce() throws Exception {
System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
String uri = nameSearcher.getClass().getClassLoader().getResource("sensitive-species.xml").toURI().toString();
finder = SensitiveSpeciesFinderFactory.getSensitiveSpeciesFinder(uri, nameSearcher, true);
Expand Down
3 changes: 2 additions & 1 deletion src/test/java/au/org/ala/sds/SensitiveDataServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import au.org.ala.names.search.ALANameSearcher;
import au.org.ala.sds.util.Configuration;
import au.org.ala.sds.util.TestUtils;
import au.org.ala.sds.validation.FactCollection;
import au.org.ala.sds.validation.MessageFactory;
import au.org.ala.sds.validation.ValidationOutcome;
Expand All @@ -41,7 +42,7 @@ public class SensitiveDataServiceTest {
@BeforeClass
public static void runOnce() throws Exception {

System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
System.out.println(Configuration.getInstance().getNameMatchingIndex());
nameSearcher = new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex());
//The URI to the test list - only contains entries that are used in one or more the the tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
import au.org.ala.sds.SensitiveSpeciesFinder;
import au.org.ala.sds.SensitiveSpeciesFinderFactory;
import au.org.ala.sds.util.Configuration;
import au.org.ala.sds.util.TestUtils;
import org.junit.Test;

public class SensitiveSpeciesStoreTest {
@Test
public void testCreate() throws Exception {
System.setProperty("sds.config.file", "/sds-test.properties");
Configuration.getInstance().setSpeciesUrl(SensitiveSpeciesStoreTest.class.getResource("/sensitive-species.xml").toExternalForm());
Configuration.getInstance().setZoneUrl(SensitiveSpeciesStoreTest.class.getResource("/sensitivity-zones.xml").toExternalForm());
Configuration.getInstance().setCategoriesUrl(SensitiveSpeciesStoreTest.class.getResource("/sensitivity-categories.xml").toExternalForm());
TestUtils.initConfig();
SensitiveSpeciesFinder finder = SensitiveSpeciesFinderFactory.getSensitiveSpeciesFinder(new ALANameSearcher(Configuration.getInstance().getNameMatchingIndex()));
SensitiveTaxon taxon = finder.findSensitiveSpecies("Acacia dealbata");
}
Expand Down
10 changes: 8 additions & 2 deletions src/test/java/au/org/ala/sds/model/SensitivityZoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,18 @@
***************************************************************************/
package au.org.ala.sds.model;

import au.org.ala.sds.util.TestUtils;
import org.junit.BeforeClass;
import org.junit.Test;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;

public class SensitivityZoneTest {
@BeforeClass
public static void runOnce() throws Exception {
TestUtils.initConfig();
}

@Test
public void isInAustralia() {
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/au/org/ala/sds/util/GeoLocationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class GeoLocationTest {

@BeforeClass
public static void runOnce() throws Exception {
System.setProperty("sds.config.file", "/sds-test.properties");
TestUtils.initConfig();
}


Expand Down
20 changes: 20 additions & 0 deletions src/test/java/au/org/ala/sds/util/TestUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package au.org.ala.sds.util;

import au.org.ala.names.search.ALANameSearcher;
import au.org.ala.sds.PlantPestEradicatedTest;
import au.org.ala.sds.SensitiveSpeciesFinderFactory;

public class TestUtils {
/**
* Set up a common configuration
*
* @throws Exception
*/
public static void initConfig() throws Exception {
System.setProperty("sds.config.file", "/sds-test.properties");
Configuration.getInstance().setSpeciesUrl(TestUtils.class.getResource("/sensitive-species.xml").toExternalForm());
Configuration.getInstance().setZoneUrl(TestUtils.class.getResource("/sensitivity-zones.xml").toExternalForm());
Configuration.getInstance().setCategoriesUrl(TestUtils.class.getResource("/sensitivity-categories.xml").toExternalForm());
}

}
4 changes: 2 additions & 2 deletions src/test/resources/log4j.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<!-- Appenders -->
<appender name="console" class="org.apache.log4j.ConsoleAppender">
<param name="Threshold" value="warn"/>
<param name="Threshold" value="info"/>
<param name="Target" value="System.out" />
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5p: [%c{5}] %m%n" />
Expand All @@ -27,7 +27,7 @@

<!-- Root Logger -->
<root>
<level value="warn" />
<level value="info" />
<appender-ref ref="console" />
</root>

Expand Down

0 comments on commit b2b8157

Please sign in to comment.