Skip to content
This repository was archived by the owner on Oct 8, 2020. It is now read-only.

Commit 413e2a6

Browse files
Fixed issue with running tests from CLI.
Fixed error when calling `mvn install` by modifying the `maven-dependency-plugin` config. Closes #2.
1 parent 154275a commit 413e2a6

5 files changed

Lines changed: 32 additions & 26 deletions

File tree

sansa-inference-spark/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,8 @@
287287
<!--<version>3.0.1</version>-->
288288
<executions>
289289
<execution>
290-
<id>unpack</id>
291-
<phase>package</phase>
290+
<id>resource-dependencies</id>
291+
<phase>install</phase>
292292
<goals>
293293
<goal>unpack-dependencies</goal>
294294
</goals>
@@ -297,7 +297,7 @@
297297
<includeArtifactIds>sansa-inference-tests_${scala.binary.version}</includeArtifactIds>
298298
<excludeTransitive>true</excludeTransitive>
299299
<overWriteIfNewer>true</overWriteIfNewer>
300-
<outputDirectory>${project.build.directory}/core-resources</outputDirectory>
300+
<outputDirectory>${project.build.directory}/test-classes</outputDirectory>
301301
<excludes>org/**,META-INF/**,rebel.xml</excludes>
302302
<overWriteReleases>true</overWriteReleases>
303303
<overWriteSnapshots>true</overWriteSnapshots>

sansa-inference-tests/src/test/scala/net/sansa_stack/test/conformance/ConformanceTestBase.scala

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package net.sansa_stack.test.conformance
22

33
import java.io.File
44

5+
import net.sansa_stack.inference.data.{RDF, RDFOps}
56
import org.apache.jena.rdf.model.Model
6-
import org.junit.runner.RunWith
7-
import net.sansa_stack.inference.data.{RDF, RDFOps, RDFTriple}
87
import org.apache.jena.shared.PrefixMapping
9-
import org.apache.jena.sparql.util.{FmtUtils, PrefixMapping2}
8+
import org.junit.runner.RunWith
109
import org.scalatest.junit.JUnitRunner
1110
import org.scalatest.{BeforeAndAfterAll, FlatSpec}
1211

@@ -27,33 +26,42 @@ abstract class ConformanceTestBase[Rdf <: RDF](val rdfOps: RDFOps[Rdf]) extends
2726
def testCaseIds: Set[String]
2827

2928
// the base directory of the test cases
30-
def testsCasesFolder: File
29+
def testsCasesFolder: File = {
30+
new File(this.getClass.getClassLoader.getResource(testCasesPath).getPath)
31+
}
3132

32-
val pm = PrefixMapping.Factory.create()
33+
def testCasesPath: String
34+
35+
private val pm = PrefixMapping.Factory.create()
3336
.setNsPrefix("ex", "http://www.example.org#")
3437
.setNsPrefix("", "http://www.example.org#")
3538
.withDefaultMappings(PrefixMapping.Standard)
3639

3740
// load the test cases
38-
val testCases = TestCases.loadTestCases(testsCasesFolder).filter(t => testCaseIds.contains(t.id))
41+
private val testCases = TestCases.loadTestCases(testsCasesFolder, testCaseIds)
3942

40-
testCases.foreach{testCase =>
43+
// scalastyle:off println
44+
testCases.foreach { testCase =>
4145
println(testCase.id)
4246

4347
testCase.id should "produce the same graph" in {
4448
val triples = new mutable.HashSet[Rdf#Triple]()
4549

4650
// convert to internal triples
4751
val iterator = testCase.inputGraph.listStatements()
48-
while(iterator.hasNext) {
52+
while (iterator.hasNext) {
4953
val st = iterator.next()
5054
triples.add(
5155
rdfOps.makeTriple(
5256
rdfOps.makeUri(st.getSubject.toString),
5357
rdfOps.makeUri(st.getPredicate.toString),
54-
if(st.getObject.isLiteral)
55-
rdfOps.makeLiteral(st.getObject.asLiteral().getLexicalForm, rdfOps.makeUri(st.getObject.asLiteral().getDatatypeURI))
56-
else rdfOps.makeUri(st.getObject.toString)))
58+
if (st.getObject.isLiteral) {
59+
rdfOps.makeLiteral(st.getObject.asLiteral().getLexicalForm, rdfOps.makeUri(st.getObject.asLiteral().getDatatypeURI))
60+
} else {
61+
rdfOps.makeUri(st.getObject.toString)
62+
}
63+
)
64+
)
5765
}
5866

5967
// compute inferred graph
@@ -82,5 +90,4 @@ abstract class ConformanceTestBase[Rdf <: RDF](val rdfOps: RDFOps[Rdf]) extends
8290
}
8391

8492
def computeInferredModel(triples: mutable.HashSet[Rdf#Triple]): Model
85-
8693
}

sansa-inference-tests/src/test/scala/net/sansa_stack/test/conformance/OWLHorstConformanceTestBase.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package net.sansa_stack.test.conformance
22

3-
import java.io.File
4-
5-
import net.sansa_stack.inference.data.{JenaOps, RDF, RDFOps}
3+
import net.sansa_stack.inference.data.{RDF, RDFOps}
64
import org.junit.runner.RunWith
75
import org.scalatest.junit.JUnitRunner
86

@@ -18,6 +16,8 @@ abstract class OWLHorstConformanceTestBase[Rdf <: RDF](override val rdfOps: RDFO
1816

1917
behavior of "conformance of OWL Horst entailment rules"
2018

19+
override def testCasesPath: String = "data/conformance/owl2rl"
20+
2121
override def testCaseIds: Set[String] = Set(
2222
"rdfbased-sem-rdfs-domain-cond",
2323
"rdfbased-sem-rdfs-range-cond",
@@ -40,6 +40,4 @@ abstract class OWLHorstConformanceTestBase[Rdf <: RDF](override val rdfOps: RDFO
4040
"rdfbased-sem-restrict-somevalues-inst-subj",
4141
"rdfbased-sem-restrict-allvalues-inst-obj"
4242
)
43-
44-
override def testsCasesFolder: File = new File(this.getClass.getClassLoader.getResource("data/conformance/owl2rl").getPath)
4543
}

sansa-inference-tests/src/test/scala/net/sansa_stack/test/conformance/RDFSConformanceTestBase.scala

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package net.sansa_stack.test.conformance
22

3-
import java.io.File
4-
5-
import net.sansa_stack.inference.data.{Jena, RDF, RDFOps}
3+
import net.sansa_stack.inference.data.{RDF, RDFOps}
64
import org.junit.runner.RunWith
75
import org.scalatest.junit.JUnitRunner
86

@@ -18,13 +16,13 @@ abstract class RDFSConformanceTestBase[Rdf <: RDF](override val rdfOps: RDFOps[R
1816

1917
behavior of "conformance of RDFS(simple) entailment rules"
2018

19+
override def testCasesPath: String = "data/conformance/rdfs"
20+
2121
override def testCaseIds: Set[String] = Set(
2222
"rdfbased-sem-rdfs-domain-cond",
2323
"rdfbased-sem-rdfs-range-cond",
2424
"rdfbased-sem-rdfs-subclass-cond",
2525
"rdfbased-sem-rdfs-subclass-trans",
2626
"rdfbased-sem-rdfs-subprop-cond",
2727
"rdfbased-sem-rdfs-subprop-trans")
28-
29-
override def testsCasesFolder: File = new File(this.getClass.getClassLoader.getResource("data/conformance/rdfs").getPath)
3028
}

sansa-inference-tests/src/test/scala/net/sansa_stack/test/conformance/TestCases.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ object TestCases {
2121
* @return test cases
2222
*/
2323
def loadTestCases(directory: File, ids: Set[String] = Set.empty): Seq[TestCase] = {
24+
println("loading test cases ...")
2425

2526
val testCases = new ListBuffer[TestCase]()
2627

@@ -45,7 +46,7 @@ object TestCases {
4546
val entailmentType = (metadata \\ "entry").filter(n => n.attribute("key").get.text == "testcase.type").text
4647

4748
// currently we support only entailment test cases
48-
if(entailmentType == "POSITIVE_ENTAILMENT") {
49+
if (entailmentType == "POSITIVE_ENTAILMENT") {
4950
// load input data
5051
val inputGraph = RDFDataMgr.loadModel(files.filter(_.getName.endsWith(".premisegraph.ttl")).head.getPath)
5152

@@ -54,7 +55,9 @@ object TestCases {
5455

5556
testCases += TestCase(id, description, entailmentType, inputGraph, outputGraph)
5657
}
58+
5759
}
60+
println(s"loaded ${testCases.size} test cases")
5861

5962
testCases
6063
}

0 commit comments

Comments
 (0)