Skip to content

Commit

Permalink
Merge pull request #74 from opengeospatial/issue#39
Browse files Browse the repository at this point in the history
Closes #39
  • Loading branch information
dstenger committed Dec 7, 2023
2 parents 0ecd086 + 6f3ee18 commit 66cb503
Show file tree
Hide file tree
Showing 11 changed files with 909 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
Expand Down Expand Up @@ -62,7 +64,7 @@ public class CommonFixture {

protected ResponseLoggingFilter responseLoggingFilter;

protected URI specURI;
protected URL specURL;

protected URI rootUri;

Expand Down Expand Up @@ -102,12 +104,16 @@ public void initCommonFixture( ITestContext testContext ) {
initLogging();
rootUri = (URI) testContext.getSuite().getAttribute( SuiteAttribute.IUT.getName() );
limit = (Integer) testContext.getSuite().getAttribute( SuiteAttribute.PROCESS_TEST_LIMIT.getName() );
testAllProcesses = (Boolean) testContext.getSuite().getAttribute( SuiteAttribute.TEST_ALL_PROCESSES.getName() );
try {
specURI = new URI("https://developer.ogc.org/api/processes/openapi.yaml");
} catch (URISyntaxException e) {
e.printStackTrace();
}
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,16 @@ public enum SuiteAttribute {
* Parsed OpenApi3 document resource /api; Added during execution.
*/
API_MODEL( "apiModel", OpenApi3.class ),

/**
* Requirement classes parsed from /conformance; Added during execution.
*/
REQUIREMENTCLASSES( "requirementclasses", List.class ),


/**
* Parsed collections from resource /collections; Added during execution.
* Use local OpenAPI schema included in ETS.
*/
COLLECTIONS( "collections", List.class ),
USE_LOCAL_SCHEMA( "useLocalSchema", Boolean.class ),

/**
* Collection names assigned to a feature id parsed from resource /collections/{name}/items; Added during execution.
* Requirement classes parsed from /conformance; Added during execution.
*/
FEATUREIDS( "featureIds", Map.class );
REQUIREMENTCLASSES( "requirementclasses", List.class );

private final Class attrType;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ void processSuiteParameters( ISuite suite ) {
} catch ( NumberFormatException e ) {
TestSuiteLogger.log( Level.WARNING,
String.format( "Could not parse parameter %s: %s. Expected is a valid string",
TestRunArg.ECHOPROCESSID.toString(), echoProcessId ) );
TestRunArg.PROCESSTESTLIMIT.toString(), limit ) );
}

suite.setAttribute( SuiteAttribute.USE_LOCAL_SCHEMA.getName(), true );

String testAllProcesses = params.get( TestRunArg.TESTALLPROCESSES.toString() );

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public enum TestRunArg {
* 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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class JobList extends CommonFixture {
public void setup() {
String jobListEndpointString = rootUri.toString() + getJobListPath;
try {
openApi3 = new OpenApi3Parser().parse(specURI.toURL(), false);
openApi3 = new OpenApi3Parser().parse(specURL, false);
addServerUnderTest(openApi3);
final Path path = openApi3.getPathItemByOperationId(OPERATION_ID);
final Operation operation = openApi3.getOperationById(OPERATION_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public void setup(ITestContext testContext) {
echoProcessPath = getProcessListPath + "/" + echoProcessId;
executeEndpoint = rootUri + echoProcessPath + "/execution";
parseEchoProcess();
openApi3 = new OpenApi3Parser().parse(specURI.toURL(), false);
openApi3 = new OpenApi3Parser().parse(specURL, false);
final Path path = openApi3.getPathItemByOperationId(OPERATION_ID_GET_JOBS);
final Operation operation = openApi3.getOperationById(OPERATION_ID_GET_JOBS);
getJobsValidator = new OperationValidator(openApi3, path, operation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void setup(ITestContext testContext) {

processTestLimit = (Integer) testContext.getSuite().getAttribute( SuiteAttribute.PROCESS_TEST_LIMIT.getName() );

openApi3 = new OpenApi3Parser().parse(specURI.toURL(), false);
openApi3 = new OpenApi3Parser().parse(specURL, false);
addServerUnderTest(openApi3);
final Path path = openApi3.getPathItemByOperationId(OPERATION_ID);
final Operation operation = openApi3.getOperationById(OPERATION_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void setup(ITestContext testContext) {
String processListEndpointString = rootUri.toString() + getProcessListPath;
try {

openApi3 = new OpenApi3Parser().parse(specURI.toURL(), false);
openApi3 = new OpenApi3Parser().parse(specURL, false);
addServerUnderTest(openApi3);
final Path path = openApi3.getPathItemByOperationId(OPERATION_ID_GET_PROCESS_DESCRIPTION);
final Operation operation = openApi3.getOperationById(OPERATION_ID_GET_PROCESS_DESCRIPTION);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public class ProcessList extends CommonFixture {
public void setup() {
String processListEndpointString = rootUri.toString() + getProcessListPath;
try {
openApi3 = new OpenApi3Parser().parse(specURI.toURL(), false);
openApi3 = new OpenApi3Parser().parse(specURL, false);
addServerUnderTest(openApi3);
final Path path = openApi3.getPathItemByOperationId(OPERATION_ID);
final Operation operation = openApi3.getOperationById(OPERATION_ID);
Expand Down

0 comments on commit 66cb503

Please sign in to comment.