You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@groovy.apache.org by Jmeter Tea <jm...@gmail.com> on 2018/09/25 07:56:12 UTC

Long String concatenation failed

Hello,

I have to
concatenate a lot of variables in a script and I want to make it
readable, but I failed to separate lines as in java, The following
code doesn't compile due to:

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException:
startup failed:
Script1.groovy: 2: unexpected token: << @ line 2, column 1.
   << vars["id2"] << "<id2>"

Code:
String text ="<id>" <<vars["id1"] << "<id><id2>" << vars["id2"] << "<id2>";


Is there a workaround or a better way concatenation a string in groovy?

Related question:
https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables

Thank you

Re: Long String concatenation failed

Posted by Batuhan Bayrakçı <ba...@gmail.com>.
Hello,

You can use GString that let you put variables into double quotes more easy.

example:

String text = "<id>${vars["id"]}</id>"



2018-09-25 10:56 GMT+03:00 Jmeter Tea <jm...@gmail.com>:

> Hello,
>
> I have to
> concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
>
> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>    << vars["id2"] << "<id2>"
>
> Code:
> String text ="<id>" <<vars["id1"] << "<id><id2>" << vars["id2"] << "<id2>";
>
>
> Is there a workaround or a better way concatenation a string in groovy?
>
> Related question:
> https://stackoverflow.com/questions/47786399/jmeter-
> groovy-script-concatenation-of-variables
>
> Thank you
>



-- 
http://batuhanbayrakci.com

Re: Long String concatenation failed

Posted by Jmeter Tea <jm...@gmail.com>.
Hi Nelson, You mean to use append method as in  StringBuilder:
new StringBuilder().append( foo )
                       .append( bar )
                       .append( www )
                       .toString()

On Tue, Sep 25, 2018 at 2:19 PM, Nelson, Erick <Er...@hdsupply.com>
wrote:

> Looks like a job for MarkupBuilder or StreamingMarkupBuilder
>
> Sent from my iPhone
>
> On Sep 25, 2018, at 3:56 AM, Jmeter Tea <jm...@gmail.com> wrote:
>
> Hello,
>
> I have to
> concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
>
> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>    << vars["id2"] << "<id2>"
>
> Code:
> String text ="<id>" <<vars["id1"] << "<id><id2>" << vars["id2"] << "<id2>";
>
>
> Is there a workaround or a better way concatenation a string in groovy?
>
> Related question:
> https://stackoverflow.com/questions/47786399/jmeter-
> groovy-script-concatenation-of-variables
>
> Thank you
>
>

Re: Long String concatenation failed

Posted by "Nelson, Erick" <Er...@hdsupply.com>.
Looks like a job for MarkupBuilder or StreamingMarkupBuilder

Sent from my iPhone

On Sep 25, 2018, at 3:56 AM, Jmeter Tea <jm...@gmail.com>> wrote:


Hello,

I have to

concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
Script1.groovy: 2: unexpected token: << @ line 2, column 1.
   << vars["id2"] << "<id2>"

Code:
String text ="<id>" <<vars["id1"] << "<id><id2>"
<< vars["id2"] << "<id2>";

Is there a workaround or a better way concatenation a string in groovy?

Related question:
https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables

Thank you

Re: Long String concatenation failed

Posted by Jmeter Tea <jm...@gmail.com>.
Thanks for both answers, but it's not what I need exactly
Regarding Susanne Jaeckel: I want concatenate with *specific*(not all)
values and with different order and prefix for each, e.g. "My Name is"  <<
vars["first"] >> " " << vars["last"] << "and ..."


Regarding Batuhan Bayrakçı : I'm using inside JMeter and I'm not supposed
to use "${}" it in JMeter script as ${vars["id"]}
for more see info
http://jmeter.apache.org/usermanual/best-practices.html#jsr223

On Tue, Sep 25, 2018 at 11:23 AM, Susanne Jaeckel <su...@gmx.de> wrote:

> Hi!
>
> If I have a hashmap and have to concatenate them the way you show, I would
> try:
>
>
> def vars = ["id": "value", "id2": "value2", "id3": "value3"]
>
> String text = ""
> vars.each { k, v ->
>         text += "<${k}>${v}</${k}>"
> }
>
> println text
>
> Regards,
> Susanne.
>
>
> Am 25.09.2018 um 09:56 schrieb Jmeter Tea:
>
>> Hello,
>> I have to concatenate a lot of variables in a script and I want to make
>> it readable, but I failed to separate lines as in java, The following code
>> doesn't compile due to:
>> |
>> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException:
>> startup failed:
>> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>>    << vars["id2"] << "<id2>"
>> Code: Stringtext ="<id>"<<vars["id1"]<<"<id><id
>> 2>"<<vars["id2"]<<"<id2>";|
>>
>> Is there a workaround or a better way concatenation a string in groovy?
>>
>> Related question:
>> https://stackoverflow.com/questions/47786399/jmeter-groovy-
>> script-concatenation-of-variables
>>
>> Thank you
>>
>
>

Re: Long String concatenation failed

Posted by Susanne Jaeckel <su...@gmx.de>.
Hi!

If I have a hashmap and have to concatenate them the way you show, I 
would try:


def vars = ["id": "value", "id2": "value2", "id3": "value3"]

String text = ""
vars.each { k, v ->
         text += "<${k}>${v}</${k}>"
}

println text

Regards,
Susanne.


Am 25.09.2018 um 09:56 schrieb Jmeter Tea:
> Hello,
> I have to concatenate a lot of variables in a script and I want to 
> make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
> |
> Caused by: 
> org.codehaus.groovy.control.MultipleCompilationErrorsException: 
> startup failed:
> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>    << vars["id2"] << "<id2>"
> Code: Stringtext ="<id>"<<vars["id1"]<<"<id><id2>"<<vars["id2"]<<"<id2>";|
>
> Is there a workaround or a better way concatenation a string in groovy?
>
> Related question:
> https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables
>
> Thank you


Re: Long String concatenation failed

Posted by Paul King <pa...@asert.com.au>.
Yes, done.

On Wed, Sep 26, 2018 at 2:54 PM Jmeter Tea <jm...@gmail.com> wrote:

> Paul King: Thank you, I can live with a workaround of adding a line
> continuation slash at the end of the line
> Can you answer the original question in stackoverflow
> <https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables>
> ?
>
> On Tue, Sep 25, 2018 at 10:27 PM, Paul King <pa...@asert.com.au> wrote:
>
>>
>> Groovy uses the end of line as the statement terminator unless it can
>> safely tell that the next line should follow on. We didn't allow plus or
>> minus on the next line
>> when working out the list of things to safely accept since it would have
>> been a breaking change for anyone using the unaryPlus or unaryMinus
>> operators..
>> I suspect very few people use that operator as an overloadable operator
>> but some folks might use it in their DSLs for instance.
>>
>> We could create a GEP for Groovy 3.0 to change the behavior. We'd need to
>> outline how to allow the unary operator style.
>>
>> Why not use the line continuation slash at the end of the line:
>>
>> String text= "0"+"1" +
>> "2" \
>> +"3"
>>
>> Cheers, Paul.
>>
>>
>> On Tue, Sep 25, 2018 at 11:47 PM Jmeter Tea <jm...@gmail.com> wrote:
>>
>>> *mg: *Yes, I saw that it's working, but still,
>>>
>>> groovy should add sugar to java instead of removing support of working
>>> code in java as:
>>> String text= "0"+"1" +
>>> "2"
>>> +"3";
>>>
>>> Which I'm getting error:
>>> javax.script.ScriptException: groovy.lang.MissingMethodException: No
>>> signature of method: java.lang.String.positive() is applicable for argument
>>> types: () values: []
>>> Possible solutions: notify(), tokenize(), size(), size()
>>>
>>> Can I open a bug in groovy for this?
>>>
>>> On Tue, Sep 25, 2018 at 4:04 PM, mg <mg...@arscreat.com> wrote:
>>>
>>>> You can have new lines, just move the "<<" oi the end of the previous
>>>> line, so Groovy knows there is more coming (Groovy does not need
>>>> end-of-line semicolons btw):
>>>>
>>>> String text ="<id>" <<vars["id1"] << "<id><id2>" <<
>>>>
>>>> vars["id2"] << "<id2>"
>>>>
>>>>
>>>> -------- Ursprüngliche Nachricht --------
>>>> Von: Jmeter Tea <jm...@gmail.com>
>>>> Datum: 25.09.18 14:54 (GMT+01:00)
>>>> An: users@groovy.apache.org
>>>> Betreff: Re: Long String concatenation failed
>>>>
>>>> Thank for your answers, I still have some comments:
>>>> *mg: *I don't want to have a huge line with 20 parameters that can't
>>>> be seen on screen so I need new lines between parameters
>>>> Nelson, Erick: I don't need XML as the article suggest " builder
>>>> classes to create XML "
>>>>
>>>> On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <
>>>> Erick.Nelson@hdsupply.com> wrote:
>>>>
>>>>> No, I mean markup builder.
>>>>>
>>>>> Mr Haki says it best….
>>>>>
>>>>>
>>>>> http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Erick Nelson
>>>>>
>>>>> Senior Developer – IT
>>>>>
>>>>> HD Supply Facilities Maintenance
>>>>>
>>>>> (858) 740-6523
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> *From: *mg <mg...@arscreat.com>
>>>>> *Reply-To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>>>>> *Date: *Tuesday, September 25, 2018 at 5:19 AM
>>>>> *To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>>>>> *Subject: *Re: Long String concatenation failed
>>>>>
>>>>>
>>>>>
>>>>> If it is just the CTE that is the problem, you just have ro move the
>>>>> "<<" to the end of the previous line...
>>>>>
>>>>>
>>>>>
>>>>> -------- Ursprüngliche Nachricht --------
>>>>>
>>>>> Von: Jmeter Tea <jm...@gmail.com>
>>>>>
>>>>> Datum: 25.09.18 09:56 (GMT+01:00)
>>>>>
>>>>> An: users@groovy.apache.org
>>>>>
>>>>> Betreff: Long String concatenation failed
>>>>>
>>>>>
>>>>>
>>>>> Hello,
>>>>>
>>>>> I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
>>>>>
>>>>> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
>>>>>
>>>>> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>>>>>
>>>>>    << vars["id2"] << "<id2>"
>>>>>
>>>>>
>>>>>
>>>>> Code:
>>>>>
>>>>> String text ="<id>" <<vars["id1"] << "<id><id2>"
>>>>>
>>>>> << vars["id2"] << "<id2>";
>>>>>
>>>>>
>>>>>
>>>>> Is there a workaround or a better way concatenation a string in groovy?
>>>>>
>>>>>
>>>>>
>>>>> Related question:
>>>>>
>>>>>
>>>>> https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables
>>>>>
>>>>>
>>>>>
>>>>> Thank you
>>>>>
>>>>
>>>>
>>>
>

Re: Long String concatenation failed

Posted by Jmeter Tea <jm...@gmail.com>.
 Paul King: Thank you, I can live with a workaround of adding a line
continuation slash at the end of the line
Can you answer the original question in stackoverflow
<https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables>
?

On Tue, Sep 25, 2018 at 10:27 PM, Paul King <pa...@asert.com.au> wrote:

>
> Groovy uses the end of line as the statement terminator unless it can
> safely tell that the next line should follow on. We didn't allow plus or
> minus on the next line
> when working out the list of things to safely accept since it would have
> been a breaking change for anyone using the unaryPlus or unaryMinus
> operators..
> I suspect very few people use that operator as an overloadable operator
> but some folks might use it in their DSLs for instance.
>
> We could create a GEP for Groovy 3.0 to change the behavior. We'd need to
> outline how to allow the unary operator style.
>
> Why not use the line continuation slash at the end of the line:
>
> String text= "0"+"1" +
> "2" \
> +"3"
>
> Cheers, Paul.
>
>
> On Tue, Sep 25, 2018 at 11:47 PM Jmeter Tea <jm...@gmail.com> wrote:
>
>> *mg: *Yes, I saw that it's working, but still,
>>
>> groovy should add sugar to java instead of removing support of working
>> code in java as:
>> String text= "0"+"1" +
>> "2"
>> +"3";
>>
>> Which I'm getting error:
>> javax.script.ScriptException: groovy.lang.MissingMethodException: No
>> signature of method: java.lang.String.positive() is applicable for argument
>> types: () values: []
>> Possible solutions: notify(), tokenize(), size(), size()
>>
>> Can I open a bug in groovy for this?
>>
>> On Tue, Sep 25, 2018 at 4:04 PM, mg <mg...@arscreat.com> wrote:
>>
>>> You can have new lines, just move the "<<" oi the end of the previous
>>> line, so Groovy knows there is more coming (Groovy does not need
>>> end-of-line semicolons btw):
>>>
>>> String text ="<id>" <<vars["id1"] << "<id><id2>" <<
>>>
>>> vars["id2"] << "<id2>"
>>>
>>>
>>> -------- Ursprüngliche Nachricht --------
>>> Von: Jmeter Tea <jm...@gmail.com>
>>> Datum: 25.09.18 14:54 (GMT+01:00)
>>> An: users@groovy.apache.org
>>> Betreff: Re: Long String concatenation failed
>>>
>>> Thank for your answers, I still have some comments:
>>> *mg: *I don't want to have a huge line with 20 parameters that can't be
>>> seen on screen so I need new lines between parameters
>>> Nelson, Erick: I don't need XML as the article suggest " builder
>>> classes to create XML "
>>>
>>> On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <
>>> Erick.Nelson@hdsupply.com> wrote:
>>>
>>>> No, I mean markup builder.
>>>>
>>>> Mr Haki says it best….
>>>>
>>>> http://mrhaki.blogspot.com/2009/10/groovy-goodness-
>>>> creating-xml-with.html
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> Erick Nelson
>>>>
>>>> Senior Developer – IT
>>>>
>>>> HD Supply Facilities Maintenance
>>>>
>>>> (858) 740-6523
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> *From: *mg <mg...@arscreat.com>
>>>> *Reply-To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>>>> *Date: *Tuesday, September 25, 2018 at 5:19 AM
>>>> *To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>>>> *Subject: *Re: Long String concatenation failed
>>>>
>>>>
>>>>
>>>> If it is just the CTE that is the problem, you just have ro move the
>>>> "<<" to the end of the previous line...
>>>>
>>>>
>>>>
>>>> -------- Ursprüngliche Nachricht --------
>>>>
>>>> Von: Jmeter Tea <jm...@gmail.com>
>>>>
>>>> Datum: 25.09.18 09:56 (GMT+01:00)
>>>>
>>>> An: users@groovy.apache.org
>>>>
>>>> Betreff: Long String concatenation failed
>>>>
>>>>
>>>>
>>>> Hello,
>>>>
>>>> I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
>>>>
>>>> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
>>>>
>>>> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>>>>
>>>>    << vars["id2"] << "<id2>"
>>>>
>>>>
>>>>
>>>> Code:
>>>>
>>>> String text ="<id>" <<vars["id1"] << "<id><id2>"
>>>>
>>>> << vars["id2"] << "<id2>";
>>>>
>>>>
>>>>
>>>> Is there a workaround or a better way concatenation a string in groovy?
>>>>
>>>>
>>>>
>>>> Related question:
>>>>
>>>> https://stackoverflow.com/questions/47786399/jmeter-
>>>> groovy-script-concatenation-of-variables
>>>>
>>>>
>>>>
>>>> Thank you
>>>>
>>>
>>>
>>

Re: Long String concatenation failed

Posted by Paul King <pa...@asert.com.au>.
Groovy uses the end of line as the statement terminator unless it can
safely tell that the next line should follow on. We didn't allow plus or
minus on the next line
when working out the list of things to safely accept since it would have
been a breaking change for anyone using the unaryPlus or unaryMinus
operators..
I suspect very few people use that operator as an overloadable operator but
some folks might use it in their DSLs for instance.

We could create a GEP for Groovy 3.0 to change the behavior. We'd need to
outline how to allow the unary operator style.

Why not use the line continuation slash at the end of the line:

String text= "0"+"1" +
"2" \
+"3"

Cheers, Paul.


On Tue, Sep 25, 2018 at 11:47 PM Jmeter Tea <jm...@gmail.com> wrote:

> *mg: *Yes, I saw that it's working, but still,
>
> groovy should add sugar to java instead of removing support of working
> code in java as:
> String text= "0"+"1" +
> "2"
> +"3";
>
> Which I'm getting error:
> javax.script.ScriptException: groovy.lang.MissingMethodException: No
> signature of method: java.lang.String.positive() is applicable for argument
> types: () values: []
> Possible solutions: notify(), tokenize(), size(), size()
>
> Can I open a bug in groovy for this?
>
> On Tue, Sep 25, 2018 at 4:04 PM, mg <mg...@arscreat.com> wrote:
>
>> You can have new lines, just move the "<<" oi the end of the previous
>> line, so Groovy knows there is more coming (Groovy does not need
>> end-of-line semicolons btw):
>>
>> String text ="<id>" <<vars["id1"] << "<id><id2>" <<
>>
>> vars["id2"] << "<id2>"
>>
>>
>> -------- Ursprüngliche Nachricht --------
>> Von: Jmeter Tea <jm...@gmail.com>
>> Datum: 25.09.18 14:54 (GMT+01:00)
>> An: users@groovy.apache.org
>> Betreff: Re: Long String concatenation failed
>>
>> Thank for your answers, I still have some comments:
>> *mg: *I don't want to have a huge line with 20 parameters that can't be
>> seen on screen so I need new lines between parameters
>> Nelson, Erick: I don't need XML as the article suggest " builder classes
>> to create XML "
>>
>> On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <Erick.Nelson@hdsupply.com
>> > wrote:
>>
>>> No, I mean markup builder.
>>>
>>> Mr Haki says it best….
>>>
>>> http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
>>>
>>>
>>>
>>>
>>>
>>> Erick Nelson
>>>
>>> Senior Developer – IT
>>>
>>> HD Supply Facilities Maintenance
>>>
>>> (858) 740-6523
>>>
>>>
>>>
>>>
>>>
>>> *From: *mg <mg...@arscreat.com>
>>> *Reply-To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>>> *Date: *Tuesday, September 25, 2018 at 5:19 AM
>>> *To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>>> *Subject: *Re: Long String concatenation failed
>>>
>>>
>>>
>>> If it is just the CTE that is the problem, you just have ro move the
>>> "<<" to the end of the previous line...
>>>
>>>
>>>
>>> -------- Ursprüngliche Nachricht --------
>>>
>>> Von: Jmeter Tea <jm...@gmail.com>
>>>
>>> Datum: 25.09.18 09:56 (GMT+01:00)
>>>
>>> An: users@groovy.apache.org
>>>
>>> Betreff: Long String concatenation failed
>>>
>>>
>>>
>>> Hello,
>>>
>>> I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
>>>
>>> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
>>>
>>> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>>>
>>>    << vars["id2"] << "<id2>"
>>>
>>>
>>>
>>> Code:
>>>
>>> String text ="<id>" <<vars["id1"] << "<id><id2>"
>>>
>>> << vars["id2"] << "<id2>";
>>>
>>>
>>>
>>> Is there a workaround or a better way concatenation a string in groovy?
>>>
>>>
>>>
>>> Related question:
>>>
>>>
>>> https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables
>>>
>>>
>>>
>>> Thank you
>>>
>>
>>
>

Re: Long String concatenation failed

Posted by mg <mg...@arscreat.com>.
I don't know if your specific case might be improved in the future, but in general Groovy supports e.g. operator overloading as well as DSL creation, which in turn means that it cannot always be 100% Java copy & paste compatible, even if it strives to do so as much as possible.
In any case it should not take long to refactor your code...
-------- Ursprüngliche Nachricht --------Von: Jmeter Tea <jm...@gmail.com> Datum: 25.09.18  15:47  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: Long String concatenation failed 
mg: Yes, I saw that it's working, but still,
groovy should add sugar to java instead of removing support of working code in java as:String text= "0"+"1" +"2" +"3";
Which I'm getting error:javax.script.ScriptException: groovy.lang.MissingMethodException: No signature of method: java.lang.String.positive() is applicable for argument types: () values: []Possible solutions: notify(), tokenize(), size(), size()
Can I open a bug in groovy for this?
On Tue, Sep 25, 2018 at 4:04 PM, mg <mg...@arscreat.com> wrote:
You can have new lines, just move the "<<" oi the end of the previous line, so Groovy knows there is more coming (Groovy does not need end-of-line semicolons btw):
String text ="<id>" <<vars["id1"] << "<id><id2>" << vars["id2"] << "<id2>"
-------- Ursprüngliche Nachricht --------Von: Jmeter Tea <jm...@gmail.com> Datum: 25.09.18  14:54  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: Long String concatenation failed 
Thank for your answers, I still have some comments:mg: I don't want to have a huge line with 20 parameters that can't be seen on screen so I need new lines between parameters

Nelson, Erick: I don't need XML as the article suggest "
builder classes to create XML "

On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <Er...@hdsupply.com> wrote:








No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
 
 

Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523

 
 

From: mg <mg...@arscreat.com>

Reply-To: "users@groovy.apache.org" <us...@groovy.apache.org>

Date: Tuesday, September 25, 2018 at 5:19 AM

To: "users@groovy.apache.org" <us...@groovy.apache.org>

Subject: Re: Long String concatenation failed


 

If it is just the CTE that is the problem, you just have ro move the "<<" to the end of the previous line... 


 



-------- Ursprüngliche Nachricht --------


Von: Jmeter Tea <jm...@gmail.com>



Datum: 25.09.18 09:56 (GMT+01:00) 



An: users@groovy.apache.org 


Betreff: Long String concatenation failed



 






Hello,
I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:


Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:


Script1.groovy: 2: unexpected token: << @ line 2, column 1.


   << vars["id2"] << "<id2>"


 
Code:
String text ="<id>" <<vars["id1"] << "<id><id2>" 
<< vars["id2"] << "<id2>";

 


Is there a workaround or a better way concatenation a string in groovy?


 


Related question:


https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables


 


Thank you













Re: Long String concatenation failed

Posted by Jmeter Tea <jm...@gmail.com>.
*mg: *Yes, I saw that it's working, but still,

groovy should add sugar to java instead of removing support of working code
in java as:
String text= "0"+"1" +
"2"
+"3";

Which I'm getting error:
javax.script.ScriptException: groovy.lang.MissingMethodException: No
signature of method: java.lang.String.positive() is applicable for argument
types: () values: []
Possible solutions: notify(), tokenize(), size(), size()

Can I open a bug in groovy for this?

On Tue, Sep 25, 2018 at 4:04 PM, mg <mg...@arscreat.com> wrote:

> You can have new lines, just move the "<<" oi the end of the previous
> line, so Groovy knows there is more coming (Groovy does not need
> end-of-line semicolons btw):
>
> String text ="<id>" <<vars["id1"] << "<id><id2>" <<
>
> vars["id2"] << "<id2>"
>
>
> -------- Ursprüngliche Nachricht --------
> Von: Jmeter Tea <jm...@gmail.com>
> Datum: 25.09.18 14:54 (GMT+01:00)
> An: users@groovy.apache.org
> Betreff: Re: Long String concatenation failed
>
> Thank for your answers, I still have some comments:
> *mg: *I don't want to have a huge line with 20 parameters that can't be
> seen on screen so I need new lines between parameters
> Nelson, Erick: I don't need XML as the article suggest " builder classes
> to create XML "
>
> On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <Er...@hdsupply.com>
> wrote:
>
>> No, I mean markup builder.
>>
>> Mr Haki says it best….
>>
>> http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
>>
>>
>>
>>
>>
>> Erick Nelson
>>
>> Senior Developer – IT
>>
>> HD Supply Facilities Maintenance
>>
>> (858) 740-6523
>>
>>
>>
>>
>>
>> *From: *mg <mg...@arscreat.com>
>> *Reply-To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>> *Date: *Tuesday, September 25, 2018 at 5:19 AM
>> *To: *"users@groovy.apache.org" <us...@groovy.apache.org>
>> *Subject: *Re: Long String concatenation failed
>>
>>
>>
>> If it is just the CTE that is the problem, you just have ro move the "<<"
>> to the end of the previous line...
>>
>>
>>
>> -------- Ursprüngliche Nachricht --------
>>
>> Von: Jmeter Tea <jm...@gmail.com>
>>
>> Datum: 25.09.18 09:56 (GMT+01:00)
>>
>> An: users@groovy.apache.org
>>
>> Betreff: Long String concatenation failed
>>
>>
>>
>> Hello,
>>
>> I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
>>
>> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
>>
>> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>>
>>    << vars["id2"] << "<id2>"
>>
>>
>>
>> Code:
>>
>> String text ="<id>" <<vars["id1"] << "<id><id2>"
>>
>> << vars["id2"] << "<id2>";
>>
>>
>>
>> Is there a workaround or a better way concatenation a string in groovy?
>>
>>
>>
>> Related question:
>>
>> https://stackoverflow.com/questions/47786399/jmeter-groovy-
>> script-concatenation-of-variables
>>
>>
>>
>> Thank you
>>
>
>

Re: Long String concatenation failed

Posted by "Nelson, Erick" <Er...@hdsupply.com>.
Your example looked like you were building xml to me

Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523


From: Jmeter Tea <jm...@gmail.com>
Reply-To: "users@groovy.apache.org" <us...@groovy.apache.org>
Date: Tuesday, September 25, 2018 at 5:55 AM
To: "users@groovy.apache.org" <us...@groovy.apache.org>
Subject: Re: Long String concatenation failed

Thank for your answers, I still have some comments:
mg: I don't want to have a huge line with 20 parameters that can't be seen on screen so I need new lines between parameters
Nelson, Erick: I don't need XML as the article suggest " builder classes to create XML "

On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <Er...@hdsupply.com>> wrote:
No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html


Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523


From: mg <mg...@arscreat.com>>
Reply-To: "users@groovy.apache.org<ma...@groovy.apache.org>" <us...@groovy.apache.org>>
Date: Tuesday, September 25, 2018 at 5:19 AM
To: "users@groovy.apache.org<ma...@groovy.apache.org>" <us...@groovy.apache.org>>
Subject: Re: Long String concatenation failed

If it is just the CTE that is the problem, you just have ro move the "<<" to the end of the previous line...

-------- Ursprüngliche Nachricht --------
Von: Jmeter Tea <jm...@gmail.com>>
Datum: 25.09.18 09:56 (GMT+01:00)
An: users@groovy.apache.org<ma...@groovy.apache.org>
Betreff: Long String concatenation failed


Hello,

I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Script1.groovy: 2: unexpected token: << @ line 2, column 1.

   << vars["id2"] << "<id2>"



Code:

String text ="<id>" <<vars["id1"] << "<id><id2>"

<< vars["id2"] << "<id2>";

Is there a workaround or a better way concatenation a string in groovy?

Related question:
https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables

Thank you


Re: Long String concatenation failed

Posted by mg <mg...@arscreat.com>.
You can have new lines, just move the "<<" oi the end of the previous line, so Groovy knows there is more coming (Groovy does not need end-of-line semicolons btw):
String text ="<id>" <<vars["id1"] << "<id><id2>" << vars["id2"] << "<id2>"
-------- Ursprüngliche Nachricht --------Von: Jmeter Tea <jm...@gmail.com> Datum: 25.09.18  14:54  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: Long String concatenation failed 
Thank for your answers, I still have some comments:mg: I don't want to have a huge line with 20 parameters that can't be seen on screen so I need new lines between parameters

Nelson, Erick: I don't need XML as the article suggest "
builder classes to create XML "

On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <Er...@hdsupply.com> wrote:








No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
 
 

Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523

 
 

From: mg <mg...@arscreat.com>

Reply-To: "users@groovy.apache.org" <us...@groovy.apache.org>

Date: Tuesday, September 25, 2018 at 5:19 AM

To: "users@groovy.apache.org" <us...@groovy.apache.org>

Subject: Re: Long String concatenation failed


 

If it is just the CTE that is the problem, you just have ro move the "<<" to the end of the previous line... 


 



-------- Ursprüngliche Nachricht --------


Von: Jmeter Tea <jm...@gmail.com>



Datum: 25.09.18 09:56 (GMT+01:00) 



An: users@groovy.apache.org 


Betreff: Long String concatenation failed



 






Hello,
I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:


Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:


Script1.groovy: 2: unexpected token: << @ line 2, column 1.


   << vars["id2"] << "<id2>"


 
Code:
String text ="<id>" <<vars["id1"] << "<id><id2>" 
<< vars["id2"] << "<id2>";

 


Is there a workaround or a better way concatenation a string in groovy?


 


Related question:


https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables


 


Thank you











Re: Long String concatenation failed

Posted by Jmeter Tea <jm...@gmail.com>.
Thank for your answers, I still have some comments:
*mg: *I don't want to have a huge line with 20 parameters that can't be
seen on screen so I need new lines between parameters
Nelson, Erick: I don't need XML as the article suggest " builder classes to
create XML "

On Tue, Sep 25, 2018 at 3:39 PM, Nelson, Erick <Er...@hdsupply.com>
wrote:

> No, I mean markup builder.
>
> Mr Haki says it best….
>
> http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
>
>
>
>
>
> Erick Nelson
>
> Senior Developer – IT
>
> HD Supply Facilities Maintenance
>
> (858) 740-6523
>
>
>
>
>
> *From: *mg <mg...@arscreat.com>
> *Reply-To: *"users@groovy.apache.org" <us...@groovy.apache.org>
> *Date: *Tuesday, September 25, 2018 at 5:19 AM
> *To: *"users@groovy.apache.org" <us...@groovy.apache.org>
> *Subject: *Re: Long String concatenation failed
>
>
>
> If it is just the CTE that is the problem, you just have ro move the "<<"
> to the end of the previous line...
>
>
>
> -------- Ursprüngliche Nachricht --------
>
> Von: Jmeter Tea <jm...@gmail.com>
>
> Datum: 25.09.18 09:56 (GMT+01:00)
>
> An: users@groovy.apache.org
>
> Betreff: Long String concatenation failed
>
>
>
> Hello,
>
> I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:
>
> Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
>
> Script1.groovy: 2: unexpected token: << @ line 2, column 1.
>
>    << vars["id2"] << "<id2>"
>
>
>
> Code:
>
> String text ="<id>" <<vars["id1"] << "<id><id2>"
>
> << vars["id2"] << "<id2>";
>
>
>
> Is there a workaround or a better way concatenation a string in groovy?
>
>
>
> Related question:
>
> https://stackoverflow.com/questions/47786399/jmeter-
> groovy-script-concatenation-of-variables
>
>
>
> Thank you
>

Re: Long String concatenation failed

Posted by mg <mg...@arscreat.com>.
I replied to the original question and how to fix the the compile time error shown there, not your (valid) suggestion for a completely different approach... :-)
-------- Ursprüngliche Nachricht --------Von: "Nelson, Erick" <Er...@hdsupply.com> Datum: 25.09.18  14:39  (GMT+01:00) An: users@groovy.apache.org Betreff: Re: Long String concatenation failed 


No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html
 
 

Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523

 
 

From: mg <mg...@arscreat.com>

Reply-To: "users@groovy.apache.org" <us...@groovy.apache.org>

Date: Tuesday, September 25, 2018 at 5:19 AM

To: "users@groovy.apache.org" <us...@groovy.apache.org>

Subject: Re: Long String concatenation failed


 

If it is just the CTE that is the problem, you just have ro move the "<<" to the end of the previous line... 


 



-------- Ursprüngliche Nachricht --------


Von: Jmeter Tea <jm...@gmail.com>



Datum: 25.09.18 09:56 (GMT+01:00) 



An: users@groovy.apache.org 


Betreff: Long String concatenation failed



 






Hello,
I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:


Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:


Script1.groovy: 2: unexpected token: << @ line 2, column 1.


   << vars["id2"] << "<id2>"


 
Code:
String text ="<id>" <<vars["id1"] << "<id><id2>" 
<< vars["id2"] << "<id2>";

 


Is there a workaround or a better way concatenation a string in groovy?


 


Related question:


https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables


 


Thank you







Re: Long String concatenation failed

Posted by "Nelson, Erick" <Er...@hdsupply.com>.
No, I mean markup builder.
Mr Haki says it best….
http://mrhaki.blogspot.com/2009/10/groovy-goodness-creating-xml-with.html


Erick Nelson
Senior Developer – IT
HD Supply Facilities Maintenance
(858) 740-6523


From: mg <mg...@arscreat.com>
Reply-To: "users@groovy.apache.org" <us...@groovy.apache.org>
Date: Tuesday, September 25, 2018 at 5:19 AM
To: "users@groovy.apache.org" <us...@groovy.apache.org>
Subject: Re: Long String concatenation failed

If it is just the CTE that is the problem, you just have ro move the "<<" to the end of the previous line...

-------- Ursprüngliche Nachricht --------
Von: Jmeter Tea <jm...@gmail.com>
Datum: 25.09.18 09:56 (GMT+01:00)
An: users@groovy.apache.org
Betreff: Long String concatenation failed


Hello,

I have to  concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:

Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:

Script1.groovy: 2: unexpected token: << @ line 2, column 1.

   << vars["id2"] << "<id2>"



Code:

String text ="<id>" <<vars["id1"] << "<id><id2>"

<< vars["id2"] << "<id2>";

Is there a workaround or a better way concatenation a string in groovy?

Related question:
https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables

Thank you

Re: Long String concatenation failed

Posted by mg <mg...@arscreat.com>.
If it is just the CTE that is the problem, you just have ro move the "<<" to the end of the previous line... 
-------- Ursprüngliche Nachricht --------Von: Jmeter Tea <jm...@gmail.com> Datum: 25.09.18  09:56  (GMT+01:00) An: users@groovy.apache.org Betreff: Long String concatenation failed 


Hello,I have to 

concatenate a lot of variables in a script and I want to make it readable, but I failed to separate lines as in java, The following code doesn't compile due to:Caused by: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:Script1.groovy: 2: unexpected token: << @ line 2, column 1.   << vars["id2"] << "<id2>"
Code:
String text ="<id>" <<vars["id1"] << "<id><id2>" 
<< vars["id2"] << "<id2>";
Is there a workaround or a better way concatenation a string in groovy?
Related question:https://stackoverflow.com/questions/47786399/jmeter-groovy-script-concatenation-of-variables

Thank you