Groovy and SoapUI
发布时间:2020-12-14 16:52:13 所属栏目:大数据 来源:网络整理
导读:Groovy Groovy JDK,Process Management,Regular Expressions, Getting Started Guide Date String VS Array #!/usr/bin/groovystr = "str1,str2,S333,S566,S88A88G"def strArray = str.split('[ t]*,[ t]*')println strArrayprintln strArray.join("-") Ma
Groovy
Groovy JDK,Process Management,Regular Expressions, Getting Started Guide Date String VS Array #!/usr/bin/groovy str = "str1,str2,S333,S566,S88A88G" def strArray = str.split('[ t]*,[ t]*') println strArray println strArray.join("-") Map def items = [:] items["key1"] = "4.00" items["key2"] = "4.02" println items items = items.minus(["key2":"4.02"]) // after v1.8.7 items = items.dropWhile {it.key == "key2"} println items Find last modified file(a unix/linux way,it is not compatible with windows) import java.util.regex.Pattern def lsDateFormat = "%Y-%m-%d_%H:%M:%S" // for ls command def dateFormat = "yyyy-MM-dd_HH:mm:ss" // for Date def lscmd = """ls -lt --time-style=""" + ""+${lsDateFormat}" " lscmd += """/home/Prime/cycles/ | grep .*.csv$ -m 1 | cut -d ' ' -f 6-7""" def f = File.createTempFile('bash','.sh') f.write("#!/bin/bashn") f.append(lscmd) f.append("n") def fpath = f.getAbsolutePath() "chmod +x ${fpath}".execute() def cmd = fpath log.info(cmd) def proc1 = cmd.execute() proc1.waitFor() if ( 0 != proc1.exitValue() ) { throw new Exception("Execute ${cmd} failed.") } def str = proc1.in.text f.delete() def pattern = Pattern.compile('([^ ]{1,}) (.*)') def matcher = pattern.matcher(str) def dStr = (new Date()).format(dateFormat) if (matcher.find()) { //count = Integer.valueOf(matcher.group(1)); dStr = matcher.group(1) fileName = matcher.group(2) def d = Date.parse(dateFormat,dStr) log.info(dStr) log.info("Last modified file: ${fileName}. Modified date: ${d}" ) } else { log.error("Non file found.") } Java Java API String SoapUI SoapUI API TestCase,TestRunner (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |