通过使用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
最满意答案
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 firstversion: 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 thenov
(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). Innov
, 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.)
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
如何用bash从文本文件中删除前两行和最后四行?(How to delete first two lines and last four lines from a text file with bash?)[2022-03-26]
你可以结合尾巴和头部 : $ tail -n +3 file.txt | head -n -4 > file.txt.new && mv file.txt.new file.txt You can combine tail and head: $ tail -n +3 file.txt | head -n -4 > file.txt.new && mv file.txt.new file.txt -
最新修订基于BinaryZebra的评论意见,并在这里进行测试 。 command eval允许表达式保留在当前执行环境中,而前面的表达式仅在eval的持续时间内保持。 使用没有空格\标签的$ IFS,只是换行符/ CR $ IFS=$'\r\n' GLOBIGNORE='*' command eval 'XYZ=($(cat /etc/passwd))' $ echo "${XYZ[5]}" sync:x:5:0:sync:/sbin:/bin/sync 另请注意,您可能正在设置数组,但读取错误 - ...
-
你需要尾巴 $ tail great-big-file.log < Last 10 lines of great-big-file.log > 如果您真的需要跳过特定数量的行,请使用 $ tail -n +
< filename, excluding first N lines. > 也就是说,如果要跳过N行,则开始打印第N + 1行。 例: $ tail -n +11 /tmp/myfile < /tmp/myfile, starting at line 11, or ... -
sed -i '3,10d;13,20d;23,30d;33,40d' file sed -i '3,10d;13,20d;23,30d;33,40d' file
-
您可以使用paste命令将文件的行追加到一起... paste -d " " macs channels SSIds 这是一个完整的例子...... echo "123" > 1 echo "abc" > 2 echo "@#$" > 3 paste -d " " 1 2 3 123 abc @#$ echo "456" >> 1 paste -d " " 1 2 3 123 abc @#$ 456 所以你可以看到,如果行数不匹配,你会得到一些稍微偏斜的输出,所以你会想要确保行是1:1。 You c ...
-
从Bash文件中删除重复出现的行的最佳方法是什么?(What is the best way of removing reoccurring lines from a file in Bash?)[2022-05-27]
用GNU sed sed -ni '0,/version: 1/{p; d}; /version: 1/!p' ldap.txt 编辑:这是最初错误的。 当第一行不是版本时,它会打印重复项。 GNU版本更简单。 它从头开始打印( p )直到匹配版本正则表达式的第一行,包括两者在内。 此外,对于该范围内的每一行,打印后我们删除图案空间并开始一个新的循环( d )。 基本上,这意味着去脚本的开始和下一行(这避免了双重打印)。 不像(标准) 1,/regex/ ,如果第一行匹配,它将不会继续到另一个匹配行。 如 ... -
一个适用于FreeBSD sed (OS X)以及GNU sed (Linux)的解决方案 - 该方法的基础是基于@ anishsane的答案 : 注意: 假设可以不在输入文件中保留原始的首选顺序,以简化解决方案。 因此,该解决方案有效地首先从输入文件中移除现有的感兴趣的偏好(如果有的话),然后将它们与期望的(新的)值附加到末尾 。 sed -En '/user_pref\("network\.proxy\.(socks|socks_port|type)"/!p $ a\ user_pref ...
-
只需在它前面放一个tail -n 30 : tail -n 30 logfile | while read -r date time ... do ... ... done Just put a tail -n 30 in front of it: tail -n 30 logfile | while read -r date time ... do ... ... done
-
你的脚本在zsh中完美运行。 试试这个 sed -e 's/^#//' -e '/^[ \t]*$/d' your script work perfectly in zsh. try this sed -e 's/^#//' -e '/^[ \t]*$/d'