swrlapi
swrlapi copied to clipboard
Failure in Integration test TestSQWRLOrderByTime(org.swrlapi.sqwrl.SQWRLCoreIT)
Hello, I'm having problems with the integration tests, as described in the title, and below. I downloaded the integration tests as part of the build project from the swrlapi buildproject, version 1.1.4
I'm using the command:
mvn -Dit.test=org.swrlapi.sqwrl.SQWRLCoreIT verify
The other tests seem to work.
The failsafe report is:
-------------------------------------------------------------------------------
Test set: org.swrlapi.sqwrl.SQWRLCoreIT
-------------------------------------------------------------------------------
Tests run: 115, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 209.923 sec <<< FAILURE! - in org.swrlapi.sqwrl.SQWRLCoreIT
TestSQWRLOrderByTime(org.swrlapi.sqwrl.SQWRLCoreIT) Time elapsed: 203.501 sec <<< FAILURE!
org.junit.ComparisonFailure: expected:<p[2]> but was:<p[3]>
at org.swrlapi.sqwrl.SQWRLCoreIT.TestSQWRLOrderByTime(SQWRLCoreIT.java:1513)
It seems that "sqwrl:orderBy" is not ordering the query results as expected. I tried inserting a println command right before the assertion that fails:
SQWRLResult result = queryEngine
.runSQWRLQuery("q1", "hasTOB(?p, ?tob)-> sqwrl:select(?p, ?tob) ^ sqwrl:orderBy(?tob)");
//edited by me!
System.out.println("printing query result: \n" + result.toString());
//end edited part.
Assert.assertTrue(result.next());
Assert.assertTrue(result.getNamedIndividual("p").isNamedIndividual());
Assert.assertEquals("p2", result.getNamedIndividual("p").getShortName());
Assert.assertTrue(result.getLiteral("tob").isTime());
Assert.assertEquals(new XSDTime("09:08:08.3"), result.getLiteral("tob").getTime());
and this is the output I get:
printing query result:
[numberOfColumns: 2, isConfigured: true, isPrepared: true, isRowOpen: false, isOrdered: true, isAscending true, isDistinct: false, hasAggregates: false]
[columnDisplayNames: ]
p3 "11:11:11.11"^^xsd:time
p2 "09:08:08.3"^^xsd:time
p1 "10:10:09.2"^^xsd:time
The order is p3-p2-p1, when it should be, I guess, p2-p1-p3 (a chronological ordering).
Thanks in advance, and sorry if I'm missing something obvious.
-Martin
This is a known issue caused by my use of the non thread safe Date class. (The integration tests run in parallel so can provoke the issue.)
I will take a look at this soon.
OK, thanks! :) So, in the meantime, swrlapi for temporal information should only be used in single-threaded programs, right?
Out of curiosity, do you intend to replace it with the newer, thread-safe, java.time (JSR-310)?
Yes - that is the plan. I hope to get to this task in the next few weeks.