org.opengis.cite.iso19136.data.spatial.CompositeCurveTests Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ets-gml32 Show documentation
Show all versions of ets-gml32 Show documentation
Checks GML application schemas or data sets for conformance to ISO 19136:2007.
package org.opengis.cite.iso19136.data.spatial;
import java.util.ArrayList;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpressionException;
import org.opengis.cite.geomatics.gml.GmlUtils;
import org.opengis.cite.iso19136.data.DataFixture;
import org.opengis.cite.iso19136.general.GML32;
import org.opengis.cite.iso19136.util.XMLUtils;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
/**
* Validates the content of a gml:CompositeCurve element, which implements the
* GM_CompositeCurve class from ISO 19107. A composite curve is a sequence of
* orientable curves agreeing in orientation such that each curve (except the
* first) begins where the previous one ends.
*
* Sources
*
* - ISO 19136:2007, cl. 11.2.2.2: CompositeCurveType, CompositeCurve
* - ISO 19107:2003, cl. 6.6.5: GM_CompositeCurve
*
*/
public class CompositeCurveTests extends DataFixture {
NodeList curveNodes;
List curveElems = new ArrayList();
/**
* A configuration method ({@code BeforeClass}) that looks for
* gml:CompositeCurve elements in the GML document under test. If none are
* found all test methods defined in the class will be skipped.
*/
@BeforeClass(alwaysRun = true)
public void findCompositeCurves() {
Source data = new StreamSource(this.dataFile);
this.curveElems.add(new QName(GML32.NS_NAME, GML32.COMP_CURVE));
String xpath = "//gml:CompositeCurve";
try {
this.curveNodes = (NodeList) XMLUtils.evaluateXPath(data, xpath,
null, XPathConstants.NODESET);
} catch (XPathExpressionException xpe) { // won't happen
throw new RuntimeException(xpe);
}
Assert.assertFalse(this.curveNodes.getLength() == 0,
"No gml:CompositeCurve elements were found.");
}
/**
* [{@code Test}] Verifies that the component curves of a gml:CompositeCurve
* element are connected.
*
* Sources
*
* - ISO 19136, 11.2.2.2: CompositeCurveType, CompositeCurve
*
*/
@Test(description = "See ISO 19136: 11.2.2.2")
public void compositeCurveComponentsAreConnected() {
for (int i = 0; i < this.curveNodes.getLength(); i++) {
Element curveElem = (Element) this.curveNodes.item(i);
GmlUtils.findCRSReference(curveElem);
GeometryAssert.assertCurveComponentsAreConnected(curveElem);
}
}
}