4141import com .marklogic .client .query .StructuredQueryDefinition ;
4242
4343public class BitemporalTest {
44- // bootstrap.xqy sets up the "temporal-collection" and required underlying axes
44+ // src/test/resources/bootstrap.xqy is run by src/test/resources/boot-test.sh
45+ // and sets up the "temporal-collection" and required underlying axes
4546 // system-axis and valid-axis which have required underlying range indexes
4647 // system-start, system-end, valid-start, and valid-end
4748 static String temporalCollection = "temporal-collection" ;
@@ -66,29 +67,29 @@ public void test1() throws Exception {
6667 uniqueTerm + " version1" +
6768 "<system-start></system-start>" +
6869 "<system-end></system-end>" +
69- "<valid-start>2014-08-19T00:00:00 </valid-start>" +
70- "<valid-end>2014-08-19T00:00:01 </valid-end>" +
70+ "<valid-start>2014-08-19T00:00:00Z </valid-start>" +
71+ "<valid-end>2014-08-19T00:00:01Z </valid-end>" +
7172 "</test>" ;
7273 String version2 = "<test>" +
7374 uniqueTerm + " version2" +
7475 "<system-start></system-start>" +
7576 "<system-end></system-end>" +
76- "<valid-start>2014-08-19T00:00:02 </valid-start>" +
77- "<valid-end>2014-08-19T00:00:03 </valid-end>" +
77+ "<valid-start>2014-08-19T00:00:02Z </valid-start>" +
78+ "<valid-end>2014-08-19T00:00:03Z </valid-end>" +
7879 "</test>" ;
7980 String version3 = "<test>" +
8081 uniqueTerm + " version3" +
8182 "<system-start></system-start>" +
8283 "<system-end></system-end>" +
83- "<valid-start>2014-08-19T00:00:03 </valid-start>" +
84- "<valid-end>2014-08-19T00:00:04 </valid-end>" +
84+ "<valid-start>2014-08-19T00:00:03Z </valid-start>" +
85+ "<valid-end>2014-08-19T00:00:04Z </valid-end>" +
8586 "</test>" ;
8687 String version4 = "<test>" +
8788 uniqueTerm + " version4" +
8889 "<system-start></system-start>" +
8990 "<system-end></system-end>" +
90- "<valid-start>2014-08-19T00:00:05 </valid-start>" +
91- "<valid-end>2014-08-19T00:00:06 </valid-end>" +
91+ "<valid-start>2014-08-19T00:00:05Z </valid-start>" +
92+ "<valid-end>2014-08-19T00:00:06Z </valid-end>" +
9293 "</test>" ;
9394 XMLDocumentManager docMgr = Common .client .newXMLDocumentManager ();
9495 StringHandle handle1 = new StringHandle (version1 ).withFormat (Format .XML );
@@ -112,24 +113,26 @@ public void test1() throws Exception {
112113 DocumentPage termQueryResults = docMgr .search (termQuery , start );
113114 assertEquals ("Wrong number of results" , 4 , termQueryResults .size ());
114115
115- // sleep for 2 seconds
116+ // temporal-collection is configured to automatically advance lsqt every 1 second
117+ // so we'll sleep for 2 seconds to make sure lsqt has advanced beyond the lsqt
118+ // when we inserted our documents
116119 Thread .sleep (2000 );
117120 StructuredQueryDefinition currentQuery = sqb .temporalLsqtQuery (temporalCollection , null , 1 );
118121 StructuredQueryDefinition currentDocQuery = sqb .and (termQuery , currentQuery );
119122 DocumentPage currentDocQueryResults = docMgr .search (currentDocQuery , start );
120123 assertEquals ("Wrong number of results" , 4 , currentDocQueryResults .size ());
121124
122125 StructuredQueryBuilder .Axis validAxis = sqb .axis ("valid-axis" );
123- Calendar start1 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:00 " );
124- Calendar end1 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:04 " );
126+ Calendar start1 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:00Z " );
127+ Calendar end1 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:04Z " );
125128 StructuredQueryBuilder .Period period1 = sqb .period (start1 , end1 );
126129 StructuredQueryDefinition periodQuery1 = sqb .and (sqb .term (uniqueTerm ),
127130 sqb .temporalPeriodRange (validAxis , TemporalOperator .ALN_CONTAINED_BY , period1 ));
128131 DocumentPage periodQuery1Results = docMgr .search (periodQuery1 , start );
129132 assertEquals ("Wrong number of results" , 1 , periodQuery1Results .size ());
130133
131- Calendar start2 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:04 " );
132- Calendar end2 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:07 " );
134+ Calendar start2 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:04Z " );
135+ Calendar end2 = DatatypeConverter .parseDateTime ("2014-08-19T00:00:07Z " );
133136 StructuredQueryBuilder .Period period2 = sqb .period (start2 , end2 );
134137 StructuredQueryDefinition periodQuery2 = sqb .and (sqb .term (uniqueTerm ),
135138 sqb .temporalPeriodRange (validAxis , TemporalOperator .ALN_CONTAINED_BY , period2 ));
0 commit comments