[DS-4409] Don't use live GeoLite database for testing -- there might not be one.

This commit is contained in:
Mark H. Wood
2020-01-07 16:23:17 -05:00
parent e018386175
commit 692bbd9449

View File

@@ -10,9 +10,7 @@ package org.dspace.statistics;
import java.io.File; import java.io.File;
import com.maxmind.geoip2.DatabaseReader; import com.maxmind.geoip2.DatabaseReader;
import org.dspace.services.ConfigurationService;
import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* Mock service that uses an embedded SOLR server for the statistics core. * Mock service that uses an embedded SOLR server for the statistics core.
@@ -21,9 +19,6 @@ public class MockSolrLoggerServiceImpl
extends SolrLoggerServiceImpl extends SolrLoggerServiceImpl
implements InitializingBean { implements InitializingBean {
@Autowired(required = true)
private ConfigurationService configurationService;
public MockSolrLoggerServiceImpl() { public MockSolrLoggerServiceImpl() {
} }
@@ -34,9 +29,8 @@ public class MockSolrLoggerServiceImpl
new FakeDatabaseReader(); // Activate fake new FakeDatabaseReader(); // Activate fake
new FakeDatabaseReader.Builder(); // Activate fake new FakeDatabaseReader.Builder(); // Activate fake
String locationDbPath = configurationService.getProperty("usage-statistics.dbfile"); File locationDb = File.createTempFile("GeoIP", ".db");
File locationDb = new File(locationDbPath); locationDb.deleteOnExit();
locationDb.createNewFile();
locationService = new DatabaseReader.Builder(locationDb).build(); locationService = new DatabaseReader.Builder(locationDb).build();
} }