diff --git a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/SparqlRouteTests.scala b/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/SparqlRouteTests.scala index 9ef3025ee..a3302ab8a 100644 --- a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/SparqlRouteTests.scala +++ b/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/SparqlRouteTests.scala @@ -11,7 +11,7 @@ import akka.http.scaladsl.testkit.RouteTestTimeout import akka.http.scaladsl.testkit.ScalatestRouteTest import akka.pattern.after import eu.icoscp.envri.Envri -import org.scalatest.DoNotDiscover +import org.scalatest.BeforeAndAfterAll import org.scalatest.compatible.Assertion import org.scalatest.funspec.AsyncFunSpec import se.lu.nateko.cp.meta.SparqlServerConfig @@ -20,19 +20,21 @@ import se.lu.nateko.cp.meta.core.data.EnvriConfig import se.lu.nateko.cp.meta.core.data.EnvriConfigs import se.lu.nateko.cp.meta.routes.SparqlRoute import se.lu.nateko.cp.meta.services.sparql.Rdf4jSparqlServer -import se.lu.nateko.cp.meta.test.services.sparql.TestDbFixture import java.net.URI -import scala.concurrent.Await import scala.concurrent.Future import concurrent.duration.DurationInt +import se.lu.nateko.cp.meta.test.services.sparql.regression.TestDb -@DoNotDiscover -class SparqlRouteTests extends AsyncFunSpec with ScalatestRouteTest with TestDbFixture: +class SparqlRouteTests extends AsyncFunSpec with ScalatestRouteTest with BeforeAndAfterAll: import system.{log} + val db = new TestDb("sparqlRoutingTesting") + + override protected def afterAll(): Unit = db.cleanup() + val numberOfParallelQueries = 2 private val reqOrigin = "https://example4567.icos-cp.eu" val sparqlConfig = new SparqlServerConfig(5, 2, 2, numberOfParallelQueries, 0, 10, 8388608, Seq("test@nateko.lu.se")) diff --git a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/TestDbSuites.scala b/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/TestDbSuites.scala deleted file mode 100644 index c6d76a0fe..000000000 --- a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/TestDbSuites.scala +++ /dev/null @@ -1,17 +0,0 @@ -package se.lu.nateko.cp.meta.test.services.sparql - -import org.scalatest.BeforeAndAfterAll -import org.scalatest.Suite -import se.lu.nateko.cp.meta.test.services.sparql.regression.QueryTests -import se.lu.nateko.cp.meta.test.services.sparql.regression.TestDb - - -trait TestDbFixture: - val db: TestDb = TestDb.instance - -class TestDbSuites extends Suite with BeforeAndAfterAll: - override protected def afterAll(): Unit = - TestDb.instance.cleanup() - super.afterAll() - - override def nestedSuites = IndexedSeq(new QueryTests, new SparqlRouteTests) diff --git a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/SparqlTests.scala b/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/QueryTests.scala similarity index 98% rename from src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/SparqlTests.scala rename to src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/QueryTests.scala index 77da4c165..876e8b287 100644 --- a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/SparqlTests.scala +++ b/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/QueryTests.scala @@ -6,21 +6,20 @@ import org.eclipse.rdf4j.model.vocabulary.XSD import org.eclipse.rdf4j.query.BindingSet import org.scalatest import org.scalatest.BeforeAndAfterAll -import org.scalatest.DoNotDiscover import org.scalatest.Informer import org.scalatest.compatible.Assertion import org.scalatest.funspec.AsyncFunSpec import se.lu.nateko.cp.meta.api.CloseableIterator -import se.lu.nateko.cp.meta.test.services.sparql.TestDbFixture -import se.lu.nateko.cp.meta.utils.rdf4j.createDateTimeLiteral -import se.lu.nateko.cp.meta.utils.rdf4j.createLiteral import scala.concurrent.ExecutionContext import scala.concurrent.Future import scala.jdk.CollectionConverters.IterableHasAsScala -@DoNotDiscover -class QueryTests extends AsyncFunSpec with TestDbFixture { +class QueryTests extends AsyncFunSpec with BeforeAndAfterAll { + + val db = new TestDb("sparqlRegrTesting") + + override protected def afterAll(): Unit = db.cleanup() def timedExecution[T](f: Future[T], executedFunction: String, info: Informer)(using ExecutionContext) = { val start = System.currentTimeMillis() diff --git a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/TestDb.scala b/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/TestDb.scala index 6f0b4c912..1cec9dc09 100644 --- a/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/TestDb.scala +++ b/src/test/scala/se/lu/nateko/cp/meta/test/services/sparql/regression/TestDb.scala @@ -42,15 +42,15 @@ import java.nio.file.Files import scala.collection.concurrent.TrieMap import scala.concurrent.Future -class TestDb { +class TestDb(name: String) { private val metaConf = se.lu.nateko.cp.meta.ConfigLoader.default val akkaConf = ConfigFactory.defaultReference() .withValue("akka.loglevel", ConfigValueFactory.fromAnyRef("INFO")) - private given system: ActorSystem = ActorSystem("sparqlRegrTesting", akkaConf) + private given system: ActorSystem = ActorSystem(name, akkaConf) import system.{dispatcher, log} - val dir = Files.createTempDirectory("sparqlRegrTesting").toAbsolutePath + val dir = Files.createTempDirectory(name).toAbsolutePath def runSparql(query: String): Future[CloseableIterator[BindingSet]] = repo.map(new Rdf4jSparqlRunner(_).evaluateTupleQuery(SparqlQuery(query))) @@ -143,5 +143,3 @@ object TestDb: ("http://meta.icos-cp.eu/ontologies/stationentry/" -> "stationEntry.owl") + ("http://meta.icos-cp.eu/collections/" -> "collections.rdf") + ("http://meta.icos-cp.eu/documents/" -> "icosdocs.rdf") - - lazy val instance = new TestDb