Last active
January 22, 2016 19:12
-
-
Save vicneanschi/7d0c524d64a3a6652315 to your computer and use it in GitHub Desktop.
SoapUI code snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/////////////// | |
//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=") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What exactly does this code do. I'm trying to setup a test to check some rest services... Any suggestions?