[Groovy] Gets the current active environment, gets the name of the node in response and the value of the node

Source: Internet
Author: User
Tags soapui

123456789Ten One A - - the - - - + - + A at - - - - - in - to + - the * $Panax Notoginseng - the + A the + - $ $ - - the -Wuyi the - Wu - About import com.eviware.soapui.support.GroovyUtilsimport com.eviware.soapui.support.XmlHolderimport org.w3c.dom.Nodeimport org.apache.commons.lang.StringUtilsimport java.util.HashSet def groovyUtils = new GroovyUtils(context)def xmlHolder = groovyUtils.getXmlHolder(messageExchange.getResponseContent())def activeEnv = context.expand( ‘${#Project#activeEnv}‘ )log.info "The active environment is $activeEnv" String[] fixClientIdArrayif(activeEnv=="LIVE"){ fixClientIdArray = new String[2] fixClientIdArray[0] =       "6e2ba3e9-68a4-4c8f-a164-f026e7239cf7" fixClientIdArray[1] =      "dfba4888-348a-4fb1-91f7-8a03fb6aa775"} if(activeEnv=="QA"){ fixClientIdArray = new String[3] fixClientIdArray[0] =      "6fe9b969-3711-4083-a8c4-186e75e6e9e7" fixClientIdArray[1] =      "43ec112f-cd57-4d84-a5e8-1d62e1f71244" fixClientIdArray[2] =      "8c8e3e6a-0cb1-41d0-a07b-ca3fff506cee"} def fixSet = new HashSet() for(String clientId : fixClientIdArray){    fixSet.add(clientId)} String xPath = "//clients/client"Node[] nodeArray = xmlHolder.getDomNodes(xPath)int actualCount = nodeArray.lengthint expectedCount = context.expand(‘${#Project#ClientCount}‘).toInteger() assert fixSet.size() == expectedCount log.info "Actual : nodeArray.length of  "+xPath+" : "+actualCountlog.info "Expected : nodeArray.length  is : "+expectedCountassert actualCount==expectedCount String clientIdPath = xPath + "/@id" String[] valueArray = xmlHolder.getNodeValues(clientIdPath)log.info "valueArray.length of "+clientIdPath+":"+valueArray.lengthassert valueArray != null && valueArray.length>0for(String value : valueArray){    log.info "value:"+value    assert StringUtils.isNotBlank(value)    assert fixSet.contains(value)     fixSet.remove(value)} assert fixSet.size() == 0

[Groovy] Gets the current active environment, gets the name of the node in response and the value of the node

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.