@@ -95,7 +95,7 @@ public static void setUp() throws Exception
9595 /*
9696 * Linestring contains Point(point is the endpoint of linestring
9797 */
98- @ Ignore
98+ @ Test
9999 public void testLinestringContainsPoint () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
100100 {
101101 System .out .println ("Running testLinestringContainsPoint" );
@@ -137,29 +137,30 @@ public void testLinestringContainsPoint() throws KeyManagementException, NoSuchA
137137 String snippetFromSummary = null ;
138138 String snippetFromRead = null ;
139139
140- // Making sure that we proper results
141- expectedMap .put ("/Equator-json.json" , "Json Linestring In Equator - South America" );
142- expectedMap .put ("/Equator.xml" , "Linestring In Equator - South America" );
140+ // Making sure that we proper results. Snippets are not complete. Taking in what appears in summary.
141+ expectedMap .put ("/Equator-json.json" , "Json Point In Equator - South America" );
142+ expectedMap .put ("/Equator.xml" , "Point In Equator - South America" );
143143
144144 for (MatchDocumentSummary summary : matches ) {
145145 String docUri = summary .getUri ();
146146 System .out .println ("docURI is " + docUri );
147147 System .out .println ("Snippet from Summary is " + summary .getFirstSnippetText ());
148148 // Get only the numbers. Strip away others. Refer to data files.
149- snippetFromSummary = summary .getFirstSnippetText ().split ("LINESTRING\\ (" )[1 ];
149+ snippetFromSummary = summary .getFirstSnippetText ().split ("LINESTRING\\ (" )[0 ];
150150 // Strip the ... characters from snippets.
151- if (snippetFromSummary .contains ("74.077" ))
152- snippetFromSummary = snippetFromSummary .split ("74.077" )[0 ];
151+ if (snippetFromSummary .contains ("Json" ))
152+ snippetFromSummary = "Json " + snippetFromSummary .split ("Json" )[1 ].trim ();
153+ else
154+ snippetFromSummary = "Point " + snippetFromSummary .split ("Point" )[1 ].trim ();
153155 if (summary .getFormat ().name ().equalsIgnoreCase ("XML" )) {
154156 DOMHandle contentHandle = readDocumentUsingDOMHandle (client , docUri , "XML" );
155157 Document readDoc = contentHandle .get ();
156- linedesc = readDoc .getElementsByTagName ("line-desc" ).item (0 ).getFirstChild ().getNodeValue ();
157- snippetFromRead = readDoc .getElementsByTagName ("linestring" ).item (0 ).getFirstChild ().getNodeValue ();
158- System .out .println ("linedesc from XML file is " + linedesc );
159- System .out .println ("Snippet linestring from XML file is " + snippetFromRead );
158+ linedesc = readDoc .getElementsByTagName ("point-desc" ).item (0 ).getFirstChild ().getNodeValue ().trim ();
159+
160+ System .out .println ("Point desc from XML file is " + linedesc );
160161
161162 // Verify that snippets from qb and read contain the same.
162- assertTrue ("Snippets from summary and from XML file are incorrect " , snippetFromRead .contains (snippetFromSummary ) );
163+ assertTrue ("Snippets from summary and from XML file are incorrect " , linedesc .contains (snippetFromSummary ) );
163164
164165 readDoc = null ;
165166 contentHandle = null ;
@@ -168,13 +169,12 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
168169 JacksonHandle jacksonhandle = new JacksonHandle ();
169170 docMgr .read (docUri , jacksonhandle );
170171 JsonNode resultNode = jacksonhandle .get ();
171- linedesc = resultNode .path ("root" ).path ("item" ).path ("line-desc" ).asText ();
172- snippetFromRead = resultNode .path ("root" ).path ("item" ).path ("linestring" ).asText ();
173- System .out .println ("linedesc from JSON file is " + linedesc );
174- System .out .println ("Snippet linestring from JSON file is " + snippetFromRead );
172+ linedesc = resultNode .path ("root" ).path ("item" ).path ("point-desc" ).asText ().trim ();
173+
174+ System .out .println ("Snippet point-desc from JSON file is " + linedesc );
175175
176176 // Verify that snippets from qb and read contain the same.
177- assertTrue ("Snippets from summary and from JSON file are incorrect " , snippetFromRead .contains (snippetFromSummary ) );
177+ assertTrue ("Snippets from summary and from JSON file are incorrect " , linedesc .contains (snippetFromSummary ) );
178178 jacksonhandle = null ;
179179 resultNode = null ;
180180 }
@@ -187,7 +187,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
187187 /*
188188 * Circle contains circle
189189 */
190- @ Ignore
190+ @ Test
191191 public void testCircleContainsCircle () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
192192 {
193193 System .out .println ("Running testCircleContainsCircle" );
@@ -216,7 +216,7 @@ public void testCircleContainsCircle() throws KeyManagementException, NoSuchAlgo
216216 /*
217217 * Box contains Polygon
218218 */
219- @ Ignore
219+ @ Test
220220 public void testBoxContainsPolygon () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
221221 {
222222 System .out .println ("Running testBoxContainsPolygon" );
@@ -246,7 +246,7 @@ public void testBoxContainsPolygon() throws KeyManagementException, NoSuchAlgori
246246 /*
247247 * Circle intersects Point
248248 */
249- @ Ignore
249+ @ Test
250250 public void testCircleIntersectsPoint () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
251251 {
252252 System .out .println ("Running testCircleIntersectsPoint" );
@@ -287,7 +287,7 @@ public void testCircleIntersectsPoint() throws KeyManagementException, NoSuchAlg
287287 /*
288288 * linestring covered-by Polygon
289289 */
290- @ Ignore
290+ @ Test
291291 public void testcircleCoveredByPolygon () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
292292 {
293293 System .out .println ("Running testcircleCoveredByPolygon" );
@@ -336,7 +336,7 @@ public void testcircleCoveredByPolygon() throws KeyManagementException, NoSuchAl
336336 /*
337337 * Box covers Polygon
338338 */
339- @ Ignore
339+ @ Test
340340 public void testBoxCoversPolygon () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
341341 {
342342 System .out .println ("Running testBoxCoversPolygon" );
@@ -422,7 +422,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
422422 }
423423
424424 /*
425- * Linestring crosses Box TODO Once server side issues are sorted in 4 .0-2
425+ * Linestring crosses Box - TODO to be handled in 9 .0-2 as of 04/112/2017.
426426 */
427427 @ Ignore
428428 public void testLinestringCrossesBox () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
@@ -446,15 +446,14 @@ public void testLinestringCrossesBox() throws KeyManagementException, NoSuchAlgo
446446 JsonNode jsonPointNodes = resultNode .path ("results" );
447447
448448 // Should have 2 nodes returned.
449- //assertEquals("Two nodes not returned from testPolygonCoversBox method ", 2, resultNode.path("total").asInt());
450-
451- // Work on the asserts once server bugs are fixed.
449+ assertEquals ("Two nodes not returned from testPolygonCoversBox method " , 2 , resultNode .path ("total" ).asInt ());
450+
452451 }
453452
454453 /*
455454 * Box overlaps Circle
456455 */
457- @ Ignore
456+ @ Test
458457 public void testBoxOverlapsCircle () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
459458 {
460459 System .out .println ("Running testBoxOverlapsCircle" );
@@ -540,7 +539,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
540539 /*
541540 * Polygon disjoint Polygon - polygon near south east
542541 */
543- @ Ignore
542+ @ Test
544543 public void testPolygonDisjointPolygon () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
545544 {
546545 System .out .println ("Running testPolygonDisjointPolygon" );
@@ -573,7 +572,7 @@ public void testPolygonDisjointPolygon() throws KeyManagementException, NoSuchAl
573572 /*
574573 * Box disjoint Box--except Tropic of Capricorn-Australia
575574 */
576- @ Ignore
575+ @ Test
577576 public void testBoxDisjointBox () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
578577 {
579578 System .out .println ("Running testBoxDisjointBox" );
@@ -654,7 +653,7 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
654653 * Point equals Point
655654 */
656655
657- @ Ignore
656+ @ Test
658657 public void testPointEqualsPoint () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
659658 {
660659 System .out .println ("Running testPointEqualsPoint" );
@@ -739,10 +738,10 @@ else if (summary.getFormat().name().equalsIgnoreCase("JSON")) {
739738 }
740739
741740 /*
742- * Polygon touches Point TODO - Once Server side issues are fixed in 4.0-2
741+ * Polygon touches Point
743742 */
744743
745- @ Ignore
744+ @ Test
746745 public void testPolygonTouchesPoint () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
747746 {
748747 System .out .println ("Running testPolygonTouchesPoint" );
@@ -753,7 +752,7 @@ public void testPolygonTouchesPoint() throws KeyManagementException, NoSuchAlgor
753752 StructuredQueryBuilder qb = queryMgr .newStructuredQueryBuilder ();
754753 StructuredQueryDefinition t = qb .geospatial (qb .geoRegionPath (qb .pathIndex ("/root/item/polygon" )),
755754 GeospatialOperator .TOUCHES ,
756- qb .point (-26.797920 , 136.406250 )
755+ qb .point (-26.0 , 100.89 )
757756 );
758757 // create handle
759758 JacksonHandle resultsHandle = new JacksonHandle ();
@@ -764,16 +763,21 @@ public void testPolygonTouchesPoint() throws KeyManagementException, NoSuchAlgor
764763 JsonNode jsonPointNodes = resultNode .path ("results" );
765764
766765 // Should have 2 nodes returned.
767- // assertEquals("Two nodes not returned from testPolygonCoversBox method ", 2, resultNode.path("total").asInt());
766+ assertEquals ("Two nodes not returned from testPolygonTouchesPoint method " , 2 , resultNode .path ("total" ).asInt ());
768767
769- // Work on the asserts once server bugs are fixed.
768+ String exptdString = "POLYGON((153.65 -8.35,170.57 -26.0,162.52 -52.52,136.0 -56.35,111.0 -51.0,100.89 -26.0,108.18 1.82,136.0 10.26,153.65 -8.35))" ;
769+ String polygondesc1 = jsonPointNodes .get (0 ).path ("matches" ).get (0 ).path ("match-text" ).get (0 ).path ("highlight" ).asText ();
770+ String polygondesc2 = jsonPointNodes .get (1 ).path ("matches" ).get (0 ).path ("match-text" ).get (0 ).path ("highlight" ).asText ();
771+
772+ assertTrue ("Polygon Node not returned from testPolygonTouchesPoint method " , exptdString .equalsIgnoreCase (polygondesc1 ));
773+ assertTrue ("Polygon Node not returned from testPolygonTouchesPoint method " , exptdString .equalsIgnoreCase (polygondesc2 ));
770774 }
771775
772776 /*
773777 * Circle within Box
774778 */
775779
776- @ Ignore
780+ @ Test
777781 public void testCircleWithinBox () throws KeyManagementException , NoSuchAlgorithmException , IOException , ParserConfigurationException , SAXException , XpathException , TransformerException
778782 {
779783 System .out .println ("Running testCircleWithinBox" );
0 commit comments