Skip to content

Commit

Permalink
Make unittests run on solrJ 9.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
VictorHarbo committed Aug 1, 2024
1 parent e588b95 commit 40c5cdd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 35 deletions.
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,20 +113,20 @@
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>9.1.0</version>
<version>9.4.1</version>
</dependency>

<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-test-framework</artifactId>
<version>9.1.0</version>
<version>9.4.1</version>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.solr/solr-core -->
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>9.1.0</version>
<version>9.4.1</version>
<scope>test</scope>
<exclusions>
<exclusion>
Expand All @@ -140,7 +140,7 @@
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>9.2.0</version>
<version>9.8.0</version>
<scope>test</scope>
</dependency>

Expand Down
19 changes: 8 additions & 11 deletions src/test/java/dk/kb/netarchivesuite/solrwayback/SolrStatsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,29 @@
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;

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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!
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 40c5cdd

Please sign in to comment.