Skip to content

MAPREDUCE-7461: Fixed assertionComparision failure by resolving xml path for 'name' #6252

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import javax.ws.rs.core.MediaType;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.http.JettyUtils;
Expand Down Expand Up @@ -483,10 +486,12 @@ public void verifyAMJob(JSONObject info, Job job) throws JSONException {

}

public void verifyAMJobXML(NodeList nodes, AppContext appContext) {

public void verifyAMJobXML(NodeList nodes, AppContext appContext) throws XPathExpressionException {
assertEquals("incorrect number of elements", 1, nodes.getLength());

XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();

for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);

Expand All @@ -496,7 +501,7 @@ public void verifyAMJobXML(NodeList nodes, AppContext appContext) {

verifyAMJobGeneric(job, WebServicesTestUtils.getXmlString(element, "id"),
WebServicesTestUtils.getXmlString(element, "user"),
WebServicesTestUtils.getXmlString(element, "name"),
xpath.evaluate("name", element),
WebServicesTestUtils.getXmlString(element, "state"),
WebServicesTestUtils.getXmlLong(element, "startTime"),
WebServicesTestUtils.getXmlLong(element, "finishTime"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
import javax.ws.rs.core.MediaType;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathExpressionException;

import com.google.inject.util.Providers;
import org.apache.hadoop.conf.Configuration;
Expand Down Expand Up @@ -229,9 +232,11 @@ public void verifyHsJobPartialXML(NodeList nodes, MockHistoryContext appContext)
}
}

public void verifyHsJobXML(NodeList nodes, AppContext appContext) {
public void verifyHsJobXML(NodeList nodes, AppContext appContext) throws XPathExpressionException {

assertEquals("incorrect number of elements", 1, nodes.getLength());
XPathFactory xPathfactory = XPathFactory.newInstance();
XPath xpath = xPathfactory.newXPath();

for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
Expand All @@ -243,7 +248,7 @@ public void verifyHsJobXML(NodeList nodes, AppContext appContext) {
VerifyJobsUtils.verifyHsJobGeneric(job,
WebServicesTestUtils.getXmlString(element, "id"),
WebServicesTestUtils.getXmlString(element, "user"),
WebServicesTestUtils.getXmlString(element, "name"),
xpath.evaluate("name", element),
WebServicesTestUtils.getXmlString(element, "state"),
WebServicesTestUtils.getXmlString(element, "queue"),
WebServicesTestUtils.getXmlLong(element, "startTime"),
Expand Down