diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/CommandLineArguments.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/CommandLineArguments.java
index afc064e..a07938f 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/CommandLineArguments.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/CommandLineArguments.java
@@ -7,9 +7,8 @@
import java.util.List;
/**
- * Declares supported command line arguments that are parsed using the
- * JCommander library. All arguments are optional. The default values are as
- * follows:
+ * Declares supported command line arguments that are parsed using the JCommander library.
+ * All arguments are optional. The default values are as follows:
*
*
XML properties file: ${user.home}/test-run-props.xml
*
outputDir: ${user.home}
@@ -26,35 +25,38 @@
*/
public class CommandLineArguments {
- @Parameter(description = "Properties file")
- private final List xmlProps;
-
- @Parameter(names = {"-o", "--outputDir"}, description = "Output directory")
- private String outputDir;
-
- @Parameter(names = {"-d", "--deleteSubjectOnFinish"}, description = "Delete file containing representation of test subject when finished")
- private boolean deleteSubjectOnFinish = false;
-
- public CommandLineArguments() {
- this.xmlProps = new ArrayList<>();
- }
-
- public File getPropertiesFile() {
- File fileRef;
- if (xmlProps.isEmpty()) {
- fileRef = new File(System.getProperty("user.home"), "test-run-props.xml");
- } else {
- String propsFile = xmlProps.get(0);
- fileRef = (propsFile.startsWith("file:")) ? new File(URI.create(propsFile)) : new File(propsFile);
- }
- return fileRef;
- }
-
- public String getOutputDir() {
- return (null != outputDir) ? outputDir : System.getProperty("user.home");
- }
-
- public boolean doDeleteSubjectOnFinish() {
- return deleteSubjectOnFinish;
- }
+ @Parameter(description = "Properties file")
+ private final List xmlProps;
+
+ @Parameter(names = { "-o", "--outputDir" }, description = "Output directory")
+ private String outputDir;
+
+ @Parameter(names = { "-d", "--deleteSubjectOnFinish" },
+ description = "Delete file containing representation of test subject when finished")
+ private boolean deleteSubjectOnFinish = false;
+
+ public CommandLineArguments() {
+ this.xmlProps = new ArrayList<>();
+ }
+
+ public File getPropertiesFile() {
+ File fileRef;
+ if (xmlProps.isEmpty()) {
+ fileRef = new File(System.getProperty("user.home"), "test-run-props.xml");
+ }
+ else {
+ String propsFile = xmlProps.get(0);
+ fileRef = (propsFile.startsWith("file:")) ? new File(URI.create(propsFile)) : new File(propsFile);
+ }
+ return fileRef;
+ }
+
+ public String getOutputDir() {
+ return (null != outputDir) ? outputDir : System.getProperty("user.home");
+ }
+
+ public boolean doDeleteSubjectOnFinish() {
+ return deleteSubjectOnFinish;
+ }
+
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonDataFixture.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonDataFixture.java
index ac2ffbf..ececb65 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonDataFixture.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonDataFixture.java
@@ -20,64 +20,67 @@
*/
public class CommonDataFixture extends CommonFixture {
- private static final int DEFAULT_NUMBER_OF_COLLECTIONS = 3;
-
- private OpenApi3 apiModel;
-
- private List requirementClasses;
-
- protected int noOfCollections = DEFAULT_NUMBER_OF_COLLECTIONS;
-
- @BeforeClass
- public void requirementClasses( ITestContext testContext ) {
- this.requirementClasses = (List) testContext.getSuite().getAttribute( REQUIREMENTCLASSES.getName() );
- }
-
- @BeforeClass
- public void noOfCollections( ITestContext testContext ) {
- Object noOfCollections = testContext.getSuite().getAttribute( NO_OF_COLLECTIONS.getName() );
- if ( noOfCollections != null ) {
- this.noOfCollections = (Integer) noOfCollections;
- }
- }
-
- @BeforeClass
- public void retrieveApiModel( ITestContext testContext ) {
- this.apiModel = (OpenApi3) testContext.getSuite().getAttribute( API_MODEL.getName() );
- }
-
- public OpenApi3 getApiModel() {
- if ( apiModel == null )
- throw new SkipException( "ApiModel is not available." );
- return apiModel;
- }
-
- protected List createListOfMediaTypesToSupportForOtherResources( Map linkToSelf ) {
- if ( this.requirementClasses == null )
- throw new SkipException( "No requirement classes described in resource /conformance available" );
- List mediaTypesToSupport = new ArrayList<>();
- for ( RequirementClass requirementClass : this.requirementClasses )
- if ( requirementClass.hasMediaTypeForOtherResources() )
- mediaTypesToSupport.add( requirementClass.getMediaTypeOtherResources() );
- if ( linkToSelf != null )
- mediaTypesToSupport.remove( linkToSelf.get( "type" ) );
- return mediaTypesToSupport;
- }
-
- protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures() {
- if ( this.requirementClasses == null )
- throw new SkipException( "No requirement classes described in resource /conformance available" );
- List mediaTypesToSupport = new ArrayList<>();
- for ( RequirementClass requirementClass : this.requirementClasses )
- if ( requirementClass.hasMediaTypeForFeaturesAndCollections() )
- mediaTypesToSupport.add( requirementClass.getMediaTypeFeaturesAndCollections() );
- return mediaTypesToSupport;
- }
-
- protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures( Map linkToSelf ) {
- List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures();
- if ( linkToSelf != null )
- mediaTypesToSupport.remove( linkToSelf.get( "type" ) );
- return mediaTypesToSupport;
- }
+ private static final int DEFAULT_NUMBER_OF_COLLECTIONS = 3;
+
+ private OpenApi3 apiModel;
+
+ private List requirementClasses;
+
+ protected int noOfCollections = DEFAULT_NUMBER_OF_COLLECTIONS;
+
+ @BeforeClass
+ public void requirementClasses(ITestContext testContext) {
+ this.requirementClasses = (List) testContext.getSuite()
+ .getAttribute(REQUIREMENTCLASSES.getName());
+ }
+
+ @BeforeClass
+ public void noOfCollections(ITestContext testContext) {
+ Object noOfCollections = testContext.getSuite().getAttribute(NO_OF_COLLECTIONS.getName());
+ if (noOfCollections != null) {
+ this.noOfCollections = (Integer) noOfCollections;
+ }
+ }
+
+ @BeforeClass
+ public void retrieveApiModel(ITestContext testContext) {
+ this.apiModel = (OpenApi3) testContext.getSuite().getAttribute(API_MODEL.getName());
+ }
+
+ public OpenApi3 getApiModel() {
+ if (apiModel == null)
+ throw new SkipException("ApiModel is not available.");
+ return apiModel;
+ }
+
+ protected List createListOfMediaTypesToSupportForOtherResources(Map linkToSelf) {
+ if (this.requirementClasses == null)
+ throw new SkipException("No requirement classes described in resource /conformance available");
+ List mediaTypesToSupport = new ArrayList<>();
+ for (RequirementClass requirementClass : this.requirementClasses)
+ if (requirementClass.hasMediaTypeForOtherResources())
+ mediaTypesToSupport.add(requirementClass.getMediaTypeOtherResources());
+ if (linkToSelf != null)
+ mediaTypesToSupport.remove(linkToSelf.get("type"));
+ return mediaTypesToSupport;
+ }
+
+ protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures() {
+ if (this.requirementClasses == null)
+ throw new SkipException("No requirement classes described in resource /conformance available");
+ List mediaTypesToSupport = new ArrayList<>();
+ for (RequirementClass requirementClass : this.requirementClasses)
+ if (requirementClass.hasMediaTypeForFeaturesAndCollections())
+ mediaTypesToSupport.add(requirementClass.getMediaTypeFeaturesAndCollections());
+ return mediaTypesToSupport;
+ }
+
+ protected List createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures(
+ Map linkToSelf) {
+ List mediaTypesToSupport = createListOfMediaTypesToSupportForFeatureCollectionsAndFeatures();
+ if (linkToSelf != null)
+ mediaTypesToSupport.remove(linkToSelf.get("type"));
+ return mediaTypesToSupport;
+ }
+
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonFixture.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonFixture.java
index 5573155..d816b70 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonFixture.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/CommonFixture.java
@@ -49,358 +49,369 @@
import io.restassured.response.Response;
import io.restassured.specification.RequestSpecification;
-
/**
- * 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 {
- private ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream();
-
- private ByteArrayOutputStream responseOutputStream = new ByteArrayOutputStream();
-
- protected RequestLoggingFilter requestLoggingFilter;
-
- protected ResponseLoggingFilter responseLoggingFilter;
-
- protected URL specURL;
-
- protected URI rootUri;
-
- protected int limit = 0;
-
- protected boolean testAllProcesses = false;
-
- /** A String representing the request. */
- protected HttpRequest reqEntity;
- /** An Object representing the content of the response message. */
- protected Object rspEntity;
-
- protected final String CONTENT_TYPE = "Content-Type";
-
- protected final String CONTENT_MEDIA_TYPE_PROPERTY_KEY = "contentMediaType";
-
- protected final String CONTENT_SCHEMA_PROPERTY_KEY = "contentSchema";
-
- protected final String CONTENT_ENCODING_PROPERTY_KEY = "contentEncoding";
-
- private static final int MAX_RSP_ATTR_LENGTH = 4096;
-
- private static final String REQ_ATTR = "request";
-
- private static final String REQ_POST_ATTR = "post-request";
-
- private static final String RSP_ATTR = "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 ) {
- initLogging();
- rootUri = (URI) testContext.getSuite().getAttribute( SuiteAttribute.IUT.getName() );
- limit = (Integer) testContext.getSuite().getAttribute( SuiteAttribute.PROCESS_TEST_LIMIT.getName() );
- boolean useLocalSchema = (boolean) testContext.getSuite().getAttribute( SuiteAttribute.USE_LOCAL_SCHEMA.getName() );
- if(useLocalSchema) {
- specURL = getClass().getResource("/org/opengis/cite/ogcapiprocesses10/openapi/api-processes10.yaml");
- } else {
- try {
- specURL = new URI("https://developer.ogc.org/api/processes/openapi.yaml").toURL();
- } catch (MalformedURLException | URISyntaxException e) {
- e.printStackTrace();
- }
- }
- }
-
- @BeforeMethod
- public void clearMessages() {
- initLogging();
- }
-
- public String getRequest() {
- return requestOutputStream.toString();
- }
-
- public String getResponse() {
- return responseOutputStream.toString();
- }
-
- protected RequestSpecification init() {
- return given().filters( requestLoggingFilter, responseLoggingFilter ).log().all();
- }
-
- /**
- * 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).
- *
- * @return A ClientRequest object.
- *
- * @see ClientUtils#buildGetRequest public ClientRequest buildGetRequest( URI endpoint, Map String, String
- * qryParams, MediaType... mediaTypes ) { return ClientUtils.buildGetRequest( endpoint, qryParams, mediaTypes
- * ); }
- */
-
-
- /**
- *
- */
- protected boolean validateResponseAgainstSchema(String urlSchema,String body){
- ObjectMapper objMapper =new ObjectMapper(new YAMLFactory());
- JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7)).objectMapper(objMapper).build();
- SchemaValidatorsConfig config = new SchemaValidatorsConfig();
- config.setTypeLoose(false);
- try{
- JsonSchema jsonSchema = factory.getSchema(new URI(urlSchema), config);
- ObjectMapper objectMapper =new ObjectMapper();
- JsonNode json = objectMapper.readTree(body);
- Set validationResult = jsonSchema.validate(json);
- if (validationResult.isEmpty()) {
- System.out.println("no validation errors :-)");
- return true;
- } else {
- validationResult.forEach(vm -> System.out.println(vm.getMessage()));
- return false;
- }
- } catch (Exception e) {
- e.printStackTrace();
- return false;
+ private ByteArrayOutputStream requestOutputStream = new ByteArrayOutputStream();
+
+ private ByteArrayOutputStream responseOutputStream = new ByteArrayOutputStream();
+
+ protected RequestLoggingFilter requestLoggingFilter;
+
+ protected ResponseLoggingFilter responseLoggingFilter;
+
+ protected URL specURL;
+
+ protected URI rootUri;
+
+ protected int limit = 0;
+
+ protected boolean testAllProcesses = false;
+
+ /** A String representing the request. */
+ protected HttpRequest reqEntity;
+
+ /** An Object representing the content of the response message. */
+ protected Object rspEntity;
+
+ protected final String CONTENT_TYPE = "Content-Type";
+
+ protected final String CONTENT_MEDIA_TYPE_PROPERTY_KEY = "contentMediaType";
+
+ protected final String CONTENT_SCHEMA_PROPERTY_KEY = "contentSchema";
+
+ protected final String CONTENT_ENCODING_PROPERTY_KEY = "contentEncoding";
+
+ private static final int MAX_RSP_ATTR_LENGTH = 4096;
+
+ private static final String REQ_ATTR = "request";
+
+ private static final String REQ_POST_ATTR = "post-request";
+
+ private static final String RSP_ATTR = "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) {
+ initLogging();
+ rootUri = (URI) testContext.getSuite().getAttribute(SuiteAttribute.IUT.getName());
+ limit = (Integer) testContext.getSuite().getAttribute(SuiteAttribute.PROCESS_TEST_LIMIT.getName());
+ boolean useLocalSchema = (boolean) testContext.getSuite()
+ .getAttribute(SuiteAttribute.USE_LOCAL_SCHEMA.getName());
+ if (useLocalSchema) {
+ specURL = getClass().getResource("/org/opengis/cite/ogcapiprocesses10/openapi/api-processes10.yaml");
+ }
+ else {
+ try {
+ specURL = new URI("https://developer.ogc.org/api/processes/openapi.yaml").toURL();
+ }
+ catch (MalformedURLException | URISyntaxException e) {
+ e.printStackTrace();
+ }
+ }
}
- }
-
- /**
- * Try to implement testing for A.5. Conformance Class HTML
- * TODO: Abtract Test 56: /conf/html/content
- * Abtract Test 57: /conf/html/definition
- */
- protected void checkHtmlConfClass(String uri){
- Response request = init().baseUri( uri ).accept( HTML ).when().request( GET );
- //TestSuiteLogger.log(Level.INFO, rootUri.toString());
- request.then().statusCode( 200 );
- String headerValue = request.getHeader("Content-Type");
- System.out.println("Content-type header fecthed: "+headerValue);
- if(headerValue.indexOf("text/html")<0)
- throw new AssertionError( "The Content-type header should be text/html but '"
- + headerValue
- + "' has been found" );
- String bodyHTML = request.getBody().asString();
- }
-
-
- private void initLogging() {
- this.requestOutputStream = new ByteArrayOutputStream();
- this.responseOutputStream = new ByteArrayOutputStream();
- PrintStream requestPrintStream = new PrintStream( requestOutputStream, true );
- PrintStream responsePrintStream = new PrintStream( responseOutputStream, true );
- requestLoggingFilter = new RequestLoggingFilter( requestPrintStream );
- responseLoggingFilter = new ResponseLoggingFilter( responsePrintStream );
- }
-
- protected String printResults(ValidationResults validationResults) {
- List validationItems = validationResults.items();
- StringBuilder printedResultsStringBuilder = new StringBuilder();
- for (ValidationItem validationItem : validationItems) {
+
+ @BeforeMethod
+ public void clearMessages() {
+ initLogging();
+ }
+
+ public String getRequest() {
+ return requestOutputStream.toString();
+ }
+
+ public String getResponse() {
+ return responseOutputStream.toString();
+ }
+
+ protected RequestSpecification init() {
+ return given().filters(requestLoggingFilter, responseLoggingFilter).log().all();
+ }
+
+ /**
+ * 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).
+ * @return A ClientRequest object.
+ *
+ * @see ClientUtils#buildGetRequest public ClientRequest buildGetRequest( URI
+ * endpoint, Map String, String qryParams, MediaType... mediaTypes ) { return
+ * ClientUtils.buildGetRequest( endpoint, qryParams, mediaTypes ); }
+ */
+
+ /**
+ *
+ */
+ protected boolean validateResponseAgainstSchema(String urlSchema, String body) {
+ ObjectMapper objMapper = new ObjectMapper(new YAMLFactory());
+ JsonSchemaFactory factory = JsonSchemaFactory.builder(JsonSchemaFactory.getInstance(SpecVersion.VersionFlag.V7))
+ .objectMapper(objMapper).build();
+ SchemaValidatorsConfig config = new SchemaValidatorsConfig();
+ config.setTypeLoose(false);
+ try {
+ JsonSchema jsonSchema = factory.getSchema(new URI(urlSchema), config);
+ ObjectMapper objectMapper = new ObjectMapper();
+ JsonNode json = objectMapper.readTree(body);
+ Set validationResult = jsonSchema.validate(json);
+ if (validationResult.isEmpty()) {
+ System.out.println("no validation errors :-)");
+ return true;
+ }
+ else {
+ validationResult.forEach(vm -> System.out.println(vm.getMessage()));
+ return false;
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * Try to implement testing for A.5. Conformance Class HTML TODO: Abtract Test 56:
+ * /conf/html/content Abtract Test 57: /conf/html/definition
+ */
+ protected void checkHtmlConfClass(String uri) {
+ Response request = init().baseUri(uri).accept(HTML).when().request(GET);
+ // TestSuiteLogger.log(Level.INFO, rootUri.toString());
+ request.then().statusCode(200);
+ String headerValue = request.getHeader("Content-Type");
+ System.out.println("Content-type header fecthed: " + headerValue);
+ if (headerValue.indexOf("text/html") < 0)
+ throw new AssertionError(
+ "The Content-type header should be text/html but '" + headerValue + "' has been found");
+ String bodyHTML = request.getBody().asString();
+ }
+
+ private void initLogging() {
+ this.requestOutputStream = new ByteArrayOutputStream();
+ this.responseOutputStream = new ByteArrayOutputStream();
+ PrintStream requestPrintStream = new PrintStream(requestOutputStream, true);
+ PrintStream responsePrintStream = new PrintStream(responseOutputStream, true);
+ requestLoggingFilter = new RequestLoggingFilter(requestPrintStream);
+ responseLoggingFilter = new ResponseLoggingFilter(responsePrintStream);
+ }
+
+ protected String printResults(ValidationResults validationResults) {
+ List validationItems = validationResults.items();
+ StringBuilder printedResultsStringBuilder = new StringBuilder();
+ for (ValidationItem validationItem : validationItems) {
printedResultsStringBuilder.append(validationItem + "\n");
- }
- return printedResultsStringBuilder.toString();
- }
-
- protected void addServerUnderTest(OpenApi3 openApi3) {
+ }
+ return printedResultsStringBuilder.toString();
+ }
+
+ protected void addServerUnderTest(OpenApi3 openApi3) {
Server serverUnderTest = new Server();
String authority = rootUri.getAuthority();
String scheme = rootUri.getScheme();
serverUnderTest.setUrl(scheme + "://" + authority);
openApi3.addServer(serverUnderTest);
}
-
- protected Input createInput(JsonNode schemaNode, String id) {
- Input input = new Input(id);
- JsonNode typeNode = schemaNode.get("type");
- if(typeNode != null) {
- String typeDefinition = typeNode.asText();
- Type type = new Type(typeDefinition);
- if(typeDefinition.equals("object")) {
- JsonNode propertiesNode = schemaNode.get("properties");
- if(propertiesNode != null) {
- Iterator propertyNames = propertiesNode.fieldNames();
- while (propertyNames.hasNext()) {
- String propertyName = (String) propertyNames.next();
- if(propertyName.equals("bbox")) {
- input.setBbox(true);
- break;
+
+ protected Input createInput(JsonNode schemaNode, String id) {
+ Input input = new Input(id);
+ JsonNode typeNode = schemaNode.get("type");
+ if (typeNode != null) {
+ String typeDefinition = typeNode.asText();
+ Type type = new Type(typeDefinition);
+ if (typeDefinition.equals("object")) {
+ JsonNode propertiesNode = schemaNode.get("properties");
+ if (propertiesNode != null) {
+ Iterator propertyNames = propertiesNode.fieldNames();
+ while (propertyNames.hasNext()) {
+ String propertyName = (String) propertyNames.next();
+ if (propertyName.equals("bbox")) {
+ input.setBbox(true);
+ break;
+ }
+ }
+ }
}
- }
- }
- } else if(typeDefinition.equals("string")) {
- JsonNode formatNode = schemaNode.get("format");
- if(formatNode != null) {
- String format = formatNode.asText();
- input.setFormat(format);
- if(format.equals("byte")) {
- type.setBinary(true);
- }
- }
- JsonNode contentMediaTypeNode = schemaNode.get(CONTENT_MEDIA_TYPE_PROPERTY_KEY);
- if(contentMediaTypeNode != null && !contentMediaTypeNode.isMissingNode()) {
- type.setContentMediaType(contentMediaTypeNode.asText());
- }
- JsonNode contentEncodingNode = schemaNode.get(CONTENT_ENCODING_PROPERTY_KEY);
- if(contentEncodingNode != null && !contentEncodingNode.isMissingNode()) {
- String contentEncodingNodeText = contentEncodingNode.asText();
- if(contentEncodingNodeText.equals("binary")) {
- type.setBinary(true);
- }
- type.setContentEncoding(contentEncodingNodeText);
- }
- JsonNode contentSchemaNode = schemaNode.get(CONTENT_SCHEMA_PROPERTY_KEY);
- if(contentSchemaNode != null && !contentSchemaNode.isMissingNode()) {
- type.setContentSchema(contentSchemaNode.asText());
- }
- } else if (typeDefinition.equals("array")) {
- JsonNode itemsNode = schemaNode.get("items");
- if(itemsNode != null) {
- JsonNode itemsTypeNode = itemsNode.get("type");
- if(itemsTypeNode != null) {
- Type itemsType = new Type(itemsTypeNode.asText());
- input.addType(itemsType);
- }
- }
- }
- input.addType(type);
- }else {
- //oneOf, allOf, anyOf
- JsonNode oneOfNode = schemaNode.get("oneOf");
- if(oneOfNode != null) {
- if(oneOfNode instanceof ArrayNode) {
- ArrayNode oneOfArrayNode = (ArrayNode)oneOfNode;
- for (int i = 0; i < oneOfArrayNode.size(); i++) {
- JsonNode oneOfChildNode = oneOfArrayNode.get(i);
- JsonNode oneOfTypeNode = oneOfChildNode.get("type");
- if(oneOfTypeNode != null) {
- String typeDefinition = oneOfTypeNode.asText();
- Type type = new Type(typeDefinition);
- if(typeDefinition.equals("object")) {
- JsonNode propertiesNode = oneOfChildNode.get("properties");
- if(propertiesNode != null) {
- Iterator propertyNames = propertiesNode.fieldNames();
- while (propertyNames.hasNext()) {
- String propertyName = (String) propertyNames.next();
- if(propertyName.equals("bbox")) {
- input.setBbox(true);
- break;
+ else if (typeDefinition.equals("string")) {
+ JsonNode formatNode = schemaNode.get("format");
+ if (formatNode != null) {
+ String format = formatNode.asText();
+ input.setFormat(format);
+ if (format.equals("byte")) {
+ type.setBinary(true);
}
- }
}
- } else if(typeDefinition.equals("string")) {
- JsonNode formatNode = oneOfChildNode.get("format");
- if(formatNode != null) {
- String format = formatNode.asText();
- if(format.equals("byte")) {
- type.setBinary(true);
- }
+ JsonNode contentMediaTypeNode = schemaNode.get(CONTENT_MEDIA_TYPE_PROPERTY_KEY);
+ if (contentMediaTypeNode != null && !contentMediaTypeNode.isMissingNode()) {
+ type.setContentMediaType(contentMediaTypeNode.asText());
+ }
+ JsonNode contentEncodingNode = schemaNode.get(CONTENT_ENCODING_PROPERTY_KEY);
+ if (contentEncodingNode != null && !contentEncodingNode.isMissingNode()) {
+ String contentEncodingNodeText = contentEncodingNode.asText();
+ if (contentEncodingNodeText.equals("binary")) {
+ type.setBinary(true);
+ }
+ type.setContentEncoding(contentEncodingNodeText);
}
- JsonNode contentMediaTypeNode = oneOfChildNode.get(CONTENT_MEDIA_TYPE_PROPERTY_KEY);
- if(contentMediaTypeNode != null && !contentMediaTypeNode.isMissingNode()) {
- type.setContentMediaType(contentMediaTypeNode.asText());
+ JsonNode contentSchemaNode = schemaNode.get(CONTENT_SCHEMA_PROPERTY_KEY);
+ if (contentSchemaNode != null && !contentSchemaNode.isMissingNode()) {
+ type.setContentSchema(contentSchemaNode.asText());
}
- JsonNode contentEncodingNode = oneOfChildNode.get(CONTENT_ENCODING_PROPERTY_KEY);
- if(contentEncodingNode != null && !contentEncodingNode.isMissingNode()) {
- String contentEncodingNodeText = contentEncodingNode.asText();
- if(contentEncodingNodeText.equals("binary")) {
- type.setBinary(true);
- }
- type.setContentEncoding(contentEncodingNodeText);
+ }
+ else if (typeDefinition.equals("array")) {
+ JsonNode itemsNode = schemaNode.get("items");
+ if (itemsNode != null) {
+ JsonNode itemsTypeNode = itemsNode.get("type");
+ if (itemsTypeNode != null) {
+ Type itemsType = new Type(itemsTypeNode.asText());
+ input.addType(itemsType);
+ }
}
- JsonNode contentSchemaNode = oneOfChildNode.get(CONTENT_SCHEMA_PROPERTY_KEY);
- if(contentSchemaNode != null && !contentSchemaNode.isMissingNode()) {
- type.setContentSchema(contentSchemaNode.asText());
+ }
+ input.addType(type);
+ }
+ else {
+ // oneOf, allOf, anyOf
+ JsonNode oneOfNode = schemaNode.get("oneOf");
+ if (oneOfNode != null) {
+ if (oneOfNode instanceof ArrayNode) {
+ ArrayNode oneOfArrayNode = (ArrayNode) oneOfNode;
+ for (int i = 0; i < oneOfArrayNode.size(); i++) {
+ JsonNode oneOfChildNode = oneOfArrayNode.get(i);
+ JsonNode oneOfTypeNode = oneOfChildNode.get("type");
+ if (oneOfTypeNode != null) {
+ String typeDefinition = oneOfTypeNode.asText();
+ Type type = new Type(typeDefinition);
+ if (typeDefinition.equals("object")) {
+ JsonNode propertiesNode = oneOfChildNode.get("properties");
+ if (propertiesNode != null) {
+ Iterator propertyNames = propertiesNode.fieldNames();
+ while (propertyNames.hasNext()) {
+ String propertyName = (String) propertyNames.next();
+ if (propertyName.equals("bbox")) {
+ input.setBbox(true);
+ break;
+ }
+ }
+ }
+ }
+ else if (typeDefinition.equals("string")) {
+ JsonNode formatNode = oneOfChildNode.get("format");
+ if (formatNode != null) {
+ String format = formatNode.asText();
+ if (format.equals("byte")) {
+ type.setBinary(true);
+ }
+ }
+ JsonNode contentMediaTypeNode = oneOfChildNode.get(CONTENT_MEDIA_TYPE_PROPERTY_KEY);
+ if (contentMediaTypeNode != null && !contentMediaTypeNode.isMissingNode()) {
+ type.setContentMediaType(contentMediaTypeNode.asText());
+ }
+ JsonNode contentEncodingNode = oneOfChildNode.get(CONTENT_ENCODING_PROPERTY_KEY);
+ if (contentEncodingNode != null && !contentEncodingNode.isMissingNode()) {
+ String contentEncodingNodeText = contentEncodingNode.asText();
+ if (contentEncodingNodeText.equals("binary")) {
+ type.setBinary(true);
+ }
+ type.setContentEncoding(contentEncodingNodeText);
+ }
+ JsonNode contentSchemaNode = oneOfChildNode.get(CONTENT_SCHEMA_PROPERTY_KEY);
+ if (contentSchemaNode != null && !contentSchemaNode.isMissingNode()) {
+ type.setContentSchema(contentSchemaNode.asText());
+ }
+ }
+ else if (typeDefinition.equals("array")) {
+ JsonNode itemsNode = oneOfChildNode.get("items");
+ if (itemsNode != null) {
+ JsonNode itemsTypeNode = itemsNode.get("type");
+ if (itemsTypeNode != null) {
+ Type itemsType = new Type(itemsTypeNode.asText());
+ input.addType(itemsType);
+ }
+ }
+ }
+ input.addType(type);
+ }
+ }
+ }
+ }
+ else {
+ if (checkAllOfForBbox(schemaNode)) {
+ input.setBbox(true);
+ }
+ }
+ }
+ return input;
+ }
+
+ private boolean checkAllOfForBbox(JsonNode schemaNode) {
+ JsonNode allOfNode = schemaNode.get("allOf");
+ if (allOfNode != null) {
+ if (allOfNode instanceof ArrayNode) {
+ for (JsonNode jsonNode : allOfNode) {
+ JsonNode formatNode = jsonNode.get("format");
+ String format = formatNode.asText();
+ if (format.equals("ogc-bbox")) {
+ return true;
+ }
}
- } else if (typeDefinition.equals("array")) {
- JsonNode itemsNode = oneOfChildNode.get("items");
- if(itemsNode != null) {
- JsonNode itemsTypeNode = itemsNode.get("type");
- if(itemsTypeNode != null) {
- Type itemsType = new Type(itemsTypeNode.asText());
- input.addType(itemsType);
- }
- }
- }
- input.addType(type);
}
- }
- }
- }else {
- if(checkAllOfForBbox(schemaNode)) {
- input.setBbox(true);
- }
- }
- }
- return input;
- }
-
- private boolean checkAllOfForBbox(JsonNode schemaNode) {
- JsonNode allOfNode = schemaNode.get("allOf");
- if(allOfNode != null) {
- if(allOfNode instanceof ArrayNode) {
- for (JsonNode jsonNode : allOfNode) {
- JsonNode formatNode = jsonNode.get("format");
- String format = formatNode.asText();
- if(format.equals("ogc-bbox")) {
- return true;
- }
- }
- }
- }
- return false;
- }
-
- protected Output createOutput(JsonNode schemaNode, String id) {
+ }
+ return false;
+ }
+
+ protected Output createOutput(JsonNode schemaNode, String id) {
Output output = new Output(id);
- JsonNode typeNode = schemaNode.get("type");
- if(typeNode != null) {
- String typeDefinition = typeNode.asText();
- if (typeDefinition.equals("array")) {
- Type itemsType = new Type(typeDefinition);
- output.addType(itemsType);
- }
- } else {
- if(checkAllOfForBbox(schemaNode)) {
- output.setBbox(true);
- }
- }
+ JsonNode typeNode = schemaNode.get("type");
+ if (typeNode != null) {
+ String typeDefinition = typeNode.asText();
+ if (typeDefinition.equals("array")) {
+ Type itemsType = new Type(typeDefinition);
+ output.addType(itemsType);
+ }
+ }
+ else {
+ if (checkAllOfForBbox(schemaNode)) {
+ output.setBbox(true);
+ }
+ }
return output;
}
-
+
public class Type {
-
+
private String typeDefinition;
+
private String contentEncoding;
+
private String contentMediaType;
+
private String contentSchema;
+
private boolean isBinary;
+
private String format;
public Type(String typeDefinition) {
this.typeDefinition = typeDefinition;
}
-
+
public boolean isBinary() {
return isBinary;
}
@@ -424,12 +435,12 @@ public String getContentMediaType() {
public void setContentMediaType(String contentMediaType) {
this.contentMediaType = contentMediaType;
}
-
+
public void setContentSchema(String schema) {
this.contentSchema = schema;
-
+
}
-
+
public String getContentSchema() {
return contentSchema;
}
@@ -448,28 +459,32 @@ public String toString() {
return builder.toString();
}
- public String getFormat() {
- return format;
- }
+ public String getFormat() {
+ return format;
+ }
+
}
public class Input {
-
+
protected String id;
+
protected List types;
+
protected boolean isBbox;
+
protected String format;
-
+
public Input(String id, List types, boolean isBbox) {
this.id = id;
this.types = types;
this.isBbox = isBbox;
}
-
+
public Input(String id, Type type) {
- this(id, Arrays.asList(new Type[] {type}), false);
+ this(id, Arrays.asList(new Type[] { type }), false);
}
-
+
public Input(String id) {
this(id, new ArrayList(), false);
}
@@ -485,24 +500,24 @@ public void setBbox(boolean isBbox) {
public String getId() {
return id;
}
-
+
public List getTypes() {
return types;
}
-
+
public boolean addType(Type type) {
return types.add(type);
}
public String getFormat() {
- return format;
- }
+ return format;
+ }
- public void setFormat(String format) {
- this.format = format;
- }
+ public void setFormat(String format) {
+ this.format = format;
+ }
- @Override
+ @Override
public String toString() {
StringBuilder builder = new StringBuilder();
builder.append("Id: " + id + "\n");
@@ -510,33 +525,35 @@ public String toString() {
builder.append("\tIs bbox: " + isBbox);
return builder.toString();
}
-
+
}
public class Output {
-
+
private String id;
+
private List types;
+
private boolean bbox;
-
+
public Output(String id) {
this.id = id;
this.types = new ArrayList();
}
public void addType(Type itemsType) {
- types.add(itemsType);
- }
+ types.add(itemsType);
+ }
+
+ public void setBbox(boolean b) {
+ bbox = true;
+ }
- public void setBbox(boolean b) {
- bbox = true;
- }
-
public boolean isBbox() {
- return bbox;
+ return bbox;
}
- public String getId() {
+ public String getId() {
return id;
}
@@ -559,66 +576,68 @@ public String toString() {
builder.append("\tType: " + types + "\n");
return builder.toString();
}
-
+
}
- /**
- * Augments the test result with supplementary attributes in the event that
- * a test method failed. The "request" attribute contains a String
- * representing the request entity (POST method) or query component (GET
- * method). The "response" attribute contains the content of the response
- * entity.
- *
- * @param result
- * A description of the test result.
- */
- @AfterMethod
- public void addAttributesOnTestFailure(ITestResult result) {
- if (result.getStatus() != ITestResult.FAILURE) {
- return;
- }
- if (null != this.reqEntity) {
- result.setAttribute(REQ_ATTR, this.reqEntity.toString());
- }
- if (null != this.reqEntity) {
- String request = "";
- if (this.reqEntity instanceof HttpGet) {
- request = this.reqEntity.toString();
- } else {
- // https://github.com/opengeospatial/ets-ogcapi-processes10/issues/51
- try {
- HttpPost postRequest = (HttpPost)this.reqEntity;
- result.setAttribute(REQ_POST_ATTR, postRequest.toString());
- request = JsonUtils.inputStreamToString(postRequest.getEntity().getContent());
- // we have to add a "<" at the start, because this is used by TEAM Engine EarlReporter
- // to differentiate between GET and POST.
- request = "\n" + request;
- } catch (Exception e) {
- TestSuiteLogger.log(Level.WARNING, "Could not get POST endpoint URI.", e);
- }
- }
- result.setAttribute(REQ_ATTR, request);
- }
- if (null != this.rspEntity) {
- StringBuilder response = new StringBuilder();
- if (this.rspEntity instanceof InputStream) {
- try {
- response = response.append(JsonUtils.inputStreamToString((InputStream) rspEntity));
- } catch (IOException e) {
- TestSuiteLogger.log(Level.WARNING, "Could not write response to String.", e);
- }
- } else if(rspEntity instanceof String) {
- response = response.append((String)rspEntity);
- }
- String responseString = JsonUtils.prettifyString(response.toString());
- if (response.length() > MAX_RSP_ATTR_LENGTH) {
- response = new StringBuilder();
- response.append(responseString);
- response.delete(MAX_RSP_ATTR_LENGTH, response.length());
- responseString = response.toString();
- }
- result.setAttribute(RSP_ATTR, responseString);
- }
- }
+ /**
+ * Augments the test result with supplementary attributes in the event that a test
+ * method failed. The "request" attribute contains a String representing the request
+ * entity (POST method) or query component (GET method). The "response" attribute
+ * contains the content of the response entity.
+ * @param result A description of the test result.
+ */
+ @AfterMethod
+ public void addAttributesOnTestFailure(ITestResult result) {
+ if (result.getStatus() != ITestResult.FAILURE) {
+ return;
+ }
+ if (null != this.reqEntity) {
+ result.setAttribute(REQ_ATTR, this.reqEntity.toString());
+ }
+ if (null != this.reqEntity) {
+ String request = "";
+ if (this.reqEntity instanceof HttpGet) {
+ request = this.reqEntity.toString();
+ }
+ else {
+ // https://github.com/opengeospatial/ets-ogcapi-processes10/issues/51
+ try {
+ HttpPost postRequest = (HttpPost) this.reqEntity;
+ result.setAttribute(REQ_POST_ATTR, postRequest.toString());
+ request = JsonUtils.inputStreamToString(postRequest.getEntity().getContent());
+ // we have to add a "<" at the start, because this is used by TEAM
+ // Engine EarlReporter
+ // to differentiate between GET and POST.
+ request = "\n" + request;
+ }
+ catch (Exception e) {
+ TestSuiteLogger.log(Level.WARNING, "Could not get POST endpoint URI.", e);
+ }
+ }
+ result.setAttribute(REQ_ATTR, request);
+ }
+ if (null != this.rspEntity) {
+ StringBuilder response = new StringBuilder();
+ if (this.rspEntity instanceof InputStream) {
+ try {
+ response = response.append(JsonUtils.inputStreamToString((InputStream) rspEntity));
+ }
+ catch (IOException e) {
+ TestSuiteLogger.log(Level.WARNING, "Could not write response to String.", e);
+ }
+ }
+ else if (rspEntity instanceof String) {
+ response = response.append((String) rspEntity);
+ }
+ String responseString = JsonUtils.prettifyString(response.toString());
+ if (response.length() > MAX_RSP_ATTR_LENGTH) {
+ response = new StringBuilder();
+ response.append(responseString);
+ response.delete(MAX_RSP_ATTR_LENGTH, response.length());
+ responseString = response.toString();
+ }
+ result.setAttribute(RSP_ATTR, responseString);
+ }
+ }
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/ErrorMessage.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/ErrorMessage.java
index e3e530f..28265bf 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/ErrorMessage.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/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.ogcapiprocesses10.MessageBundle";
- private static ResourceBundle msgResources =
- ResourceBundle.getBundle(BASE_NAME);
+ private static final String BASE_NAME = "org.opengis.cite.ogcapiprocesses10.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/ogcapiprocesses10/ErrorMessageKeys.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/ErrorMessageKeys.java
index ee0cf1b..9d81194 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/ErrorMessageKeys.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/ErrorMessageKeys.java
@@ -1,22 +1,33 @@
package org.opengis.cite.ogcapiprocesses10;
/**
- * 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";
+ 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";
+
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/EtsAssert.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/EtsAssert.java
index 19ab078..dca2644 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/EtsAssert.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/EtsAssert.java
@@ -7,26 +7,24 @@
*/
public class EtsAssert {
- /**
- * @param valueToAssert
- * the boolean to assert to be true
- * @param failureMsg
- * the message to throw in case of a failure, should not be null
- */
- public static void assertTrue( boolean valueToAssert, String failureMsg ) {
- if ( !valueToAssert )
- throw new AssertionError( failureMsg );
- }
+ /**
+ * @param valueToAssert the boolean to assert to be true
+ * @param failureMsg the message to throw in case of a failure, should not be
+ * null
+ */
+ public static void assertTrue(boolean valueToAssert, String failureMsg) {
+ if (!valueToAssert)
+ throw new AssertionError(failureMsg);
+ }
- /**
- * @param valueToAssert
- * the boolean to assert to be false
- * @param failureMsg
- * the message to throw in case of a failure, should not be null
- */
- public static void assertFalse( boolean valueToAssert, String failureMsg ) {
- if ( valueToAssert )
- throw new AssertionError( failureMsg );
- }
+ /**
+ * @param valueToAssert the boolean to assert to be false
+ * @param failureMsg the message to throw in case of a failure, should not be
+ * null
+ */
+ public static void assertFalse(boolean valueToAssert, String failureMsg) {
+ if (valueToAssert)
+ throw new AssertionError(failureMsg);
+ }
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/Namespaces.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/Namespaces.java
index e64174e..9ed7a57 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/Namespaces.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/Namespaces.java
@@ -10,22 +10,25 @@
*/
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/ogcapiprocesses10/OgcApiProcesses10.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/OgcApiProcesses10.java
index 2cbc8c9..8e58fb0 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/OgcApiProcesses10.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/OgcApiProcesses10.java
@@ -7,11 +7,11 @@
*/
public class OgcApiProcesses10 {
- private OgcApiProcesses10() {
- }
+ private OgcApiProcesses10() {
+ }
- public static final String OPEN_API_MIME_TYPE = "application/vnd.oai.openapi+json;version=3.0";
+ public static final String OPEN_API_MIME_TYPE = "application/vnd.oai.openapi+json;version=3.0";
- public static final String GEOJSON_MIME_TYPE = "application/geo+json";
+ public static final String GEOJSON_MIME_TYPE = "application/geo+json";
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/ReusableEntityFilter.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/ReusableEntityFilter.java
index cc85b25..896f355 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/ReusableEntityFilter.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/ReusableEntityFilter.java
@@ -8,19 +8,20 @@
/**
* 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 {
- @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;
- }
+ @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;
+ }
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteAttribute.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteAttribute.java
index bea0366..e8430ee 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteAttribute.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteAttribute.java
@@ -9,82 +9,86 @@
import com.sun.jersey.api.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 ),
-
- /**
- * The root URL.
- */
- IUT( "instanceUnderTest", URI.class ),
-
- /**
- * A File containing the test subject or a description of it.
- */
- TEST_SUBJ_FILE( "testSubjectFile", File.class ),
-
- /**
- * The number of collections to test.
- */
- NO_OF_COLLECTIONS( "noOfCollections", Integer.class ),
-
- /**
- * The id of the echo process.
- */
- ECHO_PROCESS_ID( "echoProcessId", String.class ),
-
- /**
- * Boolean indicating whether all processes should be tested against the OGC Process Description Conformance Class.
- */
- TEST_ALL_PROCESSES( "testAllProcesses", Boolean.class ),
-
- /**
- * Number of processes that should be tested against the OGC Process Description Conformance Class.
- */
- PROCESS_TEST_LIMIT( "processTestLimit", Integer.class ),
-
- /**
- * Parsed OpenApi3 document resource /api; Added during execution.
- */
- API_MODEL( "apiModel", OpenApi3.class ),
-
- /**
- * Use local OpenAPI schema included in ETS.
- */
- USE_LOCAL_SCHEMA( "useLocalSchema", Boolean.class ),
-
- /**
- * Requirement classes parsed from /conformance; Added during execution.
- */
- REQUIREMENTCLASSES( "requirementclasses", List.class );
-
- private final Class attrType;
-
- private final String attrName;
-
- 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),
+
+ /**
+ * The root URL.
+ */
+ IUT("instanceUnderTest", URI.class),
+
+ /**
+ * A File containing the test subject or a description of it.
+ */
+ TEST_SUBJ_FILE("testSubjectFile", File.class),
+
+ /**
+ * The number of collections to test.
+ */
+ NO_OF_COLLECTIONS("noOfCollections", Integer.class),
+
+ /**
+ * The id of the echo process.
+ */
+ ECHO_PROCESS_ID("echoProcessId", String.class),
+
+ /**
+ * Boolean indicating whether all processes should be tested against the OGC Process
+ * Description Conformance Class.
+ */
+ TEST_ALL_PROCESSES("testAllProcesses", Boolean.class),
+
+ /**
+ * Number of processes that should be tested against the OGC Process Description
+ * Conformance Class.
+ */
+ PROCESS_TEST_LIMIT("processTestLimit", Integer.class),
+
+ /**
+ * Parsed OpenApi3 document resource /api; Added during execution.
+ */
+ API_MODEL("apiModel", OpenApi3.class),
+
+ /**
+ * Use local OpenAPI schema included in ETS.
+ */
+ USE_LOCAL_SCHEMA("useLocalSchema", Boolean.class),
+
+ /**
+ * Requirement classes parsed from /conformance; Added during execution.
+ */
+ REQUIREMENTCLASSES("requirementclasses", List.class);
+
+ private final Class attrType;
+
+ private final String attrName;
+
+ 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();
+ }
+
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteFixtureListener.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteFixtureListener.java
index 93407fc..2a290f9 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteFixtureListener.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/SuiteFixtureListener.java
@@ -15,126 +15,131 @@
import com.sun.jersey.api.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
+ * 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 {
- @Override
- public void onStart( ISuite suite ) {
- processSuiteParameters( suite );
- registerClientComponent( suite );
- }
+ @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" );
- }
- }
+ @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() );
- suite.setAttribute( SuiteAttribute.IUT.getName(), iutRef );
- 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 );
-
- String echoProcessId = params.get( TestRunArg.ECHOPROCESSID.toString() );
- try {
- if ( echoProcessId != null ) {
- suite.setAttribute( SuiteAttribute.ECHO_PROCESS_ID.getName(), echoProcessId );
- }
- } catch ( NumberFormatException e ) {
- TestSuiteLogger.log( Level.WARNING,
- String.format( "Could not parse parameter %s: %s. Expected is a valid string",
- TestRunArg.ECHOPROCESSID.toString(), echoProcessId ) );
- }
-
- String limit = params.get( TestRunArg.PROCESSTESTLIMIT.toString() );
- try {
- if ( limit != null ) {
- suite.setAttribute( SuiteAttribute.PROCESS_TEST_LIMIT.getName(), Integer.valueOf(limit) );
- }
- } catch ( NumberFormatException e ) {
- TestSuiteLogger.log( Level.WARNING,
- String.format( "Could not parse parameter %s: %s. Expected is a valid string",
- TestRunArg.PROCESSTESTLIMIT.toString(), limit ) );
- }
-
- suite.setAttribute( SuiteAttribute.USE_LOCAL_SCHEMA.getName(), true );
-
- String testAllProcesses = params.get( TestRunArg.TESTALLPROCESSES.toString() );
+ /**
+ * 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());
+ suite.setAttribute(SuiteAttribute.IUT.getName(), iutRef);
+ 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);
- try {
- if ( testAllProcesses != null ) {
- suite.setAttribute( SuiteAttribute.TEST_ALL_PROCESSES.getName(), Boolean.valueOf(testAllProcesses.equals("on")?true:false) );
- }else {
- suite.setAttribute( SuiteAttribute.TEST_ALL_PROCESSES.getName(), false );
- }
- } catch ( NumberFormatException e ) {
- TestSuiteLogger.log( Level.WARNING,
- String.format( "Could not parse parameter %s: %s. Expected is a valid string",
- TestRunArg.ECHOPROCESSID.toString(), echoProcessId ) );
- }
- }
+ String echoProcessId = params.get(TestRunArg.ECHOPROCESSID.toString());
+ try {
+ if (echoProcessId != null) {
+ suite.setAttribute(SuiteAttribute.ECHO_PROCESS_ID.getName(), echoProcessId);
+ }
+ }
+ catch (NumberFormatException e) {
+ TestSuiteLogger.log(Level.WARNING,
+ String.format("Could not parse parameter %s: %s. Expected is a valid string",
+ TestRunArg.ECHOPROCESSID.toString(), echoProcessId));
+ }
- /**
- * 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 );
- }
- }
+ String limit = params.get(TestRunArg.PROCESSTESTLIMIT.toString());
+ try {
+ if (limit != null) {
+ suite.setAttribute(SuiteAttribute.PROCESS_TEST_LIMIT.getName(), Integer.valueOf(limit));
+ }
+ }
+ catch (NumberFormatException e) {
+ TestSuiteLogger.log(Level.WARNING,
+ String.format("Could not parse parameter %s: %s. Expected is a valid string",
+ TestRunArg.PROCESSTESTLIMIT.toString(), limit));
+ }
+
+ suite.setAttribute(SuiteAttribute.USE_LOCAL_SCHEMA.getName(), true);
+
+ String testAllProcesses = params.get(TestRunArg.TESTALLPROCESSES.toString());
+
+ try {
+ if (testAllProcesses != null) {
+ suite.setAttribute(SuiteAttribute.TEST_ALL_PROCESSES.getName(),
+ Boolean.valueOf(testAllProcesses.equals("on") ? true : false));
+ }
+ else {
+ suite.setAttribute(SuiteAttribute.TEST_ALL_PROCESSES.getName(), false);
+ }
+ }
+ catch (NumberFormatException e) {
+ TestSuiteLogger.log(Level.WARNING,
+ String.format("Could not parse parameter %s: %s. Expected is a valid string",
+ TestRunArg.ECHOPROCESSID.toString(), echoProcessId));
+ }
+ }
+
+ /**
+ * 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/ogcapiprocesses10/SuitePreconditions.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/SuitePreconditions.java
index bfdb165..ab0852d 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/SuitePreconditions.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/SuitePreconditions.java
@@ -7,33 +7,32 @@
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.
+ * @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);
+ }
+ }
- /**
- * 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/ogcapiprocesses10/TestFailureListener.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestFailureListener.java
index 585b1c4..8e2eb32 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/TestFailureListener.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestFailureListener.java
@@ -12,87 +12,84 @@
import org.w3c.dom.Document;
/**
- * 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", fixture.getRequest());
- result.setAttribute("response", fixture.getResponse());
- }
- }
+ /**
+ * 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", fixture.getRequest());
+ result.setAttribute("response", fixture.getResponse());
+ }
+ }
- /**
- * 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(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 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(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();
+ }
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/TestNGController.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestNGController.java
index 0f2aaaa..0ba38a2 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/TestNGController.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestNGController.java
@@ -30,140 +30,138 @@
*/
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);
- 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 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);
+ 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/ogcapiprocesses10/TestRunArg.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestRunArg.java
index 3c86740..6a24abe 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/TestRunArg.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestRunArg.java
@@ -5,38 +5,43 @@
*/
public enum TestRunArg {
- /**
- * An absolute URI that refers to a representation of the test subject or metadata about it.
- */
- IUT,
-
- /**
- * The number of collections to test (a value less or equal to 0 means all collections).
- */
- NOOFCOLLECTIONS,
-
+ /**
+ * An absolute URI that refers to a representation of the test subject or metadata
+ * about it.
+ */
+ IUT,
+
+ /**
+ * The number of collections to test (a value less or equal to 0 means all
+ * collections).
+ */
+ NOOFCOLLECTIONS,
+
/**
* The id of the echo process.
*/
- ECHOPROCESSID,
-
+ ECHOPROCESSID,
+
/**
- * Limit of processes to be tested against the OGC Process Description Conformance Class.
+ * Limit of processes to be tested against the OGC Process Description Conformance
+ * Class.
*/
PROCESSTESTLIMIT,
-
- /**
- * Use local OpenAPI schema.
- */
- USELOCALSCHEMA,
-
- /**
- * Boolean indicating whether all processes should be tested against the OGC Process Description Conformance Class.
- */
+
+ /**
+ * Use local OpenAPI schema.
+ */
+ USELOCALSCHEMA,
+
+ /**
+ * Boolean indicating whether all processes should be tested against the OGC Process
+ * Description Conformance Class.
+ */
TESTALLPROCESSES;
- @Override
- public String toString() {
- return name().toLowerCase();
- }
+ @Override
+ public String toString() {
+ return name().toLowerCase();
+ }
+
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/TestRunListener.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestRunListener.java
index c7eb1cb..098c8dd 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/TestRunListener.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/TestRunListener.java
@@ -3,24 +3,27 @@
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() {
- }
+ @Override
+ public void onExecutionStart() {
+ }
+
+ @Override
+ public void onExecutionFinish() {
+ }
- @Override
- public void onExecutionFinish() {
- }
}
diff --git a/src/main/java/org/opengis/cite/ogcapiprocesses10/conformance/Conformance.java b/src/main/java/org/opengis/cite/ogcapiprocesses10/conformance/Conformance.java
index 2123727..49fee75 100644
--- a/src/main/java/org/opengis/cite/ogcapiprocesses10/conformance/Conformance.java
+++ b/src/main/java/org/opengis/cite/ogcapiprocesses10/conformance/Conformance.java
@@ -16,7 +16,6 @@
import java.util.List;
import java.util.Map;
-
import org.opengis.cite.ogcapiprocesses10.CommonFixture;
import org.opengis.cite.ogcapiprocesses10.openapi3.TestPoint;
import org.opengis.cite.ogcapiprocesses10.openapi3.UriBuilder;
@@ -35,102 +34,98 @@
*
* A.2.3. Conformance Path {root}/conformance
*
- *
* @author Lyn Goltz
*/
public class Conformance extends CommonFixture {
- private List requirementClasses;
-
- private static String urlSchema="http://schemas.opengis.net/ogcapi/processes/part1/1.0/openapi/schemas/confClasses.yaml";
-
- @DataProvider(name = "conformance")
- public Object[][] conformanceUris( ITestContext testContext ) {
- OpenApi3 apiModel = (OpenApi3) testContext.getSuite().getAttribute( API_MODEL.getName() );
- URI iut = (URI) testContext.getSuite().getAttribute( IUT.getName() );
-
- TestPoint tp = null;
- if(rootUri.toString().endsWith("/")) {
- tp = new TestPoint(rootUri.toString(),"conformance",null);
- }
- else {
- tp = new TestPoint(rootUri.toString(),"/conformance",null);
- }
-
-
- List testPoints = new ArrayList();
- testPoints.add(tp);
- Object[][] testPointsData = new Object[1][];
- int i = 0;
- for ( TestPoint testPoint : testPoints ) {
- testPointsData[i++] = new Object[] { testPoint };
- }
- return testPointsData;
- }
-
- @AfterClass
- public void storeRequirementClassesInTestContext( ITestContext testContext ) {
- testContext.getSuite().setAttribute( REQUIREMENTCLASSES.getName(), this.requirementClasses );
- }
-
- /**
- * Partly addresses Requirement 1 : /req/processes/core/conformance-success
- *
- * @param testPoint
- * the test point to test, never null
- */
- @Test(description = "Implements /conf/core/conformance-success (partial)", groups = "A.2.3. Conformance Path /conformance", dataProvider = "conformance")
- public void testValidateConformanceOperationAndResponse( TestPoint testPoint ) {
- String testPointUri = testPoint.getServerUrl() + testPoint.getPath();
- Response response = init().baseUri( testPointUri ).accept( JSON ).when().request( GET );
- this.rspEntity = response.getBody().asInputStream();
- validateConformanceOperationResponse( testPointUri, response );
- }
-
- /**
- * Requirement 1 : /req/processes/core/conformance-success
- *
- * Abstract Test A.2.3.6.1: /conf/core/conformance-success
- * Abstract Test A.2.3.6.2: /conf/core/conformance-success
- * Abstract Test A.2.3.6.3: /conf/core/conformance-success
- * Abstract Test A.2.3.6.4: /conf/core/conformance-success TODO / DOABLE?
- */
- private void validateConformanceOperationResponse( String testPointUri, Response response ) {
- response.then().statusCode( 200 );
-
- assertTrue( validateResponseAgainstSchema(Conformance.urlSchema,response.getBody().asString()),
- "Unable to validate the response document against: "+Conformance.urlSchema);
-
- JsonPath jsonPath = response.jsonPath();
- this.requirementClasses = parseAndValidateRequirementClasses( jsonPath );
- assertTrue( this.requirementClasses.contains( CORE ),
- "Conformance class \"http://www.opengis.net/spec/ogcapi-processes-1/1.0/conf/core\" is not available from path "
- + testPointUri );
- }
-
- /**
- * @param jsonPath
- * never null
- * @return the parsed requirement classes, never null
- * @throws AssertionError
- * if the json does not follow the expected structure
- */
- List parseAndValidateRequirementClasses( JsonPath jsonPath ) {
- List