Skip to content

Instantly share code, notes, and snippets.

@vicneanschi
Last active January 22, 2016 19:12
Show Gist options
  • Save vicneanschi/7d0c524d64a3a6652315 to your computer and use it in GitHub Desktop.
Save vicneanschi/7d0c524d64a3a6652315 to your computer and use it in GitHub Desktop.
SoapUI code snippets
///////////////
//Get and Set properties
//////////////
// get properties from testCase, testSuite and project
def testCaseProperty = testRunner.testCase.getPropertyValue( "MyProp" )
def testSuiteProperty = testRunner.testCase.testSuite.getPropertyValue( "MyProp" )
def projectProperty = testRunner.testCase.testSuite.project.getPropertyValue( "MyProp" )
def globalProperty = com.eviware.soapui.SoapUI.globalProperties.getPropertyValue( "MyProp" )
// setting values is equally straigh forward
testRunner.testCase.setPropertyValue( "MyProp", someValue )
testRunner.testCase.testSuite.setPropertyValue( "MyProp", someValue )
testRunner.testCase.testSuite.project.setPropertyValue( "MyProp", someValue )
com.eviware.soapui.SoapUI.globalProperties.setPropertyValue( "MyProp", someValue )
//////////////
//Parse JSON
/////////////
import groovy.json.JsonSlurper
def responseContent = messageExchange.getResponseContent()
// Create JsonSlurper Object to parse the response
def Response = new JsonSlurper().parseText(responseContent)
assert Response.result.success == false
assert Response.result.httpMessage == "Authentication Failed."
assert Response.result.httpCode == 403
//////////////////
//Access HTTP Headers
/////////////////
def cookies = messageExchange.responseHeaders["Set-Cookie"]
assert cookies.size() == 1
assert cookies[0].startsWith("X2O=")
@dutchand
Copy link

What exactly does this code do. I'm trying to setup a test to check some rest services... Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment