From 40c5cdd4aa63dea240469148c4001a3432381750 Mon Sep 17 00:00:00 2001 From: Victor Harbo Johnston Date: Thu, 1 Aug 2024 23:03:04 +0200 Subject: [PATCH 1/2] Make unittests run on solrJ 9.4.0 --- pom.xml | 8 ++--- .../solrwayback/SolrStatsTest.java | 19 +++++------- .../solrwayback/solr/EmbeddedSolrTest.java | 29 +++++++++---------- .../solr/SolrStreamDirectTest.java | 7 +++-- .../solrwayback/solr/UrlResolveTest.java | 6 ++-- 5 files changed, 34 insertions(+), 35 deletions(-) diff --git a/pom.xml b/pom.xml index a2e72ced..512d2fbd 100644 --- a/pom.xml +++ b/pom.xml @@ -113,20 +113,20 @@ org.apache.solr solr-solrj - 9.1.0 + 9.4.1 org.apache.solr solr-test-framework - 9.1.0 + 9.4.1 test org.apache.solr solr-core - 9.1.0 + 9.4.1 test @@ -140,7 +140,7 @@ org.apache.lucene lucene-core - 9.2.0 + 9.8.0 test diff --git a/src/test/java/dk/kb/netarchivesuite/solrwayback/SolrStatsTest.java b/src/test/java/dk/kb/netarchivesuite/solrwayback/SolrStatsTest.java index 41e10239..aa0e4015 100644 --- a/src/test/java/dk/kb/netarchivesuite/solrwayback/SolrStatsTest.java +++ b/src/test/java/dk/kb/netarchivesuite/solrwayback/SolrStatsTest.java @@ -13,23 +13,18 @@ import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.core.CoreContainer; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; +import org.apache.solr.core.NodeConfig; +import org.junit.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; +import java.util.*; public class SolrStatsTest { private static final Logger log = LoggerFactory.getLogger(SolrStatsTest.class); - private static String solr_home= "target/test-classes/solr_9"; + private static String SOLR_HOME = "target/test-classes/solr_9"; private static NetarchiveSolrClient server = null; private static CoreContainer coreContainer= null; private static EmbeddedSolrServer embeddedServer = null; @@ -37,8 +32,10 @@ public class SolrStatsTest { @Before public void setUp() throws Exception { // Embedded Solr 9.1+ must have absolute home both as env and explicit param - System.setProperty("solr.install.dir", Path.of(solr_home).toAbsolutePath().toString()); - coreContainer = CoreContainer.createAndLoad(Path.of(solr_home).toAbsolutePath()); + Path solrHome = Path.of(SOLR_HOME).toAbsolutePath(); + System.setProperty("solr.install.dir", solrHome.toString()); + NodeConfig nodeConfig = new NodeConfig.NodeConfigBuilder("netarchivebuilder", solrHome).build(); + coreContainer = new CoreContainer(nodeConfig); coreContainer.load(); embeddedServer = new EmbeddedSolrServer(coreContainer,"netarchivebuilder"); NetarchiveSolrTestClient.initializeOverLoadUnitTest(embeddedServer); diff --git a/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/EmbeddedSolrTest.java b/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/EmbeddedSolrTest.java index 2687bb84..994cf610 100644 --- a/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/EmbeddedSolrTest.java +++ b/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/EmbeddedSolrTest.java @@ -4,16 +4,11 @@ import java.nio.file.Path; import java.util.ArrayList; -import java.util.HashSet; -import org.apache.solr.client.solrj.SolrQuery; import org.apache.solr.client.solrj.embedded.EmbeddedSolrServer; -import org.apache.solr.client.solrj.response.QueryResponse; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.core.*; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; +import org.junit.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,23 +18,25 @@ public class EmbeddedSolrTest { private static final Logger log = LoggerFactory.getLogger(EmbeddedSolrTest.class); - private static String solr_home= "target/test-classes/solr_9"; + private static String SOLR_HOME = "target/test-classes/solr_9"; private static NetarchiveSolrClient server = null; private static CoreContainer coreContainer= null; private static EmbeddedSolrServer embeddedServer = null; @Before public void setUp() throws Exception { - // Embedded Solr 9.1+ must have absolute home both as env and explicit param - System.setProperty("solr.install.dir", Path.of(solr_home).toAbsolutePath().toString()); - coreContainer = CoreContainer.createAndLoad(Path.of(solr_home).toAbsolutePath()); - coreContainer.load(); - embeddedServer = new EmbeddedSolrServer(coreContainer,"netarchivebuilder"); - NetarchiveSolrTestClient.initializeOverLoadUnitTest(embeddedServer); - server = NetarchiveSolrClient.getInstance(); - + // Embedded Solr 9.1+ must have absolute home both as env and explicit param + Path solrHome = Path.of(SOLR_HOME).toAbsolutePath(); + System.setProperty("solr.install.dir", solrHome.toString()); + NodeConfig nodeConfig = new NodeConfig.NodeConfigBuilder("netarchivebuilder", solrHome).build(); + coreContainer = new CoreContainer(nodeConfig); + coreContainer.load(); + embeddedServer = new EmbeddedSolrServer(coreContainer,"netarchivebuilder"); + NetarchiveSolrTestClient.initializeOverLoadUnitTest(embeddedServer); + server = NetarchiveSolrClient.getInstance(); + // Remove any items from previous executions: - embeddedServer.deleteByQuery("*:*"); //This is not on the NetarchiveSolrClient API! + embeddedServer.deleteByQuery("*:*"); //This is not on the NetarchiveSolrClient API! } /** diff --git a/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/SolrStreamDirectTest.java b/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/SolrStreamDirectTest.java index 12c15d0b..b20e6b63 100644 --- a/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/SolrStreamDirectTest.java +++ b/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/SolrStreamDirectTest.java @@ -27,6 +27,7 @@ import org.apache.solr.common.SolrDocument; import org.apache.solr.common.SolrInputDocument; import org.apache.solr.core.CoreContainer; +import org.apache.solr.core.NodeConfig; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -62,8 +63,10 @@ public static void setUp() throws Exception { PropertiesLoader.initProperties(UnitTestUtils.getFile("properties/solrwayback_unittest.properties").getPath()); // Embedded Solr 9.1+ must have absolute home both as env and explicit param - System.setProperty("solr.install.dir", Path.of(SOLR_HOME).toAbsolutePath().toString()); - coreContainer = CoreContainer.createAndLoad(Path.of(SOLR_HOME).toAbsolutePath()); + Path solrHome = Path.of(SOLR_HOME).toAbsolutePath(); + System.setProperty("solr.install.dir", solrHome.toString()); + NodeConfig nodeConfig = new NodeConfig.NodeConfigBuilder("netarchivebuilder", solrHome).build(); + coreContainer = new CoreContainer(nodeConfig); coreContainer.load(); embeddedServer = new EmbeddedSolrServer(coreContainer,"netarchivebuilder"); NetarchiveSolrTestClient.initializeOverLoadUnitTest(embeddedServer); diff --git a/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/UrlResolveTest.java b/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/UrlResolveTest.java index 71336aae..b485f60b 100644 --- a/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/UrlResolveTest.java +++ b/src/test/java/dk/kb/netarchivesuite/solrwayback/solr/UrlResolveTest.java @@ -64,8 +64,10 @@ public static void setUp() throws Exception { PropertiesLoader.initProperties(UnitTestUtils.getFile("properties/solrwayback_unittest.properties").getPath()); // Embedded Solr 9.1+ must have absolute home both as env and explicit param - System.setProperty("solr.install.dir", Path.of(SOLR_HOME).toAbsolutePath().toString()); - coreContainer = CoreContainer.createAndLoad(Path.of(SOLR_HOME).toAbsolutePath()); + Path solrHome = Path.of(SOLR_HOME).toAbsolutePath(); + System.setProperty("solr.install.dir", solrHome.toString()); + NodeConfig nodeConfig = new NodeConfig.NodeConfigBuilder("netarchivebuilder", solrHome).build(); + coreContainer = new CoreContainer(nodeConfig); coreContainer.load(); solr = new ConvenientEmbeddedSolrServer(coreContainer, "netarchivebuilder"); NetarchiveSolrTestClient.initializeOverLoadUnitTest(solr); From 0ecd2ef74f8b83f424c8229c12cc1859ccb207aa Mon Sep 17 00:00:00 2001 From: Victor Harbo Johnston Date: Thu, 1 Aug 2024 23:10:39 +0200 Subject: [PATCH 2/2] changelog --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 2939b086..7e94b257 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,8 @@ # SolrWayback changelog +UNRELEASED +----- +Upgraded solr dependencies from v9.1.0 to v9.4.1 5.1.2