首页 \ 问答 \ 通过使用groovy脚本,不会在SOAP UI中更新本地属性值(By using groovy scripts local property value is not updated in SOAP UI)

通过使用groovy脚本,不会在SOAP UI中更新本地属性值(By using groovy scripts local property value is not updated in SOAP UI)

我在下面写了groovy脚本来更新Properties选项卡中的本地测试用例属性值:

String testString = "TestString"
testRunner.testCase.setPropertyValue( "Pro_Response", testString )
def getLocalPropValue = testRunner.testCase.getPropertyValue("Pro_Response")
log.info(getLocalPropValue)

所以在运行这个groovy脚本之后我的预期输出是Pro_Response属性应该用testString值更新。 但这不会发生。

注意:groovy log.info(getLocalPropValue)在脚本输出中给出了testString值没有问题。

任何人都可以提出建议


I have written below groovy script to update the local test case property values in Properties tab:

String testString = "TestString"
testRunner.testCase.setPropertyValue( "Pro_Response", testString )
def getLocalPropValue = testRunner.testCase.getPropertyValue("Pro_Response")
log.info(getLocalPropValue)

So after running this groovy script my expected out put is Pro_Response property should be updated with testString value. But this is not happening.

Note: There is no issues wit the groovy log.info(getLocalPropValue) is giving me the testString value in script output.

Can anyone plse suggest


原文:https://stackoverflow.com/questions/32153613
更新时间:2023-07-01 13:07

最满意答案

GNU sed

sed -ni '0,/version: 1/{p; d}; /version: 1/!p' ldap.txt

编辑:这是最初错误的。 当第一行不是版本时,它会打印重复项。

GNU版本更简单。 它从头开始打印( p )直到匹配版本正则表达式的第一行,包括两者在内。 此外,对于该范围内的每一行,打印后我们删除图案空间并开始一个新的循环( d )。 基本上,这意味着去脚本的开始和下一行(这避免了双重打印)。 不像(标准) 1,/regex/ ,如果第一行匹配,它将不会继续到另一个匹配行。

如果我们还没有完成(所以我们在第一个version: 1 ),那么我们只需打印每一行与正则表达式( ! )不匹配的行。

用标准sed):

sed -ni 'p; /version: 1/ b nov; d; :nov /version: 1/!p; n; b nov' ldap.txt

这首先打印每一行( p )。 在打印之后,如果我们匹配正则表达式,我们转到nov (无版本)标签; 标签名称取决于我们。 如果我们不分支,我们( d )删除模式空间并开始一个新的循环(换行符,脚本的开始)。 如果它不匹配,我们会打印这行(与GNU相同)。 然后我们去一个新的路线,然后回到nov。 这个循环一直持续到结束。


我(Jonathan Leffler)可以证实@ kuti对Solaris 10标准“sed”的观察结果; 什么工作是:

/bin/sed -n 'p
/version: 1/ b nov
d
:nov
/version: 1/!p
n
b nov' ldap.txt

'代替换行符的分号'似乎不能与Solaris'sed'通用。 具体而言,至少在使用标签后不能有分号。

这似乎工作:

/bin/sed -n 'p; /version: 1/ b nov
d; :nov
/version: 1/!p; n; b nov' ldap.txt

我无法考虑如何在评论中展示修复 - 多行格式在这里非常重要。


With GNU sed

sed -ni '0,/version: 1/{p; d}; /version: 1/!p' ldap.txt

EDIT: This was initially wrong. When the first line wasn't version, it printed duplicates.

The GNU version is simpler. It prints (p) from the beginning until the first line matching the version regex, both inclusive. Also, for each line in that range, after printing we delete the pattern space and start a new cycle (d). Basically, this means go to the beginning of the script and to the next line (this avoids double printing). Unlike (standard) 1,/regex/, if the first line matches, it will not continue to another matching line.

If we haven't d'ed (so we're after the first version: 1), we then simply print every line that doesn't match the regex (!).

With standard sed):

sed -ni 'p; /version: 1/ b nov; d; :nov /version: 1/!p; n; b nov' ldap.txt

This begins by simply printing every line (p). After that print, if we match the regex, we branch to the nov (no version) label; the label name is up to us. If we do not branch, we (d) delete the pattern space and start a new cycle (newline, beginning of script). In nov, we print the line if it does not match (same as GNU). We then go to a new line, and branch back to nov. This loop continues until the end.


I (Jonathan Leffler) can confirm @kuti's observations on Solaris 10 standard 'sed'; what works is:

/bin/sed -n 'p
/version: 1/ b nov
d
:nov
/version: 1/!p
n
b nov' ldap.txt

The 'semi-colons in lieu of newlines' trick does not seem to work universally with Solaris 'sed'. Specifically, at the least, there cannot be a semi-colon after any use of a label.

This seems to work:

/bin/sed -n 'p; /version: 1/ b nov
d; :nov
/version: 1/!p; n; b nov' ldap.txt

(I can't think how to present the fix in a comment - the multiline formatting is crucial here.)

相关问答

更多

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。