not-bob
not-bob

Reputation: 835

How do I build a base64 string from properties in SoapUI?

Here is what I've got.

The questions I think I have are:

I appreciate your time :)

Upvotes: 0

Views: 1944

Answers (1)

not-bob
not-bob

Reputation: 835

This sample does the trick.

def writer = new StringWriter()
def xml = new groovy.xml.MarkupBuilder(writer) 
def propertyUrl = testRunner.testCase.getPropertyValue("url")

xml.records() { 
    car(name: 'HSV Maloo', make: 'Holden', year: 2006) {
        country('Australia')
        record(type: 'speed', propertyUrl)
    }
    car(name: 'Royale', make: 'Bugatti', year: 1931) {
        country('France')
        record(type: 'price', 'Most Valuable Car at $15 million')
    }
}

def records = new XmlSlurper().parseText(writer.toString()) 

xmlString = writer.toString()
log.info(xmlString)

xmlBase64 = xmlString.bytes.encodeBase64()
log.info(xmlBase64);

A couple things stumped me initially

  • The specific incantation to get the property from the test
  • using 'groovy.xml.MarkupBuilder' instead of just 'MarkupBuilder'

After that, it was a piece of cake :)

Upvotes: 3

Related Questions