[Webtest] Accessing a variable created in a previous project

Paul King webtest@lists.canoo.com
Tue, 28 Mar 2006 06:49:15 +1000


Hi Mike, try putting your Session1 exec statements into their own
ant target and use an antcall instead of the current antWrapper.
The antWrapper step doesn't expand #{} within tasks like exec
which aren't steps at the moment. I think you are observing
ant's early binding "feature" which is binding the ${} variables
to values at the beginning of the task. You won't need an antWrapper
in Session2 either.

Cheers, Paul.

Michael Knapp wrote:
> Hello,
> 
> I am trying to do the following:
> Have a session where a user is assigned an ID, then have another
> subsequent session where the user accesses that ID.
> 
>>From what I can tell, I have to do this in separate Ant projects  (I
> tried restructuring my entire architecture to have a single top level
> project, but then encountered countless other obstacles that would have
> necessitated me re-writing the entire suite from scratch -- IIRC because
> of what can and can't be nested...).
> 
> So, what I'm trying to do is use antWrapper calls as follows:
> 
> Session1:
> <storeRegEx
>       description="Remember registry number"
>       text="gl[0-9]+[a-z]?"
>       group="0"
>       property="regNumber" 
> 	  />
> <storeProperty
>             description="convert prop type "
>             name="registryNumber"
>             value="#{regNumber}" 
> 		propertyType="ant"/>
> <antWrapper>
> <exec executable="touch"> <arg
> value="tmp/${registry.accessLevel}.lastName.${registrantLastName.value}"
> /></exec>
> <exec  executable="touch"> <arg
> value="tmp/${registry.accessLevel}.regNumber.${registryNumber}"
> /></exec>
> </antWrapper>
> 
> Session2 (separate project):
> <antWrapper>
> <exec executable="ls" outputproperty="lastName"><arg
> value="tmp/protected.lastName.*"/> </exec>
> <exec executable="ls" outputproperty="regNumber"><arg
> value="tmp/protected.regNumber.*"/> </exec>
> <echo message="last name is ${lastName}"/>
> </antWrapper>
> 
> 
> Note:  in the Session1 example, I've tried -- within the antWrapper --
> to access the registryNumber both with #{} and ${}.
> Also, it might seem a funny way to try to store values (using a
> filename, with touch and ls....);  I tried to set environment variables,
> but to no avail.
> 
> I can see in my results that the #{regNumber}  does resolve to a  value
> and gets assigned to registryNumber, however, looking in my tmp
> diorectory I have only seen files named
> protected.regNumber.${registryNumber}
> Or
> protected.regNumber.#{registryNumber}
> 	
> Also, in the echo statement form session2, it echoes 'last name is
> ${lastName}', without resolving the variable. (looking in the directory,
> the variable has been resolved in the "touch" operation, and should be
> something like "protected.lastName.Smith")
> 
> I suspect that most of this is caused by and variables being reasolved
> at compile time, and dynamic variables being resolved at runtime (or in
> realtime - forget the phraseology used...), but then I don't understand
> how any variable could be converted from Dynamic to Ant as explained in
> the docs.
> 
> In any event, if anyone has a better way of doing what I'm trying to do,
> it would be appreciated.
> 
> Thanks,
> Mike
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
> 
>