Search in sources :

Example 51 with XPathExpressionException

use of javax.xml.xpath.XPathExpressionException in project ddf by codice.

the class TestCatalog method testCswUpdateByFilterConstraint.

@Test
public void testCswUpdateByFilterConstraint() {
    Response firstResponse = ingestCswRecord();
    Response secondResponse = ingestCswRecord();
    ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateByFilterConstraintRequest")).post(CSW_PATH.getUrl()).then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("2")));
    String firstId;
    String secondId;
    try {
        firstId = getMetacardIdFromCswInsertResponse(firstResponse);
        secondId = getMetacardIdFromCswInsertResponse(secondResponse);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
        return;
    }
    String firstUrl = REST_PATH.getUrl() + firstId;
    when().get(firstUrl).then().log().all().assertThat().body(hasXPath("//metacard/dateTime[@name='modified']/value", startsWith("2015-08-25")), hasXPath("//metacard/string[@name='title']/value", is("Updated Title")), hasXPath("//metacard/string[@name='media.format']/value", is("")), // Check that an attribute that was not updated was not changed.
    hasXPath("//metacard/string[@name='topic.category']/value", is("Hydrography--Dictionaries")));
    String secondUrl = REST_PATH.getUrl() + secondId;
    when().get(secondUrl).then().log().all().assertThat().body(hasXPath("//metacard/dateTime[@name='modified']/value", startsWith("2015-08-25")), hasXPath("//metacard/string[@name='title']/value", is("Updated Title")), hasXPath("//metacard/string[@name='media.format']/value", is("")), // Check that an attribute that was not updated was not changed.
    hasXPath("//metacard/string[@name='topic.category']/value", is("Hydrography--Dictionaries")));
    deleteMetacard(firstId);
    deleteMetacard(secondId);
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) XPathExpressionException(javax.xml.xpath.XPathExpressionException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IOException(java.io.IOException) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 52 with XPathExpressionException

use of javax.xml.xpath.XPathExpressionException in project ddf by codice.

the class TestCatalog method testCswXmlIngest.

@Test
public void testCswXmlIngest() {
    Response response = ingestXmlViaCsw();
    ValidatableResponse validatableResponse = response.then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/InsertResult/BriefRecord/title", is("myXmlTitle")), hasXPath("//TransactionResponse/InsertResult/BriefRecord/BoundingBox"));
    try {
        CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
    }
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 53 with XPathExpressionException

use of javax.xml.xpath.XPathExpressionException in project ddf by codice.

the class TestCatalog method testCombinedCswIngestAndDelete.

@Test
public void testCombinedCswIngestAndDelete() {
    // This record will be deleted with the <Delete> in the next transaction request.
    ingestCswRecord();
    // The record being inserted in this transaction request will be deleted at the end of the
    // test.
    Response response = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswInsertAndDeleteRequest")).post(CSW_PATH.getUrl());
    ValidatableResponse validatableResponse = response.then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")));
    try {
        CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
    }
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 54 with XPathExpressionException

use of javax.xml.xpath.XPathExpressionException in project ddf by codice.

the class TestCatalog method testCswIngest.

@Test
public void testCswIngest() {
    Response response = ingestCswRecord();
    ValidatableResponse validatableResponse = response.then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("1")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/InsertResult/BriefRecord/title", is("Aliquam fermentum purus quis arcu")), hasXPath("//TransactionResponse/InsertResult/BriefRecord/BoundingBox"));
    try {
        CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
    }
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) XPathExpressionException(javax.xml.xpath.XPathExpressionException) IOException(java.io.IOException) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Example 55 with XPathExpressionException

use of javax.xml.xpath.XPathExpressionException in project ddf by codice.

the class TestCatalog method testCswUpdateByFilterConstraintNoMetacardsFound.

@Test
public void testCswUpdateByFilterConstraintNoMetacardsFound() {
    Response response = ingestCswRecord();
    String updateRequest = getFileContent(CSW_REQUEST_RESOURCE_PATH + "/CswUpdateByFilterConstraintRequest");
    // Change the <Filter> property being searched for so no results will be found.
    updateRequest = updateRequest.replace("title", "subject");
    ValidatableResponse validatableResponse = given().header(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_XML).body(updateRequest).post(CSW_PATH.getUrl()).then();
    validatableResponse.body(hasXPath("//TransactionResponse/TransactionSummary/totalDeleted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalInserted", is("0")), hasXPath("//TransactionResponse/TransactionSummary/totalUpdated", is("0")));
    try {
        CatalogTestCommons.deleteMetacardUsingCswResponseId(response);
    } catch (IOException | XPathExpressionException e) {
        fail("Could not retrieve the ingested record's ID from the response.");
    }
}
Also used : CswTestCommons.getMetacardIdFromCswInsertResponse(org.codice.ddf.itests.common.csw.CswTestCommons.getMetacardIdFromCswInsertResponse) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) Response(com.jayway.restassured.response.Response) ValidatableResponse(com.jayway.restassured.response.ValidatableResponse) XPathExpressionException(javax.xml.xpath.XPathExpressionException) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) IOException(java.io.IOException) SkipUnstableTest(org.codice.ddf.itests.common.annotations.SkipUnstableTest) Test(org.junit.Test) AbstractIntegrationTest(org.codice.ddf.itests.common.AbstractIntegrationTest)

Aggregations

XPathExpressionException (javax.xml.xpath.XPathExpressionException)157 XPath (javax.xml.xpath.XPath)79 NodeList (org.w3c.dom.NodeList)74 Document (org.w3c.dom.Document)51 Node (org.w3c.dom.Node)50 IOException (java.io.IOException)47 XPathExpression (javax.xml.xpath.XPathExpression)42 SAXException (org.xml.sax.SAXException)32 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)29 XPathFactory (javax.xml.xpath.XPathFactory)29 ArrayList (java.util.ArrayList)23 Element (org.w3c.dom.Element)22 InputSource (org.xml.sax.InputSource)20 HashMap (java.util.HashMap)19 Test (org.junit.Test)17 DocumentBuilder (javax.xml.parsers.DocumentBuilder)14 Response (com.jayway.restassured.response.Response)12 ValidatableResponse (com.jayway.restassured.response.ValidatableResponse)12 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)12 AbstractIntegrationTest (org.codice.ddf.itests.common.AbstractIntegrationTest)12