
FitNesseRoot.files.testResults.RestFixtureTests.LetTests.20130612232016_16_0_0_2.xml Maven / Gradle / Ivy
<?xml version="1.0"?> <testResults> <FitNesseVersion>v20130530</FitNesseVersion> <rootPath>LetTests</rootPath> <result> <counts> <right>16</right> <wrong>0</wrong> <ignores>0</ignores> <exceptions>2</exceptions> </counts> <runTimeInMillis>1193</runTimeInMillis> <content><br/><div class="collapsible closed"><ul><li><a href='#' class='expandall'>Expand All</a></li><li><a href='#' class='collapseall'>Collapse All</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> <td>script</td> <td colspan="2"><span class="pass">smartrics.rest.test.fitnesse.fixture.HttpServerFixture</span></td> </tr> <tr> <td>check</td> <td>is started</td> <td><span class="pass">true</span></td> </tr> <tr> <td colspan="3"><span class="pass">reset resources database</span></td> </tr> </table> </div> </div> <br/>Usages of LET (See also <a href="RestFixtureTests.PostTests">PostTests</a> for more examples) <br/><br/><i>LET used to extract values from header, using regular expressions</i><br/><br/><table> <tr> <td><span class="pass">Table: Rest Fixture</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr> <td>setBody</td> <td colspan="4">&lt;resource&gt;&lt;name&gt;Bill&lt;/name&gt;&lt;data&gt;Some data on Bill&lt;/data&gt;&lt;/resource&gt;</td> </tr> <tr> <td>POST</td> <td>/resources/</td> <td><span class="pass">201</span></td> <td>Location : /resources/2 Content-Length : 0 Server : Jetty(6.0.2)</td> <td><span class="pass">no-body</span></td> </tr> <tr> <td>let</td> <td>id</td> <td>header</td> <td>Location:/resources/(.+)</td> <td>2</td> </tr> <tr> <td>let</td> <td>testrunner</td> <td>const</td> <td>&lt;span class="meta"&gt;undefined variable: id&lt;/span&gt; / 2 / slim</td> <td>&lt;span class="meta"&gt;undefined variable: id&lt;/span&gt; / 2 / slim</td> </tr> <tr> <td>let</td> <td>testrunner2</td> <td>js</td> <td><span class="meta">undefined variable: id</span> / %id% / slim <span class="error">ReferenceError: "slim" is not defined. (unnamed script#1)</span></td> <td></td> </tr> </table> <br/>The regex is applied to each header. On the first match the first group is extracted and<br/>assigned as value to the label <i>id</i>.<br/><br/>Labels are global and can be shared across rest fixture instances.<br/><br/><i>LET used to extract values from XML body via XPath</i><br/><i>Values are re-usable across instances of RestFixture</i> <br/><br/>Here follows an usage of the previously extracted <i>id</i>.<br/>This example also shows how to use let to extract data from the XML body of a response using XPath.<br/><br/><table> <tr> <td><span class="pass">Table: Rest Fixture</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr> <td>GET</td> <td>/resources/2</td> <td><span class="pass">200</span></td> <td>Content-Type : application/xml;charset=ISO-8859-1 Content-Length : 68 Server : Jetty(6.0.2)</td> <td><span class="pass"> /resource/name[text()='Bill']&lt;br/&gt; /resource/data[text()='Some data on Bill'] expected----- &lt;resource&gt;&lt;name&gt;Bill&lt;/name&gt;&lt;data&gt;Some data on Bill&lt;/data&gt;&lt;/resource&gt; actual</span></td> </tr> <tr> <td>let</td> <td>name</td> <td>body</td> <td>/resource/name/text()</td> <td>Bill</td> </tr> </table> <br/>...or from a JSON body<br/><br/><table> <tr> <td><span class="pass">Table: Rest Fixture</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr> <td>GET</td> <td>/resources/1.json</td> <td><span class="pass">200</span></td> <td><span class="pass">Content-Type : application/json expected----- Content-Type : application/json;charset=ISO-8859-1 Content-Length : 77 Server : Jetty(6.0.2) actual</span></td> <td><span class="pass"> jsonbody.resource.name=='a funky name' &lt;br/&gt; jsonbody.resource.data=='an important message' expected----- { "resource" : { "name" : "a funky name", "data" : "an important message" } } actual</span></td> </tr> <tr> <td>let</td> <td>name</td> <td>body</td> <td>/resource/name/text()</td> <td>a funky name</td> </tr> </table> <br/><div class="collapsible"><ul><li><a href='#' class='expandall'>Expand All</a></li><li><a href='#' class='collapseall'>Collapse All</a></li></ul> <p class="title">Note</p> <div>Label values can be accessed from code using <b>new Variables().get("labelname");</b><br/></div> </div> <br/><br/><i>LET resolves names from Fixture Symbol map if not found in the local map</i><br/><br/>LetTestActionFixture allows to get/set values in the Fixture Symbol map<br/><br/><br/><table> <tr> <td>script</td> <td><span class="pass">smartrics.rest.test.fitnesse.fixture.LetTestActionFixture</span></td> </tr> <tr> <td>symbolName</td> <td>resType</td> </tr> <tr> <td>symbolValue</td> <td>/resources</td> </tr> </table> <br/><div class="collapsible"><ul><li><a href='#' class='expandall'>Expand All</a></li><li><a href='#' class='collapseall'>Collapse All</a></li></ul> <p class="title">Note</p> <div>Look at the source code of this page to see that the resource URI<br/>for the GET method below is defined as <b>%resType%/%id%</b><br/></div> </div> <br/><br/><table> <tr> <td><span class="pass">Table: Rest Fixture</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr> <td>GET</td> <td>/resources/2</td> <td><span class="pass">200</span></td> <td>Content-Type : application/xml;charset=ISO-8859-1 Content-Length : 68 Server : Jetty(6.0.2)</td> <td>&lt;resource&gt;&lt;name&gt;Bill&lt;/name&gt;&lt;data&gt;Some data on Bill&lt;/data&gt;&lt;/resource&gt;</td> </tr> <tr> <td>let</td> <td>theName</td> <td>body</td> <td>/resource/name/text()</td> <td>Bill</td> </tr> </table> <br/><table> <tr> <td>script</td> <td colspan="2"><span class="pass">smartrics.rest.test.fitnesse.fixture.LetTestActionFixture</span></td> </tr> <tr> <td>symbolName</td> <td colspan="2">theName</td> </tr> <tr> <td>check</td> <td>symbolValue</td> <td><span class="pass">Bill</span></td> </tr> </table> <br/>Other fixtures can set a value in the symbol map with <i>Fixture.setSymbol</i>.<br/>The RestFixture<a title="create page" href="RestFixtureTests.RestFixture?edit&amp;nonExistent=true">[?]</a> can then pick them up<br/><br/>This fixture sets <i>symbolName=/resources</i>...<br/><br/><br/><table> <tr> <td>script</td> <td><span class="pass">smartrics.rest.test.fitnesse.fixture.LetTestActionFixture</span></td> </tr> <tr> <td>symbolName</td> <td>aNameOfASymbol</td> </tr> <tr> <td>symbolValue</td> <td>/resources</td> </tr> </table> <br/>... then the value is used by the RestFixture<br/><table> <tr> <td><span class="pass">Table: Rest Fixture</span></td> <td colspan="4"><a href="http://localhost:9876">http://localhost:9876</a></td> </tr> <tr> <td>GET</td> <td>/resources/2</td> <td><span class="pass">200</span></td> <td>Content-Type : application/xml;charset=ISO-8859-1 Content-Length : 68 Server : Jetty(6.0.2)</td> <td>&lt;resource&gt;&lt;name&gt;Bill&lt;/name&gt;&lt;data&gt;Some data on Bill&lt;/data&gt;&lt;/resource&gt;</td> </tr> </table> <br/></content> <relativePageName>LetTests</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>pass(Table: Rest Fixture)</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_1_0</instructionId> <col>0</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>Table: Rest Fixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_1_1', instruction='call', instanceName='tableTable_1', methodName='doTable', args=[[[setBody, <resource><name>Bill</name><data>Some data on Bill</data></resource>], [POST, /resources/, 201, , no-body], [let, id, header, Location:/resources/(.+), ], [let, testrunner, const, <span class="meta">undefined variable: id</span> / %id% / slim, ], [let, testrunner2, js, <span class="meta">undefined variable: id</span> / %id% / slim, ]]]}</instruction> <slimResult>error()</slimResult> <expectation> <status>error</status> <instructionId>tableTable_1_1</instructionId> <type>TableTableExpectation</type> </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>pass(Table: Rest Fixture)</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_2_0</instructionId> <col>0</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>Table: Rest Fixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_2_1', instruction='call', instanceName='tableTable_2', methodName='doTable', args=[[[GET, /resources/%id%, 200, , /resource/name[text()='Bill']<br/> /resource/data[text()='Some data on Bill'] ], [let, name, body, /resource/name/text(), ]]]}</instruction> <slimResult>pass()</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_2_1</instructionId> <type>TableTableExpectation</type> </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>pass(Table: Rest Fixture)</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_3_0</instructionId> <col>0</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>Table: Rest Fixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_3_1', instruction='call', instanceName='tableTable_3', methodName='doTable', args=[[[GET, /resources/1.json, 200, Content-Type : application/json, jsonbody.resource.name=='a funky name' <br/> jsonbody.resource.data=='an important message' ], [let, name, body, /resource/name/text(), ]]]}</instruction> <slimResult>pass()</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_3_1</instructionId> <type>TableTableExpectation</type> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_4_0', instruction='make', instanceName='scriptTableActor', className='smartrics.rest.test.fitnesse.fixture.LetTestActionFixture', args=[]}</instruction> <slimResult>pass(smartrics.rest.test.fitnesse.fixture.LetTestActionFixture)</slimResult> <expectation> <status>pass</status> <instructionId>scriptTable_4_0</instructionId> <col>1</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>smartrics.rest.test.fitnesse.fixture.LetTestActionFixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_4_1', instruction='call', instanceName='scriptTableActor', methodName='symbolName', args=[resType]}</instruction> <slimResult></slimResult> <expectation> <instructionId>scriptTable_4_1</instructionId> <col>0</col> <row>1</row> <type>ScriptActionExpectation</type> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_4_2', instruction='call', instanceName='scriptTableActor', methodName='symbolValue', args=[/resources]}</instruction> <slimResult></slimResult> <expectation> <instructionId>scriptTable_4_2</instructionId> <col>0</col> <row>2</row> <type>ScriptActionExpectation</type> </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>pass(Table: Rest Fixture)</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_5_0</instructionId> <col>0</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>Table: Rest Fixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_5_1', instruction='call', instanceName='tableTable_5', methodName='doTable', args=[[[GET, %resType%/%id%, 200, , ], [let, theName, body, /resource/name/text(), ]]]}</instruction> <slimResult>pass()</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_5_1</instructionId> <type>TableTableExpectation</type> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_6_0', instruction='make', instanceName='scriptTableActor', className='smartrics.rest.test.fitnesse.fixture.LetTestActionFixture', args=[]}</instruction> <slimResult>pass(smartrics.rest.test.fitnesse.fixture.LetTestActionFixture)</slimResult> <expectation> <status>pass</status> <instructionId>scriptTable_6_0</instructionId> <col>1</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>smartrics.rest.test.fitnesse.fixture.LetTestActionFixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_6_1', instruction='call', instanceName='scriptTableActor', methodName='symbolName', args=[theName]}</instruction> <slimResult></slimResult> <expectation> <instructionId>scriptTable_6_1</instructionId> <col>0</col> <row>1</row> <type>ScriptActionExpectation</type> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_6_2', instruction='call', instanceName='scriptTableActor', methodName='symbolValue', args=[]}</instruction> <slimResult>pass(Bill)</slimResult> <expectation> <status>pass</status> <instructionId>scriptTable_6_2</instructionId> <col>2</col> <row>2</row> <type>ReturnedValueExpectation</type> <evaluationMessage>Bill</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_7_0', instruction='make', instanceName='scriptTableActor', className='smartrics.rest.test.fitnesse.fixture.LetTestActionFixture', args=[]}</instruction> <slimResult>pass(smartrics.rest.test.fitnesse.fixture.LetTestActionFixture)</slimResult> <expectation> <status>pass</status> <instructionId>scriptTable_7_0</instructionId> <col>1</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>smartrics.rest.test.fitnesse.fixture.LetTestActionFixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_7_1', instruction='call', instanceName='scriptTableActor', methodName='symbolName', args=[aNameOfASymbol]}</instruction> <slimResult></slimResult> <expectation> <instructionId>scriptTable_7_1</instructionId> <col>0</col> <row>1</row> <type>ScriptActionExpectation</type> </expectation> </instructionResult> <instructionResult> <instruction>{id='scriptTable_7_2', instruction='call', instanceName='scriptTableActor', methodName='symbolValue', args=[/resources]}</instruction> <slimResult></slimResult> <expectation> <instructionId>scriptTable_7_2</instructionId> <col>0</col> <row>2</row> <type>ScriptActionExpectation</type> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_8_0', instruction='make', instanceName='tableTable_8', className='RestFixture', args=[<a href="http://localhost:9876">http://localhost:9876</a>]}</instruction> <slimResult>pass(Table: Rest Fixture)</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_8_0</instructionId> <col>0</col> <row>0</row> <type>ConstructionExpectation</type> <evaluationMessage>Table: Rest Fixture</evaluationMessage> </expectation> </instructionResult> <instructionResult> <instruction>{id='tableTable_8_1', instruction='call', instanceName='tableTable_8', methodName='doTable', args=[[[GET, %aNameOfASymbol%/%id%, 200, , ]]]}</instruction> <slimResult>pass()</slimResult> <expectation> <status>pass</status> <instructionId>tableTable_8_1</instructionId> <type>TableTableExpectation</type> </expectation> </instructionResult> </instructions> </result> <finalCounts> <right>0</right> <wrong>0</wrong> <ignores>0</ignores> <exceptions>0</exceptions> </finalCounts> <totalRunTimeInMillis>0</totalRunTimeInMillis> </testResults>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy