![JAR search and dependency download from the Maven repository](/logo.png)
FitNesseRoot.files.testResults.RestFixtureTests.JavascriptExpectations.20160517141612_0_0_0_1.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of smartrics-RestFixture-LiveDoc Show documentation
Show all versions of smartrics-RestFixture-LiveDoc Show documentation
FitNesse tests documenting the RestFixture
<?xml version="1.0"?> <testResults> <FitNesseVersion>v20151230</FitNesseVersion> <rootPath>RestFixtureTests.JavascriptExpectations</rootPath> <result> <counts> <right>2</right> <wrong>0</wrong> <ignores>0</ignores> <exceptions>14</exceptions> </counts> <date>2016-05-17T14:16:12+01:00</date> <runTimeInMillis>48</runTimeInMillis> <content><div class="collapsible closed"><ul><li><a href='#' class='expandall'>Expand</a></li><li><a href='#' class='collapseall'>Collapse</a></li></ul> <p class="title">Included page: <a href="RestFixtureTests.SetUp">.RestFixtureTests.SetUp</a> <a href="RestFixtureTests.SetUp?edit&amp;redirectToReferer=true&amp;redirectAction=" class="edit">(edit)</a></p> <div><table> <tr class="slimRowTitle"> <td>script</td> <td colspan="2"><span class="pass">smartrics.rest.test.fitnesse.fixture.HttpServerFixture</span></td> </tr> <tr class="slimRowColor0"> <td>check</td> <td>is started</td> <td><span class="pass">true</span></td> </tr> <tr class="slimRowColor9"> <td colspan="3"><span class="pass">reset resources database</span></td> </tr> </table> </div> </div> <br/><h3>Expectations in Javascript on responses with content type application/json</h3> <br/>As of <a href="RestFixture">.RestFixture</a>. Version 2, a javascript engine is embedded to allow expectations in Javascript on response body contents in JSON format.<br/><br/><div class="collapsible"><ul><li><a href='#' class='expandall'>Expand</a></li><li><a href='#' class='collapseall'>Collapse</a></li></ul> <p class="title">XPaths and JSON</p> <div>For backward compatibility XPath expressions are maintained and executed<br/></div> </div> <br/>After a successful response is received with content type "application/json" the expectation cell in a <a href="RestFixture">.RestFixture</a> row is<br/>interpreted as a string with Javascript and executed within the context of the response body.<br/><br/><table> <tr class="slimRowTitle"> <td>Table: Rest Fixture <span class="error">Could not invoke constructor for RestFixture[1]</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr class="slimRowColor0"> <td>setBody</td> <td colspan="4"> { "resource" : { "name" : "test post", "data" : "some data" } } </td> </tr> <tr class="slimRowColor1"> <td>POST</td> <td>/resources/</td> <td>201</td> <td></td> <td>no-body</td> </tr> <tr class="slimRowColor0"> <td>let</td> <td>id</td> <td>header</td> <td>Location:/resources/(.+)</td> <td></td> </tr> </table> <br/>A variable &lt;code&gt;jsonbody&lt;/code&gt; is defined holding the JSON in the response.<br/><br/>The test passes if the result of the evaluation of the cell is a boolean.<br/><br/><table> <tr class="slimRowTitle"> <td>Table: Rest Fixture <span class="error">Could not invoke constructor for RestFixture[1]</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr class="slimRowColor0"> <td>GET</td> <td>/resources/%id%.json</td> <td>200</td> <td>Content-Type : application/json</td> <td> jsonbody.resource.name=="test post" && jsonbody.resource.data=="some data" </td> </tr> </table> <br/>It is possible to specify multiple assertions, one for each line.<br/>The test passes if each line evaluates to true.<br/><br/><table> <tr class="slimRowTitle"> <td>Table: Rest Fixture <span class="error">Could not invoke constructor for RestFixture[1]</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr class="slimRowColor0"> <td>GET</td> <td>/resources/%id%.json</td> <td>200</td> <td>Content-Type : application/json</td> <td> jsonbody.resource.name.length >= 0 jsonbody.resource.name.length < 1000 jsonbody.resource.name.length < jsonbody.resource.name.length+1 </td> </tr> <tr class="slimRowColor1"> <td>let</td> <td>content</td> <td>js</td> <td>response.body</td> <td></td> </tr> </table> <br/><table> <tr class="slimRowTitle"> <td>Table: Rest Fixture <span class="error">Could not invoke constructor for RestFixture[1]</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr class="slimRowColor0"> <td>setBody</td> <td colspan="4">%content%</td> </tr> <tr class="slimRowColor1"> <td>POST</td> <td>/resources/</td> <td>201</td> <td></td> <td>no-body</td> </tr> <tr class="slimRowColor0"> <td>let</td> <td>id</td> <td>header</td> <td>Location:/resources/(.+)</td> <td></td> </tr> </table> <br/>In some cases may be useful to force evaluation of the expectation cell as a javascript block.<br/>By embedding the &lt;code&gt;/* javascript */&lt;/code&gt; comment, the whole expectation cell will be parsed and evaluated entirely using the javascript interpreter.<br/><br/><table> <tr class="slimRowTitle"> <td>Table: Rest Fixture <span class="error">Could not invoke constructor for RestFixture[1]</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr class="slimRowColor0"> <td>GET</td> <td>/resources/%id%.json</td> <td>200</td> <td>Content-Type : application/json</td> <td><pre> /* javascript */ var concat = jsonbody.resource.name + " and " + jsonbody.resource.data concat=="test post and some data" </pre></td> </tr> <tr class="slimRowColor1"> <td>let</td> <td>content</td> <td>js</td> <td>response.body</td> <td></td> </tr> </table> <br/>It is possible to inject external javascript scripts by setting the "restfixture.javascript.imports.map" property to a map value (script name=script path).<br/>The path to the script can be to a file in the filesystem or to an racheable URL<br/><br/><table> <tr class="slimRowTitle"> <td>Table: Rest Fixture Config <span class="error">Could not invoke constructor for RestFixtureConfig[1]</span></td> <td>imp</td> </tr> <tr class="slimRowColor0"> <td>restfixture.javascript.imports.map</td> <td> sampleJs=src/main/resources/FitNesseRoot/files/javascript/sample.js jsonpath=src/main/resources/FitNesseRoot/files/javascript/jsonpath-0.8.0.js</td> </tr> </table> <br/><table> <tr class="slimRowTitle"> <td>Table: Rest Fixture <span class="error">Could not invoke constructor for RestFixture[2]</span></td> <td><a href="http://localhost:9876">http://localhost:9876</a></td> <td colspan="3">imp</td> </tr> <tr class="slimRowColor0"> <td>GET</td> <td>/resources/%id%.json</td> <td>200</td> <td>Content-Type : application/json</td> <td>JSONPath.eval(jsonbody, "$..resource.name") == "test post"</td> </tr> <tr class="slimRowColor1"> <td>let</td> <td>sum</td> <td>js</td> <td>var sum = sampleAdd(1, 2); sum;</td> <td></td> </tr> </table> </content> <relativePageName>JavascriptExpectations</relativePageName> <instructions> <instructionResult> <instruction>{id='scriptTable_0_0', instruction='make', instanceName='scriptTableActor', className='smartrics.rest.test.fitnesse.fixture.HttpServerFixture', args=[]}</instruction> <slimResult>pass(smartrics.rest.test.fitnesse.fixture.HttpServerFixture)</slimResult> <expectation> <status>pass</status> <instructionId>scriptTable_0_0</instructionId> <col>1</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>smartrics.rest.test.fitnesse.fixture.HttpServerFixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_0_1', instruction='call', instanceName='scriptTableActor', methodName='isStarted', args=[]}</instruction> <slimResult>pass(true)</slimResult> <expectation> <status>pass</status> <instructionId>scriptTable_0_1</instructionId> <col>2</col> <row>1</row> <type>ReturnedValueExpectation</type> <evaluationMessage>true</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_0_2', instruction='call', instanceName='scriptTableActor', methodName='resetResourcesDatabase', args=[]}</instruction> <slimResult>pass()</slimResult> <expectation> <status>pass</status> <instructionId>scriptTable_0_2</instructionId> <col>0</col> <row>2</row> <type>ScriptActionExpectation</type> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_1_0', instruction='make', instanceName='tableTable_1', className='RestFixture', args=[<a href="http://localhost:9876">http://localhost:9876</a>]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_1_0</instructionId> <type>ConstructionExpectation</type> <evaluationMessage>Could not invoke constructor for RestFixture[1]</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_1_1', instruction='call', instanceName='tableTable_1', methodName='doTable', args=[[[setBody, { "resource" : { "name" : "test post", "data" : "some data" } } ], [POST, /resources/, 201, , no-body], [let, id, header, Location:/resources/(.+), ]]]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_1_1</instructionId> <type>TableTableExpectation</type> <evaluationMessage>The instance tableTable_1.doTable. does not exist</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_2_0', instruction='make', instanceName='tableTable_2', className='RestFixture', args=[<a href="http://localhost:9876">http://localhost:9876</a>]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_2_0</instructionId> <type>ConstructionExpectation</type> <evaluationMessage>Could not invoke constructor for RestFixture[1]</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_2_1', instruction='call', instanceName='tableTable_2', methodName='doTable', args=[[[GET, /resources/%id%.json, 200, Content-Type : application/json, jsonbody.resource.name=="test post" && jsonbody.resource.data=="some data" ]]]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_2_1</instructionId> <type>TableTableExpectation</type> <evaluationMessage>The instance tableTable_2.doTable. does not exist</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_3_0', instruction='make', instanceName='tableTable_3', className='RestFixture', args=[<a href="http://localhost:9876">http://localhost:9876</a>]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_3_0</instructionId> <type>ConstructionExpectation</type> <evaluationMessage>Could not invoke constructor for RestFixture[1]</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_3_1', instruction='call', instanceName='tableTable_3', methodName='doTable', args=[[[GET, /resources/%id%.json, 200, Content-Type : application/json, jsonbody.resource.name.length >= 0 jsonbody.resource.name.length < 1000 jsonbody.resource.name.length < jsonbody.resource.name.length+1 ], [let, content, js, response.body, ]]]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_3_1</instructionId> <type>TableTableExpectation</type> <evaluationMessage>The instance tableTable_3.doTable. does not exist</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_4_0', instruction='make', instanceName='tableTable_4', className='RestFixture', args=[<a href="http://localhost:9876">http://localhost:9876</a>]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_4_0</instructionId> <type>ConstructionExpectation</type> <evaluationMessage>Could not invoke constructor for RestFixture[1]</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_4_1', instruction='call', instanceName='tableTable_4', methodName='doTable', args=[[[setBody, %content%], [POST, /resources/, 201, , no-body], [let, id, header, Location:/resources/(.+), ]]]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_4_1</instructionId> <type>TableTableExpectation</type> <evaluationMessage>The instance tableTable_4.doTable. does not exist</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_5_0', instruction='make', instanceName='tableTable_5', className='RestFixture', args=[<a href="http://localhost:9876">http://localhost:9876</a>]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_5_0</instructionId> <type>ConstructionExpectation</type> <evaluationMessage>Could not invoke constructor for RestFixture[1]</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_5_1', instruction='call', instanceName='tableTable_5', methodName='doTable', args=[[[GET, /resources/%id%.json, 200, Content-Type : application/json, <pre> /* javascript */ var concat = jsonbody.resource.name + " and " + jsonbody.resource.data concat=="test post and some data" </pre>], [let, content, js, response.body, ]]]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_5_1</instructionId> <type>TableTableExpectation</type> <evaluationMessage>The instance tableTable_5.doTable. does not exist</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_6_0', instruction='make', instanceName='tableTable_6', className='RestFixtureConfig', args=[imp]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_6_0</instructionId> <type>ConstructionExpectation</type> <evaluationMessage>Could not invoke constructor for RestFixtureConfig[1]</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_6_1', instruction='call', instanceName='tableTable_6', methodName='doTable', args=[[[restfixture.javascript.imports.map, sampleJs=src/main/resources/FitNesseRoot/files/javascript/sample.js jsonpath=src/main/resources/FitNesseRoot/files/javascript/jsonpath-0.8.0.js]]]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_6_1</instructionId> <type>TableTableExpectation</type> <evaluationMessage>The instance tableTable_6.doTable. does not exist</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_7_0', instruction='make', instanceName='tableTable_7', className='RestFixture', args=[<a href="http://localhost:9876">http://localhost:9876</a>, imp]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_7_0</instructionId> <type>ConstructionExpectation</type> <evaluationMessage>Could not invoke constructor for RestFixture[2]</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_7_1', instruction='call', instanceName='tableTable_7', methodName='doTable', args=[[[GET, /resources/%id%.json, 200, Content-Type : application/json, JSONPath.eval(jsonbody, "$..resource.name") == "test post"], [let, sum, js, var sum = sampleAdd(1, 2); sum;, ]]]}</instruction> <slimResult></slimResult> <expectation> <status>error</status> <instructionId>tableTable_7_1</instructionId> <type>TableTableExpectation</type> <evaluationMessage>The instance tableTable_7.doTable. does not exist</evaluationMessage> </expectation> </instructionResult> </instructions> </result> <finalCounts> <right>0</right> <wrong>0</wrong> <ignores>0</ignores> <exceptions>1</exceptions> </finalCounts> <totalRunTimeInMillis>48</totalRunTimeInMillis> </testResults>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy