+ * @return a boolean
+ */
+ public boolean doDeleteSubjectOnFinish() {
+ return deleteSubjectOnFinish;
+ }
+
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/CommonFixture.java b/src/main/java/org/opengis/cite/geotiff11/CommonFixture.java
index 4f5f052..6246283 100644
--- a/src/main/java/org/opengis/cite/geotiff11/CommonFixture.java
+++ b/src/main/java/org/opengis/cite/geotiff11/CommonFixture.java
@@ -1,20 +1,5 @@
package org.opengis.cite.geotiff11;
-import com.sun.jersey.api.client.Client;
-import com.sun.jersey.api.client.ClientRequest;
-import com.sun.jersey.api.client.ClientResponse;
-
-import java.io.BufferedReader;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import javax.ws.rs.core.MediaType;
import org.opengis.cite.geotiff11.util.ClientUtils;
import org.testng.ITestContext;
import org.testng.SkipException;
@@ -22,86 +7,93 @@
import org.testng.annotations.BeforeMethod;
import org.w3c.dom.Document;
+import jakarta.ws.rs.client.Client;
+import jakarta.ws.rs.client.ClientRequestContext;
+import jakarta.ws.rs.core.Response;
+
/**
- * A supporting base class that sets up a common test fixture. These
- * configuration methods are invoked before those defined in a subclass.
+ * A supporting base class that sets up a common test fixture. These configuration methods
+ * are invoked before those defined in a subclass.
*/
public class CommonFixture {
- /**
- * Root test suite package (absolute path).
- */
- public static final String ROOT_PKG_PATH = "/org/opengis/cite/geotiff11/";
- /**
- * HTTP client component (JAX-RS Client API).
- */
- protected Client client;
- /**
- * An HTTP request message.
- */
- protected ClientRequest request;
- /**
- * An HTTP response message.
- */
- protected ClientResponse response;
+ /**
+ * Root test suite package (absolute path).
+ */
+ public static final String ROOT_PKG_PATH = "/org/opengis/cite/geotiff11/";
+
+ // TODO: are the members below ever set?
+ /**
+ * HTTP client component (JAX-RS Client API).
+ */
+ protected Client client;
+
+ /**
+ * An HTTP request message.
+ */
+ protected ClientRequestContext request;
+
+ /**
+ * An HTTP response message.
+ */
+ protected Response response;
+
+ /**
+ * Initializes the common test fixture with a client component for interacting with
+ * HTTP endpoints.
+ * @param testContext The test context that contains all the information for a test
+ * run, including suite attributes.
+ */
+ @BeforeClass
+ public void initCommonFixture(ITestContext testContext) {
+ Object obj = testContext.getSuite().getAttribute(SuiteAttribute.CLIENT.getName());
+ if (null != obj) {
+ this.client = Client.class.cast(obj);
+ }
+ obj = testContext.getSuite().getAttribute(SuiteAttribute.TEST_SUBJECT.getName());
+ if (null == obj) {
+ throw new SkipException("Test subject not found in ITestContext.");
+ }
+ }
- /**
- * Initializes the common test fixture with a client component for
- * interacting with HTTP endpoints.
- *
- * @param testContext The test context that contains all the information for
- * a test run, including suite attributes.
- */
- @BeforeClass
- public void initCommonFixture(ITestContext testContext) {
- Object obj = testContext.getSuite().getAttribute(SuiteAttribute.CLIENT.getName());
- if (null != obj) {
- this.client = Client.class.cast(obj);
- }
- obj = testContext.getSuite().getAttribute(SuiteAttribute.TEST_SUBJECT.getName());
- if (null == obj) {
- throw new SkipException("Test subject not found in ITestContext.");
- }
- }
+ /**
+ *
+ * clearMessages.
+ *
+ */
+ @BeforeMethod
+ public void clearMessages() {
+ this.request = null;
+ this.response = null;
+ }
- @BeforeMethod
- public void clearMessages() {
- this.request = null;
- this.response = null;
- }
+ /**
+ * Obtains the (XML) response entity as a DOM Document. This convenience method wraps
+ * a static method call to facilitate unit testing (Mockito workaround).
+ * @param response A representation of an HTTP response message.
+ * @param targetURI The target URI from which the entity was retrieved (may be null).
+ * @return A Document representing the entity.
+ * @see ClientUtils#getResponseEntityAsDocument
+ */
+ public Document getResponseEntityAsDocument(Response response, String targetURI) {
+ return ClientUtils.getResponseEntityAsDocument(response, targetURI);
+ }
- /**
- * Obtains the (XML) response entity as a DOM Document. This convenience
- * method wraps a static method call to facilitate unit testing (Mockito
- * workaround).
- *
- * @param response A representation of an HTTP response message.
- * @param targetURI The target URI from which the entity was retrieved (may
- * be null).
- * @return A Document representing the entity.
- *
- * @see ClientUtils#getResponseEntityAsDocument
- */
- public Document getResponseEntityAsDocument(ClientResponse response,
- String targetURI) {
- return ClientUtils.getResponseEntityAsDocument(response, targetURI);
- }
+ /**
+ * Builds an HTTP request message that uses the GET method. This convenience method
+ * wraps a static method call to facilitate unit testing (Mockito workaround).
+ * @param endpoint A URI indicating the target resource.
+ * @param qryParams A Map containing query parameters (may be null);
+ * @param mediaTypes A list of acceptable media types; if not specified, generic XML
+ * ("application/xml") is preferred.
+ * @return A ClientRequest object.
+ *
+ * @see ClientUtils#buildGetRequest
+ */
+ /*
+ * seems unused public ClientRequestContext buildGetRequest(URI endpoint, Map qryParams, MediaType... mediaTypes) { return
+ * ClientUtils.buildGetRequest(endpoint, qryParams, mediaTypes); }
+ */
- /**
- * Builds an HTTP request message that uses the GET method. This convenience
- * method wraps a static method call to facilitate unit testing (Mockito
- * workaround).
- *
- * @param endpoint A URI indicating the target resource.
- * @param qryParams A Map containing query parameters (may be null);
- * @param mediaTypes A list of acceptable media types; if not specified,
- * generic XML ("application/xml") is preferred.
- * @return A ClientRequest object.
- *
- * @see ClientUtils#buildGetRequest
- */
- public ClientRequest buildGetRequest(URI endpoint,
- Map qryParams, MediaType... mediaTypes) {
- return ClientUtils.buildGetRequest(endpoint, qryParams, mediaTypes);
- }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/ETSAssert.java b/src/main/java/org/opengis/cite/geotiff11/ETSAssert.java
index 5d6e529..0b56e51 100644
--- a/src/main/java/org/opengis/cite/geotiff11/ETSAssert.java
+++ b/src/main/java/org/opengis/cite/geotiff11/ETSAssert.java
@@ -25,186 +25,161 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-import com.sun.jersey.api.client.ClientResponse;
-
/**
* Provides a set of custom assertion methods.
*/
public class ETSAssert {
- private static final Logger LOGR = Logger.getLogger(ETSAssert.class.getPackage().getName());
+ private static final Logger LOGR = Logger.getLogger(ETSAssert.class.getPackage().getName());
+
+ private ETSAssert() {
+ }
- private ETSAssert() {
- }
+ /**
+ * Asserts that the qualified name of a DOM Node matches the expected value.
+ * @param node The Node to check.
+ * @param qName A QName object containing a namespace name (URI) and a local part.
+ */
+ public static void assertQualifiedName(Node node, QName qName) {
+ Assert.assertEquals(node.getLocalName(), qName.getLocalPart(), ErrorMessage.get(ErrorMessageKeys.LOCAL_NAME));
+ Assert.assertEquals(node.getNamespaceURI(), qName.getNamespaceURI(),
+ ErrorMessage.get(ErrorMessageKeys.NAMESPACE_NAME));
+ }
- /**
- * Asserts that the qualified name of a DOM Node matches the expected value.
- *
- * @param node
- * The Node to check.
- * @param qName
- * A QName object containing a namespace name (URI) and a local
- * part.
- */
- public static void assertQualifiedName(Node node, QName qName) {
- Assert.assertEquals(node.getLocalName(), qName.getLocalPart(), ErrorMessage.get(ErrorMessageKeys.LOCAL_NAME));
- Assert.assertEquals(node.getNamespaceURI(), qName.getNamespaceURI(),
- ErrorMessage.get(ErrorMessageKeys.NAMESPACE_NAME));
- }
+ /**
+ * Asserts that an XPath 1.0 expression holds true for the given evaluation context.
+ * The following standard namespace bindings do not need to be explicitly declared:
+ *
+ *
- *
- * @param expr
- * A valid XPath 1.0 expression.
- * @param context
- * The context node.
- * @param namespaceBindings
- * A collection of namespace bindings for the XPath expression,
- * where each entry maps a namespace URI (key) to a prefix
- * (value). It may be {@code null}.
- */
- public static void assertXPath(String expr, Node context, Map namespaceBindings) {
- if (null == context) {
- throw new NullPointerException("Context node is null.");
- }
- NamespaceBindings bindings = NamespaceBindings.withStandardBindings();
- bindings.addAllBindings(namespaceBindings);
- XPath xpath = XPathFactory.newInstance().newXPath();
- xpath.setNamespaceContext(bindings);
- Boolean result;
- try {
- result = (Boolean) xpath.evaluate(expr, context, XPathConstants.BOOLEAN);
- } catch (XPathExpressionException xpe) {
- String msg = ErrorMessage.format(ErrorMessageKeys.XPATH_ERROR, expr);
- LOGR.log(Level.WARNING, msg, xpe);
- throw new AssertionError(msg);
- }
- Element elemNode;
- if (Document.class.isInstance(context)) {
- elemNode = Document.class.cast(context).getDocumentElement();
- } else {
- elemNode = (Element) context;
- }
- Assert.assertTrue(result, ErrorMessage.format(ErrorMessageKeys.XPATH_RESULT, elemNode.getNodeName(), expr));
- }
+ /**
+ * Asserts that an XML resource is schema-valid.
+ * @param validator The Validator to use.
+ * @param source The XML Source to be validated.
+ */
+ public static void assertSchemaValid(Validator validator, Source source) {
+ ValidationErrorHandler errHandler = new ValidationErrorHandler();
+ validator.setErrorHandler(errHandler);
+ try {
+ validator.validate(source);
+ }
+ catch (Exception e) {
+ throw new AssertionError(ErrorMessage.format(ErrorMessageKeys.XML_ERROR, e.getMessage()));
+ }
+ Assert.assertFalse(errHandler.errorsDetected(), ErrorMessage.format(ErrorMessageKeys.NOT_SCHEMA_VALID,
+ errHandler.getErrorCount(), errHandler.toString()));
+ }
- /**
- * Asserts that an XML resource is schema-valid.
- *
- * @param validator
- * The Validator to use.
- * @param source
- * The XML Source to be validated.
- */
- public static void assertSchemaValid(Validator validator, Source source) {
- ValidationErrorHandler errHandler = new ValidationErrorHandler();
- validator.setErrorHandler(errHandler);
- try {
- validator.validate(source);
- } catch (Exception e) {
- throw new AssertionError(ErrorMessage.format(ErrorMessageKeys.XML_ERROR, e.getMessage()));
- }
- Assert.assertFalse(errHandler.errorsDetected(), ErrorMessage.format(ErrorMessageKeys.NOT_SCHEMA_VALID,
- errHandler.getErrorCount(), errHandler.toString()));
- }
+ /**
+ * Asserts that an XML resource satisfies all applicable constraints defined for the
+ * specified phase in a Schematron (ISO 19757-3) schema. The "xslt2" query language
+ * binding is supported. Two phase names have special meanings:
+ *
+ *
"#ALL": All patterns are active
+ *
"#DEFAULT": The phase identified by the defaultPhase attribute on the schema
+ * element should be used.
+ *
+ * @param schemaRef A URL that denotes the location of a Schematron schema.
+ * @param xmlSource The XML Source to be validated.
+ * @param activePhase The active phase (pattern set) whose patterns are used for
+ * validation; this is set to "#ALL" if not specified.
+ */
+ public static void assertSchematronValid(URL schemaRef, Source xmlSource, String activePhase) {
+ String phase = (null == activePhase || activePhase.isEmpty()) ? "#ALL" : activePhase;
+ SchematronValidator validator;
+ try {
+ validator = new SchematronValidator(new StreamSource(schemaRef.toString()), phase);
+ }
+ catch (Exception e) {
+ StringBuilder msg = new StringBuilder("Failed to process Schematron schema at ");
+ msg.append(schemaRef).append('\n');
+ msg.append(e.getMessage());
+ throw new AssertionError(msg);
+ }
+ DOMResult result = (DOMResult) validator.validate(xmlSource);
+ Assert.assertFalse(validator.ruleViolationsDetected(), ErrorMessage.format(ErrorMessageKeys.NOT_SCHEMA_VALID,
+ validator.getRuleViolationCount(), XMLUtils.writeNodeToString(result.getNode())));
+ }
- /**
- * Asserts that an XML resource satisfies all applicable constraints defined
- * for the specified phase in a Schematron (ISO 19757-3) schema. The "xslt2"
- * query language binding is supported. Two phase names have special
- * meanings:
- *
- *
"#ALL": All patterns are active
- *
"#DEFAULT": The phase identified by the defaultPhase attribute on the
- * schema element should be used.
- *
- *
- * @param schemaRef
- * A URL that denotes the location of a Schematron schema.
- * @param xmlSource
- * The XML Source to be validated.
- * @param activePhase
- * The active phase (pattern set) whose patterns are used for
- * validation; this is set to "#ALL" if not specified.
- */
- public static void assertSchematronValid(URL schemaRef, Source xmlSource, String activePhase) {
- String phase = (null == activePhase || activePhase.isEmpty()) ? "#ALL" : activePhase;
- SchematronValidator validator;
- try {
- validator = new SchematronValidator(new StreamSource(schemaRef.toString()), phase);
- } catch (Exception e) {
- StringBuilder msg = new StringBuilder("Failed to process Schematron schema at ");
- msg.append(schemaRef).append('\n');
- msg.append(e.getMessage());
- throw new AssertionError(msg);
- }
- DOMResult result = (DOMResult) validator.validate(xmlSource);
- Assert.assertFalse(validator.ruleViolationsDetected(), ErrorMessage.format(ErrorMessageKeys.NOT_SCHEMA_VALID,
- validator.getRuleViolationCount(), XMLUtils.writeNodeToString(result.getNode())));
- }
+ /**
+ * Asserts that the given XML entity contains the expected number of descendant
+ * elements having the specified name.
+ * @param xmlEntity A Document representing an XML entity.
+ * @param elementName The qualified name of the element.
+ * @param expectedCount The expected number of occurrences.
+ */
+ public static void assertDescendantElementCount(Document xmlEntity, QName elementName, int expectedCount) {
+ NodeList features = xmlEntity.getElementsByTagNameNS(elementName.getNamespaceURI(), elementName.getLocalPart());
+ Assert.assertEquals(features.getLength(), expectedCount,
+ String.format("Unexpected number of %s descendant elements.", elementName));
+ }
- /**
- * Asserts that the given XML entity contains the expected number of
- * descendant elements having the specified name.
- *
- * @param xmlEntity
- * A Document representing an XML entity.
- * @param elementName
- * The qualified name of the element.
- * @param expectedCount
- * The expected number of occurrences.
- */
- public static void assertDescendantElementCount(Document xmlEntity, QName elementName, int expectedCount) {
- NodeList features = xmlEntity.getElementsByTagNameNS(elementName.getNamespaceURI(), elementName.getLocalPart());
- Assert.assertEquals(features.getLength(), expectedCount,
- String.format("Unexpected number of %s descendant elements.", elementName));
- }
+ /**
+ * Asserts that the given response message contains an OGC exception report. The
+ * message body must contain an XML document that has a document element with the
+ * following properties:
+ *
+ *
- *
- * @param rsp
- * A ClientResponse object representing an HTTP response message.
- * @param exceptionCode
- * The expected OGC exception code.
- * @param locator
- * A case-insensitive string value expected to occur in the
- * locator attribute (e.g. a parameter name); the attribute value
- * will be ignored if the argument is null or empty.
- */
- public static void assertExceptionReport(ClientResponse rsp, String exceptionCode, String locator) {
- Assert.assertEquals(rsp.getStatus(), ClientResponse.Status.BAD_REQUEST.getStatusCode(),
- ErrorMessage.get(ErrorMessageKeys.UNEXPECTED_STATUS));
- Document doc = rsp.getEntity(Document.class);
- String expr = String.format("//ows:Exception[@exceptionCode = '%s']", exceptionCode);
- NodeList nodeList = null;
- try {
- nodeList = XMLUtils.evaluateXPath(doc, expr, null);
- } catch (XPathExpressionException xpe) {
- // won't happen
- }
- Assert.assertTrue(nodeList.getLength() > 0, "Exception not found in response: " + expr);
- if (null != locator && !locator.isEmpty()) {
- Element exception = (Element) nodeList.item(0);
- String locatorValue = exception.getAttribute("locator").toLowerCase();
- Assert.assertTrue(locatorValue.contains(locator.toLowerCase()),
- String.format("Expected locator attribute to contain '%s']", locator));
- }
- }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/ErrorMessage.java b/src/main/java/org/opengis/cite/geotiff11/ErrorMessage.java
index e43ef51..e15c69e 100644
--- a/src/main/java/org/opengis/cite/geotiff11/ErrorMessage.java
+++ b/src/main/java/org/opengis/cite/geotiff11/ErrorMessage.java
@@ -4,46 +4,39 @@
import java.util.ResourceBundle;
/**
- * Utility class for retrieving and formatting localized error messages that
- * describe failed assertions.
+ * Utility class for retrieving and formatting localized error messages that describe
+ * failed assertions.
*/
public class ErrorMessage {
- private static final String BASE_NAME =
- "org.opengis.cite.geotiff11.MessageBundle";
- private static ResourceBundle msgResources =
- ResourceBundle.getBundle(BASE_NAME);
+ private static final String BASE_NAME = "org.opengis.cite.geotiff11.MessageBundle";
- /**
- * Produces a formatted error message using the supplied substitution
- * arguments and the current locale. The arguments should reflect the order
- * of the placeholders in the message template.
- *
- * @param msgKey
- * The key identifying the message template; it should be a
- * member of {@code ErrorMessageKeys}.
- * @param args
- * An array of arguments to be formatted and substituted in the
- * content of the message.
- * @return A String containing the message content. If no message is found
- * for the given key, a {@link java.util.MissingResourceException}
- * is thrown.
- */
- public static String format(String msgKey, Object... args) {
- return MessageFormat.format(msgResources.getString(msgKey), args);
- }
+ private static ResourceBundle msgResources = ResourceBundle.getBundle(BASE_NAME);
+
+ /**
+ * Produces a formatted error message using the supplied substitution arguments and
+ * the current locale. The arguments should reflect the order of the placeholders in
+ * the message template.
+ * @param msgKey The key identifying the message template; it should be a member of
+ * {@code ErrorMessageKeys}.
+ * @param args An array of arguments to be formatted and substituted in the content of
+ * the message.
+ * @return A String containing the message content. If no message is found for the
+ * given key, a {@link java.util.MissingResourceException} is thrown.
+ */
+ public static String format(String msgKey, Object... args) {
+ return MessageFormat.format(msgResources.getString(msgKey), args);
+ }
+
+ /**
+ * Retrieves a simple message according to the current locale.
+ * @param msgKey The key identifying the message; it should be a member of
+ * {@code ErrorMessageKeys}.
+ * @return A String containing the message content. If no message is found for the
+ * given key, a {@link java.util.MissingResourceException} is thrown.
+ */
+ public static String get(String msgKey) {
+ return msgResources.getString(msgKey);
+ }
- /**
- * Retrieves a simple message according to the current locale.
- *
- * @param msgKey
- * The key identifying the message; it should be a member of
- * {@code ErrorMessageKeys}.
- * @return A String containing the message content. If no message is found
- * for the given key, a {@link java.util.MissingResourceException}
- * is thrown.
- */
- public static String get(String msgKey) {
- return msgResources.getString(msgKey);
- }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/ErrorMessageKeys.java b/src/main/java/org/opengis/cite/geotiff11/ErrorMessageKeys.java
index 13a10fa..20adc25 100644
--- a/src/main/java/org/opengis/cite/geotiff11/ErrorMessageKeys.java
+++ b/src/main/java/org/opengis/cite/geotiff11/ErrorMessageKeys.java
@@ -1,22 +1,44 @@
package org.opengis.cite.geotiff11;
/**
- * Defines keys used to access localized messages for assertion errors. The
- * messages are stored in Properties files that are encoded in ISO-8859-1
- * (Latin-1). For some languages the {@code native2ascii} tool must be used to
- * process the files and produce escaped Unicode characters.
+ * Defines keys used to access localized messages for assertion errors. The messages are
+ * stored in Properties files that are encoded in ISO-8859-1 (Latin-1). For some languages
+ * the {@code native2ascii} tool must be used to process the files and produce escaped
+ * Unicode characters.
*/
public class ErrorMessageKeys {
- public static final String NOT_SCHEMA_VALID = "NotSchemaValid";
- public static final String EMPTY_STRING = "EmptyString";
- public static final String XPATH_RESULT = "XPathResult";
- public static final String NAMESPACE_NAME = "NamespaceName";
- public static final String LOCAL_NAME = "LocalName";
- public static final String XML_ERROR = "XMLError";
- public static final String XPATH_ERROR = "XPathError";
- public static final String MISSING_INFOSET_ITEM = "MissingInfosetItem";
- public static final String UNEXPECTED_STATUS = "UnexpectedStatus";
- public static final String UNEXPECTED_MEDIA_TYPE = "UnexpectedMediaType";
- public static final String MISSING_ENTITY = "MissingEntity";
+ /** Constant NOT_SCHEMA_VALID="NotSchemaValid" */
+ public static final String NOT_SCHEMA_VALID = "NotSchemaValid";
+
+ /** Constant EMPTY_STRING="EmptyString" */
+ public static final String EMPTY_STRING = "EmptyString";
+
+ /** Constant XPATH_RESULT="XPathResult" */
+ public static final String XPATH_RESULT = "XPathResult";
+
+ /** Constant NAMESPACE_NAME="NamespaceName" */
+ public static final String NAMESPACE_NAME = "NamespaceName";
+
+ /** Constant LOCAL_NAME="LocalName" */
+ public static final String LOCAL_NAME = "LocalName";
+
+ /** Constant XML_ERROR="XMLError" */
+ public static final String XML_ERROR = "XMLError";
+
+ /** Constant XPATH_ERROR="XPathError" */
+ public static final String XPATH_ERROR = "XPathError";
+
+ /** Constant MISSING_INFOSET_ITEM="MissingInfosetItem" */
+ public static final String MISSING_INFOSET_ITEM = "MissingInfosetItem";
+
+ /** Constant UNEXPECTED_STATUS="UnexpectedStatus" */
+ public static final String UNEXPECTED_STATUS = "UnexpectedStatus";
+
+ /** Constant UNEXPECTED_MEDIA_TYPE="UnexpectedMediaType" */
+ public static final String UNEXPECTED_MEDIA_TYPE = "UnexpectedMediaType";
+
+ /** Constant MISSING_ENTITY="MissingEntity" */
+ public static final String MISSING_ENTITY = "MissingEntity";
+
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/Namespaces.java b/src/main/java/org/opengis/cite/geotiff11/Namespaces.java
index d76285e..488c598 100644
--- a/src/main/java/org/opengis/cite/geotiff11/Namespaces.java
+++ b/src/main/java/org/opengis/cite/geotiff11/Namespaces.java
@@ -4,28 +4,30 @@
/**
* XML namespace names.
- *
- * @see Namespaces in XML 1.0
*
+ * @see Namespaces in XML 1.0
*/
public class Namespaces {
- private Namespaces() {
- }
-
- /** SOAP 1.2 message envelopes. */
- public static final String SOAP_ENV = "http://www.w3.org/2003/05/soap-envelope";
- /** W3C XLink */
- public static final String XLINK = "http://www.w3.org/1999/xlink";
- /** OGC 06-121r3 (OWS 1.1) */
- public static final String OWS = "http://www.opengis.net/ows/1.1";
- /** ISO 19136 (GML 3.2) */
- public static final String GML = "http://www.opengis.net/gml/3.2";
- /** W3C XML Schema namespace */
- public static final URI XSD = URI
- .create("http://www.w3.org/2001/XMLSchema");
- /** Schematron (ISO 19757-3) namespace */
- public static final URI SCH = URI
- .create("http://purl.oclc.org/dsdl/schematron");
+ private Namespaces() {
+ }
+
+ /** SOAP 1.2 message envelopes. */
+ public static final String SOAP_ENV = "http://www.w3.org/2003/05/soap-envelope";
+
+ /** W3C XLink */
+ public static final String XLINK = "http://www.w3.org/1999/xlink";
+
+ /** OGC 06-121r3 (OWS 1.1) */
+ public static final String OWS = "http://www.opengis.net/ows/1.1";
+
+ /** ISO 19136 (GML 3.2) */
+ public static final String GML = "http://www.opengis.net/gml/3.2";
+
+ /** W3C XML Schema namespace */
+ public static final URI XSD = URI.create("http://www.w3.org/2001/XMLSchema");
+
+ /** Schematron (ISO 19757-3) namespace */
+ public static final URI SCH = URI.create("http://purl.oclc.org/dsdl/schematron");
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/ReusableEntityFilter.java b/src/main/java/org/opengis/cite/geotiff11/ReusableEntityFilter.java
index 49e26d6..478e08e 100644
--- a/src/main/java/org/opengis/cite/geotiff11/ReusableEntityFilter.java
+++ b/src/main/java/org/opengis/cite/geotiff11/ReusableEntityFilter.java
@@ -1,26 +1,28 @@
package org.opengis.cite.geotiff11;
-import com.sun.jersey.api.client.ClientHandlerException;
-import com.sun.jersey.api.client.ClientRequest;
-import com.sun.jersey.api.client.ClientResponse;
-import com.sun.jersey.api.client.filter.ClientFilter;
+import java.io.IOException;
+
+import org.glassfish.jersey.client.ClientResponse;
+
+import jakarta.ws.rs.client.ClientRequestContext;
+import jakarta.ws.rs.client.ClientResponseContext;
+import jakarta.ws.rs.client.ClientResponseFilter;
/**
* Buffers the (response) entity so it can be read multiple times.
*
- *
WARNING: The entity InputStream must be reset after each
- * read attempt.
+ *
+ * WARNING: The entity InputStream must be reset after each read attempt.
+ *
*/
-public class ReusableEntityFilter extends ClientFilter {
+public class ReusableEntityFilter implements ClientResponseFilter {
- @Override
- public ClientResponse handle(ClientRequest req) throws ClientHandlerException {
- // leave request entity--it can usually be read multiple times
- ClientResponse rsp = getNext().handle(req);
- if (rsp.hasEntity()) {
- rsp.bufferEntity();
- }
- return rsp;
- }
+ /** {@inheritDoc} */
+ @Override
+ public void filter(ClientRequestContext requestContext, ClientResponseContext responseContext) throws IOException {
+ if (responseContext instanceof ClientResponse) {
+ ((ClientResponse) responseContext).bufferEntity();
+ }
+ }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/SuiteAttribute.java b/src/main/java/org/opengis/cite/geotiff11/SuiteAttribute.java
index 8b3743f..4cabf22 100644
--- a/src/main/java/org/opengis/cite/geotiff11/SuiteAttribute.java
+++ b/src/main/java/org/opengis/cite/geotiff11/SuiteAttribute.java
@@ -1,55 +1,70 @@
package org.opengis.cite.geotiff11;
-import com.sun.jersey.api.client.Client;
-
import java.io.File;
import org.w3c.dom.Document;
+import jakarta.ws.rs.client.Client;
+
/**
- * An enumerated type defining ISuite attributes that may be set to constitute a
- * shared test fixture.
+ * An enumerated type defining ISuite attributes that may be set to constitute a shared
+ * test fixture.
*/
@SuppressWarnings("rawtypes")
public enum SuiteAttribute {
- /**
- * A client component for interacting with HTTP endpoints.
- */
- CLIENT("httpClient", Client.class),
- /**
- * A DOM Document that represents the test subject or metadata about it.
- */
- TEST_SUBJECT("testSubject", Document.class),
- /**
- * A File containing the test subject or a description of it.
- */
- TEST_SUBJ_FILE("testSubjectFile", File.class),
- /**
- * GeoTiff metadata document.
- */
- TEST_SUBJ_GEOTIFF("testSubjGeotiff", Document.class);
-
- private final Class attrType;
- private final String attrName;
-
- private SuiteAttribute(String attrName, Class attrType) {
- this.attrName = attrName;
- this.attrType = attrType;
- }
-
- public Class getType() {
- return attrType;
- }
-
- public String getName() {
- return attrName;
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(attrName);
- sb.append('(').append(attrType.getName()).append(')');
- return sb.toString();
- }
+ /**
+ * A client component for interacting with HTTP endpoints.
+ */
+ CLIENT("httpClient", Client.class),
+ /**
+ * A DOM Document that represents the test subject or metadata about it.
+ */
+ TEST_SUBJECT("testSubject", Document.class),
+ /**
+ * A File containing the test subject or a description of it.
+ */
+ TEST_SUBJ_FILE("testSubjectFile", File.class),
+ /**
+ * GeoTiff metadata document.
+ */
+ TEST_SUBJ_GEOTIFF("testSubjGeotiff", Document.class);
+
+ private final Class attrType;
+
+ private final String attrName;
+
+ private SuiteAttribute(String attrName, Class attrType) {
+ this.attrName = attrName;
+ this.attrType = attrType;
+ }
+
+ /**
+ *
+ * getType.
+ *
+ * @return a {@link java.lang.Class} object
+ */
+ public Class getType() {
+ return attrType;
+ }
+
+ /**
+ *
+ * getName.
+ *
+ * @return a {@link java.lang.String} object
+ */
+ public String getName() {
+ return attrName;
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ StringBuilder sb = new StringBuilder(attrName);
+ sb.append('(').append(attrType.getName()).append(')');
+ return sb.toString();
+ }
+
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/SuiteFixtureListener.java b/src/main/java/org/opengis/cite/geotiff11/SuiteFixtureListener.java
index 43a4eac..01ab3b9 100644
--- a/src/main/java/org/opengis/cite/geotiff11/SuiteFixtureListener.java
+++ b/src/main/java/org/opengis/cite/geotiff11/SuiteFixtureListener.java
@@ -2,137 +2,136 @@
import java.io.File;
import java.io.IOException;
-import java.io.InputStream;
import java.net.URI;
-import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.logging.Level;
-import org.apache.commons.io.IOUtils;
-import org.opengis.cite.geotiff11.SuiteAttribute;
import org.opengis.cite.geotiff11.util.ClientUtils;
import org.opengis.cite.geotiff11.util.TestSuiteLogger;
import org.opengis.cite.geotiff11.util.URIUtils;
import org.testng.ISuite;
import org.testng.ISuiteListener;
-import com.sun.jersey.api.client.Client;
+
+import jakarta.ws.rs.client.Client;
/**
- * A listener that performs various tasks before and after a test suite is run,
- * usually concerned with maintaining a shared test suite fixture. Since this
- * listener is loaded using the ServiceLoader mechanism, its methods will be
- * called before those of other suite listeners listed in the test suite
- * definition and before any annotated configuration methods.
+ * A listener that performs various tasks before and after a test suite is run, usually
+ * concerned with maintaining a shared test suite fixture. Since this listener is loaded
+ * using the ServiceLoader mechanism, its methods will be called before those of other
+ * suite listeners listed in the test suite definition and before any annotated
+ * configuration methods.
*
- * Attributes set on an ISuite instance are not inherited by constituent test
- * group contexts (ITestContext). However, suite attributes are still accessible
- * from lower contexts.
+ * Attributes set on an ISuite instance are not inherited by constituent test group
+ * contexts (ITestContext). However, suite attributes are still accessible from lower
+ * contexts.
*
* @see org.testng.ISuite ISuite interface
*/
public class SuiteFixtureListener implements ISuiteListener {
+
private static final String GEOTIFF_TXT = "tiffMeta.txt";
-
- @Override
- public void onStart(ISuite suite) {
- processSuiteParameters(suite);
- registerClientComponent(suite);
- }
- @Override
- public void onFinish(ISuite suite) {
- if (null != System.getProperty("deleteSubjectOnFinish")) {
- deleteTempFiles(suite);
- System.getProperties().remove("deleteSubjectOnFinish");
- }
- }
+ /** {@inheritDoc} */
+ @Override
+ public void onStart(ISuite suite) {
+ processSuiteParameters(suite);
+ registerClientComponent(suite);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void onFinish(ISuite suite) {
+ if (null != System.getProperty("deleteSubjectOnFinish")) {
+ deleteTempFiles(suite);
+ System.getProperties().remove("deleteSubjectOnFinish");
+ }
+ }
+
+ /**
+ * Processes test suite arguments and sets suite attributes accordingly. The entity
+ * referenced by the {@link TestRunArg#IUT iut} argument is retrieved and written to a
+ * File that is set as the value of the suite attribute
+ * {@link SuiteAttribute#TEST_SUBJ_FILE testSubjectFile}.
+ * @param suite An ISuite object representing a TestNG test suite.
+ */
+ void processSuiteParameters(ISuite suite) {
+ Map params = suite.getXmlSuite().getParameters();
+ TestSuiteLogger.log(Level.CONFIG, "Suite parameters\n" + params.toString());
+ String iutParam = params.get(TestRunArg.IUT.toString());
+ if ((null == iutParam) || iutParam.isEmpty()) {
+ throw new IllegalArgumentException("Required test run parameter not found: " + TestRunArg.IUT.toString());
+ }
+ URI iutRef = URI.create(iutParam.trim());
+ File entityFile = null;
+ try {
+ entityFile = URIUtils.dereferenceURI(iutRef);
+ }
+ catch (IOException iox) {
+ throw new RuntimeException("Failed to dereference resource located at " + iutRef, iox);
+ }
+ TestSuiteLogger.log(Level.FINE, String.format("Wrote test subject to file: %s (%d bytes)",
+ entityFile.getAbsolutePath(), entityFile.length()));
+ suite.setAttribute(SuiteAttribute.TEST_SUBJ_FILE.getName(), entityFile);
+ // Document iutDoc = null;
+ try {
+ // iutDoc = URIUtils.parseURI(entityFile.toURI());
+ boolean result = URIUtils.parseGeoTiff(suite, entityFile.toURI(), GEOTIFF_TXT);
+
+ // if the parse fails
+ if (!result) {
+ return;
+ }
+ }
+ catch (Exception x) {
+ throw new RuntimeException("Failed to parse resource retrieved from " + iutRef, x);
+ }
+
+ // try {
+ // InputStream inputStream = URIUtils.class.getResourceAsStream("/tmp/" +
+ // GEOTIFF_TXT);
+ // suite.setAttribute(SuiteAttribute.TEST_SUBJECT.getName(),
+ // IOUtils.toString(inputStream, StandardCharsets.UTF_8));
+ //
+ //// System.out.println("Suite: " +
+ // suite.getAttribute(SuiteAttribute.TEST_SUBJECT.getName()));
+ // } catch (IOException e) {
+ // e.printStackTrace();
+ // }
- /**
- * Processes test suite arguments and sets suite attributes accordingly. The
- * entity referenced by the {@link TestRunArg#IUT iut} argument is retrieved
- * and written to a File that is set as the value of the suite attribute
- * {@link SuiteAttribute#TEST_SUBJ_FILE testSubjectFile}.
- *
- * @param suite
- * An ISuite object representing a TestNG test suite.
- */
- void processSuiteParameters(ISuite suite) {
- Map params = suite.getXmlSuite().getParameters();
- TestSuiteLogger.log(Level.CONFIG, "Suite parameters\n" + params.toString());
- String iutParam = params.get(TestRunArg.IUT.toString());
- if ((null == iutParam) || iutParam.isEmpty()) {
- throw new IllegalArgumentException("Required test run parameter not found: " + TestRunArg.IUT.toString());
- }
- URI iutRef = URI.create(iutParam.trim());
- File entityFile = null;
- try {
- entityFile = URIUtils.dereferenceURI(iutRef);
- } catch (IOException iox) {
- throw new RuntimeException("Failed to dereference resource located at " + iutRef, iox);
- }
- TestSuiteLogger.log(Level.FINE, String.format("Wrote test subject to file: %s (%d bytes)",
- entityFile.getAbsolutePath(), entityFile.length()));
- suite.setAttribute(SuiteAttribute.TEST_SUBJ_FILE.getName(), entityFile);
- //Document iutDoc = null;
- try {
- //iutDoc = URIUtils.parseURI(entityFile.toURI());
- boolean result = URIUtils.parseGeoTiff(suite, entityFile.toURI(), GEOTIFF_TXT);
+ if (TestSuiteLogger.isLoggable(Level.FINE)) {
+ StringBuilder logMsg = new StringBuilder("Parsed resource retrieved from ");
+ logMsg.append(iutRef).append("\n");
+ // logMsg.append(XMLUtils.writeNodeToString(iutDoc));
+ TestSuiteLogger.log(Level.FINE, logMsg.toString());
+ }
+ }
- //if the parse fails
- if (!result) {
- return;
- }
- } catch (Exception x) {
- throw new RuntimeException("Failed to parse resource retrieved from " + iutRef, x);
- }
-
-// try {
-// InputStream inputStream = URIUtils.class.getResourceAsStream("/tmp/" + GEOTIFF_TXT);
-// suite.setAttribute(SuiteAttribute.TEST_SUBJECT.getName(), IOUtils.toString(inputStream, StandardCharsets.UTF_8));
-//
-//// System.out.println("Suite: " + suite.getAttribute(SuiteAttribute.TEST_SUBJECT.getName()));
-// } catch (IOException e) {
-// e.printStackTrace();
-// }
-
- if (TestSuiteLogger.isLoggable(Level.FINE)) {
- StringBuilder logMsg = new StringBuilder("Parsed resource retrieved from ");
- logMsg.append(iutRef).append("\n");
- //logMsg.append(XMLUtils.writeNodeToString(iutDoc));
- TestSuiteLogger.log(Level.FINE, logMsg.toString());
- }
- }
+ /**
+ * A client component is added to the suite fixture as the value of the
+ * {@link SuiteAttribute#CLIENT} attribute; it may be subsequently accessed via the
+ * {@link org.testng.ITestContext#getSuite()} method.
+ * @param suite The test suite instance.
+ */
+ void registerClientComponent(ISuite suite) {
+ Client client = ClientUtils.buildClient();
+ if (null != client) {
+ suite.setAttribute(SuiteAttribute.CLIENT.getName(), client);
+ }
+ }
- /**
- * A client component is added to the suite fixture as the value of the
- * {@link SuiteAttribute#CLIENT} attribute; it may be subsequently accessed
- * via the {@link org.testng.ITestContext#getSuite()} method.
- *
- * @param suite
- * The test suite instance.
- */
- void registerClientComponent(ISuite suite) {
- Client client = ClientUtils.buildClient();
- if (null != client) {
- suite.setAttribute(SuiteAttribute.CLIENT.getName(), client);
- }
- }
+ /**
+ * Deletes temporary files created during the test run if TestSuiteLogger is enabled
+ * at the INFO level or higher (they are left intact at the CONFIG level or lower).
+ * @param suite The test suite.
+ */
+ void deleteTempFiles(ISuite suite) {
+ if (TestSuiteLogger.isLoggable(Level.CONFIG)) {
+ return;
+ }
+ File testSubjFile = (File) suite.getAttribute(SuiteAttribute.TEST_SUBJ_FILE.getName());
+ if (testSubjFile.exists()) {
+ testSubjFile.delete();
+ }
+ }
- /**
- * Deletes temporary files created during the test run if TestSuiteLogger is
- * enabled at the INFO level or higher (they are left intact at the CONFIG
- * level or lower).
- *
- * @param suite
- * The test suite.
- */
- void deleteTempFiles(ISuite suite) {
- if (TestSuiteLogger.isLoggable(Level.CONFIG)) {
- return;
- }
- File testSubjFile = (File) suite.getAttribute(SuiteAttribute.TEST_SUBJ_FILE.getName());
- if (testSubjFile.exists()) {
- testSubjFile.delete();
- }
- }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/SuitePreconditions.java b/src/main/java/org/opengis/cite/geotiff11/SuitePreconditions.java
index 31dd2ca..465f2e3 100644
--- a/src/main/java/org/opengis/cite/geotiff11/SuitePreconditions.java
+++ b/src/main/java/org/opengis/cite/geotiff11/SuitePreconditions.java
@@ -4,36 +4,36 @@
import java.util.logging.Logger;
import org.testng.ITestContext;
+import org.testng.Reporter;
import org.testng.annotations.BeforeSuite;
/**
- * Checks that various preconditions are satisfied before the test suite is run.
- * If any of these (BeforeSuite) methods fail, all tests will be skipped.
+ * Checks that various preconditions are satisfied before the test suite is run. If any of
+ * these (BeforeSuite) methods fail, all tests will be skipped.
*/
public class SuitePreconditions {
- private static final Logger LOGR = Logger.getLogger(SuitePreconditions.class.getName());
+ private static final Logger LOGR = Logger.getLogger(SuitePreconditions.class.getName());
+
+ /**
+ * Verifies that the referenced test subject exists and has the expected type.
+ */
+ @BeforeSuite
+ @SuppressWarnings("rawtypes")
+ public void verifyTestSubject() {
+ SuiteAttribute testFileAttr = SuiteAttribute.TEST_SUBJ_FILE;
+ ITestContext testContext = Reporter.getCurrentTestResult().getTestContext();
+ Object sutObj = testContext.getSuite().getAttribute(testFileAttr.getName());
+ Class expectedType = testFileAttr.getType();
+ if (null != sutObj && expectedType.isInstance(sutObj)) {
+ // TODO: Verify test subject
+ }
+ else {
+ String msg = String.format("Value of test suite attribute '%s' is missing or is not an instance of %s",
+ testFileAttr.getName(), expectedType.getName());
+ LOGR.log(Level.SEVERE, msg);
+ throw new AssertionError(msg);
+ }
+ }
- /**
- * Verifies that the referenced test subject exists and has the expected
- * type.
- *
- * @param testContext
- * Information about the (pending) test run.
- */
- @BeforeSuite
- @SuppressWarnings("rawtypes")
- public void verifyTestSubject(ITestContext testContext) {
- SuiteAttribute testFileAttr = SuiteAttribute.TEST_SUBJ_FILE;
- Object sutObj = testContext.getSuite().getAttribute(testFileAttr.getName());
- Class expectedType = testFileAttr.getType();
- if (null != sutObj && expectedType.isInstance(sutObj)) {
- // TODO: Verify test subject
- } else {
- String msg = String.format("Value of test suite attribute '%s' is missing or is not an instance of %s",
- testFileAttr.getName(), expectedType.getName());
- LOGR.log(Level.SEVERE, msg);
- throw new AssertionError(msg);
- }
- }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/SyncPipe.java b/src/main/java/org/opengis/cite/geotiff11/SyncPipe.java
index e0afdb7..add7934 100644
--- a/src/main/java/org/opengis/cite/geotiff11/SyncPipe.java
+++ b/src/main/java/org/opengis/cite/geotiff11/SyncPipe.java
@@ -3,26 +3,45 @@
import java.io.InputStream;
import java.io.OutputStream;
-public class SyncPipe implements Runnable
-{
-public SyncPipe(InputStream istrm, OutputStream ostrm) {
- this.istrm_ = istrm;
- this.ostrm_ = ostrm;
- }
- public void run() {
- try
- {
- final byte[] buffer = new byte[1024];
- for (int length = 0; (length = this.istrm_.read(buffer)) != -1; )
- {
- this.ostrm_.write(buffer, 0, length);
- }
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- }
- private final OutputStream ostrm_;
- private final InputStream istrm_;
-}
\ No newline at end of file
+/**
+ *
+ */
+ public void run() {
+ try {
+ final byte[] buffer = new byte[1024];
+ for (int length = 0; (length = this.istrm_.read(buffer)) != -1;) {
+ this.ostrm_.write(buffer, 0, length);
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ private final OutputStream ostrm_;
+
+ private final InputStream istrm_;
+
+}
diff --git a/src/main/java/org/opengis/cite/geotiff11/TestFailureListener.java b/src/main/java/org/opengis/cite/geotiff11/TestFailureListener.java
index 8332ea1..9b4346b 100644
--- a/src/main/java/org/opengis/cite/geotiff11/TestFailureListener.java
+++ b/src/main/java/org/opengis/cite/geotiff11/TestFailureListener.java
@@ -1,97 +1,97 @@
package org.opengis.cite.geotiff11;
-import com.sun.jersey.api.client.ClientRequest;
-import com.sun.jersey.api.client.ClientResponse;
import java.nio.charset.StandardCharsets;
-import javax.ws.rs.core.MediaType;
+
import org.opengis.cite.geotiff11.util.ClientUtils;
import org.opengis.cite.geotiff11.util.XMLUtils;
import org.testng.ITestResult;
import org.testng.TestListenerAdapter;
import org.w3c.dom.Document;
+import jakarta.ws.rs.client.ClientRequestContext;
+import jakarta.ws.rs.core.MediaType;
+import jakarta.ws.rs.core.Response;
+
/**
- * A listener that augments a test result with diagnostic information in the
- * event that a test method failed. This information will appear in the XML
- * report when the test run is completed.
+ * A listener that augments a test result with diagnostic information in the event that a
+ * test method failed. This information will appear in the XML report when the test run is
+ * completed.
*/
public class TestFailureListener extends TestListenerAdapter {
- /**
- * Sets the "request" and "response" attributes of a test result. The value
- * of these attributes is a string that contains information about the
- * content of an outgoing or incoming message: target resource, status code,
- * headers, entity (if present). The entity is represented as a String with
- * UTF-8 character encoding.
- *
- * @param result A description of a test result (with a fail verdict).
- */
- @Override
- public void onTestFailure(ITestResult result) {
- super.onTestFailure(result);
- Object instance = result.getInstance();
- if (CommonFixture.class.isInstance(instance)) {
- CommonFixture fixture = CommonFixture.class.cast(instance);
- result.setAttribute("request", getRequestMessageInfo(fixture.request));
- result.setAttribute("response", getResponseMessageInfo(fixture.response));
- }
- }
+ /**
+ * {@inheritDoc}
+ *
+ * Sets the "request" and "response" attributes of a test result. The value of these
+ * attributes is a string that contains information about the content of an outgoing
+ * or incoming message: target resource, status code, headers, entity (if present).
+ * The entity is represented as a String with UTF-8 character encoding.
+ */
+ @Override
+ public void onTestFailure(ITestResult result) {
+ super.onTestFailure(result);
+ Object instance = result.getInstance();
+ if (CommonFixture.class.isInstance(instance)) {
+ CommonFixture fixture = CommonFixture.class.cast(instance);
+ result.setAttribute("request", getRequestMessageInfo(fixture.request));
+ result.setAttribute("response", getResponseMessageInfo(fixture.response));
+ }
+ }
- /**
- * Gets diagnostic information about a request message. If the request
- * contains a message body, it should be represented as a DOM Document node
- * or as an object having a meaningful toString() implementation.
- *
- * @param req An object representing an HTTP request message.
- * @return A string containing information gleaned from the request message.
- */
- String getRequestMessageInfo(ClientRequest req) {
- if (null == req) {
- return "No request message.";
- }
- StringBuilder msgInfo = new StringBuilder();
- msgInfo.append("Method: ").append(req.getMethod()).append('\n');
- msgInfo.append("Target URI: ").append(req.getURI()).append('\n');
- msgInfo.append("Headers: ").append(req.getHeaders()).append('\n');
- if (null != req.getEntity()) {
- Object entity = req.getEntity();
- String body;
- if (Document.class.isInstance(entity)) {
- Document doc = Document.class.cast(entity);
- body = XMLUtils.writeNodeToString(doc);
- } else {
- body = entity.toString();
- }
- msgInfo.append(body).append('\n');
- }
- return msgInfo.toString();
- }
+ /**
+ * Gets diagnostic information about a request message. If the request contains a
+ * message body, it should be represented as a DOM Document node or as an object
+ * having a meaningful toString() implementation.
+ * @param req An object representing an HTTP request message.
+ * @return A string containing information gleaned from the request message.
+ */
+ String getRequestMessageInfo(ClientRequestContext req) {
+ if (null == req) {
+ return "No request message.";
+ }
+ StringBuilder msgInfo = new StringBuilder();
+ msgInfo.append("Method: ").append(req.getMethod()).append('\n');
+ msgInfo.append("Target URI: ").append(req.getUri()).append('\n');
+ msgInfo.append("Headers: ").append(req.getHeaders()).append('\n');
+ if (null != req.getEntity()) {
+ Object entity = req.getEntity();
+ String body;
+ if (Document.class.isInstance(entity)) {
+ Document doc = Document.class.cast(entity);
+ body = XMLUtils.writeNodeToString(doc);
+ }
+ else {
+ body = entity.toString();
+ }
+ msgInfo.append(body).append('\n');
+ }
+ return msgInfo.toString();
+ }
- /**
- * Gets diagnostic information about a response message.
- *
- * @param rsp An object representing an HTTP response message.
- * @return A string containing information gleaned from the response
- * message.
- */
- String getResponseMessageInfo(ClientResponse rsp) {
- if (null == rsp) {
- return "No response message.";
- }
- StringBuilder msgInfo = new StringBuilder();
- msgInfo.append("Status: ").append(rsp.getStatus()).append('\n');
- msgInfo.append("Headers: ").append(rsp.getHeaders()).append('\n');
- if (rsp.hasEntity()) {
- if (rsp.getType().isCompatible(MediaType.APPLICATION_XML_TYPE)) {
- Document doc = ClientUtils.getResponseEntityAsDocument(rsp, null);
- msgInfo.append(XMLUtils.writeNodeToString(doc));
- } else {
- byte[] body = rsp.getEntity(byte[].class);
- msgInfo.append(new String(body, StandardCharsets.UTF_8));
- }
- msgInfo.append('\n');
- }
- return msgInfo.toString();
- }
+ /**
+ * Gets diagnostic information about a response message.
+ * @param rsp An object representing an HTTP response message.
+ * @return A string containing information gleaned from the response message.
+ */
+ String getResponseMessageInfo(Response rsp) {
+ if (null == rsp) {
+ return "No response message.";
+ }
+ StringBuilder msgInfo = new StringBuilder();
+ msgInfo.append("Status: ").append(rsp.getStatus()).append('\n');
+ msgInfo.append("Headers: ").append(rsp.getHeaders()).append('\n');
+ if (rsp.hasEntity()) {
+ if (rsp.getMediaType().isCompatible(MediaType.APPLICATION_XML_TYPE)) {
+ Document doc = ClientUtils.getResponseEntityAsDocument(rsp, null);
+ msgInfo.append(XMLUtils.writeNodeToString(doc));
+ }
+ else {
+ byte[] body = rsp.readEntity(byte[].class);
+ msgInfo.append(new String(body, StandardCharsets.UTF_8));
+ }
+ msgInfo.append('\n');
+ }
+ return msgInfo.toString();
+ }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/TestNGController.java b/src/main/java/org/opengis/cite/geotiff11/TestNGController.java
index 876e188..a220c3a 100644
--- a/src/main/java/org/opengis/cite/geotiff11/TestNGController.java
+++ b/src/main/java/org/opengis/cite/geotiff11/TestNGController.java
@@ -30,142 +30,144 @@
*/
public class TestNGController implements TestSuiteController {
- private TestRunExecutor executor;
- private Properties etsProperties = new Properties();
-
- /**
- * A convenience method for running the test suite using a command-line
- * interface. The default values of the test run arguments are as follows:
- *
- *
XML properties file: ${user.home}/test-run-props.xml
- *
- * @param args
- * Test run arguments (optional). The first argument must refer
- * to an XML properties file containing the expected set of test
- * run arguments. If no argument is supplied, the file located at
- * ${user.home}/test-run-props.xml will be used.
- * @throws Exception
- * If the test run cannot be executed (usually due to
- * unsatisfied pre-conditions).
- */
- public static void main(String[] args) throws Exception {
- CommandLineArguments testRunArgs = new CommandLineArguments();
- JCommander cmd = new JCommander(testRunArgs);
- try {
- cmd.parse(args);
- } catch (ParameterException px) {
- System.out.println(px.getMessage());
- cmd.usage();
- }
- if (testRunArgs.doDeleteSubjectOnFinish()) {
- System.setProperty("deleteSubjectOnFinish", "true");
- }
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- File xmlArgs = testRunArgs.getPropertiesFile();
- Document testRunProps = db.parse(xmlArgs);
- TestNGController controller = new TestNGController(testRunArgs.getOutputDir());
- Source testResults = controller.doTestRun(testRunProps);
- System.out.println("Test results: " + testResults.getSystemId());
- }
-
- /**
- * Default constructor uses the location given by the "java.io.tmpdir"
- * system property as the root output directory.
- */
- public TestNGController() {
- this(System.getProperty("java.io.tmpdir"));
- }
-
- /**
- * Construct a controller that writes results to the given output directory.
- *
- * @param outputDir
- * The location of the directory in which test results will be
- * written (a file system path or a 'file' URI). It will be
- * created if it does not exist.
- */
- public TestNGController(String outputDir) {
- InputStream is = getClass().getResourceAsStream("ets.properties");
- try {
- this.etsProperties.load(is);
- } catch (IOException ex) {
- TestSuiteLogger.log(Level.WARNING, "Unable to load ets.properties. " + ex.getMessage());
- }
- URL tngSuite = TestNGController.class.getResource("testng.xml");
- File resultsDir;
- if (null == outputDir || outputDir.isEmpty()) {
- resultsDir = new File(System.getProperty("user.home"));
- } else if (outputDir.startsWith("file:")) {
- resultsDir = new File(URI.create(outputDir));
- } else {
- resultsDir = new File(outputDir);
- }
- TestSuiteLogger.log(Level.CONFIG, "Using TestNG config: " + tngSuite);
- TestSuiteLogger.log(Level.CONFIG, "Using outputDirPath: " + resultsDir.getAbsolutePath());
- // NOTE: setting third argument to 'true' enables the default listeners
- this.executor = new TestNGExecutor(tngSuite.toString(), resultsDir.getAbsolutePath(), false);
- }
-
- @Override
- public String getCode() {
- return etsProperties.getProperty("ets-code");
- }
-
- @Override
- public String getVersion() {
- return etsProperties.getProperty("ets-version");
- }
-
- @Override
- public String getTitle() {
- return etsProperties.getProperty("ets-title");
- }
-
- @Override
- public Source doTestRun(Document testRunArgs) throws Exception {
- validateTestRunArgs(testRunArgs);
- // TODO: next steps to make this run tests on multiple files if a folder is given
- //executor.execute(testRunArgs);
- return executor.execute(testRunArgs);
- }
-
- /**
- * Validates the test run arguments. The test run is aborted if any of these
- * checks fail.
- *
- * @param testRunArgs
- * A DOM Document containing a set of XML properties (key-value
- * pairs).
- * @throws IllegalArgumentException
- * If any arguments are missing or invalid for some reason.
- */
- void validateTestRunArgs(Document testRunArgs) {
- if (null == testRunArgs || !testRunArgs.getDocumentElement().getNodeName().equals("properties")) {
- throw new IllegalArgumentException("Input is not an XML properties document.");
- }
- NodeList entries = testRunArgs.getDocumentElement().getElementsByTagName("entry");
- if (entries.getLength() == 0) {
- throw new IllegalArgumentException("No test run arguments found.");
- }
- Map args = new HashMap();
- for (int i = 0; i < entries.getLength(); i++) {
- Element entry = (Element) entries.item(i);
- args.put(entry.getAttribute("key"), entry.getTextContent());
- }
- if (!args.containsKey(TestRunArg.IUT.toString())) {
- throw new IllegalArgumentException(
- String.format("Missing argument: '%s' must be present.", TestRunArg.IUT));
- }
- }
+ private TestRunExecutor executor;
+
+ private Properties etsProperties = new Properties();
+
+ /**
+ * A convenience method for running the test suite using a command-line interface. The
+ * default values of the test run arguments are as follows:
+ *
+ *
XML properties file: ${user.home}/test-run-props.xml
+ * @param args Test run arguments (optional). The first argument must refer to an XML
+ * properties file containing the expected set of test run arguments. If no argument
+ * is supplied, the file located at ${user.home}/test-run-props.xml will be used.
+ * @throws java.lang.Exception If the test run cannot be executed (usually due to
+ * unsatisfied pre-conditions).
+ */
+ public static void main(String[] args) throws Exception {
+ CommandLineArguments testRunArgs = new CommandLineArguments();
+ JCommander cmd = new JCommander(testRunArgs);
+ try {
+ cmd.parse(args);
+ }
+ catch (ParameterException px) {
+ System.out.println(px.getMessage());
+ cmd.usage();
+ }
+ if (testRunArgs.doDeleteSubjectOnFinish()) {
+ System.setProperty("deleteSubjectOnFinish", "true");
+ }
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ File xmlArgs = testRunArgs.getPropertiesFile();
+ Document testRunProps = db.parse(xmlArgs);
+ TestNGController controller = new TestNGController(testRunArgs.getOutputDir());
+ Source testResults = controller.doTestRun(testRunProps);
+ System.out.println("Test results: " + testResults.getSystemId());
+ }
+
+ /**
+ * Default constructor uses the location given by the "java.io.tmpdir" system property
+ * as the root output directory.
+ */
+ public TestNGController() {
+ this(System.getProperty("java.io.tmpdir"));
+ }
+
+ /**
+ * Construct a controller that writes results to the given output directory.
+ * @param outputDir The location of the directory in which test results will be
+ * written (a file system path or a 'file' URI). It will be created if it does not
+ * exist.
+ */
+ public TestNGController(String outputDir) {
+ InputStream is = getClass().getResourceAsStream("ets.properties");
+ try {
+ this.etsProperties.load(is);
+ }
+ catch (IOException ex) {
+ TestSuiteLogger.log(Level.WARNING, "Unable to load ets.properties. " + ex.getMessage());
+ }
+ URL tngSuite = TestNGController.class.getResource("testng.xml");
+ File resultsDir;
+ if (null == outputDir || outputDir.isEmpty()) {
+ resultsDir = new File(System.getProperty("user.home"));
+ }
+ else if (outputDir.startsWith("file:")) {
+ resultsDir = new File(URI.create(outputDir));
+ }
+ else {
+ resultsDir = new File(outputDir);
+ }
+ TestSuiteLogger.log(Level.CONFIG, "Using TestNG config: " + tngSuite);
+ TestSuiteLogger.log(Level.CONFIG, "Using outputDirPath: " + resultsDir.getAbsolutePath());
+ // NOTE: setting third argument to 'true' enables the default listeners
+ this.executor = new TestNGExecutor(tngSuite.toString(), resultsDir.getAbsolutePath(), false);
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getCode() {
+ return etsProperties.getProperty("ets-code");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getVersion() {
+ return etsProperties.getProperty("ets-version");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public String getTitle() {
+ return etsProperties.getProperty("ets-title");
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public Source doTestRun(Document testRunArgs) throws Exception {
+ validateTestRunArgs(testRunArgs);
+ // TODO: next steps to make this run tests on multiple files if a folder is given
+ // executor.execute(testRunArgs);
+ return executor.execute(testRunArgs);
+ }
+
+ /**
+ * Validates the test run arguments. The test run is aborted if any of these checks
+ * fail.
+ * @param testRunArgs A DOM Document containing a set of XML properties (key-value
+ * pairs).
+ * @throws IllegalArgumentException If any arguments are missing or invalid for some
+ * reason.
+ */
+ void validateTestRunArgs(Document testRunArgs) {
+ if (null == testRunArgs || !testRunArgs.getDocumentElement().getNodeName().equals("properties")) {
+ throw new IllegalArgumentException("Input is not an XML properties document.");
+ }
+ NodeList entries = testRunArgs.getDocumentElement().getElementsByTagName("entry");
+ if (entries.getLength() == 0) {
+ throw new IllegalArgumentException("No test run arguments found.");
+ }
+ Map args = new HashMap();
+ for (int i = 0; i < entries.getLength(); i++) {
+ Element entry = (Element) entries.item(i);
+ args.put(entry.getAttribute("key"), entry.getTextContent());
+ }
+ if (!args.containsKey(TestRunArg.IUT.toString())) {
+ throw new IllegalArgumentException(
+ String.format("Missing argument: '%s' must be present.", TestRunArg.IUT));
+ }
+ }
+
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/TestRunArg.java b/src/main/java/org/opengis/cite/geotiff11/TestRunArg.java
index 346384f..d5f43eb 100644
--- a/src/main/java/org/opengis/cite/geotiff11/TestRunArg.java
+++ b/src/main/java/org/opengis/cite/geotiff11/TestRunArg.java
@@ -5,14 +5,16 @@
*/
public enum TestRunArg {
- /**
- * An absolute URI that refers to a representation of the test subject or
- * metadata about it.
- */
- IUT;
+ /**
+ * An absolute URI that refers to a representation of the test subject or metadata
+ * about it.
+ */
+ IUT;
+
+ /** {@inheritDoc} */
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
- @Override
- public String toString() {
- return name().toLowerCase();
- }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/TestRunListener.java b/src/main/java/org/opengis/cite/geotiff11/TestRunListener.java
index 7e07276..fd4b398 100644
--- a/src/main/java/org/opengis/cite/geotiff11/TestRunListener.java
+++ b/src/main/java/org/opengis/cite/geotiff11/TestRunListener.java
@@ -3,24 +3,28 @@
import org.testng.IExecutionListener;
/**
- * A listener that is invoked before and after a test run. It is often used to
- * configure a shared fixture that endures for the duration of the entire test
- * run. A FixtureManager may be used to manage such a fixture.
+ * A listener that is invoked before and after a test run. It is often used to configure a
+ * shared fixture that endures for the duration of the entire test run. A FixtureManager
+ * may be used to manage such a fixture.
*
- *
A shared fixture should be used with caution in order to avoid undesirable
- * test interactions. In general, it should be populated with "read-only"
- * objects that are not modified during the test run.
+ *
+ * A shared fixture should be used with caution in order to avoid undesirable test
+ * interactions. In general, it should be populated with "read-only" objects that are not
+ * modified during the test run.
+ *
*
* @see com.occamlab.te.spi.executors.FixtureManager FixtureManager
- *
*/
public class TestRunListener implements IExecutionListener {
- @Override
- public void onExecutionStart() {
- }
+ /** {@inheritDoc} */
+ @Override
+ public void onExecutionStart() {
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public void onExecutionFinish() {
+ }
- @Override
- public void onExecutionFinish() {
- }
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/package-info.java b/src/main/java/org/opengis/cite/geotiff11/package-info.java
index 796c567..26089ae 100644
--- a/src/main/java/org/opengis/cite/geotiff11/package-info.java
+++ b/src/main/java/org/opengis/cite/geotiff11/package-info.java
@@ -1,8 +1,9 @@
/**
- * The root package includes supporting classes of general utility such as the
- * main controller, listeners, and reporters.
+ * The root package includes supporting classes of general utility such as the main
+ * controller, listeners, and reporters.
*
- *
Subsidiary packages correspond to distinct test groups such as conformance
- * classes.
+ *
+ * Subsidiary packages correspond to distinct test groups such as conformance classes.
+ *
*/
-package org.opengis.cite.geotiff11;
\ No newline at end of file
+package org.opengis.cite.geotiff11;
\ No newline at end of file
diff --git a/src/main/java/org/opengis/cite/geotiff11/tiffTests/AsciiParamsTests.java b/src/main/java/org/opengis/cite/geotiff11/tiffTests/AsciiParamsTests.java
index 91aacf5..e71645b 100644
--- a/src/main/java/org/opengis/cite/geotiff11/tiffTests/AsciiParamsTests.java
+++ b/src/main/java/org/opengis/cite/geotiff11/tiffTests/AsciiParamsTests.java
@@ -1,200 +1,263 @@
package org.opengis.cite.geotiff11.tiffTests;
+import static org.opengis.cite.geotiff11.util.GeoKeyID.GEOASCIIPARAMSTAG;
+import static org.opengis.cite.geotiff11.util.GeoKeyID.GEODETICCITATIONGEOKEY;
+import static org.opengis.cite.geotiff11.util.GeoKeyID.GTCITATIONGEOKEY;
+import static org.opengis.cite.geotiff11.util.GeoKeyID.PROJECTEDCITATIONGEOKEY;
+import static org.opengis.cite.geotiff11.util.GeoKeyID.VERTICALCITATIONGEOKEY;
+
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-import static org.opengis.cite.geotiff11.util.GeoKeyID.*;
-
// https://github.com/opengeospatial/geotiff/blob/master/GeoTIFF_Standard/standard/abstract_tests/TIFF_Tests/TEST_Double_Param.adoc
+/**
+ *
+ * AsciiParamsTests class.
+ *
+ *
+ */
public class AsciiParamsTests extends GeoKeysTests {
/*
- * ASCII Parameters Test
- * Test id: TIFF_Test/AsciiParameters
- * Requirements:
- * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.KeyEntry.ID
- * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.keyEntryTIFFTagLocation
- * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.keyEntryKeyCount
- * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.keyEntryValueOffset
- * http://www.opengis.net/spec/GeoTIFF/1.1/GeoAsciiParamsTag.ID
- * http://www.opengis.net/spec/GeoTIFF/1.1/GeoAsciiParamsTag.count
- * http://www.opengis.net/spec/GeoTIFF/1.1/CitationGeoKeys.ID
- * http://www.opengis.net/spec/GeoTIFF/1.1/CitationGeoKeys.type
- * Purpose: Verify an ASCII parameter
- * Pre-conditions: The GeoKeyDirectory, ASCIIValues and GeoKeyOffset values have been set.
- * Test Variables:
- * Variable Scope Description
- * GeoKeyDirectory Global Location of the GeoTIFF GeoKey directory
- * ASCIIValues Global Location of the ASCII values for GeoTIFF ASCII GeoKeys
- * GeoKeyOffset Parameter Location of this Key Entry Set in the GeoKey directory
- * GeoKey Local Temporary value of the GeoKey
- * KeyLength Local Temporary value for the length of the value for the GeoKey
- * KeyValueOffset Local The location of the GeoKey value in the file
-
- */
-
+ * ASCII Parameters Test Test id: TIFF_Test/AsciiParameters Requirements:
+ * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.KeyEntry.ID
+ * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.keyEntryTIFFTagLocation
+ * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.keyEntryKeyCount
+ * http://www.opengis.net/spec/GeoTIFF/1.1/GeoKeyDirectoryTag.keyEntryValueOffset
+ * http://www.opengis.net/spec/GeoTIFF/1.1/GeoAsciiParamsTag.ID
+ * http://www.opengis.net/spec/GeoTIFF/1.1/GeoAsciiParamsTag.count
+ * http://www.opengis.net/spec/GeoTIFF/1.1/CitationGeoKeys.ID
+ * http://www.opengis.net/spec/GeoTIFF/1.1/CitationGeoKeys.type Purpose: Verify an
+ * ASCII parameter Pre-conditions: The GeoKeyDirectory, ASCIIValues and GeoKeyOffset
+ * values have been set. Test Variables: Variable Scope Description GeoKeyDirectory
+ * Global Location of the GeoTIFF GeoKey directory ASCIIValues Global Location of the
+ * ASCII values for GeoTIFF ASCII GeoKeys GeoKeyOffset Parameter Location of this Key
+ * Entry Set in the GeoKey directory GeoKey Local Temporary value of the GeoKey
+ * KeyLength Local Temporary value for the length of the value for the GeoKey
+ * KeyValueOffset Local The location of the GeoKey value in the file
+ *
+ */
+
String asciiParamsSet;
-
+
+ /**
+ *
+ * @throws java.lang.Exception if any.
+ */
+ @Test(description = "Ascii Params Tag Count Test", dependsOnGroups = { "verifyGeoKeyDirectory" })
public void verifyGeoAsciiParamsTagCount() throws Exception {
- if(keyEntrySet.contains(GEOASCIIPARAMSTAG))
- {
- // The GeoAsciiParamsTag SHALL contain the values of the key parameters of type = ASCII referenced by the GeoKeyDirectoryTag.
- Assert.assertTrue(directory.hasTag(GEOASCIIPARAMSTAG), "the GeoAsciiParamsTag SHALL contain the values of the key parameters of type = ASCII referenced by the GeoKeyDirectoryTag");
+ if (keyEntrySet.contains(GEOASCIIPARAMSTAG)) {
+ // The GeoAsciiParamsTag SHALL contain the values of the key parameters of
+ // type = ASCII referenced by the GeoKeyDirectoryTag.
+ Assert.assertTrue(directory.hasTag(GEOASCIIPARAMSTAG),
+ "the GeoAsciiParamsTag SHALL contain the values of the key parameters of type = ASCII referenced by the GeoKeyDirectoryTag");
}
- else
- {
- // TODO: ??? If there is no key parameters of type = ASCII, it SHALL not be present
- Assert.assertFalse(directory.hasTag(GEOASCIIPARAMSTAG), "if there is no key parameters of type = ASCII, it SHALL not be present");
+ else {
+ // TODO: ??? If there is no key parameters of type = ASCII, it SHALL not be
+ // present
+ Assert.assertFalse(directory.hasTag(GEOASCIIPARAMSTAG),
+ "if there is no key parameters of type = ASCII, it SHALL not be present");
}
}
-
- // TODO: this is redoing some TiffTagsTests stuff. Gotta decide how to properly organize this.
- @Test(description = "Ascii Params Tag Type Test", dependsOnGroups ={"verifyGeoKeyDirectory"})
+
+ // TODO: this is redoing some TiffTagsTests stuff. Gotta decide how to properly
+ // organize this.
+ /**
+ *
+ * verifyGeoAsciiParamsTagType.
+ *
+ * @throws java.lang.Exception if any.
+ */
+ @Test(description = "Ascii Params Tag Type Test", dependsOnGroups = { "verifyGeoKeyDirectory" })
public void verifyGeoAsciiParamsTagType() throws Exception {
// the GeoAsciiParamsTag SHALL have type = ASCII
- if(directory.hasTag(GEOASCIIPARAMSTAG))
- Assert.assertTrue(directory.getTag(GEOASCIIPARAMSTAG).getTypeValue() == 2, "the GeoAsciiParamsTag SHALL have type = ASCII");
+ if (directory.hasTag(GEOASCIIPARAMSTAG))
+ Assert.assertTrue(directory.getTag(GEOASCIIPARAMSTAG).getTypeValue() == 2,
+ "the GeoAsciiParamsTag SHALL have type = ASCII");
}
-
- @Test(description = "Ascii Params Tag NULLWrite Test", dependsOnGroups ={"verifyGeoKeyDirectory"})
+
+ /**
+ *
+ * verifyGeoAsciiParamsTagNULLWrite.
+ *
+ * @throws java.lang.Exception if any.
+ */
+ @Test(description = "Ascii Params Tag NULLWrite Test", dependsOnGroups = { "verifyGeoKeyDirectory" })
public void verifyGeoAsciiParamsTagNULLWrite() throws Exception {
- // NULL (ASCII code = 0) characters SHALL not be present in the string content written in the GeoAsciiParamsTag
- if (asciiParamsSet == null) return;
-
- for(int i = 0; i < asciiParamsSet.length() - 1; i++) {
- Assert.assertTrue(asciiParamsSet.charAt(i) != '\0', "NULL (ASCII code = 0) characters SHALL not be present in the string content written in the GeoAsciiParamsTag");
+ // NULL (ASCII code = 0) characters SHALL not be present in the string content
+ // written in the GeoAsciiParamsTag
+ if (asciiParamsSet == null)
+ return;
+
+ for (int i = 0; i < asciiParamsSet.length() - 1; i++) {
+ Assert.assertTrue(asciiParamsSet.charAt(i) != '\0',
+ "NULL (ASCII code = 0) characters SHALL not be present in the string content written in the GeoAsciiParamsTag");
}
-
- Assert.assertTrue(asciiParamsSet.charAt(asciiParamsSet.length() - 1) == '\0', "the string content written in the GeoAsciiParamsTag should end in NULL (ASCII code = 0) characters ");
+
+ Assert.assertTrue(asciiParamsSet.charAt(asciiParamsSet.length() - 1) == '\0',
+ "the string content written in the GeoAsciiParamsTag should end in NULL (ASCII code = 0) characters ");
}
-
-
+
String processFourthShortForAscii(int index, int keyLength) {
// process the fourth Short integer in the Key Entry Set
- int asciiIndex = (int) keyEntrySet.get(index+3);
-
- //Assert.assertTrue(directory.hasTag(GEOASCIIPARAMSTAG));
-
+ int asciiIndex = (int) keyEntrySet.get(index + 3);
+
+ // Assert.assertTrue(directory.hasTag(GEOASCIIPARAMSTAG));
+
// SET KeyValueOffset to the value
-
- // Read the contents of the GeoTIFF file starting at KeyValueOffset up to and including the first NULL.
+
+ // Read the contents of the GeoTIFF file starting at KeyValueOffset up to and
+ // including the first NULL.
// Verify that the contents read consists of ASCII characters.
- // Verify that the contents read is KeyLength characters long not including the NULL.
+ // Verify that the contents read is KeyLength characters long not including the
+ // NULL.
String value = "";
-
- for(int i = asciiIndex; ; i++)
- {
- Assert.assertTrue(i < asciiParamsSet.length());
- //Assert.assertTrue(asciiParamsSet.charAt(i) != '\0');
-
- // The pipe character | in the GeoAsciiParamsTag SHALL be used as the character to terminate a string written in as ASCII tag
- if(asciiParamsSet.charAt(i) == '|') {
- Assert.assertTrue(value.length() == keyLength - 1, "the pipe character | in the GeoAsciiParamsTag SHALL be used as the character to terminate a string written in as ASCII tag");
+
+ for (int i = asciiIndex;; i++) {
+ Assert.assertTrue(i < asciiParamsSet.length());
+ // Assert.assertTrue(asciiParamsSet.charAt(i) != '\0');
+
+ // The pipe character | in the GeoAsciiParamsTag SHALL be used as the
+ // character to terminate a string written in as ASCII tag
+ if (asciiParamsSet.charAt(i) == '|') {
+ Assert.assertTrue(value.length() == keyLength - 1,
+ "the pipe character | in the GeoAsciiParamsTag SHALL be used as the character to terminate a string written in as ASCII tag");
break;
}
value += asciiParamsSet.charAt(i);
}
-
+
return value;
}
-
-
-// GeoKey Requirements Class
-
-// 1026 CitationGeoKeys/GTCitationGeoKey
-
- @Test(description = "Ascii Params GTCitationGeoKey (1026) Test", dependsOnGroups ={"verifyGeoKeyDirectory"})
+
+ // GeoKey Requirements Class
+
+ // 1026 CitationGeoKeys/GTCitationGeoKey
+
+ /**
+ *
+ * verifyGTCitationGeoKey.
+ *
+ * @throws java.lang.Exception if any.
+ */
+ @Test(description = "Ascii Params GTCitationGeoKey (1026) Test", dependsOnGroups = { "verifyGeoKeyDirectory" })
public void verifyGTCitationGeoKey() throws Exception {
// the GTCitationGeoKey SHALL have ID = 1026
int index = getKeyIndex(GTCITATIONGEOKEY);
-
+
// not required
- if(index == -1) {
+ if (index == -1) {
return;
}
-
+
int type = processSecondShort(index);
int geoKey = processFirstShort(index);
int keyLength = processThirdShort(index);
String value = processFourthShortForAscii(index, keyLength);
-
- // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
+
+ // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
Assert.assertTrue(type == GEOASCIIPARAMSTAG, "the GeogLinearUnitSizeGeoKey SHALL have type = ASCII");
}
-
-// 2049 CitationGeoKeys/GeodeticCitationGeoKey
-
- @Test(description = "Ascii Params GeodeticCitationGeoKey (2049) Test", dependsOnGroups ={"verifyGeoKeyDirectory"})
+
+ // 2049 CitationGeoKeys/GeodeticCitationGeoKey
+
+ /**
+ *
+ * verifyGeodeticCitationGeoKey.
+ *
+ * @throws java.lang.Exception if any.
+ */
+ @Test(description = "Ascii Params GeodeticCitationGeoKey (2049) Test",
+ dependsOnGroups = { "verifyGeoKeyDirectory" })
public void verifyGeodeticCitationGeoKey() throws Exception {
// the GeodeticCitationGeoKey SHALL have ID = 2049
int index = getKeyIndex(GEODETICCITATIONGEOKEY);
-
+
// not required
- if(index == -1) {
+ if (index == -1) {
return;
}
-
+
int type = processSecondShort(index);
int geoKey = processFirstShort(index);
int keyLength = processThirdShort(index);
String value = processFourthShortForAscii(index, keyLength);
-
- // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
+
+ // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
Assert.assertTrue(type == GEOASCIIPARAMSTAG, "the GeogLinearUnitSizeGeoKey SHALL have type = ASCII");
}
-
-// 3073 CitationGeoKeys/ProjectedCitationGeoKey
-
- @Test(description = "Ascii Params ProjectedCitationGeoKey (3073) Test", dependsOnGroups ={"verifyGeoKeyDirectory"})
+
+ // 3073 CitationGeoKeys/ProjectedCitationGeoKey
+
+ /**
+ *
+ * verifyProjectedCitationGeoKey.
+ *
+ * @throws java.lang.Exception if any.
+ */
+ @Test(description = "Ascii Params ProjectedCitationGeoKey (3073) Test",
+ dependsOnGroups = { "verifyGeoKeyDirectory" })
public void verifyProjectedCitationGeoKey() throws Exception {
// the ProjectedCitationGeoKey SHALL have ID = 3073
int index = getKeyIndex(PROJECTEDCITATIONGEOKEY);
-
+
// not required
- if(index == -1) {
+ if (index == -1) {
return;
}
-
+
int type = processSecondShort(index);
int geoKey = processFirstShort(index);
int keyLength = processThirdShort(index);
String value = processFourthShortForAscii(index, keyLength);
-
- // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
+
+ // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
Assert.assertTrue(type == GEOASCIIPARAMSTAG, "the GeogLinearUnitSizeGeoKey SHALL have type = ASCII");
}
-
-// 4097 CitationGeoKeys/VerticalCitationGeoKey
- @Test(description = "Ascii Params VerticalCitationGeoKey (4097) Test", dependsOnGroups ={"verifyGeoKeyDirectory"})
+ // 4097 CitationGeoKeys/VerticalCitationGeoKey
+
+ /**
+ *
+ * verifyVerticalCitationGeoKey.
+ *
+ * @throws java.lang.Exception if any.
+ */
+ @Test(description = "Ascii Params VerticalCitationGeoKey (4097) Test",
+ dependsOnGroups = { "verifyGeoKeyDirectory" })
public void verifyVerticalCitationGeoKey() throws Exception {
// the VerticalCitationGeoKey SHALL have ID = 4097
int index = getKeyIndex(VERTICALCITATIONGEOKEY);
-
+
// not required
- if(index == -1) {
+ if (index == -1) {
return;
}
-
+
int type = processSecondShort(index);
int geoKey = processFirstShort(index);
int keyLength = processThirdShort(index);
String value = processFourthShortForAscii(index, keyLength);
-
- // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
+
+ // the GeogLinearUnitSizeGeoKey SHALL have type = ASCII
Assert.assertTrue(type == GEOASCIIPARAMSTAG, "the GeogLinearUnitSizeGeoKey SHALL have type = ASCII");
}
-
+
}
diff --git a/src/main/java/org/opengis/cite/geotiff11/tiffTests/CommonTiffMeta.java b/src/main/java/org/opengis/cite/geotiff11/tiffTests/CommonTiffMeta.java
index e547b85..1428750 100644
--- a/src/main/java/org/opengis/cite/geotiff11/tiffTests/CommonTiffMeta.java
+++ b/src/main/java/org/opengis/cite/geotiff11/tiffTests/CommonTiffMeta.java
@@ -6,29 +6,36 @@
import org.testng.ITestContext;
import org.testng.annotations.BeforeClass;
+/**
+ *
+ *
+ */
public class DoubleParamsTests extends GeoKeysTests {
/*
- * Double Parameters Test
- * Test id: http://www.opengis.net/spec/GeoTIFF/1.1/conf/DoubleParameters
- * Requirements:
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.KeyEntry.ID
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.keyEntryTIFFTagLocation
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.keyEntryKeyCount
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.keyEntryValueOffset
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoDoubleParamsTag.ID
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoDoubleParamsTag.count
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/PrimeMeridianLongitudeGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/UnitSizeGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/EllipsoidSemiMajorAxisGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/EllipsoidSemiMinorAxisGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/EllipsoidInvFlatteningGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjAngularParameterGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjLinearParameterGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjScalarParameterGeoKey
- * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjAzimuthAngleGeoKey
- * Purpose: Verify Double parameters
- * Pre-conditions The GeoKeyDirectory, DoubleValues and GeoKeyOffset values have been set.
- * Test Variables:
- * Variable Scope Description
- * GeoKeyDirectory Global Location of the GeoTIFF GeoKey directory
- * DoubleValues Global Location of the Double values for GeoTIFF Double GeoKeys
- * GeoKeyOffset Parameter Location of this Key Entry Set in the GeoKey directory
- * GeoKey Local Temporary value of the GeoKey
- * KeyLength Local Temporary value for the length of the value for the GeoKey
- * KeyValueOffset Local The location of the GeoKey value in the file
- */
-
+ * Double Parameters Test Test
+ * id: http://www.opengis.net/spec/GeoTIFF/1.1/conf/DoubleParameters Requirements:
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.KeyEntry.ID
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.
+ * keyEntryTIFFTagLocation
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.keyEntryKeyCount
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoKeyDirectoryTag.keyEntryValueOffset
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoDoubleParamsTag.ID
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/GeoDoubleParamsTag.count
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/PrimeMeridianLongitudeGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/UnitSizeGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/EllipsoidSemiMajorAxisGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/EllipsoidSemiMinorAxisGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/EllipsoidInvFlatteningGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjAngularParameterGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjLinearParameterGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjScalarParameterGeoKey
+ * http://www.opengis.net/spec/GeoTIFF/1.1/req/ProjAzimuthAngleGeoKey Purpose: Verify
+ * Double parameters Pre-conditions The GeoKeyDirectory, DoubleValues and GeoKeyOffset
+ * values have been set. Test Variables: Variable Scope Description GeoKeyDirectory
+ * Global Location of the GeoTIFF GeoKey directory DoubleValues Global Location of the
+ * Double values for GeoTIFF Double GeoKeys GeoKeyOffset Parameter Location of this
+ * Key Entry Set in the GeoKey directory GeoKey Local Temporary value of the GeoKey
+ * KeyLength Local Temporary value for the length of the value for the GeoKey
+ * KeyValueOffset Local The location of the GeoKey value in the file
+ */
+
float processFourthShortForDouble(int index) {
- int doubleIndex = (int) keyEntrySet.get(index+3);
+ int doubleIndex = (int) keyEntrySet.get(index + 3);
// process the fourth Short integer in the Key Entry Set
- List