Invalid XML path keys still evaluate in Rest Assured - rest-assured

My example web service is returning following XML.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<errorResponse>
<errorCode>Wrong ID</errorCode>
<errorId>2</errorId>
</errorResponse>
Following tests are passed.
response.then().body("errorResponse.errorId", Matchers.is("2"));
response.then().body("errorResponse.errorCode", Matchers.is("Wrong ID"));
response.then().body("errorResponse1.errorCode", Matchers.is("Wrong ID"));
response.then().body("errorResponse2.errorCode", Matchers.is("Wrong ID"));
I understand that first two tests are fine, what I am not getting is why the last two are getting passed?

Rest-assured uses its xml-path library to evaluate your hamcrest matcher and that library contains the XMLAssertion class which does the actual checking.
The source can be found on GitHub: https://github.com/rest-assured/rest-assured/blob/master/xml-path/src/main/groovy/io/restassured/assertion/XMLAssertion.groovy
At line 60 of this file you can see it removes the part of the search key before the first dot, because it recognizes we're evaluating from a root node.
Hence your key:
"errorResponse3.errorCode"
becomes
".errorCode"
So it turns out it doesn't matter what this initial path looks like, it assumes it's the name of the root node and discards it anyway.

Related

What does "Building tree for null using TinyBuilder" mean with Saxon extension function and using -t option?

With my Saxon extension function code I have the log messages:
> java -cp ./saxon-he-10.2.jar:./ net.sf.saxon.Transform -t -init:MyInitializer -xsl:./exttest.xsl -o:./out.xml -it:initialtemplate
Saxon-HE 10.2J from Saxonica
Java version 14.0.2
Stylesheet compilation time: 305.437652ms
Processing (no source document) initial template = initialtemplate
Using parser com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser
Building tree for null using class net.sf.saxon.tree.tiny.TinyBuilder
Tree built in 0.850325ms
Tree size: 3 nodes, 0 characters, 0 attributes
Execution time: 29.965658ms
Memory used: 14Mb
It is not clear to me wether Building tree for null using class net.sf.saxon.tree.tiny.TinyBuilder means that there is something wrong with my code https://gitlab.com/ms452206/socode20200915 and how to avoid it.
It's a poor message and I will improve it; the "null" would be the base URI (or systemId) of the document if it had one. The fact that the document has no known base URI could be a predictor of trouble downstream, since some things rely on a document having a known base URI; but it's not an error in itself.
It's most likely to happen if you build a document using a JAXP Source object whose systemId property is null. Which is what you have done when you wrote:
new StreamSource(new StringReader("<foo/>"))
This is likely to cause failures only if the document contains relative URIs (for example in external entity references or href or xml:base attributes), which is not the case with your simple XML document.

xml to xml field attribute transformation using ESQL on message broker compute node

I am new to message broker development. I tried to convert source SOAP over xml file to target SOAP over xml file.On my message flow source message discarded to catch terminal.I am not able to find out the problem
my flow : MQINPUT NODE ---> COMPUTE NODE --> MQOUTPUT NODE
If any provide solution on this that may me helpful for me.
DECLARE soapenv CHARACTER 'SOAP-ENV';
SET OutputRoot.XMNLSC.soapenv:Envelope.soapenv:Body.params.ORIGIN_TYPE_CD = InputRoot.XMNLSC.soapenv:Envelope.soapenv:Body.params.originType;
**
Your first line is definitely wrong, but you should be able to see that from the exceptions you are getting.
The first line should be:
DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
An in the further lines the domain should be XMLNSC not XMNLSC.

How to generate documentation of robot file using sphinx?

I have a robot file (calc_check.robot) in which each test case has separate documentation.
*** Settings ***
Documentation
... The test cases are designed to test the calculator .
Library ../../Library/AddNumbers
*** Test Cases ***
Calc_check_test Testcase01_a
[Documentation]
... Verify that two numbers are added or not
[Tags] add calculator
${addition}= Add numbers 10 20
Calc_check_test Testcase01_b
[Documentation]
... Verify that two numbers are added or not with negative sign
[Tags] add calculator
${addition}= Add numbers 10 -20
When i try to generate documentation for that robot file using the rst file (call_check.rst) i'm getting complete test case along with documentation as well, but i need only "[Documentation]" part only.
calc_check
======================================
.. robot-settings::
:source:/Users/sphinx/calc_check.robot
.. robot-tests::
:source:/Users/sphinx/calc_check.robot
I want documentation (i.e., only [Documentation] part of test case) from two test cases excluding the test case code.
Please tell me how to generate only the documentation part of it.
Robot provides documentation generation libraries called libdoc:
https://robot-framework.readthedocs.io/en/2.9.2/_modules/robot/libdoc.html
Problem is that it generates only for libraries and resources files (those without ***Testcase*** part).
If you need to generate docs from test suites, I would recommand to temporary change TestSuite into Resource file (change section to Keywords) and run libdoc for such file:
python -m robot.libdoc <path to res/lib> <list/show>

What is the second value of quartz.net configuration job-type parameter?

I'm trying to use Quartz.net in my web project. I configured my application like this:
<job>
<name>CRMMoreThanOneJob</name>
<group>jobGroup1</group>
<job-type>ReportingPortalBLL.Jobs.CRMCalledMoreThanOneJob, ReportingPortalBLL.Jobs</job-type>
<durable>true</durable>
<recover>false</recover>
<job-data-map>
<entry>
<key>MessageToLog</key>
<value>Hello from MyJob</value>
</entry>
</job-data-map>
</job>
But it did not work because of the job-type statement. My Job class' is defined like below and its namespace is ReportingPortalBll.Jobs
namespace ReportingPortalBLL.Jobs
{
public class CRMCalledMoreThanOneJob:IJob
{ .
.
}
}
After i changed it to ReportingPortalBLL.Jobs.CRMCalledMoreThanOneJob, ReportingPortalBLL (without .Job) it worked well.
I looked at the documentation but couldn't find what is represented at the second value of job-type parameter. What should i write on the second parameter? What is the second value on the below representation means? I will be using Quartz on my other projects so it would be nice to know how to configure it easily.
<job-type>Namespace.Job1, secondValue</job-type>
The secondValue corresponds to assembly name.
If you go through the source code of quartz.net you can see that the job-type is being passed to Type.GetType as parameter and Type.GetType accepts a assembly qualified name. The assembly-qualified name of a type consists of the type name, including its namespace, followed by a comma, followed by the display name of the assembly.
refer to these links for more info
http://msdn.microsoft.com/en-us/library/c5cf8k43.aspx
http://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx

JUnit/Ant XML file format for stdout

I'm writing my own test program and I want to be able to re-use tools like Hudson for displaying the results of the test cases. I've so far gotten the results of the text file all into the same XML file and with success, failure, and errors.
Now I want to add the output of the test into the file. I have it set up so I can get the output of a test for each test individually, but I can't seem to figure out how to get it into the XML file in a way Hudson will recognize.
I want to do something like this...
<testsuite>
<testcase>
<success classname="...">
<stdout>
This is standard output
</stdout>
</success>
</testcase>
</testsuite>
But this doesn't get recognized. I see in the Ant source code that it's defined as "system-out", but I also see that it seems it wants the file in this format.
<testsuite>
<testcase classname="..." />
<system-out>
This is standard output
</system-out>
</testsuite>
Is there anyway to make this file so that I can have a specific stdout for each test case? Or do I have to make a new testsuite for every test case?
Edit: I seem to be able to get this format to work, but I'm still disappointed that I can't print the output during a success. I'd like it it while browsing tests, someone could see the output of that test.
<testsuite>
<testcase name="...">
<failure message="shows up as error message">
standard out (shows up as stacktrace)
</failure>
</testcase>
</testsuite>
Is there anywhere that shows what format Hudson accepts? I feel bad commiting bad revisions to source control just to get it to run on the automated build server.
I also can't seem to find where inside of Hudson the code for this functionality is.
Yes, you can not use the "success".
Code for this functionality is https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/tasks/junit/CaseResult.java

Resources