Skip to content

Commit

Permalink
Merge pull request opengeospatial#22 from opengeospatial/develop
Browse files Browse the repository at this point in the history
Add Async test A.5.19
  • Loading branch information
dstenger authored Nov 2, 2022
2 parents b44e564 + 772bbe3 commit a529e88
Show file tree
Hide file tree
Showing 3 changed files with 312 additions and 0 deletions.
288 changes: 288 additions & 0 deletions src/main/java/org/opengis/cite/wps20/level1/BasicTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class BasicTests extends CommonFixture {
String OUTPUT_VALUE_TRANSMISSION_TEMPLATE_PATH = "/org/opengis/cite/wps20/examples/ValidOutputValue.xml";
String OUTPUT_REFERENCE_TRANSMISSION_TEMPLATE_PATH = "/org/opengis/cite/wps20/examples/ValidOutputReference.xml";
String UNIQUE_JOB_IDS_TEMPLATE_PATH = "/org/opengis/cite/wps20/examples/ValidUniqueJobIds.xml";
String GET_STATUS_TEMPLATE_PATH = "/org/opengis/cite/wps20/examples/ValidGetStatus.xml";
String GET_RESULT_TEMPLATE_PATH = "/org/opengis/cite/wps20/examples/ValidGetResult.xml";

/**
* A.4.1. Verify that a given process description is in compliance with the
Expand Down Expand Up @@ -927,6 +929,129 @@ public void ValidAutoExcecuteViaPOSTXML() throws Exception {
}
}

/**
* A.5.14. Verify that the server can handle GetStatus requests via POST/XML.
* Flow of Test Description: Send a valid XML Execute request to the server under test,
* setting the “mode” attribute to “async”. Verify that a valid wps:StatusInfo document
* is returned. Extract the wps:JobID. Send a valid XML GetStatus request to the server
* under test using the extracted JobID. Test passes if a valid wps:StatusInfo document
* is returned.
*
* @throws Exception
*/
@Test(enabled = true, groups = "A.5. Basic Tests", description = "A.5.14. Verify that the server can handle GetStatus requests via POST/XML.")
public void ValidGetStatusViaPOSTXML() throws Exception {
String SERVICE_URL = this.ServiceUrl.toString();

URI uriLiteralRequestTemplate = BasicTests.class.getResource(LITERAL_REQUEST_TEMPLATE_PATH).toURI();
Document literalDocument = URIUtils.parseURI(uriLiteralRequestTemplate);
ProcessEchoProcessLiteralDataRequest(SERVICE_URL, literalDocument);
Element executeElement = (Element) literalDocument
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Execute").item(0);
executeElement.setAttribute("mode", "async");
executeElement.setAttribute("response", "document");

String VAEXmlString = GetContentFromPOSTXMLRequest(SERVICE_URL, literalDocument);
Document VAEDocument = TransformXMLStringToXMLDocument(VAEXmlString);

Boolean VAE_Flag = (VAEDocument.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "StatusInfo").getLength() > 0) ? true : false;

if (VAE_Flag) {
Element JobIDElement1 = (Element) VAEDocument
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);

URI URIGetStatusTemplate = BasicTests.class.getResource(GET_STATUS_TEMPLATE_PATH).toURI();
Document GetStatusDocument = URIUtils.parseURI(URIGetStatusTemplate);
Element JobIDElement2 = (Element) GetStatusDocument
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);
JobIDElement2.setTextContent(JobIDElement1.getTextContent());

String VGSXmlString = GetContentFromPOSTXMLRequest(SERVICE_URL, GetStatusDocument);
Document VGSDocument = TransformXMLStringToXMLDocument(VGSXmlString);

Boolean VGS_Flag = (VGSDocument.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Status").getLength() > 0) ? true : false;

if (VGS_Flag) {
String msg = "Valid GetStatus via POST/XML for WPS 2.0";
Assert.assertTrue(VGS_Flag, msg);
} else {
String msg = "Invalid GetStatus via POST/XML for WPS 2.0";
Assert.assertTrue(VGS_Flag, msg);
}
} else {
String msg = "Invalid Execute via POST/XML for WPS 2.0";
Assert.assertTrue(VAE_Flag, msg);
}
}

/**
* A.5.15. VSend a valid XML Execute request to the server under test, setting the “mode”
* attribute to “async”. Modulate the “response” parameter. Verify that a valid wps:StatusInfo
* document is returned. Extract the wps:JobID. Check the status of the job. If the job
* succeeded, send a valid XML GetResult request to the server under test using the extracted
* JobID. Depending on the value of the “response” parameter of the above Execute request.
*
* @throws Exception
*/
@Test(enabled = true, groups = "A.5. Basic Tests", description = "A.5.15. Verify that the server can handle GetResult requests via POST/XML.")
public void ValidGetResultViaPOSTXML() throws Exception {
String SERVICE_URL = this.ServiceUrl.toString();

URI uriLiteralRequestTemplate = BasicTests.class.getResource(LITERAL_REQUEST_TEMPLATE_PATH).toURI();
Document literalDocument = URIUtils.parseURI(uriLiteralRequestTemplate);
ProcessEchoProcessLiteralDataRequest(SERVICE_URL, literalDocument);
Element executeElement = (Element) literalDocument
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Execute").item(0);
executeElement.setAttribute("mode", "async");
executeElement.setAttribute("response", "raw");
String VAEXmlString1 = GetContentFromPOSTXMLRequest(SERVICE_URL, literalDocument);
Document VAEDocument1 = TransformXMLStringToXMLDocument(VAEXmlString1);
Boolean VAE_Flag1 = (VAEDocument1.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "StatusInfo").getLength() > 0) ? true : false;

executeElement.setAttribute("response", "document");
String VAEXmlString2 = GetContentFromPOSTXMLRequest(SERVICE_URL, literalDocument);
Document VAEDocument2 = TransformXMLStringToXMLDocument(VAEXmlString2);
Boolean VAE_Flag2 = (VAEDocument2.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "StatusInfo").getLength() > 0) ? true : false;

Boolean VAE_Flag = VAE_Flag1 && VAE_Flag2;

if (VAE_Flag) {
URI URIGetResultTemplate1 = BasicTests.class.getResource(GET_RESULT_TEMPLATE_PATH).toURI();
Element JobIDElement1 = (Element) VAEDocument1.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);
Document GetResultDocument1 = URIUtils.parseURI(URIGetResultTemplate1);
Element JobIDElement2 = (Element) GetResultDocument1.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);
JobIDElement2.setTextContent(JobIDElement1.getTextContent());
String VGRXmlString1 = GetContentFromPOSTXMLRequest(SERVICE_URL, GetResultDocument1);
Document VGRDocument1 = TransformXMLStringToXMLDocument(VGRXmlString1);
Boolean VGR_Flag1 = (VGRDocument1.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "LiteralValue").getLength() > 0) ? true : false;

URI URIGetResultTemplate2 = BasicTests.class.getResource(GET_RESULT_TEMPLATE_PATH).toURI();
Element JobIDElement3 = (Element) VAEDocument2.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);
Document GetResultDocument2 = URIUtils.parseURI(URIGetResultTemplate2);
Element JobIDElement4 = (Element) GetResultDocument2.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);
JobIDElement4.setTextContent(JobIDElement3.getTextContent());
String VGRXmlString2 = GetContentFromPOSTXMLRequest(SERVICE_URL, GetResultDocument2);

Boolean VGR_Flag2 = VGRXmlString2.contains("LiteralValue") ? true : false;

// Document VGRDocument2 = TransformXMLStringToXMLDocument(VGRXmlString2);
// Boolean VGR_Flag2 = (VGRDocument2.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Result").getLength() > 0) ? true : false;

Boolean VGR_Flag = VGR_Flag1 && VGR_Flag2;

if (VGR_Flag) {
String msg = "Valid GetResult via POST/XML for WPS 2.0";
Assert.assertTrue(VGR_Flag, msg);
} else {
String msg = "Invalid GetResult via POST/XML for WPS 2.0";
Assert.assertTrue(VGR_Flag, msg);
}
} else {
String msg = "Invalid Execute via POST/XML for WPS 2.0";
Assert.assertTrue(VAE_Flag, msg);
}
}

/**
* A.5.16. Verify that the server can handle GetCapabilities requests via
* GET/KVP
Expand Down Expand Up @@ -1015,7 +1140,170 @@ private void ValidDescribeProcessViaGETKVP() throws IOException, URISyntaxExcept
Assert.assertTrue(DP_KVP_Flag, msg);
}
}

/**
* A.5.18. Verify that the server can handle GetStatus requests via GET/KVP.
* Send a valid XML Execute request to the server under test, setting the “mode” attribute
* to “async”. Verify that a valid wps:StatusInfo document is returned. Extract the
* wps:JobID. Send a valid KVP GetStatus request to the server under test, using the
* extracted JobID and modulating upper and lower case of the parameter names. Test passes
* if a valid document of the type wps:StatusInfo is returned.
* @throws IOException
* @throws URISyntaxException
* @throws SAXException
*/
@Test(enabled = true, groups = "A.5. Basic Tests", description = "A.5.18. Verify that the server can handle GetStatus requests via GET/KVP.")
private void ValidGetStausViaGETKVP() throws IOException, URISyntaxException, SAXException {
String SERVICE_URL = this.ServiceUrl.toString();

URI uriLiteralRequestTemplate = BasicTests.class.getResource(LITERAL_REQUEST_TEMPLATE_PATH).toURI();
Document literalDocument = URIUtils.parseURI(uriLiteralRequestTemplate);
ProcessEchoProcessLiteralDataRequest(SERVICE_URL, literalDocument);
Element executeElement = (Element) literalDocument
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Execute").item(0);
executeElement.setAttribute("mode", "async");
executeElement.setAttribute("response", "document");

String VAEXmlString = GetContentFromPOSTXMLRequest(SERVICE_URL, literalDocument);
Document VAEDocument = TransformXMLStringToXMLDocument(VAEXmlString);

Boolean VAE_Flag = (VAEDocument.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "StatusInfo").getLength() > 0) ? true : false;

if (VAE_Flag) {
Element JobIDElement1 = (Element) VAEDocument
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);

Map<String, Object> GS_Parameters = new LinkedHashMap<>();
GS_Parameters.put("Service", "WPS");
GS_Parameters.put("Version", "2.0.0");
GS_Parameters.put("Request", "GetStatus");
GS_Parameters.put("JobID", JobIDElement1.getTextContent());
String GS_XmlString = GetContentFromGETKVPRequest(SERVICE_URL, GS_Parameters);
Document GS_Document = TransformXMLStringToXMLDocument(GS_XmlString);

Boolean VGS_Flag = (GS_Document.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Status").getLength() > 0) ? true : false;

if (VGS_Flag) {
String msg = "Valid GetStatus via GET/KVP for WPS 2.0";
Assert.assertTrue(VGS_Flag, msg);
} else {
String msg = "Invalid GetStatus via GET/KVP for WPS 2.0";
Assert.assertTrue(VGS_Flag, msg);
}
} else {
String msg = "Invalid Execute via POST/XML for WPS 2.0";
Assert.assertTrue(VAE_Flag, msg);
}
}

/**
* A.5.19. Verify that the server can handle GetResult requests via GET/KVP.
* Send a valid XML Execute request to the server under test, setting the “mode” attribute
* to “async”. Modulate the “response” parameter. Verify that a valid wps:StatusInfo
* document is returned. Extract the wps:JobID. Check the status of the job. If the job
* succeeded, send a valid KVP GetResult request to the server under test using the
* extracted JobID and modulating upper and lower case of the parameter names. Depending
* on the value of the “response” parameter of the above Execute request:
* - Parameter value equal “document”. Verify that a valid Execute wps:Result document is returned.
* - Parameter equal to “raw”. Verify that raw is returned.
* @throws IOException
* @throws URISyntaxException
* @throws SAXException
*/
@Test(enabled = true, groups = "A.5. Basic Tests", description = "A.5.19. Verify that the server can handle GetResult requests via GET/KVP.")
private void ValidGetResultViaGETKVP() throws IOException, URISyntaxException, SAXException {
String SERVICE_URL = this.ServiceUrl.toString();

URI uriLiteralRequestTemplate = BasicTests.class.getResource(LITERAL_REQUEST_TEMPLATE_PATH).toURI();
Document literalDocument = URIUtils.parseURI(uriLiteralRequestTemplate);
ProcessEchoProcessLiteralDataRequest(SERVICE_URL, literalDocument);
Element executeElement = (Element) literalDocument
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Execute").item(0);
executeElement.setAttribute("mode", "async");

executeElement.setAttribute("response", "document");
String VAEXmlString1 = GetContentFromPOSTXMLRequest(SERVICE_URL, literalDocument);
Document VAEDocument1 = TransformXMLStringToXMLDocument(VAEXmlString1);
Boolean VAE_Flag1 = (VAEDocument1.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "StatusInfo").getLength() > 0) ? true : false;

executeElement.setAttribute("response", "raw");
String VAEXmlString2 = GetContentFromPOSTXMLRequest(SERVICE_URL, literalDocument);
Document VAEDocument2 = TransformXMLStringToXMLDocument(VAEXmlString2);
Boolean VAE_Flag2 = (VAEDocument2.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "StatusInfo").getLength() > 0) ? true : false;

Boolean VAE_Flag = VAE_Flag1 && VAE_Flag2;

if (VAE_Flag) {
Element JobIDElement1 = (Element) VAEDocument1
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);
CheckGetStatus(SERVICE_URL, JobIDElement1.getTextContent());
Map<String, Object> GR_Parameters1 = new LinkedHashMap<>();
GR_Parameters1.put("Service", "WPS");
GR_Parameters1.put("Version", "2.0.0");
GR_Parameters1.put("Request", "GetResult");
GR_Parameters1.put("JobID", JobIDElement1.getTextContent());
String GR_XmlString1 = GetContentFromGETKVPRequest(SERVICE_URL, GR_Parameters1);
Document GR_Document1 = TransformXMLStringToXMLDocument(GR_XmlString1);

Boolean VGR_Flag1 = (GR_Document1.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Result").getLength() > 0) ? true : false;

Element JobIDElement2 = (Element) VAEDocument2
.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "JobID").item(0);
CheckGetStatus(SERVICE_URL, JobIDElement2.getTextContent());
Map<String, Object> GR_Parameters2 = new LinkedHashMap<>();
GR_Parameters2.put("Service", "WPS");
GR_Parameters2.put("Version", "2.0.0");
GR_Parameters2.put("Request", "GetResult");
GR_Parameters2.put("JobID", JobIDElement2.getTextContent());
String GR_XmlString2 = GetContentFromGETKVPRequest(SERVICE_URL, GR_Parameters2);
// System.out.println(GR_XmlString2);
// System.out.println(JobIDElement2.getTextContent());

// Boolean VGR_Flag2 = GR_XmlString2.contains("wps:LiteralValue") ? true : false;

Document GR_Document2 = TransformXMLStringToXMLDocument(GR_XmlString2);
Boolean VGR_Flag2 = (GR_Document2.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "LiteralValue").getLength() > 0) ? true : false;

Boolean VGR_Flag = VGR_Flag1 && VGR_Flag2;

if (VGR_Flag) {
String msg = "Valid GetResult via GET/KVP for WPS 2.0";
Assert.assertTrue(VGR_Flag, msg);
} else {
String msg = "Invalid GetResult via GET/KVP for WPS 2.0";
Assert.assertTrue(VGR_Flag, msg);
}
} else {
String msg = "Invalid Execute via POST/XML for WPS 2.0";
Assert.assertTrue(VAE_Flag, msg);
}
}

public void CheckGetStatus(String SERVICE_URL, String jobID) {
Map<String, Object> GR_Parameters1 = new LinkedHashMap<>();
GR_Parameters1.put("Service", "WPS");
GR_Parameters1.put("Version", "2.0.0");
GR_Parameters1.put("Request", "GetStatus");
GR_Parameters1.put("JobID", jobID);

String GR_XmlString1 = GetContentFromGETKVPRequest(SERVICE_URL, GR_Parameters1);
Document docGetStatus = TransformXMLStringToXMLDocument(GR_XmlString1);
Boolean statusFlag = (docGetStatus.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Status").getLength() > 0) ? true : false;
String msg = "Invalid GetStatus via GET/KVP for WPS 2.0";
if (!statusFlag)
Assert.assertTrue(false, msg);
else {
Element statusElement = (Element) docGetStatus.getElementsByTagNameNS("http://www.opengis.net/wps/2.0", "Status").item(0);
String status = statusElement.getTextContent();
if (status.toLowerCase().equals("succeeded")) {
return;
}
else {
Assert.assertTrue(false, msg);
}
}
}

public void TestPostWithDocumentAndAssertMessage(String SERVICE_URL, Document literalDocument, String message)
throws Exception {
// status code is 200 response validation
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<wps:GetResult
xmlns:wps="http://www.opengis.net/wps/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wps/2.0 ../wps.xsd"

service="WPS"
version="2.0.0">

<wps:JobID>FB6DD4B0-A2BB-11E3-A5E2-0800200C9A66</wps:JobID>

</wps:GetResult>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<wps:GetStatus
xmlns:wps="http://www.opengis.net/wps/2.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.opengis.net/wps/2.0 ../wps.xsd"

service="WPS"
version="2.0.0">

<wps:JobID>FB6DD4B0-A2BB-11E3-A5E2-0800200C9A66</wps:JobID>

</wps:GetStatus>

0 comments on commit a529e88

Please sign in to comment.