<?xml version='1.0' encoding='UTF-8'?><rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearchrss/1.0/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" version="2.0"><channel><atom:id>tag:blogger.com,1999:blog-28344537</atom:id><lastBuildDate>Thu, 24 Oct 2024 06:26:10 +0000</lastBuildDate><category>soapUI</category><category>groovy</category><category>Java</category><category>security</category><category>maven</category><category>programming</category><category>web services</category><title>Are you for a hot cup?</title><description>My thoughts mostly about Java, Web, different OS etc..</description><link>http://www.robert-nemet.com/</link><managingEditor>noreply@blogger.com (ddd)</managingEditor><generator>Blogger</generator><openSearch:totalResults>14</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-2622730967601234332</guid><pubDate>Sun, 10 Mar 2013 20:46:00 +0000</pubDate><atom:updated>2013-08-14T22:31:54.319+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>How to mock REST Service In soapUI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;div style=&quot;font-size: medium; font-weight: normal;&quot;&gt;
-------------------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div style=&quot;font-size: medium; font-weight: normal;&quot;&gt;
Book Groovy for soapUI users will be available soon. More information on this&amp;nbsp;&lt;a href=&quot;https://leanpub.com/groovy4soapUI&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;page&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;font-size: medium; font-weight: normal;&quot;&gt;
-------------------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Problem&lt;/h3&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; soapUI is mostly about SOAP protocol and by SOAP definition you need WSDL( &lt;i&gt;Web Service Description Language&lt;/i&gt; ) file for particular web service you are working on. That would be service definition or contract that specifies client-server conversation. Existence of service definition allows soapUI to easy and automatically create service mock.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;In case of REST service situation is quite different. REST is not protocol, it is&amp;nbsp;architectural&amp;nbsp;style or paradigm which relies on HTTP protocol. WADL ( Web Application Description Language ) file can be used to describe REST web service but it is not necessary. Actually in many cases service publisher do not have WADL file, just documentation describing &lt;i&gt;service resources and parameters&lt;/i&gt;. This makes REST automatically mocking quite a challenge.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Static REST mocking&lt;/h3&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;For this you need several responses and create folder where you will those store responses. Create empty soapUI project and then add one mock service. Open it and configure it:&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlP-dvxP47vnqMM0J8Gx4LhtC8hmSc2OhfAn5TugHlf1fw8dVpuS0GQV08PXrb2cZS-6s0MHDQWAJ_1w6xvjCOnpdfJVt81niiWJBtFN0E3XSg1i9DgyXB4TYRRlOJpcZjBJqJ/s1600/Screenshot+-+02282013+-+08:26:01+AM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlP-dvxP47vnqMM0J8Gx4LhtC8hmSc2OhfAn5TugHlf1fw8dVpuS0GQV08PXrb2cZS-6s0MHDQWAJ_1w6xvjCOnpdfJVt81niiWJBtFN0E3XSg1i9DgyXB4TYRRlOJpcZjBJqJ/s1600/Screenshot+-+02282013+-+08:26:01+AM.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Important things here are:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Path - this would be base path for mock service&lt;/li&gt;
&lt;li&gt;Port - port on which mock service works. Be sure it is not used by any other service.&lt;/li&gt;
&lt;li&gt;Docroot - root directory where responses will be searched for.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;Other settings are not necessary and they can be left not set.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;Now if you open your browser and go to&amp;nbsp;&lt;i&gt;http://localhost:8089/test&amp;nbsp;&lt;/i&gt;you should get this:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimlQc2LvgvVfUojf9139qY-ph11eB_4zAAW8SShLJZzBfx9WKJQ9EwdOCKBXHcvk37yCLTubSN3BbcwXjSD0RWpr7Ba0CTf2Nzqjvmf04FBNZFuf9FyGmJOne6IZhTnoMjwHpQ/s1600/Screenshot+-+02282013+-+08:45:35+AM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEimlQc2LvgvVfUojf9139qY-ph11eB_4zAAW8SShLJZzBfx9WKJQ9EwdOCKBXHcvk37yCLTubSN3BbcwXjSD0RWpr7Ba0CTf2Nzqjvmf04FBNZFuf9FyGmJOne6IZhTnoMjwHpQ/s1600/Screenshot+-+02282013+-+08:45:35+AM.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;OK, mock service is working but we need to add some responses. You do not need to stop service just in &lt;i&gt;docroot &lt;/i&gt;folder add new folder named &lt;i&gt;user&lt;/i&gt; and create file &lt;i&gt;response_one.json. &lt;/i&gt;I put simple text in response file, it do not need to be JSON. Then when go to&amp;nbsp;&lt;i&gt;http://localhost:8089/test/user/response_one.json &lt;/i&gt;you should see something like this:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTNeSSxaqdLhQ0QaeWom3-3qCc-u5A5aiiZ5KZeoiA6bBe3e5vNW1mi43ktFQhDj87PYxEUtdx61yWkNhM8QQuTUe_BTKrpZIb9132hJrT5HKn_kYmn_ne708PKGQH02ULUxYr/s1600/Screenshot+-+02282013+-+08:51:22+AM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiTNeSSxaqdLhQ0QaeWom3-3qCc-u5A5aiiZ5KZeoiA6bBe3e5vNW1mi43ktFQhDj87PYxEUtdx61yWkNhM8QQuTUe_BTKrpZIb9132hJrT5HKn_kYmn_ne708PKGQH02ULUxYr/s1600/Screenshot+-+02282013+-+08:51:22+AM.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp;So to add another response you need to create file and store it in docroot or its sub folders. When sending request you need specify path to response. This is quite simple but rather limited:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;You need to create file structure that look like REST resources and store responses in files.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;This only work with GET HTTP method&amp;nbsp;&lt;/li&gt;
&lt;li&gt;This do not support parameters in request. Links like : &lt;i&gt;http://localhost:8089/test/find?user=test&lt;/i&gt;&amp;nbsp;will not work unless you make file named&amp;nbsp;&lt;i&gt;find?user=test &lt;/i&gt;which could be problematic based on OS you are using.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;One small advice instead setting static value for &lt;i&gt;docroot &lt;/i&gt;use relative value from project file for example:&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;${projectDir}/REST Example&lt;/i&gt;.&lt;/blockquote&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Dynamic REST mocking&lt;/h3&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;As already mentioned REST relies on HTTP protocol. That means service provider can use all HTTP methods ( POST, GET, PUT, DELETE, HEAD, TRACE, OPTIONS, CONNECT and PATCH ). Most of the time only POST, GET, PUT and DELETE are used as they are CRUD ( Create, Read, Update and Delete ) operations.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;Obviously best way to achieve this in soapUI is to use Groovy. If you look at Mock service panel you can notice &lt;i&gt;OnRequest Script&lt;/i&gt; tab:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgvtS3yp0kxKPmiJQxGF3ZnmaCKw-4BDMJT5V7j1H2w1I46JxRnj0oHmub-8ypL4tIqWB4wDMSc5xptChzShkizx2fh4h49Ep_Bj7OoFZxZQXjdO2xKKGIyvexGwtQIlfOHPIg/s1600/Screenshot+-+03092013+-+10:25:49+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;439&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhgvtS3yp0kxKPmiJQxGF3ZnmaCKw-4BDMJT5V7j1H2w1I46JxRnj0oHmub-8ypL4tIqWB4wDMSc5xptChzShkizx2fh4h49Ep_Bj7OoFZxZQXjdO2xKKGIyvexGwtQIlfOHPIg/s640/Screenshot+-+03092013+-+10:25:49+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&amp;nbsp; &amp;nbsp;This a place where I can put my Groovy script to handle incoming requests to mock service. First thing I would like to be able to support any non POST request. Reason as I already mentioned is that soapUI mock service by default support only POST requests, but they also can be handled with Groovy scripts. To do that we can use this snippet:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;if ( mockRequest.method == &quot;GET&quot; ) {&lt;br /&gt;....&lt;br /&gt;}&lt;br /&gt;if ( mockRequest.method == &quot;PUT&quot; ) {&lt;br /&gt;...&lt;br /&gt;}&lt;/i&gt;&lt;/blockquote&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;b&gt;&amp;nbsp; &amp;nbsp;mockRequest &lt;/b&gt;is mock service variable available in &lt;i&gt;OnRequest Script &lt;/i&gt;and represent incoming request. Checking its property &lt;i&gt;method &lt;/i&gt;you can determine which HTTP method is used for request.&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Next thing I need to determine is &lt;i&gt;path. Path &lt;/i&gt;would be part of URL that determine path to some service resource relative to base URL. If service base URL is &lt;i&gt;http://www.example.com/rest/&lt;/i&gt; and service have several operations like &lt;i&gt;get user,&lt;/i&gt; &lt;i&gt;add user&lt;/i&gt; etc. then URLs to them can be: &lt;i&gt;http://www.example.com/rest/adduser&lt;/i&gt;,&lt;i&gt; http://www.example.com/rest/getuser&lt;/i&gt;, etc. In these cases paths are &lt;i&gt;adduser&lt;/i&gt; and &lt;i&gt;getuser&lt;/i&gt;. Those paths tells me what service method is to be used. Again to get path I can use &lt;i&gt;mockRequest &lt;/i&gt;variable:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;def path =&amp;nbsp;mockRequest.getPath()&lt;/i&gt;&lt;/blockquote&gt;
&lt;/div&gt;
Some service methods or resources can have or require one or more parameters. For example, this &lt;b&gt;GET&lt;/b&gt;&amp;nbsp;request:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;http://www.somedomain.com/service/getuser?id=121&lt;/i&gt;&lt;/blockquote&gt;
&amp;nbsp;Method &lt;i&gt;getuser&lt;/i&gt;&amp;nbsp;will return user but it need to be told what user you need. To do that client specify parameter &lt;i&gt;id&lt;/i&gt;&amp;nbsp;with unique user id value. In this case &lt;b&gt;id &lt;/b&gt;is parameter and &lt;b&gt;121 &lt;/b&gt;is passed value. In above example there is only one parameter in request but there could be much more, like:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;http://www.somedomain.com/service/adduser?nick=tito&amp;amp;name=tata&amp;amp;last_name=roro&lt;/i&gt;&lt;/blockquote&gt;
&amp;nbsp;In this example there are three parameters: &lt;i&gt;nick, name &lt;/i&gt;and &lt;i&gt;last_name&lt;/i&gt;. String that comes after &lt;b&gt;? &lt;/b&gt;&amp;nbsp;is parameter string. To get is value you can use:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;def queryString = mockRequest.getHttpRequest().getQueryString()&lt;/i&gt;&lt;/blockquote&gt;
&lt;div&gt;
If we put above all together:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;def path = mockRequest.getPath() &lt;br /&gt; def queryString = mockRequest.getHttpRequest().getQueryString()&lt;br /&gt; if ( mockRequest.method == &quot;GET&quot; ) {&lt;br /&gt;if( path == &quot;getuser&quot; ) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// anallyze parameters and create response&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // send response&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// handle other paths here&lt;br /&gt;}&lt;br /&gt;if ( mockRequest.method == &quot;PUT&quot; ) {&lt;br /&gt;if( path == &quot;update_user&quot; ) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;// anallyze parameters and create response&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // send response&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;if ( mockRequest.method == &quot;DELETE&quot; ) {&lt;br /&gt;if( path == &quot;delete_user&quot; ) {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // anallyze parameters and create response&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // send response&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;br /&gt;...&lt;br /&gt;}&lt;/i&gt;&amp;nbsp;&lt;/blockquote&gt;
&lt;br /&gt;
This would be basic boilerplate for REST mocking with soupUI. Analysing parameters are quite simple and basic stuff. Response creating is simple if you use XML or JSON builders from Groovy. Sending response can be tricky part. From soapUI documentation this is used:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;mockRunner.returnFile(mockRequest.httpResponse, new File(responseFolder, &quot;response_file.json&quot;) )&lt;br /&gt;mockRequest.httpResponse.setContentType(&quot;application/json;charset=utf-8&quot;)&lt;br /&gt;return new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult(mockRequest)&lt;/i&gt;&lt;/blockquote&gt;
From this means you have to save response in some file and then use it to send response. In example above response is in JSON format. That is can be changed to XML or any other format you need. If you write response to some file and then use:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;mockRunner.returnFile(mockRequest.httpResponse, new File(responseFolder, &quot;response_file.json&quot;) )&lt;/i&gt;&lt;/blockquote&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Than all is fine. But if you construct response and convert it to String then you can use this code instead above line:&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;i&gt;def response = &quot;Some response as String&quot;&lt;br /&gt;InputStream in = new ByteArrayInputStream(response.getBytes())&lt;br /&gt;response.setStatus( HttpServletResponse.SC_OK );&lt;br /&gt;long length = response.length();&lt;br /&gt;response.setContentLength( ( int )length );&lt;br /&gt;response.setContentType( &quot;set content type here&quot; );&lt;br /&gt;Tools.readAndWrite( in, length, response.getOutputStream() );&lt;br /&gt;in.close();&lt;/i&gt;&lt;/blockquote&gt;
This will put response string in response object and it will be shipped back to client.&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2013/03/how-to-mock-rest-service-in-soapui.html</link><author>noreply@blogger.com (ddd)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhlP-dvxP47vnqMM0J8Gx4LhtC8hmSc2OhfAn5TugHlf1fw8dVpuS0GQV08PXrb2cZS-6s0MHDQWAJ_1w6xvjCOnpdfJVt81niiWJBtFN0E3XSg1i9DgyXB4TYRRlOJpcZjBJqJ/s72-c/Screenshot+-+02282013+-+08:26:01+AM.png" height="72" width="72"/><thr:total>3</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-1406777270416092334</guid><pubDate>Tue, 25 Sep 2012 09:30:00 +0000</pubDate><atom:updated>2013-03-11T18:51:57.543+01:00</atom:updated><title>stoolz: soapUI helpers</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
Book Groovy for soapUI users will be available soon. More information on this&amp;nbsp;&lt;a href=&quot;https://leanpub.com/groovy4soapUI&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;page&lt;/a&gt;.&lt;br /&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://bitbucket.org/robert_nemet/soapuitools/wiki/Home&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;stoolz&lt;/a&gt;&amp;nbsp;is set of utilities that should help tester to maximize soapUI&#39;s ability to extend its functionality with Groovy.&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Goal&lt;/h3&gt;
&lt;div&gt;
Idea is to increase learning curve of soapUI API. &lt;b&gt;stoolz&lt;/b&gt;&amp;nbsp;will try to hide all boilerplate you usually need to do for simple tasks.&amp;nbsp;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Run Context Wrapper&lt;/h3&gt;
&lt;div&gt;
&lt;b&gt;RunContextWrapper&lt;/b&gt;&amp;nbsp;is helper that&amp;nbsp;wraps run context in attempt to make accessing to its properties, test steps, test case, test suites, project and workspace easier.&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Examples&lt;/h4&gt;
&lt;div&gt;
Assuming you have soapUI project with one test suite named &lt;b&gt;TestSuite - Groovy&lt;/b&gt;. This test suite have test case&amp;nbsp;
&lt;b&gt;TC - Examples&lt;/b&gt;&amp;nbsp;and it have test steps:&amp;nbsp;&lt;b&gt;Context Wrapper - items&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&lt;b&gt;CW - properties&lt;/b&gt;.&lt;/div&gt;
&lt;div&gt;
In test step&amp;nbsp;&lt;b&gt;Context Wrapper - items&lt;/b&gt;&amp;nbsp;which is Groovy test step type you define wrapper like this:&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
import stoolz.soapui.wrappers.RunContextWrapper&lt;br /&gt;
def cw = new RunContextWrapper(context)&lt;/blockquote&gt;
&lt;b&gt;cw&lt;/b&gt;&amp;nbsp;would be run context wrapper while &lt;b&gt;context&lt;/b&gt;&amp;nbsp;is build in soapUI&#39;s run context. Then this all is true:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
cw.testCase == context.testCase&lt;br /&gt;
cw.testSuite == context.testCase.testSuite&lt;br /&gt;
cw.project == context.testCase.testSuite.project&lt;br /&gt;
cw.&quot;CW - properties&quot; == context.testCase.getTestStepByName(&quot;CW - properties&quot;)&lt;br /&gt;
cw.&quot;General Test&quot; == ModelSupport.getModelItemProject(context.getModelItem()).getTestSuiteByName(&quot;General Test&quot;))&lt;/blockquote&gt;
In last line we are assuming that project have test suite &lt;b&gt;General Test&lt;/b&gt;, which do not contain running test case.&lt;br /&gt;
Adding properties on run context is in same manner:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
context.setProperty(&quot;test property&quot;, &quot;test property value&quot;)&lt;br /&gt;
cw.&quot;test property&quot; == context.getProperty(&quot;test property&quot;)&amp;nbsp;&lt;/blockquote&gt;
&lt;/div&gt;
or&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
context.setProperty(&quot;test property&quot;, &quot;XXX&quot;)&lt;br /&gt;
cw.&quot;test property&quot; = &quot;YYY&quot;&lt;br /&gt;
cw.&quot;test property&quot;== context.getProperty(&quot;test property&quot;)&lt;/blockquote&gt;
or&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
cw.&quot;test property&quot; = &quot;YYY&quot;&lt;br /&gt;
cw.&quot;test property&quot; ==context.getProperty(&quot;test property&quot;)&amp;nbsp;&lt;/blockquote&gt;
This means that with wrapper you can set/read run context property. In same manner you can access other test steps in owner test case or other test suites. Only thing that needs to have in mind is order of resolution. When you do:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
cw.myThing&amp;nbsp;&lt;/blockquote&gt;
context wrapper first checks for run &amp;nbsp;context properties, then for test steps and last for test suite names. Than means if you have property named &lt;b&gt;myProperty&lt;/b&gt;&amp;nbsp;and test step with same name line above will always return property value.&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Send mail script&lt;/h3&gt;
&lt;div&gt;
At your disposal is send mail script:&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
import stoolz.utils.SendMail&lt;br /&gt;
def mail = new SendMail()&lt;br /&gt;
mail.initGMail(&quot;my gmail account&quot; , &quot;my secret password&quot;)&lt;br /&gt;
mail.send( &quot;to address&quot;, &quot;subject&quot;, &quot;mail body&quot; )&lt;/blockquote&gt;
In previous example built in gmail configuration is used, but you can configure it to use your own mail server with:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
mail.configure(mailHost, mailPort, fromAddress, user, password, ssl, enableStartTLS)&lt;/blockquote&gt;
for properties &lt;b&gt;ssl&lt;/b&gt;&amp;nbsp;and&amp;nbsp;&amp;nbsp;&lt;b&gt;enableStartTLS&lt;/b&gt;&amp;nbsp;correct values can be &lt;b&gt;true/false &lt;/b&gt;or &lt;b&gt;on&lt;/b&gt;/&lt;b&gt;off&lt;/b&gt;. For others you&#39;ll probably need to check you mail client configuration or/and talk with local admin.&lt;br /&gt;
There is two ways to send emails, without attachments ( look above ) or with them:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
mail.send(toAddress, subject, mailMessage, attachmentDir, filePattern)&lt;/blockquote&gt;
where file pattern is something like *.zip.&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Installing&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
To use stoolz &amp;nbsp;you need to add it to {soapui.home}/ext folder, while&amp;nbsp;dependencies need to be in lib folder ( {soapui.home}/../lib ).&amp;nbsp;Dependencies ( see build.gradle file for versions ), which goes in lib folder are:&amp;nbsp;&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;ant-javamail&lt;/li&gt;
&lt;li&gt;ant&lt;/li&gt;
&lt;li&gt;antlr&lt;/li&gt;
&lt;li&gt;ant-launcher&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
You can download &lt;a href=&quot;https://bitbucket.org/robert_nemet/soapuitools/downloads&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;stoolz here&lt;/a&gt;.&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Issues, suggestions etc...&lt;/h3&gt;
&lt;div&gt;
If you thinks this can help you in your daily work, have issues or have any suggestion you can send me email or open issue &lt;a href=&quot;https://bitbucket.org/robert_nemet/soapuitools/issues?status=new&amp;amp;status=open&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;here&lt;/a&gt;.&lt;/div&gt;
&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2012/09/stoolz-soapui-helpers.html</link><author>noreply@blogger.com (ddd)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-2801259011848626052</guid><pubDate>Wed, 29 Aug 2012 12:49:00 +0000</pubDate><atom:updated>2013-03-11T18:52:48.120+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>Asserting JSON in soapUI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
Book Groovy for soapUI users will be available soon. More information on this&amp;nbsp;&lt;a href=&quot;https://leanpub.com/groovy4soapUI&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;page&lt;/a&gt;.&lt;br /&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; JSON stands for JavaScript Object Notation and it is lightweight data presentation format. It should be easy understandable for humans. Basically if you do not want and do not need to go in details it is same thing as XML just different&amp;nbsp;packaging. As you already know or guessed when soapUI was created SOAP services were in team focus.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; So, in soapUI you have good support for testing SOAP services and manipulating XML. What about REST and JSON?&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
JSON is soapUI&lt;/h4&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Good news is that there is no much difference when working with XML and JSON in soapUI. soapUI have number of features that uses XPath to manipulate XML.&amp;nbsp;Of course, you can not use XPath&amp;nbsp;&amp;nbsp;expressions on JSON. Or maybe you can? In soapUI you can thanks to the fact that soapUI converts JSON to XML. That way what ever you did to assert, validate, check on etc..on XML response same thing you can do with JSON response. Only difference is that instead using &lt;b&gt;Response&lt;/b&gt;&amp;nbsp;property you have to use &lt;b&gt;ResponseAsXml&lt;/b&gt;&amp;nbsp;property. &lt;b&gt;ResponseAsXml &lt;/b&gt;is soapUI&#39;s attempt to convert JSON to XML and all tools that you already used for XML use on JSON.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhayOuDCFO3j0b3F8QAP6ZyRQ_WdGvNc9pcY4exyS4pyM0Q9wwYzY6cOE-oMFTpTR9A4Cp0MMgjPV7WVBzpdVJAf6ZjwZsi9IpsWVg85mUvN1sLEMkJ7BVpFAcUERGjsI3hE47O/s1600/Screenshot-2012-08-29_13.44.29.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;336&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhayOuDCFO3j0b3F8QAP6ZyRQ_WdGvNc9pcY4exyS4pyM0Q9wwYzY6cOE-oMFTpTR9A4Cp0MMgjPV7WVBzpdVJAf6ZjwZsi9IpsWVg85mUvN1sLEMkJ7BVpFAcUERGjsI3hE47O/s640/Screenshot-2012-08-29_13.44.29.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
And this is how converted XML looks likes:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpisImj_kdGiLAj04nhatDy1No7JzQyGkaMbMir1y4HBZrk_f-QxRfutVCP6fqy4miTMsqGBoIsWrRcv_iZzcsQuQiTtxO2w-Vl5lh9Mo1vtw9k3QZ5pASxwrbUuuN0w4azfil/s1600/Screenshot-2012-08-29_13.48.54.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;606&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpisImj_kdGiLAj04nhatDy1No7JzQyGkaMbMir1y4HBZrk_f-QxRfutVCP6fqy4miTMsqGBoIsWrRcv_iZzcsQuQiTtxO2w-Vl5lh9Mo1vtw9k3QZ5pASxwrbUuuN0w4azfil/s640/Screenshot-2012-08-29_13.48.54.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpisImj_kdGiLAj04nhatDy1No7JzQyGkaMbMir1y4HBZrk_f-QxRfutVCP6fqy4miTMsqGBoIsWrRcv_iZzcsQuQiTtxO2w-Vl5lh9Mo1vtw9k3QZ5pASxwrbUuuN0w4azfil/s1600/Screenshot-2012-08-29_13.48.54.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;br /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
and original JSON like this:&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvKUAi71Vi9mosgks_XbracIit1OmRJ8BUbUtmUW99epSZ8B8ELjL4QCj_gltPkOblp2d_XAahXgxbdrunrwe2iF1KLG1a7ZChdXHmQdXWV2UgP_xJmVSzNtH4Bhg3JU80iIHZ/s1600/Screenshot-2012-08-29_13.48.07.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;582&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvKUAi71Vi9mosgks_XbracIit1OmRJ8BUbUtmUW99epSZ8B8ELjL4QCj_gltPkOblp2d_XAahXgxbdrunrwe2iF1KLG1a7ZChdXHmQdXWV2UgP_xJmVSzNtH4Bhg3JU80iIHZ/s640/Screenshot-2012-08-29_13.48.07.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Nice and peachy but...&lt;/h3&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
There is always one but. Problem with converting JSON to XML is that XML forces some rules that JSON do not have:&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Names can contain letters, numbers, and other characters&lt;/li&gt;
&lt;li&gt;Names cannot start with a number or punctuation character&lt;/li&gt;
&lt;li&gt;Names cannot start with the letters xml (or XML, or Xml, etc)&lt;/li&gt;
&lt;li&gt;Names cannot contain spaces&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Here you have an issue in soapUI, since soapUI can not convert JSON to XML if any of those rules will be broken. For example look at Twitters daily trends JSON response:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;{&lt;br /&gt;&amp;nbsp; &amp;nbsp;&quot;trends&quot;: &amp;nbsp; &amp;nbsp;{&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;2012-08-29 08:20&quot;: &amp;nbsp; &amp;nbsp; &amp;nbsp; [ &lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;events&quot;: null,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;name&quot;: &quot;Bizim İçin Saldır Fenerbahçe&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;query&quot;: &quot;\&quot;Bizim İçin Saldır Fenerbahçe\&quot;&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;promoted_content&quot;: null&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;},&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;events&quot;: null,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;name&quot;: &quot;#RemajaIndonesiaSeptemberWish&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;query&quot;: &quot;#RemajaIndonesiaSeptemberWish&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;promoted_content&quot;: null&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;},&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;events&quot;: null,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;name&quot;: &quot;Most Share-Worthy Video&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;query&quot;: &quot;\&quot;Most Share-Worthy Video\&quot;&quot;,&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;promoted_content&quot;: null&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
As you can notice &quot;2012-08-29 08:20&quot; should be node value if converted to XML but that breaks XML naming rules. So you are stuck here since there is no XML and you need to do asserting.&amp;nbsp;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Asserting JSON&lt;/h3&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; Problem is soapUI cannot convert JSON to XML because it will broke XML naming rules. You can not use XPath and XQuery assertions because of that. You can use &lt;b&gt;Contains &lt;/b&gt;and &lt;b&gt;Not Contains&lt;/b&gt;&amp;nbsp;assertions but they have very limited usage. What to do?&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;You should use your favorite assertion &lt;b&gt;Script Assertion&lt;/b&gt;&amp;nbsp;with Groovy&amp;nbsp;flavor. It is easy and fun, look:&lt;/div&gt;
&lt;div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;import groovy.json.JsonSlurper&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;def response = messageExchange.response.responseContent&lt;br /&gt;def slurper = new JsonSlurper()&lt;br /&gt;def json = slurper.parseText response&lt;/span&gt;&lt;/blockquote&gt;
&lt;div&gt;
Script above get response content as String and pass it to &lt;a href=&quot;http://groovy.codehaus.org/gapi/groovy/json/JsonSlurper.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;JsonSlurper&lt;/a&gt;&amp;nbsp;which parse this string and produce one big &lt;a href=&quot;http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;HashMap&lt;/a&gt;. Now working with &lt;a href=&quot;http://groovy.codehaus.org/JN1035-Maps&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;HashMap is very easy in Groovy&lt;/a&gt;.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;In this example ( &lt;a href=&quot;https://dev.twitter.com/docs/api/1/get/trends/daily&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;Twitter Daily Trends&lt;/a&gt; ) JSON response have trends for number of dates, so if I want check if it contains trends for some particular date and time:&amp;nbsp;&lt;/div&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;assert json.trends.&#39;2012-08-29 08:20&#39; != null&lt;/span&gt;&lt;/blockquote&gt;
Notice that I had to put date under quotes since date contains&amp;nbsp;white space, but &lt;b&gt;trends&lt;/b&gt;&amp;nbsp;are good. And now I want to be sure that I have eight trends for that date and time:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
assert json.trends.&#39;2012-08-29 08:20&#39;.size == 8&amp;nbsp; &amp;nbsp;&lt;/blockquote&gt;
&amp;nbsp;and 7th element &lt;b&gt;name&lt;/b&gt;&amp;nbsp;is Toby:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;assert json.trends.&#39;2012-08-29 08:20&#39;[7].name == &quot;Toby&quot;&lt;/span&gt;&lt;/blockquote&gt;
and so on...Whole script can look like this:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;import groovy.json.JsonSlurper&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;def response = messageExchange.response.responseContent&lt;br /&gt;def slurper = new JsonSlurper()&lt;br /&gt;def json = slurper.parseText response&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span style=&quot;font-family: Georgia, Times New Roman, serif;&quot;&gt;assert json.trends.&#39;2012-08-29 08:20&#39; != null&lt;br /&gt;assert json.trends.&#39;2012-08-29 08:20&#39;.size == 8&lt;br /&gt;assert json.trends.&#39;2012-08-29 08:20&#39;[7].name == &quot;Toby&quot;&lt;/span&gt;&amp;nbsp;&lt;/blockquote&gt;
&lt;div&gt;
Notice that is you have several assertions one by one in &lt;b&gt;Script Assertion&lt;/b&gt;&amp;nbsp;like on example above first assertion that fails will stop executing script, which means assertions under it ( in script ) will not be executed.&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
That is it..have fun...&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2012/08/json-asserting-in-soapui.html</link><author>noreply@blogger.com (ddd)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhayOuDCFO3j0b3F8QAP6ZyRQ_WdGvNc9pcY4exyS4pyM0Q9wwYzY6cOE-oMFTpTR9A4Cp0MMgjPV7WVBzpdVJAf6ZjwZsi9IpsWVg85mUvN1sLEMkJ7BVpFAcUERGjsI3hE47O/s72-c/Screenshot-2012-08-29_13.44.29.png" height="72" width="72"/><thr:total>8</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-3304351829333494130</guid><pubDate>Mon, 26 Mar 2012 18:05:00 +0000</pubDate><atom:updated>2012-08-19T16:18:15.435+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>Modularization, Action and Keyword Testing in soapUI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
New post published on Smart Bear blog:&lt;br /&gt;
&lt;a href=&quot;http://blog.smartbear.com/post/12-03-13/modularization-action-and-keyword-testing-in-soapui/&quot;&gt;http://blog.smartbear.com/post/12-03-13/modularization-action-and-keyword-testing-in-soapui/&lt;/a&gt;&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2012/03/modularization-action-and-keyword.html</link><author>noreply@blogger.com (ddd)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-6590929026133967542</guid><pubDate>Thu, 01 Mar 2012 11:23:00 +0000</pubDate><atom:updated>2012-03-01T12:23:52.741+01:00</atom:updated><title>soapUI 4.5 Beta 1 Overview</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
This week we got chance to try new soapUI. It is soapUI 4.5.0 Beta 1, so it is still rough on some edges but shape is nicely visible. Of all new stuff that soapUI 4.5 bring us these are major:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Environments&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Test Debugging&lt;/li&gt;
&lt;li&gt;Message Content Assertion&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Assertion Test Step&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Unfortunately all are in Pro version, so either you buy soapUI or use trial.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Environments&lt;/span&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
This feature bring us a possibility to create different testing environments. This makes me easier to update all properties ( usernames, passwords, etc ) when switching to test on different server. In Project panel you can find &lt;b&gt;Environment&lt;/b&gt;&amp;nbsp;tab and add, remove or clone environments.&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSy4vYpjkdaQ7UDqaqCPBBkWP4AJ3osaAfXm2Grgzks9pr1iCUKhClLlDlvBIGGy4tL8ks_FoQDYd48OlzSkSxQfikE0ElrcvL2s6pbO83_DjJJfXCSrWjwxdJUQ9-eX04UMeB/s1600/Screenshot-2012-03-01_11.03.56.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;593&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSy4vYpjkdaQ7UDqaqCPBBkWP4AJ3osaAfXm2Grgzks9pr1iCUKhClLlDlvBIGGy4tL8ks_FoQDYd48OlzSkSxQfikE0ElrcvL2s6pbO83_DjJJfXCSrWjwxdJUQ9-eX04UMeB/s640/Screenshot-2012-03-01_11.03.56.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;soapUI Environment&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
As you can see environment is defined with:&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;one SOAP endpoint - this is optional. Here you define it and while environment is active only in this panel you can change it.&lt;/li&gt;
&lt;li&gt;one REST endpoint - same as above.&lt;/li&gt;
&lt;li&gt;custom properties - optional. This is actually project properties. Environment custom properties override project properties. Names and number of properties is same for all environments just values can be different.&lt;/li&gt;
&lt;li&gt;jdbc connections - here you override configurations set in JDBC tab.&lt;/li&gt;
&lt;/ol&gt;
&lt;div&gt;
Changing/setting environment is done on test suite or test case level:&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-GlfcBDcIKDxOzKZ22849feUJunrFwNT_1GR3l6Nht3uef7waVu99ZizAwzJFGgb8MCjxHdlZzS3efLHyf_bCuQPmvhBXMxelKoZXCGoqRmChtKsKmBLq9P3arBEJOojc9vD1/s1600/Screenshot-2012-03-01_11.23.31.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;208&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-GlfcBDcIKDxOzKZ22849feUJunrFwNT_1GR3l6Nht3uef7waVu99ZizAwzJFGgb8MCjxHdlZzS3efLHyf_bCuQPmvhBXMxelKoZXCGoqRmChtKsKmBLq9P3arBEJOojc9vD1/s640/Screenshot-2012-03-01_11.23.31.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Selecting Environment&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
As you can see there is one hidden environment, it is default one. This one is created when you create project and you can look at it as baseline environment.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Test Debugging&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Finally not only developers can do debugging. Idea behind this one was to allow tester to see how test case&amp;nbsp;behaves.&amp;nbsp;Excellent to see if your test is buggy or web service you are testing, since now you can be sure from where those&amp;nbsp;weird values are coming from.&lt;/div&gt;
&lt;div&gt;
You can find test debugging on test case level:&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVV-8x7BLOmh8XaRqcMp9J2DKshhNLhdQaakHEwn5a3FPyRIRNkcgGzxz736GFZaZz8v_YHctfrAMZbHIhEJU0TNRbD7FKN4pLkLKLyhgH1VfPKgBxliNqdd8pKljIiLKdU54X/s1600/Screenshot-2012-03-01_11.38.37.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;593&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiVV-8x7BLOmh8XaRqcMp9J2DKshhNLhdQaakHEwn5a3FPyRIRNkcgGzxz736GFZaZz8v_YHctfrAMZbHIhEJU0TNRbD7FKN4pLkLKLyhgH1VfPKgBxliNqdd8pKljIiLKdU54X/s640/Screenshot-2012-03-01_11.38.37.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;Test Case Debugging&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
Here you can see:&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;test step list on left. Here you can add ordinary and conditional breakpoint. For conditional breakpoint you need to write groovy script in which you check for condition and based on it return &lt;b&gt;true&lt;/b&gt;&amp;nbsp;or &lt;b&gt;false&lt;/b&gt;. Test case execution will stop on ordinary break point or on conditional if condition script returns true. That small green arrow shows which test step is about to be executed.&lt;/li&gt;
&lt;li&gt;on right you can see listed project properties, test suite properties, etc...Here you can inspect them. Of course you can have lot of test step and this can be crowded, so you can filter only those you need. And you can keep them collapsed since soapUI will notify you if some property change its value. Notice there is &lt;b&gt;Property Expansion&lt;/b&gt;&amp;nbsp;table. Now you can see what property expansion is executed and what is its current value.&lt;/li&gt;
&lt;li&gt;at bottom right you can see property value you selected in upper table. This is for those properties which have lot of text as value, like response.&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Message Content Assertion&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
This would be like aggregated version on XPath assertion:&lt;/div&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwY5OhQ46Q0fduk9nmWyJvQGoRUB8TQhDg7XVk96UjdwIJziWV_aeQZqUCMc3icXSW7OB-vRsPO-VPTW6x7N0AmgBsFE6jspXLJWHhvHGrZamedKUynl43ChQnpg1VhnsQTxf-/s1600/Screenshot-2012-03-01_11.58.09.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;409&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjwY5OhQ46Q0fduk9nmWyJvQGoRUB8TQhDg7XVk96UjdwIJziWV_aeQZqUCMc3icXSW7OB-vRsPO-VPTW6x7N0AmgBsFE6jspXLJWHhvHGrZamedKUynl43ChQnpg1VhnsQTxf-/s640/Screenshot-2012-03-01_11.58.09.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;&lt;br /&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
Picture says all. Based on one request you select elements you want to compare and select operator ( &amp;lt;, &amp;gt;, =, etc ), set expected value and that is it. This assertion based on your selection generates XPaths which are saved with expected values. Next time request is run this assertion looking for nodes based on saved XPaths and if they exists compare theirs values with expected values. This means even if response XML changes response gets validated. You can reconfigure it. In that case you are asked do you want to keep old XPaths and add new ones or start from begging.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Assertion Test Step&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This would be assertions aggregation. In this test step you add assertions which targets other test steps, test case properties, test suite properties or project properties. Than you can group those assertions and apply &lt;b&gt;AND &lt;/b&gt;or &lt;b&gt;OR &lt;/b&gt;logic:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO0z00f_o4eveEZO6ZPp6FoZivQCP-FPtev8_OFNj0sHFSD_lPQVNAx3aMi8jl7FDsfxRlvyME2uk-2gFAmbOlv9FsWB1JhpqnHucRsGmRnUPlkibWSSAL3z3T3DNQuBqBIWCR/s1600/Screenshot-2012-03-01_12.08.14.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;252&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhO0z00f_o4eveEZO6ZPp6FoZivQCP-FPtev8_OFNj0sHFSD_lPQVNAx3aMi8jl7FDsfxRlvyME2uk-2gFAmbOlv9FsWB1JhpqnHucRsGmRnUPlkibWSSAL3z3T3DNQuBqBIWCR/s640/Screenshot-2012-03-01_12.08.14.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Here you can notice that we also got new assertion logic. Now you can assert property value, not just Response or Request. This is also visible in new Add Assertion Dialog:&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEZlDtOuJ54b0Xpnkn0XVRKzoMK3XqApm6Ua9wf-yP-TC-QeBCWGozKquddGti_Ik_Dlpz_Yb9IzMRf-lQZjMzFvUXinUJe14bWbwJFtlM1cDT7d46jYhfNbbBTkOaXSKHMvCh/s1600/Screenshot-2012-03-01_12.12.44.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;485&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjEZlDtOuJ54b0Xpnkn0XVRKzoMK3XqApm6Ua9wf-yP-TC-QeBCWGozKquddGti_Ik_Dlpz_Yb9IzMRf-lQZjMzFvUXinUJe14bWbwJFtlM1cDT7d46jYhfNbbBTkOaXSKHMvCh/s640/Screenshot-2012-03-01_12.12.44.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Assertions are also grouped in categories and I have &lt;b&gt;Recently Used&lt;/b&gt;.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;Conclusion&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
I think we got nice set of features that can help in every day work. There other improvements like new licensing system ( floating licenses ), improved wss and saml support, etc..but these four stand out for now.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</description><link>http://www.robert-nemet.com/2012/03/soapui-45-beta-1-overview.html</link><author>noreply@blogger.com (ddd)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgSy4vYpjkdaQ7UDqaqCPBBkWP4AJ3osaAfXm2Grgzks9pr1iCUKhClLlDlvBIGGy4tL8ks_FoQDYd48OlzSkSxQfikE0ElrcvL2s6pbO83_DjJJfXCSrWjwxdJUQ9-eX04UMeB/s72-c/Screenshot-2012-03-01_11.03.56.png" height="72" width="72"/><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-5657812077554767313</guid><pubDate>Thu, 22 Dec 2011 20:34:00 +0000</pubDate><atom:updated>2011-12-22T21:34:59.346+01:00</atom:updated><title>Security Scans in soapUI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here I show you how to use soapUI to hack a Hacme Casino. Read and enjoy...Here is a link on&amp;nbsp;&lt;a href=&quot;http://www.softwarequalityconnection.com/2011/12/how-to-check-your-web-app-for-security-vulnerabilities/&quot;&gt;http://www.softwarequalityconnection.com/2011/12/how-to-check-your-web-app-for-security-vulnerabilities/&lt;/a&gt;&lt;/div&gt;</description><link>http://www.robert-nemet.com/2011/12/security-scans-in-soapui.html</link><author>noreply@blogger.com (ddd)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-7714553406271031547</guid><pubDate>Mon, 07 Nov 2011 21:45:00 +0000</pubDate><atom:updated>2013-03-11T18:50:33.190+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>XML Parsing in soapUI</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;Book Groovy for soapUI users will be available soon. More information on this&amp;nbsp;&lt;a href=&quot;https://leanpub.com/groovy4soapUI&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;page&lt;/a&gt;.&lt;br /&gt;-------------------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Introduction&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&amp;nbsp; &amp;nbsp; Since soapUI allows users to add Groovy scripts in large number of places ( property expansions, setup /teardown scripts, listeners, test step, etc... ) users can use any technology to reach to the goal. Lets look at those which can make our life easier when it comes to XML parsing.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;soapUI XML Support&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Old way would be soapUI way or using &lt;b&gt;&lt;a href=&quot;http://www.soapui.org/apidocs/com/eviware/soapui/support/GroovyUtils.html&quot; target=&quot;_blank&quot;&gt;GroovyUtils&lt;/a&gt;&lt;/b&gt;&amp;nbsp;from soapUI.&amp;nbsp;Its goal is to simplify scripting and it can be&amp;nbsp;instantiate from any Groovy script in soapUI, with:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )&lt;/span&gt;&lt;/blockquote&gt;
where&amp;nbsp;&lt;b&gt;context &lt;/b&gt;is available in any Groovy script in soapUI. Lets look at GroovyUtils:&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;http://www.blogger.com/blogger.g?blogID=28344537&quot; name=&quot;method_summary&quot; style=&quot;background-color: white; text-align: -webkit-auto;&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;background-color: white; color: black;&quot; summary=&quot;&quot;&gt;&lt;tbody&gt;
&lt;tr bgcolor=&quot;#CCCCFF&quot; class=&quot;TableHeadingColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #003366; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: white;&quot;&gt;&lt;th align=&quot;left&quot; colspan=&quot;2&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;GroovyUtils Methods&lt;/span&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;expand&lt;/b&gt;(property)&lt;/code&gt;&amp;nbsp;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns value of property, if there are property expansions they are expanded.&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;extractErrorLineNumber&lt;/b&gt;(error)&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns line number where error&amp;nbsp;occurred&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: right;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: monospace; text-align: -webkit-auto;&quot;&gt;getProjectPath&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace; font-size: x-small;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns path to project file&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;b style=&quot;font-family: monospace; text-align: -webkit-auto;&quot;&gt;getXml&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;(node)&lt;/span&gt;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns xml as a string from passed node&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getXmlHolder&lt;/b&gt;(xmlPropertyOrString)&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns &lt;b&gt;&lt;a href=&quot;http://www.soapui.org/apidocs/com/eviware/soapui/support/XmlHolder.html&quot; target=&quot;_blank&quot;&gt;XmlHolder&lt;/a&gt;&lt;/b&gt; as a result of parsing passed Xml string&lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;registerJdbcDriver&lt;/b&gt;(driver)&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;register JDBC driver for use in Groovy script&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;setPropertyValue&lt;/b&gt;(testStep, property, value)&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;sets a value for given test step property&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
This time &lt;b&gt;getXmlHolder&lt;/b&gt;&amp;nbsp;is one that does what we need. Pars a given string as XML and returns object which we can use to manipulate with it.&lt;br /&gt;
&lt;br /&gt;
&lt;table border=&quot;1&quot; cellpadding=&quot;3&quot; cellspacing=&quot;0&quot; style=&quot;background-color: white; color: black;&quot; summary=&quot;&quot;&gt;&lt;tbody&gt;
&lt;tr bgcolor=&quot;#CCCCFF&quot; class=&quot;TableHeadingColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #003366; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; color: white;&quot;&gt;&lt;th align=&quot;left&quot; colspan=&quot;2&quot;&gt;&lt;b&gt;XmlHolder Methods&lt;/b&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: -webkit-auto;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code&gt;&lt;b&gt;declareNamespace&lt;/b&gt;(prefix, uri)&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;declare namespace prefix and URI&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getDomNode&lt;/b&gt;(xpath)&lt;/code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns a DOM node pointed by XPath expression&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getDomNodes&lt;/b&gt;(xpath)&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns an array of DOM nodes pointed by XPath expression&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getNamespaces&lt;/b&gt;()&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;td style=&quot;text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns a Map of namespaces&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getNodeValue&lt;/b&gt;(xpath)&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns a value of node specified by XPath expression&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getNodeValues&lt;/b&gt;(xpath)&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns an array of values specified by XPath expression&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getPrettyXml&lt;/b&gt;()&lt;/code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns a&amp;nbsp;formatted XML&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getXml&lt;/b&gt;()&lt;/code&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/div&gt;
&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns a&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;XML&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;getXmlObject&lt;/b&gt;()&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;returns a XmlBean Object&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;b style=&quot;font-family: monospace; text-align: -webkit-auto;&quot;&gt;removeDomNodes&lt;/b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;(xpath)&lt;/span&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;removes a nodes specified by XPath expression&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;setNodeValue&lt;/b&gt;(xpath, value)&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;set a node value&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td style=&quot;text-align: left;&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;updateProperty&lt;/b&gt;()&lt;/code&gt;&amp;nbsp;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;if a XmlHolder is created from test step property this updates that property&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;tr bgcolor=&quot;white&quot; class=&quot;TableRowColor&quot; style=&quot;background-attachment: initial; background-clip: initial; background-color: #efefef; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial;&quot;&gt;&lt;td align=&quot;right&quot; valign=&quot;top&quot; width=&quot;1%&quot;&gt;&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;code style=&quot;text-align: -webkit-auto;&quot;&gt;&lt;b&gt;updateProperty&lt;/b&gt;(prettyPrint)&lt;/code&gt;&amp;nbsp;&lt;/div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;code&gt;&amp;nbsp;&lt;/code&gt;&lt;/td&gt;&lt;td&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: monospace;&quot;&gt;if a XmlHolder is created from test step property this updates that property with well&amp;nbsp;formatted&amp;nbsp;XML&lt;/span&gt;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Few Examples&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Assume you have&amp;nbsp;response:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:sim=&quot;http://www.example.org/SimpleSocialSOA/&quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;lt;soapenv:Header/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;lt;soapenv:Body&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;sim:LoginResponse&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;id&amp;gt;4456643453&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/sim:LoginResponse&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;lt;/soapenv:Body&amp;gt;&lt;br /&gt;&amp;lt;/soapenv:Envelope&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;
For this examples I added a &lt;b&gt;Properties Test Step &lt;/b&gt;&amp;nbsp;with property&amp;nbsp;&lt;b&gt;response&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. Parsing XML&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
According to that to get &lt;b&gt;id&lt;/b&gt;&amp;nbsp;from response you can do:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )&lt;br /&gt;def holder = groovyUtils.getXmlHolder(&quot;Properties#response&quot;)&lt;br /&gt;log.info holder.getNodeValue(&quot;//id&quot;)&lt;br /&gt;log.info holder[&#39;//id&#39;]&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
notice two ways to get node value with &lt;b&gt;getNodeValue&lt;/b&gt;&amp;nbsp;method and with &lt;b&gt;[] operator&lt;/b&gt;. Difference is that &lt;b&gt;getNodeValue&lt;/b&gt;&amp;nbsp;will return first value that can be found with set XPath, while &lt;b&gt;[]&lt;/b&gt;&amp;nbsp;operator returns a array of values.&lt;br /&gt;
If you assume that response is like:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:sim=&quot;http://www.example.org/SimpleSocialSOA/&quot;&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;lt;soapenv:Header/&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;lt;soapenv:Body&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;sim:LoginResponse&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;id&amp;gt;4456643453&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;id&amp;gt;4456643452&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;id&amp;gt;4456643451&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;id&amp;gt;4456643450&amp;lt;/id&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/sim:LoginResponse&amp;gt;&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;lt;/soapenv:Body&amp;gt;&lt;br /&gt;&amp;lt;/soapenv:Envelope&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;
Than this script:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )&lt;br /&gt;def holder = groovyUtils.getXmlHolder(&quot;Properties#response&quot;)&lt;br /&gt;log.info holder.getNodeValue(&quot;//id&quot;)&lt;br /&gt;for( node in holder[&#39;//id&#39;] )&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;log.info node&lt;/span&gt;&lt;/blockquote&gt;
will produce result like this:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWPR9AoQT_kuV8mlnO_fsawnCcWGf5nC5vaRrSzGQ3RpMwRpHW4SfZ_RisGiFQ3_GoL1-BL3M7Ik0-WVj4oTC1oXg2sLgx1-x3dD7sc67EJUkRcyu8hF4RyUM8MzYxGC7K-lAt/s1600/Screenshot+-+11072011+-+07%253A22%253A08+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;582&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWPR9AoQT_kuV8mlnO_fsawnCcWGf5nC5vaRrSzGQ3RpMwRpHW4SfZ_RisGiFQ3_GoL1-BL3M7Ik0-WVj4oTC1oXg2sLgx1-x3dD7sc67EJUkRcyu8hF4RyUM8MzYxGC7K-lAt/s640/Screenshot+-+11072011+-+07%253A22%253A08+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;b&gt;2.&lt;/b&gt;&amp;nbsp;&lt;b&gt;Updating&amp;nbsp;XML&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
Response as above and we do:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )&lt;br /&gt;def holder = groovyUtils.getXmlHolder(&quot;Properties#response&quot;)&lt;br /&gt;holder.setNodeValue(&quot;//id&quot;, &quot;aaaaa&quot;)&lt;br /&gt;for( node in holder[&#39;//id&#39;] )&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;log.info node&lt;br /&gt;def holder2 = groovyUtils.getXmlHolder(&quot;Properties#response&quot;)&lt;br /&gt;holder2.getNodeValue(&quot;//id&quot;)&lt;br /&gt;for( node in holder2[&#39;//id&#39;] )&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;log.info node&lt;/span&gt;&lt;/blockquote&gt;
&amp;nbsp;Result is:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2XH0avQiGBrsNeMbTaeNisrRZfZ7Ayxu5yh8FqlV8EdDAH-RmcF9-9cgrbuGJjf_Sdxcoq6pBmzWh7Wfos_Aa55lwW0CLvt0VUP1UlS1unvK1Oc0zXKuXo0PRMciKZ3QaOO9a/s1600/Screenshot+-+11072011+-+07%253A36%253A57+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;166&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2XH0avQiGBrsNeMbTaeNisrRZfZ7Ayxu5yh8FqlV8EdDAH-RmcF9-9cgrbuGJjf_Sdxcoq6pBmzWh7Wfos_Aa55lwW0CLvt0VUP1UlS1unvK1Oc0zXKuXo0PRMciKZ3QaOO9a/s640/Screenshot+-+11072011+-+07%253A36%253A57+PM.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
from this we can learn:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;if there are several nodes as result of XPath expression only first&#39;s node value will be changed with &lt;b&gt;setNodeValue&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;setting node value is not enough to update property value, we forgot to use &lt;b&gt;updateProperty&lt;/b&gt;&amp;nbsp;method&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Correct Groovy script would be:&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )&lt;br /&gt;def holder = groovyUtils.getXmlHolder(&quot;Properties#response&quot;)&lt;br /&gt;holder.setNodeValue(&quot;//id&quot;, &quot;aaaaa&quot;)&lt;br /&gt;for( node in holder[&#39;//id&#39;] )&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;log.info node&lt;br /&gt;holder.updateProperty()&lt;br /&gt;def holder2 = groovyUtils.getXmlHolder(&quot;Properties#response&quot;)&lt;br /&gt;holder2.getNodeValue(&quot;//id&quot;)&lt;br /&gt;for( node in holder2[&#39;//id&#39;] )&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;log.info node&lt;/span&gt;&lt;/blockquote&gt;
&lt;br /&gt;
Instead of using:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;holder.setNodeValue(&quot;//id&quot;, &quot;aaaaa&quot;)&lt;/span&gt;&lt;/blockquote&gt;
you can use also:&lt;br /&gt;
&lt;blockquote class=&quot;tr_bq&quot;&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;holder[&quot;//id&quot;] = &quot;aaaaa&quot;&lt;/span&gt;&lt;/blockquote&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;And if &lt;b&gt;XmlNode &lt;/b&gt;is created from property as in example above use &lt;b&gt;updateProperty&lt;/b&gt;&amp;nbsp;method to apply your changes to property or use &lt;b&gt;GroovyUtils.setPropertyValue&lt;/b&gt;&amp;nbsp;method.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Groovy XML&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
There are three classes built in Groovy for processing XML: &lt;b&gt;XMLParser, XMLSlurper &lt;/b&gt;and &lt;b&gt;DOMCategory&lt;/b&gt;. Best practice is to use &lt;b&gt;XMLSlurper&lt;/b&gt;&amp;nbsp;in soapUI. Reason is that it have smallest memory footprint from all three. I would no go in depths for those, you can read here &lt;a href=&quot;http://groovy.codehaus.org/Processing+XML&quot; target=&quot;_blank&quot;&gt;XML processing&lt;/a&gt;.&lt;br /&gt;
This for example:&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;import groovy.xml.StreamingMarkupBuilder&lt;br /&gt;def response = context.testCase.testSteps[&#39;Properties&#39;].properties[&#39;response&#39;].value&lt;br /&gt;def responseXml = new XmlSlurper().parseText(response)&lt;br /&gt;responseXml.breadthFirst().each {&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def v = it.toString()&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if ( it.name() == &#39;id&#39;)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp; it.replaceBody(&quot;$v XX&quot;)&lt;br /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/blockquote&gt;
appends &quot; XX&quot; to values of all &lt;b&gt;id &lt;/b&gt;nodes.&lt;br /&gt;
&lt;br /&gt;
Generally it is easier to use &lt;b&gt;GroovyUtils&lt;/b&gt;&amp;nbsp;but if you are familiar or invest some time in &lt;b&gt;XmlSlurper&lt;/b&gt;&amp;nbsp;you can get better results and more flexible scripts.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2011/11/groovy-xml-parsing-in-soapui.html</link><author>noreply@blogger.com (ddd)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhWPR9AoQT_kuV8mlnO_fsawnCcWGf5nC5vaRrSzGQ3RpMwRpHW4SfZ_RisGiFQ3_GoL1-BL3M7Ik0-WVj4oTC1oXg2sLgx1-x3dD7sc67EJUkRcyu8hF4RyUM8MzYxGC7K-lAt/s72-c/Screenshot+-+11072011+-+07%253A22%253A08+PM.png" height="72" width="72"/><thr:total>20</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-9026421832432780210</guid><pubDate>Tue, 01 Nov 2011 08:28:00 +0000</pubDate><atom:updated>2011-11-06T19:30:48.700+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">security</category><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>soapUI &amp; HTTP Authentications ( part two )</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Discover how to use &lt;a href=&quot;http://blog.smartbear.com/post/11-10-31/how-to-use-digest-http-authentication-in-soapui/&quot; target=&quot;_blank&quot;&gt;Digest HTTP&amp;nbsp;Authentication&lt;/a&gt;.&amp;nbsp;&amp;nbsp;The second part is published on &lt;a href=&quot;http://blog.smartbear.com/&quot; target=&quot;_blank&quot;&gt;SmartBear blog&lt;/a&gt;.&lt;/div&gt;</description><link>http://www.robert-nemet.com/2011/11/soapui-http-authentications-part-two.html</link><author>noreply@blogger.com (ddd)</author><thr:total>2</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-5240789862353575206</guid><pubDate>Sun, 02 Oct 2011 14:44:00 +0000</pubDate><atom:updated>2013-03-11T18:53:16.067+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">security</category><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>soapUI &amp; HTTP Authentications ( part one )</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
Book Groovy for soapUI users will be available soon. More information on this&amp;nbsp;&lt;a href=&quot;https://leanpub.com/groovy4soapUI&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;page&lt;/a&gt;.&lt;br /&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Basic HTTP Authentication&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;What is it?&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; It is a method for client ( like web browser ) to provide &lt;b&gt;user name&lt;/b&gt; and &lt;b&gt;password&lt;/b&gt; to server when making a request. It is specified in&amp;nbsp;&lt;a href=&quot;http://tools.ietf.org/html/rfc1945&quot;&gt;RFC 1945&lt;/a&gt;&lt;a href=&quot;http://en.wikipedia.org/wiki/Basic_access_authentication#cite_note-1&quot;&gt;[2]&lt;/a&gt; (Hypertext Transfer Protocol – HTTP/1.0). Additional information can be found in &lt;a href=&quot;http://tools.ietf.org/html/rfc2616&quot;&gt;RFC 2616&lt;/a&gt; (Hypertext Transfer Protocol – HTTP/1.1) and &lt;a href=&quot;http://tools.ietf.org/html/rfc2617&quot;&gt;RFC 2617&lt;/a&gt; (HTTP Authentication: Basic and Digest Access Authentication).&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;How does it work?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;When client request a content from server if it authentication required server informs client that authentication is required and authentication type. Than client repeats request with required &amp;nbsp;authentication&amp;nbsp;type. This would be general description.&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; In case of basic HTTP authentication it would be like this:&lt;/div&gt;
&lt;div&gt;
1. Client request some content from browser:&lt;br /&gt;
&lt;blockquote&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;GET /user/list.html HTTP/1.1
Host: localhost&lt;/span&gt;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;
&lt;/span&gt;&lt;/blockquote&gt;
&lt;/div&gt;
&lt;div&gt;
2. Server returns HTTP error 401 which means that authentication is required, with authentication type:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;HTTP/1.1 401 Authorization Required
Server: HTTPd/1.0
Date: Sat, 27 Nov 2004 10:18:15 GMT
WWW-Authenticate: Basic realm=&quot;Secure Area&quot;
Content-Type: text/html
Content-Length: 311

&amp;lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
 &quot;http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd&quot;&amp;gt;
&amp;lt;HTML&amp;gt;
  &amp;lt;HEAD&amp;gt;
    &amp;lt;TITLE&amp;gt;Error&amp;lt;/TITLE&amp;gt;
    &amp;lt;META HTTP-EQUIV=&quot;Content-Type&quot; CONTENT=&quot;text/html; charset=ISO-8859-1&quot;&amp;gt;
  &amp;lt;/HEAD&amp;gt;
  &amp;lt;BODY&amp;gt;&amp;lt;H1&amp;gt;401 Unauthorized.&amp;lt;/H1&amp;gt;&amp;lt;/BODY&amp;gt;
&amp;lt;/HTML&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
Where in response header this:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;WWW-Authenticate: Basic realm=&quot;Secure Area&quot;&lt;/pre&gt;
&lt;br /&gt;
is HTTP header which caries this information.&lt;br /&gt;
&lt;br /&gt;
3. Client ask user for user name and password,&amp;nbsp;encrypts them and send to server :&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;GET /user/list.html HTTP/1.1
Host: localhost
Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==&lt;/pre&gt;
&lt;br /&gt;
Basically algorithm is like this:&lt;br /&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Client takes values for username and password and creates string &lt;b&gt;username + &lt;/b&gt;&quot;&lt;b&gt;:&lt;/b&gt;&quot; +&amp;nbsp;&lt;b&gt;password&lt;/b&gt;.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;Than that string is encoded&amp;nbsp;with base 64.&amp;nbsp;&lt;/li&gt;
&lt;li&gt;In HTTP header of new request is added header &lt;b&gt;Authentication&lt;/b&gt;&amp;nbsp;with value &quot;&lt;b&gt;Basic &amp;lt;encoded64base( username:password )&amp;gt;&lt;/b&gt;&quot;.&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
So,&amp;nbsp;this :&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==&lt;/pre&gt;
&lt;br /&gt;
is information required by server. This tells server that this is &lt;b&gt;basic HTTP authentication. &lt;/b&gt;Server authenticate user from:&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;QWxhZGRpbjpvcGVuIHNlc2FtZQ==&lt;/pre&gt;
&lt;br /&gt;
That is a string &quot;&lt;b&gt;username:password&lt;/b&gt;&quot; encrypted with base 64. Server just execute reverse operations: decode and than splits string to get username and password provided by user.&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;How this works in soapUI?&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
In &lt;a href=&quot;http://www.soapui.org/&quot;&gt;soapUI&lt;/a&gt;&amp;nbsp;this works out of box. First you need to enable preemptive authentication:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8IrWsDnz3p4RqrZwHWTk9To0UhK3U2eeT7kCoQ4bVgNFogaTbOqobNTCwUXM_QBf615TjT4F5_rsDCBGewXgZzxEDfgTiRmb2l7zSEUtoa1Y4WV6aLrsWV7vrA1L55lNHx4ge/s1600/basic-auth.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;452&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8IrWsDnz3p4RqrZwHWTk9To0UhK3U2eeT7kCoQ4bVgNFogaTbOqobNTCwUXM_QBf615TjT4F5_rsDCBGewXgZzxEDfgTiRmb2l7zSEUtoa1Y4WV6aLrsWV7vrA1L55lNHx4ge/s640/basic-auth.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Now you are able to specify username password in several places:&lt;br /&gt;
1. On request level:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQx8ZYEWtSYRbKaZ9l4SWNctOiw3spEpR4Fn4kHnp59CmKNRrxcCP1rxEY6GaDF6L-xd82qXqGporMKrCC5Dc5QFGhFs-c9bZu-Aun0umpGYClS_huuBG3Qs2CJGtBVBlYFqe8/s1600/basic-auth-user-pass.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjQx8ZYEWtSYRbKaZ9l4SWNctOiw3spEpR4Fn4kHnp59CmKNRrxcCP1rxEY6GaDF6L-xd82qXqGporMKrCC5Dc5QFGhFs-c9bZu-Aun0umpGYClS_huuBG3Qs2CJGtBVBlYFqe8/s640/basic-auth-user-pass.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
2. On test case level:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqi0jGUcoRbfisZvCUY9iNckIDUyFQUwgkC3Fz8qQCA9Ro0f-b3et_ffW-ec_pUTVEQmvPstTVCsoNPELF5yJBwL_vnge5XVh9iRXzXdnZKHXGKmT7WR9i8NSxL5HzkZGtYe9h/s1600/testcase-auth.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;476&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgqi0jGUcoRbfisZvCUY9iNckIDUyFQUwgkC3Fz8qQCA9Ro0f-b3et_ffW-ec_pUTVEQmvPstTVCsoNPELF5yJBwL_vnge5XVh9iRXzXdnZKHXGKmT7WR9i8NSxL5HzkZGtYe9h/s640/testcase-auth.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
These values will be applied to all requests in test case.&lt;br /&gt;
3. On interface level:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHCQ8E_vs-j5UZSsCl9d-ikt6Tz5kmIeAoGt2wiQcDWitSRatBNTJR6pyiEhn5-Rp7ykRxxVzPYiGz95PuT3VFaHBgIghxZGzK_J0LwaxbXvPi5S82g0FAvl5eFqIHCpbvF8wA/s1600/interface-auth.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;480&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHCQ8E_vs-j5UZSsCl9d-ikt6Tz5kmIeAoGt2wiQcDWitSRatBNTJR6pyiEhn5-Rp7ykRxxVzPYiGz95PuT3VFaHBgIghxZGzK_J0LwaxbXvPi5S82g0FAvl5eFqIHCpbvF8wA/s640/interface-auth.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
These values will be applied when ever this endpoint is used in request based on &lt;b&gt;mode&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;OVERRIDE&lt;/b&gt;&amp;nbsp;- use this values and override if same HTTP header already exists, do not change username/password properties on request&lt;/li&gt;
&lt;li&gt;&lt;b&gt;COMPLEMENT&lt;/b&gt;&amp;nbsp;- add this values to existing headers&lt;/li&gt;
&lt;li&gt;&lt;b&gt;COPY &lt;/b&gt;- copy these values to username/password properties on request&lt;/li&gt;
&lt;/ul&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;soapUI MockService and Basic HTTP Authentication&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&amp;nbsp; &amp;nbsp; Unfortunately basic HTTP authentication does not work out of box in soapUI, so some effort is needed for you to have in your mock service. First you need to be familiar how to use scripting possibilities in mock service (&amp;nbsp;&lt;a href=&quot;http://lostcybersoul.blogspot.com/2011/06/soapui-developing-web-service-with.html&quot;&gt;soapUI - Developing Web Service with Groovy&lt;/a&gt;&amp;nbsp;).&lt;br /&gt;
&amp;nbsp; &amp;nbsp; We&#39;ll start with this script:&lt;br /&gt;
&lt;blockquote&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; line-height: 19px;&quot;&gt;for( header in mockRequest.requestHeaders )&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;
  &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; line-height: 19px;&quot;&gt; log.info &quot;${header.key} : ${header.value[0]}&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: x-small;&quot;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; font-size: 13px; line-height: 19px;&quot;&gt;
&lt;/span&gt;&lt;/blockquote&gt;
If this script is placed in &lt;b&gt;OnRequest Script&lt;/b&gt;&amp;nbsp;in MockService panel, when request is sent on mock service you should see something like this:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaecdCAXMdQpuBiZp0MR28IaDd53AG1WRas-EFlKEXGMLfF0m9AVzH9soNfZ1cDKjR_Bpp0UxR3sxw6jqNxjfU57kaAj6sxB8ydCCMgS9slatp0K-8qdK5J5Vbqen3rANJ0ka5/s1600/basic-auth-mock.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;449&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiaecdCAXMdQpuBiZp0MR28IaDd53AG1WRas-EFlKEXGMLfF0m9AVzH9soNfZ1cDKjR_Bpp0UxR3sxw6jqNxjfU57kaAj6sxB8ydCCMgS9slatp0K-8qdK5J5Vbqen3rANJ0ka5/s640/basic-auth-mock.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Item &lt;b&gt;mockRequest&lt;/b&gt;&amp;nbsp;is available in &lt;b&gt;OnRequest Script&lt;/b&gt;&amp;nbsp;and it represent request received. Than this: &lt;b&gt;mockRequest.requestHeaders &lt;/b&gt;is a map of all HTTP headers in request and their values. Notice that one HTTP header can have multiple values. In this case we are interested in first one that comes in requests header. Result could be verified if you look raw request in &lt;b&gt;Request Panel&lt;/b&gt;:&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLEDtDL81Kdf6DUJoB8DVrrYGO3IA4V0kHezBOEuvs25ok3LYerFU4xnyAGShpg1TSlrdShT3vGVh70Z7Lkh3Kzefqap5lr07FEQnWszmUrwLL1OjyBlogZIlEfMMaJz4qaZm_/s1600/raw-request.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;640&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLEDtDL81Kdf6DUJoB8DVrrYGO3IA4V0kHezBOEuvs25ok3LYerFU4xnyAGShpg1TSlrdShT3vGVh70Z7Lkh3Kzefqap5lr07FEQnWszmUrwLL1OjyBlogZIlEfMMaJz4qaZm_/s640/raw-request.png&quot; width=&quot;622&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
O.k, plan is to check if request have &lt;b&gt;Authorization&lt;/b&gt;&amp;nbsp;header and correct values for username and password. If any of these conditions are not met client needs to be notified:&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; line-height: 19px;&quot;&gt; def response = new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult( mockRequest )
 mockRequest.httpResponse.status = 401
 mockRequest.httpResponse.writer &amp;lt;&amp;lt; &quot;ERROR&quot;
 return response&lt;/span&gt;&lt;/pre&gt;
In case that &lt;b&gt;Authorization &lt;/b&gt;header exists username and password needs to be verified:&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; line-height: 19px;&quot;&gt;def value = auth[0]
      if ( value.startsWith(&quot;Basic &quot;)) {
       value = value.substring( 6 )
         def up = new String(value.decodeBase64()).split(&quot;:&quot;)
         def user = up[0]
         def pass = up[1]
         if( !(user == &quot;robert&quot; &amp;amp;&amp;amp; pass == &quot;test&quot;) ) {
        return errorResult.call()
         }
      }&lt;/span&gt;&lt;/pre&gt;
Here &lt;b&gt;Authorization &lt;/b&gt;header value is taken, checked if it is &lt;b&gt;Basic&lt;/b&gt;&amp;nbsp;authorization. Rest of value is decoded and split so username and password can be extracted. Than those values are compared with set username and password. So, whole script looks like this:&lt;br /&gt;
&lt;pre style=&quot;background-color: #f9f9f9; border-bottom-color: rgb(47, 111, 171); border-bottom-style: dashed; border-bottom-width: 1px; border-left-color: rgb(47, 111, 171); border-left-style: dashed; border-left-width: 1px; border-right-color: rgb(47, 111, 171); border-right-style: dashed; border-right-width: 1px; border-top-color: rgb(47, 111, 171); border-top-style: dashed; border-top-width: 1px; color: black; font-family: monospace, &#39;Courier New&#39;; line-height: 1.1em; padding-bottom: 1em; padding-left: 1em; padding-right: 1em; padding-top: 1em;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white; font-family: sans-serif; line-height: 19px;&quot;&gt;def errorResult = {
 def response = new com.eviware.soapui.impl.wsdl.mock.WsdlMockResult( mockRequest )
 mockRequest.httpResponse.status = 401
 mockRequest.httpResponse.writer &amp;lt;&amp;lt; &quot;ERROR&quot;
 return response
}

def auth = mockRequest.requestHeaders[&quot;Authorization&quot;] 
if ( auth  ) {
      def value = auth[0]
      if ( value.startsWith(&quot;Basic &quot;)) {
       value = value.substring( 6 )
       def up = new String(value.decodeBase64()).split(&quot;:&quot;)
       def user = up[0]
       def pass = up[1]
       log.info &quot;$user $pass&quot;
       if( !(user == &quot;robert&quot; &amp;amp;&amp;amp; pass == &quot;test&quot;) ) {
        return errorResult.call()
       }
      } else {
       return errorResult.call()
      }  
   } else {
    return errorResult.call()
   }&lt;/span&gt;&lt;/pre&gt;
Notice that &lt;b&gt;errorResponse&lt;/b&gt;&amp;nbsp;is closure which creates error response and it will be called if no &lt;b&gt;Authorization &lt;/b&gt;header or it is not basic authorization or user name or password do not matches required values. In this script username/password pair is set to be robert/test.&lt;br /&gt;
&amp;nbsp; &lt;br /&gt;
That is it about basic HTTP authentication in soapUI....next time digest&amp;nbsp;authentication...&lt;/div&gt;
&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2011/10/soapui-http-authentications-part-one.html</link><author>noreply@blogger.com (ddd)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh8IrWsDnz3p4RqrZwHWTk9To0UhK3U2eeT7kCoQ4bVgNFogaTbOqobNTCwUXM_QBf615TjT4F5_rsDCBGewXgZzxEDfgTiRmb2l7zSEUtoa1Y4WV6aLrsWV7vrA1L55lNHx4ge/s72-c/basic-auth.png" height="72" width="72"/><thr:total>3</thr:total><georss:featurename>Belgrade, Serbia</georss:featurename><georss:point>44.802416 20.465601</georss:point><georss:box>44.6221565 20.149744 44.9826755 20.781458</georss:box></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-7803311735994757064</guid><pubDate>Tue, 21 Jun 2011 20:10:00 +0000</pubDate><atom:updated>2013-03-11T18:54:23.708+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>soapUI: Working with properties</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
Book Groovy for soapUI users will be available soon. More information on this&amp;nbsp;&lt;a href=&quot;https://leanpub.com/groovy4soapUI&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;page&lt;/a&gt;.&lt;br /&gt;
-------------------------------------------------------------------------------------------------------------&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Almost every item in soapUI have a set of a properties that describes its context. It is a string to string map. That means each property have name and value which are strings.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Overview&lt;/b&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Basically, they are used to describe context of elements in your test. That means they are one of crucial mechanics in soapUI. When ever you select any test element in project tree you can inspect its property values in down left corner. As you can notice each element have default properties which are set by soapUI.&lt;br /&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrTQxywMMvQxy7TrIEsd0vXIYjd2-Rg3R6d3HaH0lXr0PeNquGqARd4vyatCIJT9bX8nacMbdV8gu7v_G8OSHCCCIcEG9wlMaZ-K2Ekw3zlUVgbAKmi1v8lfrT7kVsciM8i8el/s1600/properties.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;400&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrTQxywMMvQxy7TrIEsd0vXIYjd2-Rg3R6d3HaH0lXr0PeNquGqARd4vyatCIJT9bX8nacMbdV8gu7v_G8OSHCCCIcEG9wlMaZ-K2Ekw3zlUVgbAKmi1v8lfrT7kVsciM8i8el/s400/properties.png&quot; width=&quot;166&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;properties&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&amp;nbsp; &amp;nbsp; In this example you can see properties in navigator, too. Showing properties in navigator is turned on by button in navigator&#39;s top left corner.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Describing and manipulating tests are not only purpose of properties. They can be used to store, keep and transfer values from one test item to another. Simple said if I want any value to be kept and than reused somewhere else I&#39;ll use properties. Obvious example for this is need to use values from response in next request. Like, user id which is obtained from login request. Most of properties are available for writing and reading, but some are just for reading. Those read only are important for projects consistency, so they can be changed as regular properties.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Inspecting Properties&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; To see what are properties on some item there are two ways: in UI by selecting item in navigator tree and inspecting table in down left corner or by &amp;nbsp;soapUI API. Doing it with Java means invoking &lt;b&gt;getProperties()&lt;/b&gt;&amp;nbsp;method on item. In Groovy it can be done same way or Groovy way:&lt;br /&gt;
&lt;br /&gt;
&lt;div style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;
context.currentStep.properties.each { key, value -&amp;gt;&lt;/div&gt;
&lt;div style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;log.info &quot;${key} : ${value.value}&quot;&lt;/div&gt;
&lt;div style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;
}&lt;/div&gt;
&lt;div style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
And result would be:&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Sun Jun 19 17:48:18 CEST 2011:INFO:result : {result=com.eviware.soapui.model.support.DefaultTestStepProperty@440d13, script=com.eviware.soapui.model.support.TestStepBeanProperty@1b69500}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;Sun Jun 19 17:48:18 CEST 2011:INFO:script : context.currentStep.properties.each { key, value -&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;log.info &quot;${key} : ${value.value}&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
Which can be checked if you look in test properties table for groovy script test step. &amp;nbsp;It have two default properties: &lt;b&gt;script&lt;/b&gt;&amp;nbsp;and &lt;b&gt;result&lt;/b&gt;. Second one is read only, and holds result of last execution.&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;b&gt;Accessing Properties&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; As you can see some properties can be set by user and some are set as execution&#39;s result by some operation which is usually test step. Those properties which are set as execution&#39;s result are most valuable ones so I need to be able to use those values automatically all over my test. That means in it should be available&amp;nbsp;across whole project. There are two ways to do that: &lt;b&gt;property transfer test step &lt;/b&gt;and &amp;nbsp;&lt;b&gt;property expansion&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Property Transfer Test Step&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;This is easy one. All one should do here is to create transfer, select source and its property, than destination and its property. Since here is common for result to be a XML you have a panel to add a XPath statement so the right node/value can be extracted from it. In soapUI Pro you have XPath selector to make your life easier. &lt;br /&gt;
&lt;table align=&quot;center&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;margin-left: auto; margin-right: auto; text-align: center;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjD55B7IMuddSb1i-BDWwWDRxt15TlN2YRIahul9OpkkZxr4s00bJfRp24P5ZhKdUBq6NuRwtbrtW1qkSzX3QussCCMF3Ywp-LyNLhhJlNQn4y_Sk1PK4OCDmj6THZFWIDu-Jd/s1600/property+transfer.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;409&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhjD55B7IMuddSb1i-BDWwWDRxt15TlN2YRIahul9OpkkZxr4s00bJfRp24P5ZhKdUBq6NuRwtbrtW1qkSzX3QussCCMF3Ywp-LyNLhhJlNQn4y_Sk1PK4OCDmj6THZFWIDu-Jd/s640/property+transfer.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;property transfer&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;b&gt;Property Expansion&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Property Transfer test step is there to make life easier and it is&amp;nbsp;enough if you need to transfer value or part of its value ( XML node for example ) to another property. But if you need to use some properties in mock service, or have chain of test steps and need to &amp;nbsp;propagate property values from previous one to next one it is&amp;nbsp;cumbersome to add property transfer in between each two test steps. For cases like these it is more appropriate to use &lt;b&gt;property expansion&lt;/b&gt;.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Syntax for property expansion looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232;&quot;&gt;&amp;nbsp; &amp;nbsp; ${#&amp;lt;scope&amp;gt;#&amp;lt;property name&amp;gt;}&amp;nbsp;&lt;/span&gt;&lt;/i&gt;-- property expansion for defined scope&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232;&quot;&gt;&amp;nbsp; &amp;nbsp; ${&amp;lt;test step name&amp;gt;#&amp;lt;property name&amp;gt;}&amp;nbsp;&lt;/span&gt;&lt;/i&gt;-- test step property&lt;br /&gt;
&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232;&quot;&gt;&amp;nbsp; &amp;nbsp; ${=&amp;lt;groovy expression&amp;gt;}&amp;nbsp;&lt;/span&gt;&lt;/i&gt;-- dynamic property&lt;br /&gt;
&lt;br /&gt;
In soapUI when talking about property transfer you have these scopes:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;b&gt;Project&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;TestSuite&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;TestCase&lt;/b&gt;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Security&lt;/b&gt;&amp;nbsp;, these are properties defined for security tests which are available from soapUI 4.0&lt;/li&gt;
&lt;li&gt;&lt;b&gt;MockService &lt;/b&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Global&lt;/b&gt;&amp;nbsp;, these are global properties&lt;/li&gt;
&lt;li&gt;&lt;b&gt;System&lt;/b&gt;&amp;nbsp;, system properties&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Env &lt;/b&gt;,&amp;nbsp;environment&amp;nbsp;properties&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
Properties for project, test suite, test case, security and mock service scopes are only available &amp;nbsp;if you call property expansion in that scope, notice that there is a hierarchy for those scopes:&lt;/div&gt;
&lt;table cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; class=&quot;tr-caption-container&quot; style=&quot;float: left; margin-right: 1em; text-align: left;&quot;&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style=&quot;text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtrDn9hVmqkvzMikBuOvVelMB7iD2c3UtBz6skkGp2sAITMzh5bJZaDVUlLq8qJhE6pz0Pvzvj9xtAhj6blXcLrDn8Uo4WM3sRUZYeFWQIXe-i5EooORV3jsE0Ozya-ADAs7Us/s1600/scopes.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; margin-bottom: 1em; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;283&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhtrDn9hVmqkvzMikBuOvVelMB7iD2c3UtBz6skkGp2sAITMzh5bJZaDVUlLq8qJhE6pz0Pvzvj9xtAhj6blXcLrDn8Uo4WM3sRUZYeFWQIXe-i5EooORV3jsE0Ozya-ADAs7Us/s320/scopes.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;tr-caption&quot; style=&quot;text-align: center;&quot;&gt;property scopes&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This means that you can call property expansion to get project level property any where in project, but if you want to get test case property you can call it when you are on test case level or on its children level ( security test, test steps, load test ).&lt;/div&gt;
&lt;div&gt;
So, if you have property &lt;b&gt;jira domain&lt;/b&gt;&amp;nbsp;on project level you can access it anywhere in project with:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;${#Project#jira domain}&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
but if you have domain &lt;b&gt;domain password &lt;/b&gt;property for test case with:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232;&quot;&gt; ${#TestCase#domain password}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
you can access it &lt;u&gt;only in test case where this property exists and its children&lt;/u&gt;.&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Last three scopes are available trough whole soapUI, where &lt;b&gt;Global&lt;/b&gt;&amp;nbsp;represent properties defined for whole soapUI. You can set them in soapUI preferences, or load them when starting soapUI by setting value for &lt;b&gt;soapui.property&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt; -Dsoapui.property=&amp;lt;path to file&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;System &lt;/b&gt;properties could be seen from &lt;b&gt;Help &lt;/b&gt;menu. And &lt;b&gt;Env &lt;/b&gt;are&amp;nbsp;environment properties like &lt;b&gt;MAVEN_HOME&lt;/b&gt;:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt; &amp;nbsp;${#System#user.home}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;${#Env#MAVEN_HOME}&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; In property transfer test step you can specify a XPath expression to extract a portion of property value if it is a XML. To do that with property expansion you need to add XPath expression and the end of property expansion like:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;${IsValidEmail#Request#declare namespace res=\&#39;http://www.example.org\&#39;; //res:userName[1]}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;Where &lt;b&gt;IsValidEmail&lt;/b&gt;&amp;nbsp;is a soap request test step name. In last example test step&#39;s&amp;nbsp;&lt;b&gt;IsValidEmail &lt;/b&gt;property &lt;b&gt;Request&lt;/b&gt;&amp;nbsp;(which all request test steps have) is taken as source. Also, since it have a XML value XPath expression is evaluated on it, so I could get just a value of node to transfer to my next request, for example. So, that would be like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:sim=&quot;http://www.example.org/SimpleSocialSOA/&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;soapenv:Header/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;soapenv:Body&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;sim:FindUser&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;name&amp;gt;${IsValidEmail#Request#declare namespace res=\&#39;http://www.example.org\&#39;; //res:userName[1]}&amp;lt;/name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/sim:FindUser&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;lt;/soapenv:Body&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;lt;/soapenv:Envelope&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
Last, and maybe most interesting way to execute property expansion is&amp;nbsp;dynamic ones. You could look on them like inserting a portion of Groovy code where ever property expansion could fit. So, if your request is needed to pass unique id in request you could use it like this:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;${=Math.random() * 10000}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
or you want to get a number of test suites in your project:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp;${=project.testSuites.size()}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
or if you want to put result of external command to your property:&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;${=new Scanner(\&quot;ls -al\&quot;.execute().inputStream).useDelimiter(\&quot;A\&quot;).next()}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
which will return list of files from current working directory in one line if you are on linux. But, what is powerful here is that this is execution a run time added &lt;b&gt;execute()&lt;/b&gt;&amp;nbsp;on a String, this is done by Groovy. Than I pick up result and with a little help of java.util.Scanner turn into String. This means that I can make my set of classes, Java or Groovy, package it all in jar file and if put in ext folder they will be added to class path. So, I can use them to execute my functions... So, with this I&#39;m not bound to use just Java/Groovy or soapUI classes but can&amp;nbsp;easily add mine. How hard is that? I&#39;ll give you example. Let say my Java class looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;public class HelloJava {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;public static String hello(String name) {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; return &quot;Hello &quot; + name + &quot;. How are you?&quot;;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
or in Groovy:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;public class HelloGroovy&amp;nbsp;{&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;def hello = { name -&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp; &amp;nbsp; &quot;Hello $name. How are you?&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;}&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;}&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Than save it java in &lt;b&gt;HelloJava.java &lt;/b&gt;and Groovy in &lt;b&gt;HelloGroovy.groovy&lt;/b&gt;, and compile it:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&amp;nbsp;javac HelloJava.java&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Groovy:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;groovyc GroovyJava.groovy&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
than pack it:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;jar cf javahello.jar H*.class&lt;/span&gt;&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
and Groovy:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;jar cf groovyhello.jar G*.class&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Notice that groovyc produced two class files since I have closure. Than copy it in &lt;b&gt;{soapui.home}/bin/ext&lt;/b&gt;&amp;nbsp;and it is ready to use:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;${=HelloJava.hello(&quot;Robert&quot;)}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
and:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt; ${=new HelloGroovy().hello(&quot;Robert&quot;)}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Simple....Now all what is left to let your imagination work...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2011/06/soapui-working-with-properties.html</link><author>noreply@blogger.com (ddd)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrTQxywMMvQxy7TrIEsd0vXIYjd2-Rg3R6d3HaH0lXr0PeNquGqARd4vyatCIJT9bX8nacMbdV8gu7v_G8OSHCCCIcEG9wlMaZ-K2Ekw3zlUVgbAKmi1v8lfrT7kVsciM8i8el/s72-c/properties.png" height="72" width="72"/><thr:total>6</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-7942278058497150565</guid><pubDate>Mon, 06 Jun 2011 19:49:00 +0000</pubDate><atom:updated>2011-06-06T21:58:23.397+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">soapUI</category><category domain="http://www.blogger.com/atom/ns#">web services</category><title>soapUI - Developing Web Service with Groovy</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;This article is moved from&amp;nbsp;&lt;a href=&quot;http://sites.google.com/site/groovyrhythm/groovy/change-testing-soapui---developing-web-service-with-groovy&quot;&gt;my Google site.&lt;/a&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; soapUI, well known, tool for functional and load testing web services, have integrated Groovy in it. It is usually used for creating complex tests, or doing stuff that are specific for test or not supported by tool itself.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp;  &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;MockService really cool thing...&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;    This soapUI feature enables mocking a web service based on its definition. So, I can write a test for web service while it is in development just based on wsdl,  if wsdl changes soapUI have a solution for that, too. That is for another time. Most important thing now is how can I test my tests before they are used on real thing?&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Creating a MockService&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; Doing this in soapUI is quite easy, with just click on a button it creates you a basic setup for MockService. Just right click on interface and choose “Generate MockService”. Now I have something to work with:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; color: black; font-size: small; line-height: normal; margin-left: auto; margin-right: auto;&quot;&gt;&lt;img height=&quot;462px;&quot; src=&quot;https://lh3.googleusercontent.com/gzhtkzePkvnbD0h8dIj-MezNLW5YSY1YH7UfHsjIX5F31rbC0bh0djAF7o7jTlqGF0PYWfugNoWvJlcqcLbq5O6yrdL8qGr9iSWuxCb68ANsj5oSmQ&quot; style=&quot;display: block; margin-left: auto; margin-right: auto; text-align: center;&quot; width=&quot;616px;&quot; /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Things of my interest are:&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;Properties tab - for properties, look at them as a global properties for mock service.&lt;/span&gt;&lt;/li&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;
&lt;li&gt;Start/Stop Script tab - these two Groovy scipts are executed when mock is started/stoped.&lt;/li&gt;
&lt;li&gt;OnRequest Script - this one Groovy script executes when request is received&lt;/li&gt;
&lt;li&gt;AfterRequest Script - and this Groovy script when response is dispatched&amp;nbsp;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; If you double click on any of those operation you’ll get an operation editor. Here you can choose several ways to determine a response. They are all pretty powerful features but I’m going for script dispatch method.&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Scripting a dispatching...&lt;span style=&quot;background-color: transparent; color: black; font-style: normal; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: Arial; font-size: 15px; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; If you choose script as dispatch method you’ll see a script editor and that you have several variables for your disposal:&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;ul&gt;&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;log - for logging/debugging since println is useless here.&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;context - mock runner context&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;requestContext - mock request context&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;mockRequest - request&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;mockOperation - operation&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&amp;nbsp; &amp;nbsp; Use these based on what you need. Basically what you need is to get xml from request and to modify response according to request. One more thing script should return a string which is a name of response. And a list of response for that operation is in upper tab.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&lt;/span&gt; So, I set two responses named Response and Error. I’ll be using a Response content to create a real response and Error content when I want send error. Actually I’ll not modify Error response at all, I’ll use as I defined it. So, script looks like this:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;import groovy.util.XmlSlurper&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;import groovy.xml.StreamingMarkupBuilder&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;request = new XmlSlurper().parseText(mockRequest.requestContent).declareNamespace(soapenv:&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;, gro:&quot;http://www.example.org/GroovyWSDL/&quot;)&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;response = new XmlSlurper().parseText(mockOperation.getMockResponseByName(&quot;Response&quot;).responseContent).declareNamespace(soapenv:&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;, gro:&quot;http://www.example.org/GroovyWSDL/&quot;)&lt;/code&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-size: small; line-height: normal;&quot;&gt;&lt;span style=&quot;white-space: pre-wrap;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;if ( request.&#39;soapenv:Body&#39;.&#39;gro:getFriendRequest&#39;.name == &quot;Robert&quot; ) {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;response.&#39;soapenv:Body&#39;.&#39;gro:getFriendResponse&#39;.friend.with {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;firstName = &quot;Robert&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;lastName = &quot;Nice&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;birthday = &quot;Some day&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;}&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;mockOperation.getMockResponseByName(&quot;Response&quot;).responseContent = new StreamingMarkupBuilder().bindNode(response)&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&quot;Response&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;} else {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&quot;Error&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
xml I expect to get is like:&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:gro=&quot;http://www.example.org/GroovyWSDL/&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;soapenv:Header/&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;soapenv:Body&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;gro:getFriendRequest&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;name&amp;gt;?&amp;lt;/name&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/gro:getFriendRequest&amp;gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;lt;/soapenv:Body&amp;gt;&lt;br /&gt;
&amp;lt;/soapenv:Envelope&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code style=&quot;color: #ccff66;&quot;&gt;&lt;br /&gt;
&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt; &lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
So, with :&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;mockRequest.requestContent&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I’m getting an xml and user XmlSlurper to parse it and check for incoming values. Next, thing is to modify response. Since I have to possible response I’ll fetch one that keeps xml response template and modify it to my needs:&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;response.&#39;soapenv:Body&#39;.&#39;gro:getFriendResponse&#39;.friend.with {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; firstName = &quot;Robert&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; lastName = &quot;Nice&quot;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; birthday = &quot;Some day&quot;&lt;br /&gt;
}&lt;/i&gt;&lt;/span&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;color: #ccff66; line-height: normal;&quot;&gt;&lt;i&gt;&lt;br /&gt;
&lt;/i&gt;&lt;/span&gt;   Now, I have to update Response content and dispatch it:&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; mockOperation.getMockResponseByName(&quot;Response&quot;).responseContent = new StreamingMarkupBuilder().bindNode(response)&lt;br /&gt;
“Response”&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;nbsp; This script checks if name is Robert and than it returns a response for that input, otherwise returns Error, which in this case in Unknown.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&amp;nbsp; &amp;nbsp; But this have one flaw, I’m changing a Response content so I’m changing my template, which is no good. So, I’ll add a property to mock service as default response holder. All I have to do is to go back to MockService panel, open a Properties tab and add one property which will contain a default xml. I named my property def_response and change this:&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;response = new XmlSlurper().parseText(context.mockService.properties.def_response.value).declareNamespace(soapenv:&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;, gro:&quot;http://www.example.org/GroovyWSDL/&quot;)&lt;/span&gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now, I’m using a template to create a response.&amp;nbsp;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Moving outside soapUI...&lt;span style=&quot;background-color: transparent; color: black; font-style: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: normal; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;Keeping everything in soapUI is nice, but I would like to create my logic a bit complicated and more modular. What I could do is to create script which could handle request xml and return a response xml. Something like this:&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-style: normal; white-space: normal;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;import groovy.util.XmlSlurper&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;import groovy.xml.StreamingMarkupBuilder&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;public class Dispatch {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;def def_response = &#39;&#39;&#39;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&#39;http://schemas.xmlsoap.org/soap/envelope/&#39;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;soapenv:Header/&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;soapenv:Body&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;gro:getFriendResponse xmlns:gro=&#39;http://www.example.org/GroovyWSDL/&#39;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;friend&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;firstName&amp;gt;?&amp;lt;/firstName&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;lastName&amp;gt;?&amp;lt;/lastName&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;birthday&amp;gt;?&amp;lt;/birthday&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;/friend&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;/gro:getFriendResponse&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;/soapenv:Body&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;/soapenv:Envelope&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&#39;&#39;&#39;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;def error = &#39;&#39;&#39;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:gro=&quot;http://www.example.org/GroovyWSDL/&quot;&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt; &amp;nbsp;&amp;nbsp;&amp;lt;soapenv:Header/&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt; &amp;nbsp;&amp;nbsp;&amp;lt;soapenv:Body&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;gro:getFriendResponse&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Unknown&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/gro:getFriendResponse&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt; &amp;nbsp;&amp;nbsp;&amp;lt;/soapenv:Body&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&amp;lt;/soapenv:Envelope&amp;gt;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;&#39;&#39;&#39;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;String process( String input) {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;def request = new XmlSlurper().parseText(input).declareNamespace(soapenv:&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;, gro:&quot;http://www.example.org/GroovyWSDL/&quot;)&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;def response = new XmlSlurper().parseText(def_response).declareNamespace(soapenv:&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;, gro:&quot;http://www.example.org/GroovyWSDL/&quot;)&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;if ( request.&#39;soapenv:Body&#39;.&#39;gro:getFriendRequest&#39;.name == &quot;Robert&quot; ) {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;response.&#39;soapenv:Body&#39;.&#39;gro:getFriendResponse&#39;.friend.with {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;firstName = &quot;Robert&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;lastName = &quot;Nice&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;birthday = &quot;Some day&quot;&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;}&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;new StreamingMarkupBuilder().bindNode(response)&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;} else {&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;error&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;}&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;code&gt;}&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;}&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: monospace;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;&lt;i&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: black; font-family: &#39;Times New Roman&#39;; font-style: normal; white-space: normal;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 10pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code style=&quot;color: #ccff66;&quot;&gt;&lt;br /&gt;
&lt;/code&gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
and in soapUI to have:&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;mockOperation.getMockResponseByName(&quot;Response&quot;).responseContent = new Dispatch().process(mockRequest.requestContent)&lt;/code&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;code&gt;&quot;Response&lt;/code&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; line-height: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&amp;nbsp; &amp;nbsp; Which is much cleaner. To do this just create a script and put in &lt;b&gt;{soapui.home}/bin.scripts&lt;/b&gt; or some other folder and in soapUI project properties set property &lt;b&gt;“Script Library”&lt;/b&gt;. Basically Dispach script is a gateway to your business logic. Layer under it could do what ever you wish, you could create a whole web service this way. It will not be a best one, but it will be more that enough for creating a test cases and validation for real web service while it is developed, before it can be deployed on test servers. &lt;/div&gt;&lt;/div&gt;</description><link>http://www.robert-nemet.com/2011/06/soapui-developing-web-service-with.html</link><author>noreply@blogger.com (ddd)</author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://lh3.googleusercontent.com/gzhtkzePkvnbD0h8dIj-MezNLW5YSY1YH7UfHsjIX5F31rbC0bh0djAF7o7jTlqGF0PYWfugNoWvJlcqcLbq5O6yrdL8qGr9iSWuxCb68ANsj5oSmQ=s72-c" height="72" width="72"/><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-5075762928150296508</guid><pubDate>Sun, 05 Jun 2011 20:03:00 +0000</pubDate><atom:updated>2013-03-11T18:55:34.512+01:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">soapUI</category><title>soapUI: extending a tool - adding Groovy scripts library</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;
&lt;div id=&quot;internal-source-marker_0.4886336661875248&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;
&lt;br /&gt;
&lt;div style=&quot;text-indent: 0px;&quot;&gt;
-------------------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;div style=&quot;text-indent: 0px;&quot;&gt;
Book Groovy for soapUI users will be available soon. More information on this&amp;nbsp;&lt;a href=&quot;https://leanpub.com/groovy4soapUI&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;page&lt;/a&gt;.&lt;/div&gt;
&lt;div style=&quot;text-indent: 0px;&quot;&gt;
-------------------------------------------------------------------------------------------------------------&lt;/div&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;
&lt;/span&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;soapUI as functional web service testing tool can do almost anything. If there is something that is missing with little help of Groovy scripts it can be done. So, with time you end with bunch groovy scripts. And when ever you want to use them you go trough your projects to look for them. And most of the time they are almost same. So, they could be reused. &lt;/span&gt;&lt;/div&gt;
&lt;div id=&quot;internal-source-marker_0.4886336661875248&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h3&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;soapUI extension mechanic&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;margin-bottom: 0pt; margin-top: 0pt; text-indent: 36pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;If you look at open source version you’ll find soapui-actions.xml file. There you first associate an alias, id, with action implementation class and than you group them in action groups. Each of these action groups are associated with some modelItem ( test step, test case ...) Since, already there are action groups associated with different modelItem best approach for start is to add new action to desired group. Basically, soapUI have action registry and there you add or merge actions. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Let say you installed soapUI at {soapui.home} than {soapui.home}/bin/actions is a place where you put a xml file which tells soapUI how to handle pop-up menus in navigator. &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;In, this example it is a test case :&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;tns:soapui-actions xmlns:tns=&quot;http://eviware.com/soapui/config&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;!-- defined action --&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;tns:action id=&quot;scriptLibrary&quot; actionClass=&quot;com.soapuitools.action.ScriptLibrary&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;!-- add action to project popup --&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;tns:actionGroup id=&quot;WsdlTestCaseActions&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;tns:actionMapping actionId=&quot;scriptLibrary&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;lt;/tns:actionGroup&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;/tns:soapui-actions&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;So, I said here that my class that performs an action is &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;com.soapuitools.action.ScriptLibrary&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; and add it to test case action group which name is &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;WsdlTestCaseActions.&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; This file goes to &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;{soapui.home}/bin/actions&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;. I named it my-actions.xml. One notice here this xml have to ends with &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;-actions.xml&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; to be picked up by soapUI.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: large;&quot;&gt;Implementation&lt;/span&gt; &lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;Ok, now you need to implement ScriptLibrary class. To do that you just need to implement &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;AbstractSoapUIAction. And that means, this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;import com.eviware.soapui.model.ModelItem&lt;br class=&quot;kix-line-break&quot; /&gt;import com.eviware.soapui.support.action.support.AbstractSoapUIAction&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;public class ScriptLibrary extends AbstractSoapUIAction&lt;br class=&quot;kix-line-break&quot; /&gt;{&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public ScriptLibrary()&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;super( &quot;soapUI Tools-ScriptLib&quot;, &quot;Script Lib&quot; )&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void perform( ModelItem target, Object param )&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;{&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;// do something usefull here&lt;br class=&quot;kix-line-break&quot; /&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;br class=&quot;kix-line-break&quot; /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;I did this in Groovy here, if you do it in Java its same story. In my case it looks like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;package com.soapuitools.action&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import javax.swing.JDialog&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import javax.swing.JFileChooser&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import javax.swing.filechooser.FileFilter&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import groovy.swing.SwingBuilder&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.eviware.soapui.impl.wsdl.WsdlProject&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.eviware.soapui.model.ModelItem&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.eviware.soapui.support.UISupport&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.eviware.soapui.support.action.support.AbstractSoapUIAction&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.eviware.soapui.impl.wsdl.WsdlInterface&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.eviware.soapui.impl.wsdl.testcase.WsdlTestCase&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.eviware.soapui.impl.wsdl.teststeps.registry.GroovyScriptStepFactory&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;public class ScriptLibrary extends AbstractSoapUIAction {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;WsdlTestCase testCase&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def swing = new SwingBuilder()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;String tsName&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;File templateFile&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;JDialog dialog&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public ScriptLibrary() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;super( &quot;soapUI Tools-ScriptLib&quot;, &quot;Script Lib&quot; )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public void perform( ModelItem modelItem, Object arg1 ) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;dialog = swing.dialog(modal:true) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;gridLayout(cols: 1, rows: 2)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;label(text:&quot;Enter test step name&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def tx = textField(columns:10)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;button(action: action(name:&quot;Choose File&quot;) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def openDialog &amp;nbsp;= swing.fileChooser(&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;currentDirectory: new File( System.getProperty(&quot;soapui.home&quot;,&quot;.&quot;) ),&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;dialogTitle:&quot;Choose a template file&quot;,&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;id:&quot;openDialog&quot;, &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;fileFilter: [getDescription: {-&amp;gt; &quot;*.gtp&quot;}, accept:{file-&amp;gt; file ==~ /.*?\.gtp/ || file.isDirectory() }] as FileFilter) {}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if(openDialog.showOpenDialog() != JFileChooser.APPROVE_OPTION) return //user cancelled&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;templateFile = openDialog.selectedFile&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;})&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;button(action:action(name:&quot;Ok&quot;) { &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;tsName = tx.text&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;dialog.visible=false&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;})&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;dialog.pack()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;dialog.show()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if (modelItem instanceof WsdlTestCase )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;testCase = modelItem as WsdlTestCase&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if ( tsName?.trim() != &quot;&quot; &amp;amp;&amp;amp; templateFile?.exists()) { &lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def gs = testCase.addTestStep( GroovyScriptStepFactory.GROOVY_TYPE, tsName )&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;def script = &quot;&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;templateFile.eachLine { line -&amp;gt; script+=&#39;\n&#39; + line}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;gs.properties[&quot;script&quot;].value = script&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;So, I just created &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;templates&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; directory in {soapui.home}/bin directory and I put my Groovy script templates in it with extension &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;gtp&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;. Now, all I need is to compile &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;ScriptLibrary&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;, pack it in jar and put that jar in {soapui.home}/bin/ext folder. Next time I started soapUI I got new menu item in test case pop-up. UI is lame but it does the job. You can modify it foryour needs.&lt;/span&gt;&lt;br /&gt;
&lt;h4&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;core and pro&lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;There is one difference regarding soapUI core version ( free one ) and soapUI Pro, second one support actions in Groovy scrips. That means you do not need to compile it and pack it in jar file. Even more you do not need to restart soapUI Pro to pick up the changes in your action script. So, to use example above just remove package statement in script and put it in {soapui.home}/bin/scripts or in directory where you pointed soapUI Pro ( check global settings, look for script library settings ). Also, my-actions.xml needs to be modified too:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;tns:soapui-actions xmlns:tns=&quot;http://eviware.com/soapui/config&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;lt;tns:action id=&quot;GroovyScriptAction&quot; actionClass=&quot;com.eviware.soapui.support.scripting.actions.SoapUIScriptAction&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;lt;tns:actionGroup id=&quot;WsdlTestCaseActions&quot;&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;lt;tns:actionMapping actionId=&quot;GroovyScriptAction&quot; name=&quot;Add GTP&quot; description=&quot;Add groovy test step from template&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;param=&quot;ScriptLibrary&quot;/&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;lt;/tns:actionGroup&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;/tns:soapui-actions&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Difference here is that you map your acction to SoapUIScriptAction and you pass to it your Groovy script. Simple...&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Verdana; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</description><link>http://www.robert-nemet.com/2011/06/soapui-extending-tool-adding-groovy.html</link><author>noreply@blogger.com (ddd)</author><thr:total>1</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-5148446181453899981</guid><pubDate>Sun, 05 Jun 2011 19:34:00 +0000</pubDate><atom:updated>2011-06-05T22:03:54.770+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">groovy</category><category domain="http://www.blogger.com/atom/ns#">maven</category><title>Change Testing: Groovy &amp; Maven</title><description>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;This article is moved from: &lt;/span&gt;&lt;a href=&quot;http://sites.google.com/site/groovyrhythm/groovy/change-testing-groovy-maven&quot;&gt;my Google site.&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;    Using unit testing usually becomes burden for developers and very often misleads. It is like testing bricks used to build house. They all could be perfect but still house could be lousy. What usually is problem with unit testing is actually hiding an errors in application design. Also, application design and its components design due all the rules like coupling, cohesion, modularity etc makes testing harder. For example take all those private methods and classes, they are so well hidden that you can not test them or you need to invest too much time to do it. Than if they are changed your tests needs to be changed to test properly functionality they are providing, again very often design forgets on tests.&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;    Using Groovy for testing make testing much more easy and even brings some fun. Groovy have less restricted, simpler syntax. The one thing many people do not like is Groovy modifiers. And that is everything is accessible in Groovy, no more private and protected methods and properties. Well, true is they are there, but what interest me is that I can avoid access modifiers for my tests.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;    My goal is unit testing, that means to test units, bricks, that will allow me to build my system. And when I put my brick in some wall I need free access to it so I can test it. Also, from a point of Java developer it looks almost like Java, and makes you to change a way of thinking in more open minded way..&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-size: 19px; white-space: pre-wrap;&quot;&gt;&lt;b&gt; &lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large; font-weight: bold; white-space: pre-wrap;&quot;&gt;GMaven.....&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;GMaven is a maven 2 plugin that help you uses a groovy in your projects. So, basically I want to be able to write unit tests in Groovy and I want maven to use those tests. So, basically you need gmaven to project’s pom file:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;...&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;plugin&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;    &amp;lt;groupId&amp;gt;org.codehaus.gmaven&amp;lt;/groupId&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre-wrap;&quot;&gt;&amp;lt;artifactId&amp;gt;gmaven-plugin&amp;lt;/artifactId&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;    &amp;lt;version&amp;gt;1.3&amp;lt;/version&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;  &amp;lt;executions&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;      &amp;lt;execution&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;            &amp;lt;goals&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;                &amp;lt;goal&amp;gt;generateTestStubs&amp;lt;/goal&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;                &amp;lt;goal&amp;gt;testCompile&amp;lt;/goal&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;            &amp;lt;/goals&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;        &amp;lt;/execution&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;     &amp;lt;/executions&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;/plugin&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;and than add this:&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: #f1c232; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: inherit; font-style: normal; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;font-family: inherit; font-style: normal; white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;...&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;groupId&amp;gt;org.codehaus.groovy&amp;lt;/groupId&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;artifactId&amp;gt;groovy&amp;lt;/artifactId&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;version&amp;gt;1.8.0-beta-1&amp;lt;/version&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;/dependency&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;dependency&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;groupId&amp;gt;org.codehaus.groovy.maven.runtime&amp;lt;/groupId&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;artifactId&amp;gt;gmaven-runtime-1.0&amp;lt;/artifactId&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;/dependency&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;dependency&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;groupId&amp;gt;junit&amp;lt;/groupId&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;artifactId&amp;gt;junit&amp;lt;/artifactId&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;version&amp;gt;4.8.1&amp;lt;/version&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&amp;lt;/dependency&amp;gt;&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;margin-bottom: 0pt; margin-left: 72pt; margin-top: 0pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i&gt;...&lt;/i&gt;&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Now when you do:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;mvn clean test&lt;/i&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;It will not only run java unit tests but also unit tests done in groovy. Now all is needed is to write some tests.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;Groovy &amp;amp; JUnit&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;div&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: large;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;As you can notice in pom file JUnit dependency is added. It is not necessary unless you want to run JUnit tests. So, how does it look :&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import org.junit.After&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import org.junit.Before&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import org.junit.Test&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;class CustomerLookup2Test &amp;nbsp;{&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@Before&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void setUp() throws Exception {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;nbsp;println &quot;setup&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@After&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void tearDown() throws Exception {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt; &amp;nbsp;&amp;nbsp;println &quot;teardown&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;@Test&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void testTests() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;println &quot;Test junit&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;white-space: pre;&quot;&gt;&lt;br /&gt;
&lt;/span&gt; &lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;This is a simple example of JUnit test that test a class CustomerLookup2 which could be a Java or Groovy, it does not matter. You can use all JUnit feature like in Java. There is nothing much to say about this its like in Java. But this is expected.&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 14pt; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;GroovyTestCase&lt;/span&gt;&lt;/h3&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt; &lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;Groovy brings on stage GrooovyTestCase which makes testing more easier. You got simpler syntax, new assertions :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertArrayEquals(Object[] expected, Object[] value)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertLength(int length, char[] array)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertLength(int length, int[] array)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertLength(int length, Object[] array)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertContains(char expected, char[] array)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertContains(int expected, int[] array)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertToString(Object value, String expected)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertInspect(Object value, String expected)&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;assertScript(final String script) // assert that a script runs without exceptions&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;shouldFail(Closure code) // assert that an exception was thrown in that closure&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li style=&quot;background-color: transparent; font-style: normal; font-weight: normal; list-style-type: disc; text-decoration: none; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;shouldFail(Class clazz, Closure code) // the same but for a class&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Assuming you are testing this class:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;package com.blogstar.custormer;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import java.lang.System;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;public class CustomerLookup {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String user;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private String pass;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public CustomerLookup(String user, String pass) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;this.user = user;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;this.pass = pass;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;public Customer lookForCustomerWithId(long id) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;createConnection();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return queryForUserWithId(id);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private Customer queryForUserWithId(long id) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;System.out.println(&quot;Fetching customer&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;return new Customer();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;private void createConnection() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;System.out.println(&quot;Creating connection! user = &quot; + user + &quot; and pass = &quot; + pass);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;So for this test class could look like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import groovy.util.GroovyTestCase&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import com.blogstar.custormer.CustomerLookup&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;class CustomerLookupTest extends GroovyTestCase {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;CustomerLookup customerLookup&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void setUp() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;customerLookup = new CustomerLookup(&quot;robert&quot;, &quot;blogstar&quot;)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void testQueryForUserWithId() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;customerLookup.lookForCustomerWithId(345)&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void testCreateConnection() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;customerLookup.createConnection()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void testingSomeMethod() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;println &quot;Here we are testing some method&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void tearDown() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;println &quot;tearDown&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Basically Groovy unit test is something like this:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import groovy.util.GroovyTestCase&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;class BasicTest extends GroovyTestCase {&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;void testingSomeMethod() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;println &quot;Here we are testing some method&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;As you can in &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;CustomerLookupTest &lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;I called a private methods to invoke them and test them. Here should be cleared that this is o.k if you test a private method without using others private methods, or to more clear on this it have to tested as a individual unit. If it is done differently than that it would mean you used it in manner not supposed to be used by &amp;nbsp;design. In that case you are not testing it a properly, since you are using it in a way it will not be used, since design do not allow that.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;h3&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit; font-size: small;&quot;&gt;Making a hierarchy of test...&lt;/span&gt;&lt;/span&gt;&lt;/h3&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;As parts of a code are put in some logical units, packages, in a same manner tests should be organized. Grouping unit tests that test some particular feature is done by test suites. Groovy also supports test suite. Actually GroovyTestSuite expands JUnit’s TestSuite. So, those who have expirience with JUnit TestSuite will have no problem creating one in Groovy:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import groovy.util.GroovyTestSuite&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;import junit.framework.Test&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;class RunAllTests extends GroovyTestSuite {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;static Test suite() {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;def allTests = new GroovyTestSuite()&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;allTests.addTestSuite(allTests.compile(&quot;src/test/groovy/CustomerLookupTest.groovy&quot;))&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;allTests.addTestSuite(allTests.compile(&quot;src/test/groovy/CustomerLookup2Test.groovy&quot;))&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return allTests&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;}&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;And to run this by maven add this to pom file:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif;&quot;&gt;&lt;i&gt;&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&amp;lt;properties&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;test&amp;gt;RunAllTests&amp;lt;/test&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;lt;/properties&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;....&lt;/span&gt;&lt;/i&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;or start test with:&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;mvn clean test -Dtest=&amp;lt;test suite name&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: inherit;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;With this you can organize test in way your project’s design requires. You just need to point to test cases and compile them while putting in test suite. This looks a bit strange:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: #f1c232; font-family: &#39;Trebuchet MS&#39;, sans-serif; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;allTests.addTestSuite(allTests.compile(&quot;src/test/groovy/CustomerLookupTest.groovy&quot;))&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; font-family: inherit; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;pointing to test case source and compiling it before adding to test suite but this could be used for something very useful.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent; font-size: 11pt;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: 11pt; font-style: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: transparent;&quot;&gt;&lt;span style=&quot;background-color: transparent; font-family: inherit; font-size: medium; font-style: normal; font-weight: bold; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial; font-size: 11pt; font-style: italic; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style=&quot;background-color: transparent; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;&quot;&gt;&lt;br /&gt;
&lt;/div&gt;&lt;/div&gt;</description><link>http://www.robert-nemet.com/2011/06/change-testing-groovy-maven.html</link><author>noreply@blogger.com (ddd)</author><thr:total>0</thr:total></item><item><guid isPermaLink="false">tag:blogger.com,1999:blog-28344537.post-1308981233014275275</guid><pubDate>Tue, 19 Jun 2007 12:05:00 +0000</pubDate><atom:updated>2007-06-20T22:38:29.573+02:00</atom:updated><category domain="http://www.blogger.com/atom/ns#">Java</category><category domain="http://www.blogger.com/atom/ns#">programming</category><title>Java keywords and their meaning</title><description>&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; Access Modifiers&lt;/span&gt;&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;private&lt;/strong&gt; - Makes method or variable accessible only within its own class.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;protected&lt;/strong&gt; - Makes method or variable accessible to classes in same package or to subclasses of the class.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;public&lt;/strong&gt; - Makes class, method or variable accessible from any other class.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Class, Method and Variable Modifiers&lt;/span&gt;&lt;/h4&gt;&lt;ol&gt;&lt;li&gt;&lt;strong&gt;abstract&lt;/strong&gt; - Declares class that can not be instantiated, or method that have to be implemented by nonabstract subclass.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;class&lt;/strong&gt; - Indicates a class.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;extends&lt;/strong&gt; - Indicates a super class that subclass is extending.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;final&lt;/strong&gt; - Indicates that class is impossible to extend, method to override and variable to change value.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;implements&lt;/strong&gt; - Indicates a interface that the class is implementing.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;interface&lt;/strong&gt; - Indicates a interface.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;native&lt;/strong&gt; - Indicates that method is written in a platform dependent language. &lt;/li&gt;&lt;li&gt; &lt;strong&gt;new&lt;/strong&gt; - Creates a new instance of a class by calling class&#39;s constructor.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;static&lt;/strong&gt; - Makes a method or a variable belong to a class as opposed to an instance.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;strictfp&lt;/strong&gt; - Used in front of a method or class to indicate that floating-point numbers will follow &lt;span style=&quot;font-weight: bold;&quot;&gt;FP-strict&lt;/span&gt; rules in all expressions.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;synchronized&lt;/strong&gt; - Indicates that a method can be accessed only by one thread a time.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;transient&lt;/strong&gt; - Prevents fields from ever being serialized. Transient fields are always skipped when objects are serialized.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;volatile&lt;/strong&gt; - Indicates a variable may change out of sync because it is used in threads.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; Flow Control&lt;/span&gt;&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;break&lt;/strong&gt; - Exits a block of code in witch it is suitable.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;case&lt;/strong&gt; - Executes a block of code dependent of &lt;em&gt;&lt;strong&gt;switch&lt;/strong&gt;&lt;/em&gt; condition.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;continue&lt;/strong&gt; - Stops executing rest of loop&#39;s code( that goes after ) and starts new iteration.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;default&lt;/strong&gt; - Executes a block of code if non of &lt;em&gt;&lt;strong&gt;switch&lt;/strong&gt;&lt;/em&gt; statements are true.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;do&lt;/strong&gt; - Executes a block of code one time, than based on &lt;em&gt;&lt;strong&gt;while&lt;/strong&gt;&lt;/em&gt; statement determines will it be executed again.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;else&lt;/strong&gt; - Executes a block of code when &lt;em&gt;&lt;strong&gt;if&lt;/strong&gt;&lt;/em&gt; condition is not true.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;for&lt;/strong&gt; - Executes a conditional loop on block of a code.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;if&lt;/strong&gt; - Executes a logical test.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;instanceof&lt;/strong&gt; - Determines if a object is instance of a class, a superclass or a interface.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;return&lt;/strong&gt; - Returns from method not executing any code that follows.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;switch&lt;/strong&gt; - Indicates a variable that will be compared to &lt;em&gt;&lt;strong&gt;case&lt;/strong&gt;&lt;/em&gt; statements.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;while&lt;/strong&gt; - Executes a block of code in loop if given logical test is true.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; Error Handling&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;catch&lt;/strong&gt; - Declares a block of code that executes if exception occurs.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;finally&lt;/strong&gt; - Block of code that follows &lt;em&gt;&lt;strong&gt;try&lt;/strong&gt;&lt;/em&gt; block code and executes no matter how exception is handled. &lt;/li&gt;&lt;li&gt; &lt;strong&gt;throw&lt;/strong&gt; - Used to pass an exception to method that called this method.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;throws&lt;/strong&gt; - Indicates a exception that can be thrown by a class or method.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;try&lt;/strong&gt; - Block of code that will be tried, but which may cause an exception.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;assert&lt;/strong&gt; - Evaluates a conditional expression to verify the programmer’s  assumption.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Package Control&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;import&lt;/strong&gt; - Declares what packages or class to import in code.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;package&lt;/strong&gt; - Define to which package code in file belongs to.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt;Variable Keywords&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;super&lt;/strong&gt; - Reference variable referring to immediate parent class(&lt;em&gt;super class&lt;/em&gt;).&lt;/li&gt;&lt;li&gt; &lt;strong&gt;this&lt;/strong&gt; - Reference variable referring to the instance of current object.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; Primitives&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;boolean&lt;/strong&gt; - A value indicating &lt;em&gt;true&lt;/em&gt; or &lt;em&gt;false&lt;/em&gt;.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;byte&lt;/strong&gt; - An 8-bit signed integer.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;char&lt;/strong&gt; - An Unicode character(16-bit unsigned integer).&lt;/li&gt;&lt;li&gt; &lt;strong&gt;int&lt;/strong&gt; - An 32-bit signed integer.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;float&lt;/strong&gt; - An 32-bit signed floating-point number.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;long&lt;/strong&gt; - An 64-bit signed integer.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;double&lt;/strong&gt; - An 64-bit signed floating-point number.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; Void Return Type Keyword&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;void&lt;/strong&gt; - Indicates that method does not have return type.&lt;/li&gt;&lt;/ol&gt;&lt;br /&gt;&lt;h4&gt;&lt;span style=&quot;font-size:130%;&quot;&gt; Unused Reserved Words&lt;/h4&gt;&lt;ol&gt;&lt;li&gt; &lt;strong&gt;goto&lt;/strong&gt; - bad practice.&lt;/li&gt;&lt;li&gt; &lt;strong&gt;const&lt;/strong&gt; - use &lt;strong&gt;public final static&lt;/strong&gt;.&lt;/li&gt;&lt;/ol&gt;</description><link>http://www.robert-nemet.com/2007/06/java-keywords-and-their-meaning.html</link><author>noreply@blogger.com (ddd)</author><thr:total>0</thr:total></item></channel></rss>