Property Expansion Dynamic Expression issue with brace character.
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Property Expansion Dynamic Expression issue with brace character.
Here is my Property Dynamic Expression:
${= use (groovy.time.TimeCategory) {2.years.from.now.format('yyyy-MM-dd')}}
Upon evaluation, this trows this error:
startup failed:
Script47.groovy: 1: expecting '}', found '' @ line 1, column 71.
.from.now.format('yyyy-MM-dd')
^
org.codehaus.groovy.syntax.SyntaxException: expecting '}', found '' @ line 1, column 71.
at org.codehaus.groovy.antlr.AntlrParserPlugin.transformCSTIntoAST(AntlrParserPlugin.java:143)
Well. I understand that I cannot use braces but then how can I achieve my goal ?
Isn't there a way to escape the braces ?
Thank you.
Pierre
Solved! Go to Solution.
- Labels:
-
Scripting
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for replying.
What other detail do you need on top of the ${} bloc used for the property definition, provided in my initial question ?
I'm specifically asking how to escape brace or any work-around to achieve the same as per my groovy oneliner:
Well. I understand that I cannot use braces but then how can I achieve my goal ?
Isn't there a way to escape the braces ?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Regards,
Rao.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you nmrao!
Hi @zorglups, I hope nmrao cleared things up for you. I also recommend checking out this help topic if you need more information on property expansions.
Sonya Mihaljova
Community and Education Specialist
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello sonya_m,
Thank you for looking into this case.
nmrao has been kind enough to look at my post but I'm afraid he did not address the question raised in the first place.
I know that the braces are the problem. This the the aim of my question: how to quote them ?
If the cannot be quoted, how can I do in property expansion something without braces that would do this:
${= use (groovy.time.TimeCategory) {2.years.from.now.format('yyyy-MM-dd')}}
I went through the documentations and the forum already but this did not raise a solution.
ReadyAPI accepts groovy code as written in the documentation you refer to: ${=Groovy code}
Isn't braces valid Groovy code ?
Thanks,
Pierre
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @zorglups,
The following script works fine for me:
use(groovy.time.TimeCategory){"${2.years.from.now.format('yyyy-MM-dd')}"}
But it seems there is no way to use it in property expansions directly because of its complexity. Instead, you can try to place the script inside some Groovy test step, and then extract its result by using this property expansion:
${Groovy Script#result}
How does it work for you?
Julia
Customer Care Team
Did my reply answer your question? Please give Kudos or Accept it as a Solution to help others.
