You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by Peter Lynch <pe...@mindspring.com> on 2002/10/31 03:51:47 UTC

[Jelly] Jelly script unit tests

Hi,

Occasionally I discover scenarios where my jelly scripts appear broken.

I want to write some jelly script test cases and commit then to jelly cvs but I
am not sure where I put those cases ( ie. which files ) and how/when they get
run. Most of my problems revolve around using Ant tasks in Maven jelly scripts.

Could someone point me in the right direction?

-Peter


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Peter Lynch <pe...@mindspring.com>.
Thanks guys! Strachan puts the 'S' in JellieS.

..ahh nice ending to a 22hr day.

I think that is why I called Stefan 'Stafan'. Dreadfully sorry bout that :-)

Looking forward to try out the solution guys.

-Petzzzzzzzzzzzzzz..........


----- Original Message ----- 
From: "James Strachan" <ja...@yahoo.co.uk>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Thursday, November 21, 2002 7:27 AM
Subject: Re: [Jelly] Ant <filterset> in jelly script issues


> From: "Stefan Bodewig" <bo...@apache.org>
> > On Thu, 21 Nov 2002, James Strachan <ja...@yahoo.co.uk>
> > wrote:
> > 
> > > we will only treat Ant tags as being a Task if they are the root Ant
> > > element or their parent Ant element is a TaskContainer
> > 
> > Sounds good.
> 
> Cool. We got there in the end, thanks for your help Stefan.
> 
> Will create some test cases to check this all works...
> 
> 
> > > and if the tags name is a known Task name,
> > 
> > Does Jelly do this at run-time?  If not, you need to take <taskdef>
> > into account.
> 
> Yes - its all done at runtime, so taskdef works fine.
> 
> James
> -------
> http://radio.weblogs.com/0112098/
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Stefan Bodewig" <bo...@apache.org>
> On Thu, 21 Nov 2002, James Strachan <ja...@yahoo.co.uk>
> wrote:
> 
> > we will only treat Ant tags as being a Task if they are the root Ant
> > element or their parent Ant element is a TaskContainer
> 
> Sounds good.

Cool. We got there in the end, thanks for your help Stefan.

Will create some test cases to check this all works...


> > and if the tags name is a known Task name,
> 
> Does Jelly do this at run-time?  If not, you need to take <taskdef>
> into account.

Yes - its all done at runtime, so taskdef works fine.

James
-------
http://radio.weblogs.com/0112098/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 21 Nov 2002, James Strachan <ja...@yahoo.co.uk>
wrote:

> we will only treat Ant tags as being a Task if they are the root Ant
> element or their parent Ant element is a TaskContainer

Sounds good.

> and if the tags name is a known Task name,

Does Jelly do this at run-time?  If not, you need to take <taskdef>
into account.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "James Strachan" <ja...@yahoo.co.uk>
> From: "Stefan Bodewig" <bo...@apache.org>
> > On Thu, 21 Nov 2002, James Strachan <ja...@yahoo.co.uk>
> > wrote:
> >
> > > Now we will only treat Ant tags as being a Task if they are the root
> > > Ant element and if the tags name is a known Task name, otherwise its
> > > treated as either an Ant datatype or a nested property.
> >
> > This will not work for <parallel> and other TaskContainer
> > implementations (not that I'd know enough about Jelly).
>
> Ah. Thanks for this Stefan.
>
> So the logic should probably be like this then?
>
> * we will only treat Ant tags as being a Task if they are the root Ant
> element or their parent Ant element is a TaskContainer and if the tags
name
> is a known Task name, otherwise its treated as either an Ant datatype or a
> nested property.

FWIW I've added a few JellyUnit test cases for this and it appears to work
fine for nested filterset with <copy> inside or outside of a <parallel> tag
using both the reference and embedded way of specifying <filterset>

Thanks again for the heads up Stefan.

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Stefan Bodewig" <bo...@apache.org>
> On Thu, 21 Nov 2002, James Strachan <ja...@yahoo.co.uk>
> wrote:
>
> > Now we will only treat Ant tags as being a Task if they are the root
> > Ant element and if the tags name is a known Task name, otherwise its
> > treated as either an Ant datatype or a nested property.
>
> This will not work for <parallel> and other TaskContainer
> implementations (not that I'd know enough about Jelly).

Ah. Thanks for this Stefan.

So the logic should probably be like this then?

* we will only treat Ant tags as being a Task if they are the root Ant
element or their parent Ant element is a TaskContainer and if the tags name
is a known Task name, otherwise its treated as either an Ant datatype or a
nested property.

James
-------
http://radio.weblogs.com/0112098/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 21 Nov 2002, James Strachan <ja...@yahoo.co.uk>
wrote:

> Now we will only treat Ant tags as being a Task if they are the root
> Ant element and if the tags name is a known Task name, otherwise its
> treated as either an Ant datatype or a nested property.

This will not work for <parallel> and other TaskContainer
implementations (not that I'd know enough about Jelly).

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Peter Lynch" <pe...@mindspring.com>
> Hello,
>
> I tried to write a Jelly Unit test case for Ant filtersets. Thanks James
> Strachan for the pointers.
>
> Here is my test case I used:
>
> <!-- test case to show how filtersets are broken -->
> <test:case name="antFilterset">
>
>   <ant:filterset id="maven.webserver.filterset.default">
>       <ant:filter token="maven.webserver.home" value="some dir" />
>   </ant:filterset>
>   <ant:copy file="src/test/org/apache/commons/jelly/ant/AntFilterset.txt"
>
tofile="src/test/org/apache/commons/jelly/ant/AntFilterset.properties">
>     <ant:filterset refid="maven.webserver.filterset.default" />
>   </ant:copy>
> </test:case>
>
>
> [java] [ERROR] AntTag - -Class org.apache.commons.jelly.tags.junit.CaseTag
> doesn't support the nested "filterset" element.
>     [java]      [echo]
>     [java]      [echo]
>     [java]      [copy] Copying 1 file to
>
G:\cygwin\home\plynch\dev\apache\jakarta-commons-sandbox\jelly\src\test\org\
apac
> he\commons\jelly\ant
>
>
> Before the copy AntFilterset.txt file contains simply:
>
> maven.webserver.home=@maven.webserver.home@
>
> After the copy, u guessed it:
>
> maven.webserver.home=@maven.webserver.home@
>
>
> Needless to say the filter token was not replaced in the copied file.
Something
> needs to be done in order for the filterset to be nested in the case tag
for
> starters.


Sorry this took such a while to get to and figure out. The short answer is I
think I've fixed this now.

I took your JellyUnit test cases and got them working as well as adding a
test both for a nested <filterset> and a <filterset id=".." and nested
<filterset refid="..."/>. You can see the JellyUnit test case here (named
copy and copyWithReference)

http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/src/test/org/apa
che/commons/jelly/ant/suite.jelly?rev=HEAD


The short explaination for why this was a bug was that the nested <filter>
element was incorrectly being treated as a Task in the logic, rather than as
a nested property. (AntTag handles the 2 cases differenty).

Now we will only treat Ant tags as being a Task if they are the root Ant
element and if the tags name is a known Task name, otherwise its treated as
either an Ant datatype or a nested property.

I'm a little worried this change could break Maven since

* some Maven plugins might now break since filtering actually works now
* I always worry I might break something whenever I change AntTag

So I've only made this change in CVS HEAD for now.

James
-------
http://radio.weblogs.com/0112098/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Peter Lynch" <pe...@mindspring.com>
> dIon,
>
> The only case I have seen them work is when the "filtering" attribute of
the
> copy task is 'on' _and_ the filterset tokens are defined from within a
filterset
> nested inside the copy task.

That seems to make sense. The bug seems to have been that the <filter>
element wasn't working. <filterset> was OK, it was just that nested <filter>
elements were not processed correctly.

James
-------
http://radio.weblogs.com/0112098/


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Stefan Bodewig <bo...@apache.org>.
On Thu, 21 Nov 2002, Peter Lynch <pe...@mindspring.com> wrote:

> I use standalone Ant scripts that don't exhibit this problem.

Ah, sorry.

> Actually u may not have noticed I filed that issue :).

Actually I didn't. 8-)

> And that fix was included in Ant 1.5.1 which is why I mentioned that
> I tried that. :)

It was?  One should think that I could remember when I have applied
patches.

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Peter Lynch <pe...@mindspring.com>.
Stafan,

----- Original Message -----
From: "Stefan Bodewig" <bo...@apache.org>
To: <co...@jakarta.apache.org>
Sent: Wednesday, November 20, 2002 11:09 PM
Subject: Re: [Jelly] Ant <filterset> in jelly script issues


> On Wed, 20 Nov 2002, Peter Lynch <pe...@mindspring.com> wrote:
>
> > I tried with latest Ant 1.5.1 too, and that did not resolve it.
>
> Sounds as if you should file a bug report against Ant 8-)

I use standalone Ant scripts that don't exhibit this problem.

>
> > 1. <copy> filtering attribute not behaving as documented.
>
> Judging from the code it does.  All the filtering attribute does is
> adding the "global" filterset to the nested ones.

More specifically the attribute is affecting if the nested filterset with tokens
are being used correctly as documented by Ant. In that jelly script there are no
global filtersets defined. So if it was a basic Ant script, I wouldn't even need
to specify that attribute.

>
> > 3. nested filtersets inside a copy task using the refid attribute to
> > reference a global filterset does not reference the global
> > filterset.
>
> Fixed in CVS: <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9056>.
>

Actually u may not have noticed I filed that issue :). And it was a seperate
issue not described here. And that fix was included in Ant 1.5.1 which is why I
mentioned that I tried that. :)

> Could you try Ant's latest nightly (i.e. 1.6alpha) or the latest one
> from <http://cvs.apache.org/~bodewig/gump/ant1.5.2alpha/> to confirm
> that it works for you as well?
>

Since I don't see these problems in standalone Ant scripts I am doubting Ant is
the root cause. I have been wrong before. Thanks for the link.

Thanks,

Peter

> Stefan
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Stefan Bodewig <bo...@apache.org>.
On Wed, 20 Nov 2002, Peter Lynch <pe...@mindspring.com> wrote:

> I tried with latest Ant 1.5.1 too, and that did not resolve it.

Sounds as if you should file a bug report against Ant 8-)

> 1. <copy> filtering attribute not behaving as documented.

Judging from the code it does.  All the filtering attribute does is
adding the "global" filterset to the nested ones.

> 3. nested filtersets inside a copy task using the refid attribute to
> reference a global filterset does not reference the global
> filterset.

Fixed in CVS: <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=9056>.

Could you try Ant's latest nightly (i.e. 1.6alpha) or the latest one
from <http://cvs.apache.org/~bodewig/gump/ant1.5.2alpha/> to confirm
that it works for you as well?

Stefan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Peter Lynch <pe...@mindspring.com>.
Yeah works fine as is, but if you set the filtering attribute to no off or
false, it don't. It's not supposed to work that way.

This is another example which demonstrates how broken it is. The filtering
attribute should not even be affecting it anyways as the tokens are nested.

I tried with latest Ant 1.5.1 too, and that did not resolve it.

So here are the problems so far:

1. <copy> filtering attribute not behaving as documented.
2. <filterset> tag nested inside a jelly unit test case not accepted
3. nested filtersets inside a copy task using the refid attribute to reference a
global filterset does not reference the global filterset.

-Peter

----- Original Message -----
From: <di...@multitask.com.au>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, November 20, 2002 5:07 PM
Subject: Re: [Jelly] Ant <filterset> in jelly script issues


> Does the maven xdoc version work:
>
>     <!-- Copy maven supplied stylesheets.  -->
>     <copy todir="${maven.docs.dest}/style" overwrite="yes" filtering="yes"
> >
>       <fileset dir="${plugin.dir}/css">
>         <include name="**/*.css"/>
>       </fileset>
>       <filterset>
>         <filter token="UI_BODY_BACKGROUND" value=
> "${maven.ui.body.background}"/>
>         <filter token="UI_BODY_FOREGROUND" value=
> "${maven.ui.body.foreground}"/>
> ....
>   ?
> --
> dIon Gillard, Multitask Consulting
> Blog:      http://www.freeroller.net/page/dion/Weblog
> Work:      http://www.multitask.com.au
>
>
> "Peter Lynch" <pe...@mindspring.com> wrote on 21/11/2002 07:59:23 AM:
>
> > dIon,
> >
> > The only case I have seen them work is when the "filtering" attribute of
> the
> > copy task is 'on' _and_ the filterset tokens are defined from within
> > a filterset
> > nested inside the copy task.
> >
> > A filterset nested inside the copy task defining tokens with
> > filtering attribute
> > not there did not work for me.
> >
> > That seems doubly broken as the filtering attribute should only affect
> global
> > filters.
> >
> > With filtering on and only a global filterset defined ( not nested
> inside the
> > copy task ) the filtereing does not work.
> >
> > -Peter
> >
> > ----- Original Message -----
> > From: <di...@multitask.com.au>
> > To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
> > Sent: Wednesday, November 20, 2002 9:48 AM
> > Subject: Re: [Jelly] Ant <filterset> in jelly script issues
> >
> >
> > > Peter,
> > >
> > > do filtersets nested in the <copy> work ok?
> > > --
> > > dIon Gillard, Multitask Consulting
> > > Blog:      http://www.freeroller.net/page/dion/Weblog
> > > Work:      http://www.multitask.com.au
> > >
> > >
> > > "Peter Lynch" <pe...@mindspring.com> wrote on 20/11/2002 05:33:25
> PM:
> > >
> > > > Hello,
> > > >
> > > > I tried to write a Jelly Unit test case for Ant filtersets. Thanks
> James
> > > > Strachan for the pointers.
> > > >
> > > > Here is my test case I used:
> > > >
> > > > <!-- test case to show how filtersets are broken -->
> > > > <test:case name="antFilterset">
> > > >
> > > >   <ant:filterset id="maven.webserver.filterset.default">
> > > >       <ant:filter token="maven.webserver.home" value="some dir" />
> > > >   </ant:filterset>
> > > >   <ant:copy
> > > file="src/test/org/apache/commons/jelly/ant/AntFilterset.txt"
> > > >
> tofile="src/test/org/apache/commons/jelly/ant/AntFilterset.properties">
> > > >     <ant:filterset refid="maven.webserver.filterset.default" />
> > > >   </ant:copy>
> > > > </test:case>
> > > >
> > > >
> > > > [java] [ERROR] AntTag - -Class
> > > org.apache.commons.jelly.tags.junit.CaseTag
> > > > doesn't support the nested "filterset" element.
> > > >     [java]      [echo]
> > > >     [java]      [echo]
> > > >     [java]      [copy] Copying 1 file to
> > > > G:\cygwin\home\plynch\dev\apache\jakarta-commons-
> > > > sandbox\jelly\src\test\org\apac
> > > > he\commons\jelly\ant
> > > >
> > > >
> > > > Before the copy AntFilterset.txt file contains simply:
> > > >
> > > > maven.webserver.home=@maven.webserver.home@
> > > >
> > > > After the copy, u guessed it:
> > > >
> > > > maven.webserver.home=@maven.webserver.home@
> > > >
> > > >
> > > > Needless to say the filter token was not replaced in the copied
> > > > file. Something
> > > > needs to be done in order for the filterset to be nested in the case
> tag
> > > for
> > > > starters.
> > > >
> > > > To assert if the filter succeeds, I was going to read in the copied
> > > property
> > > > file and then test the property in the AntFilterset.properties for
> it's
> > > value.
> > > >
> > > > Please note...
> > > >
> > > > This failed case has been around in Maven for a long time. To
> reproduce
> > > in
> > > > Maven, define a goal similar to this one, assuming all properties
> are
> > > set in a
> > > > plugin.properties:
> > > >
> > > > <goal name="testFilterset">
> > > >
> > > >     <ant:filterset id="maven.webserver.filterset.default">
> > > >       <ant:filter token="maven.webserver.home"
> > > value="${maven.webserver.home}"
> > > > />
> > > >       <ant:filter token="maven.webserver.name"
> > > value="${maven.webserver.name}"
> > > > />
> > > >       <ant:filter token="maven.webserver.version"
> > > > value="${maven.webserver.version}" />
> > > >       <ant:filter token="maven.webserver.port.http"
> > > > value="${maven.webserver.port.http}" />
> > > >       <ant:filter token="maven.webserver.port.https"
> > > > value="${maven.webserver.port.https}" />
> > > >       <ant:filter token="maven.webserver.port.one"
> > > > value="${maven.webserver.port.one}" />
> > > >       <ant:filter token="maven.webserver.port.two"
> > > > value="${maven.webserver.port.two}" />
> > > >       <ant:filter token="maven.webserver.port.three"
> > > > value="${maven.webserver.port.three}" />
> > > >       <ant:filter token="maven.webserver.conf.dir"
> > > > value="${maven.webserver.conf.dir}" />
> > > >       <ant:filter token="maven.webserver.host"
> > > value="${maven.webserver.host}"
> > > > />
> > > >     </ant:filterset>
> > > >
> > > >
> > > >     <!-- copy any user configuration files w/ filtering by
> > forcing copy
> > -->
> > > >     <!-- expecting at least a httpd.conf -->
> > > >     <ant:copy todir="${maven.webserver.dir}" overwrite="true">
> > > >           <ant:fileset dir="${maven.webserver.conf.dir}" />
> > > >           <ant:filterset refid="maven.webserver.filterset.default"
> />
> > > >           <ant:filterset refid="maven.webserver.filterset" />
> > > >     </ant:copy>
> > > > </goal>
> > > >
> > > > Any files copied that contain any tokens do not get filtered with
> > > > their property
> > > > value.
> > > >
> > > > The only case I have found filtersets to work is demonstrated by
> Maven
> > > Cactus
> > > > plugin. Here is an example from Maven's Cactus plugin:
> > > >
> > > > <copy todir="${maven.cactus.build.resources.dir}"
> > > >       file="${maven.cactus.configFile}" filtering="on">
> > > >       <filterset>
> > > >         <filter token="maven.cactus.port"
> value="${maven.cactus.port}"/>
> > > >       </filterset>
> > > > </copy>
> > > >
> > > > Poor Vincent ( Cactus plugin developer ) seems to be fooling himself
> > > that
> > > > filtersets are playing happily, and by rights he does get the token
> > > > replaced in
> > > > his copied file. ( Hi Vincent :)
> > > >
> > > > In this case the port number from plugin.properties gets replaced,
> but
> > > only
> > > > because the attribute filtering="on" is there and the nested
> filterset
> > > is not
> > > > using a refid. Not to mention that the nested filterset should work
> > > without
> > > > filtering="on" as per the Ant docs re that attribute of the copy
> task:
> > > >
> > > > From Ant documentation:
> > > > " Indicates whether token filtering using the global build-file
> filters
> > > should
> > > > take place during the copy. Note: Nested <filterset> elements will
> > > always be
> > > > used, even if this attribute is not specified, or its value is false
> > > (no, or
> > > > off). "
> > > >
> > > > I looked at Jelly's AntTag.java off and on over the past month
> > > > trying to figure
> > > > out
> > > > how to fix this, but no luck so far. This one haunts me.
> > > >
> > > > ( Attention Maven users: Any proposed fix should also consider what
> > > > happens when
> > > > the filterset is defined in a prereq goal and referenced inside a
> > > > goal inside an
> > > > jelly script imported into the script which defines the filterset.
> :) )
> > > >
> > > > Any Jelly gurus know what is up?
> > > >
> > > > -Peter
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > > To unsubscribe, e-mail:
> > > <ma...@jakarta.apache.org>
> > > > For additional commands, e-mail:
> > > <ma...@jakarta.apache.org>
> > > >
> > >
> > > > ForwardSourceID:NT00090B1A
> > >
> > > --
> > > To unsubscribe, e-mail:
> <mailto:commons-dev-unsubscribe@jakarta.apache.org
> > >
> > > For additional commands, e-mail:
> <mailto:commons-dev-help@jakarta.apache.org
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
> > ForwardSourceID:NT00090D3A
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by di...@multitask.com.au.
Does the maven xdoc version work:

    <!-- Copy maven supplied stylesheets.  -->
    <copy todir="${maven.docs.dest}/style" overwrite="yes" filtering="yes"
>
      <fileset dir="${plugin.dir}/css">
        <include name="**/*.css"/>
      </fileset>
      <filterset>
        <filter token="UI_BODY_BACKGROUND" value=
"${maven.ui.body.background}"/>
        <filter token="UI_BODY_FOREGROUND" value=
"${maven.ui.body.foreground}"/>
....
  ?
--
dIon Gillard, Multitask Consulting
Blog:      http://www.freeroller.net/page/dion/Weblog
Work:      http://www.multitask.com.au


"Peter Lynch" <pe...@mindspring.com> wrote on 21/11/2002 07:59:23 AM:

> dIon,
> 
> The only case I have seen them work is when the "filtering" attribute of 
the
> copy task is 'on' _and_ the filterset tokens are defined from within
> a filterset
> nested inside the copy task.
> 
> A filterset nested inside the copy task defining tokens with 
> filtering attribute
> not there did not work for me.
> 
> That seems doubly broken as the filtering attribute should only affect 
global
> filters.
> 
> With filtering on and only a global filterset defined ( not nested 
inside the
> copy task ) the filtereing does not work.
> 
> -Peter
> 
> ----- Original Message -----
> From: <di...@multitask.com.au>
> To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
> Sent: Wednesday, November 20, 2002 9:48 AM
> Subject: Re: [Jelly] Ant <filterset> in jelly script issues
> 
> 
> > Peter,
> >
> > do filtersets nested in the <copy> work ok?
> > --
> > dIon Gillard, Multitask Consulting
> > Blog:      http://www.freeroller.net/page/dion/Weblog
> > Work:      http://www.multitask.com.au
> >
> >
> > "Peter Lynch" <pe...@mindspring.com> wrote on 20/11/2002 05:33:25 
PM:
> >
> > > Hello,
> > >
> > > I tried to write a Jelly Unit test case for Ant filtersets. Thanks 
James
> > > Strachan for the pointers.
> > >
> > > Here is my test case I used:
> > >
> > > <!-- test case to show how filtersets are broken -->
> > > <test:case name="antFilterset">
> > >
> > >   <ant:filterset id="maven.webserver.filterset.default">
> > >       <ant:filter token="maven.webserver.home" value="some dir" />
> > >   </ant:filterset>
> > >   <ant:copy
> > file="src/test/org/apache/commons/jelly/ant/AntFilterset.txt"
> > > 
tofile="src/test/org/apache/commons/jelly/ant/AntFilterset.properties">
> > >     <ant:filterset refid="maven.webserver.filterset.default" />
> > >   </ant:copy>
> > > </test:case>
> > >
> > >
> > > [java] [ERROR] AntTag - -Class
> > org.apache.commons.jelly.tags.junit.CaseTag
> > > doesn't support the nested "filterset" element.
> > >     [java]      [echo]
> > >     [java]      [echo]
> > >     [java]      [copy] Copying 1 file to
> > > G:\cygwin\home\plynch\dev\apache\jakarta-commons-
> > > sandbox\jelly\src\test\org\apac
> > > he\commons\jelly\ant
> > >
> > >
> > > Before the copy AntFilterset.txt file contains simply:
> > >
> > > maven.webserver.home=@maven.webserver.home@
> > >
> > > After the copy, u guessed it:
> > >
> > > maven.webserver.home=@maven.webserver.home@
> > >
> > >
> > > Needless to say the filter token was not replaced in the copied
> > > file. Something
> > > needs to be done in order for the filterset to be nested in the case 
tag
> > for
> > > starters.
> > >
> > > To assert if the filter succeeds, I was going to read in the copied
> > property
> > > file and then test the property in the AntFilterset.properties for 
it's
> > value.
> > >
> > > Please note...
> > >
> > > This failed case has been around in Maven for a long time. To 
reproduce
> > in
> > > Maven, define a goal similar to this one, assuming all properties 
are
> > set in a
> > > plugin.properties:
> > >
> > > <goal name="testFilterset">
> > >
> > >     <ant:filterset id="maven.webserver.filterset.default">
> > >       <ant:filter token="maven.webserver.home"
> > value="${maven.webserver.home}"
> > > />
> > >       <ant:filter token="maven.webserver.name"
> > value="${maven.webserver.name}"
> > > />
> > >       <ant:filter token="maven.webserver.version"
> > > value="${maven.webserver.version}" />
> > >       <ant:filter token="maven.webserver.port.http"
> > > value="${maven.webserver.port.http}" />
> > >       <ant:filter token="maven.webserver.port.https"
> > > value="${maven.webserver.port.https}" />
> > >       <ant:filter token="maven.webserver.port.one"
> > > value="${maven.webserver.port.one}" />
> > >       <ant:filter token="maven.webserver.port.two"
> > > value="${maven.webserver.port.two}" />
> > >       <ant:filter token="maven.webserver.port.three"
> > > value="${maven.webserver.port.three}" />
> > >       <ant:filter token="maven.webserver.conf.dir"
> > > value="${maven.webserver.conf.dir}" />
> > >       <ant:filter token="maven.webserver.host"
> > value="${maven.webserver.host}"
> > > />
> > >     </ant:filterset>
> > >
> > >
> > >     <!-- copy any user configuration files w/ filtering by 
> forcing copy
> -->
> > >     <!-- expecting at least a httpd.conf -->
> > >     <ant:copy todir="${maven.webserver.dir}" overwrite="true">
> > >           <ant:fileset dir="${maven.webserver.conf.dir}" />
> > >           <ant:filterset refid="maven.webserver.filterset.default" 
/>
> > >           <ant:filterset refid="maven.webserver.filterset" />
> > >     </ant:copy>
> > > </goal>
> > >
> > > Any files copied that contain any tokens do not get filtered with
> > > their property
> > > value.
> > >
> > > The only case I have found filtersets to work is demonstrated by 
Maven
> > Cactus
> > > plugin. Here is an example from Maven's Cactus plugin:
> > >
> > > <copy todir="${maven.cactus.build.resources.dir}"
> > >       file="${maven.cactus.configFile}" filtering="on">
> > >       <filterset>
> > >         <filter token="maven.cactus.port" 
value="${maven.cactus.port}"/>
> > >       </filterset>
> > > </copy>
> > >
> > > Poor Vincent ( Cactus plugin developer ) seems to be fooling himself
> > that
> > > filtersets are playing happily, and by rights he does get the token
> > > replaced in
> > > his copied file. ( Hi Vincent :)
> > >
> > > In this case the port number from plugin.properties gets replaced, 
but
> > only
> > > because the attribute filtering="on" is there and the nested 
filterset
> > is not
> > > using a refid. Not to mention that the nested filterset should work
> > without
> > > filtering="on" as per the Ant docs re that attribute of the copy 
task:
> > >
> > > From Ant documentation:
> > > " Indicates whether token filtering using the global build-file 
filters
> > should
> > > take place during the copy. Note: Nested <filterset> elements will
> > always be
> > > used, even if this attribute is not specified, or its value is false
> > (no, or
> > > off). "
> > >
> > > I looked at Jelly's AntTag.java off and on over the past month
> > > trying to figure
> > > out
> > > how to fix this, but no luck so far. This one haunts me.
> > >
> > > ( Attention Maven users: Any proposed fix should also consider what
> > > happens when
> > > the filterset is defined in a prereq goal and referenced inside a
> > > goal inside an
> > > jelly script imported into the script which defines the filterset. 
:) )
> > >
> > > Any Jelly gurus know what is up?
> > >
> > > -Peter
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> > >
> >
> > > ForwardSourceID:NT00090B1A
> >
> > --
> > To unsubscribe, e-mail: 
<mailto:commons-dev-unsubscribe@jakarta.apache.org
> >
> > For additional commands, e-mail: 
<mailto:commons-dev-help@jakarta.apache.org
> >
> >
> 
> 
> --
> To unsubscribe, e-mail: 
<ma...@jakarta.apache.org>
> For additional commands, e-mail: 
<ma...@jakarta.apache.org>
> 

> ForwardSourceID:NT00090D3A 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by Peter Lynch <pe...@mindspring.com>.
dIon,

The only case I have seen them work is when the "filtering" attribute of the
copy task is 'on' _and_ the filterset tokens are defined from within a filterset
nested inside the copy task.

A filterset nested inside the copy task defining tokens with filtering attribute
not there did not work for me.

That seems doubly broken as the filtering attribute should only affect global
filters.

With filtering on and only a global filterset defined ( not nested inside the
copy task ) the filtereing does not work.

-Peter

----- Original Message -----
From: <di...@multitask.com.au>
To: "Jakarta Commons Developers List" <co...@jakarta.apache.org>
Sent: Wednesday, November 20, 2002 9:48 AM
Subject: Re: [Jelly] Ant <filterset> in jelly script issues


> Peter,
>
> do filtersets nested in the <copy> work ok?
> --
> dIon Gillard, Multitask Consulting
> Blog:      http://www.freeroller.net/page/dion/Weblog
> Work:      http://www.multitask.com.au
>
>
> "Peter Lynch" <pe...@mindspring.com> wrote on 20/11/2002 05:33:25 PM:
>
> > Hello,
> >
> > I tried to write a Jelly Unit test case for Ant filtersets. Thanks James
> > Strachan for the pointers.
> >
> > Here is my test case I used:
> >
> > <!-- test case to show how filtersets are broken -->
> > <test:case name="antFilterset">
> >
> >   <ant:filterset id="maven.webserver.filterset.default">
> >       <ant:filter token="maven.webserver.home" value="some dir" />
> >   </ant:filterset>
> >   <ant:copy
> file="src/test/org/apache/commons/jelly/ant/AntFilterset.txt"
> > tofile="src/test/org/apache/commons/jelly/ant/AntFilterset.properties">
> >     <ant:filterset refid="maven.webserver.filterset.default" />
> >   </ant:copy>
> > </test:case>
> >
> >
> > [java] [ERROR] AntTag - -Class
> org.apache.commons.jelly.tags.junit.CaseTag
> > doesn't support the nested "filterset" element.
> >     [java]      [echo]
> >     [java]      [echo]
> >     [java]      [copy] Copying 1 file to
> > G:\cygwin\home\plynch\dev\apache\jakarta-commons-
> > sandbox\jelly\src\test\org\apac
> > he\commons\jelly\ant
> >
> >
> > Before the copy AntFilterset.txt file contains simply:
> >
> > maven.webserver.home=@maven.webserver.home@
> >
> > After the copy, u guessed it:
> >
> > maven.webserver.home=@maven.webserver.home@
> >
> >
> > Needless to say the filter token was not replaced in the copied
> > file. Something
> > needs to be done in order for the filterset to be nested in the case tag
> for
> > starters.
> >
> > To assert if the filter succeeds, I was going to read in the copied
> property
> > file and then test the property in the AntFilterset.properties for it's
> value.
> >
> > Please note...
> >
> > This failed case has been around in Maven for a long time. To reproduce
> in
> > Maven, define a goal similar to this one, assuming all properties are
> set in a
> > plugin.properties:
> >
> > <goal name="testFilterset">
> >
> >     <ant:filterset id="maven.webserver.filterset.default">
> >       <ant:filter token="maven.webserver.home"
> value="${maven.webserver.home}"
> > />
> >       <ant:filter token="maven.webserver.name"
> value="${maven.webserver.name}"
> > />
> >       <ant:filter token="maven.webserver.version"
> > value="${maven.webserver.version}" />
> >       <ant:filter token="maven.webserver.port.http"
> > value="${maven.webserver.port.http}" />
> >       <ant:filter token="maven.webserver.port.https"
> > value="${maven.webserver.port.https}" />
> >       <ant:filter token="maven.webserver.port.one"
> > value="${maven.webserver.port.one}" />
> >       <ant:filter token="maven.webserver.port.two"
> > value="${maven.webserver.port.two}" />
> >       <ant:filter token="maven.webserver.port.three"
> > value="${maven.webserver.port.three}" />
> >       <ant:filter token="maven.webserver.conf.dir"
> > value="${maven.webserver.conf.dir}" />
> >       <ant:filter token="maven.webserver.host"
> value="${maven.webserver.host}"
> > />
> >     </ant:filterset>
> >
> >
> >     <!-- copy any user configuration files w/ filtering by forcing copy
> -->
> >     <!-- expecting at least a httpd.conf -->
> >     <ant:copy todir="${maven.webserver.dir}" overwrite="true">
> >           <ant:fileset dir="${maven.webserver.conf.dir}" />
> >           <ant:filterset refid="maven.webserver.filterset.default" />
> >           <ant:filterset refid="maven.webserver.filterset" />
> >     </ant:copy>
> > </goal>
> >
> > Any files copied that contain any tokens do not get filtered with
> > their property
> > value.
> >
> > The only case I have found filtersets to work is demonstrated by Maven
> Cactus
> > plugin. Here is an example from Maven's Cactus plugin:
> >
> > <copy todir="${maven.cactus.build.resources.dir}"
> >       file="${maven.cactus.configFile}" filtering="on">
> >       <filterset>
> >         <filter token="maven.cactus.port" value="${maven.cactus.port}"/>
> >       </filterset>
> > </copy>
> >
> > Poor Vincent ( Cactus plugin developer ) seems to be fooling himself
> that
> > filtersets are playing happily, and by rights he does get the token
> > replaced in
> > his copied file. ( Hi Vincent :)
> >
> > In this case the port number from plugin.properties gets replaced, but
> only
> > because the attribute filtering="on" is there and the nested filterset
> is not
> > using a refid. Not to mention that the nested filterset should work
> without
> > filtering="on" as per the Ant docs re that attribute of the copy task:
> >
> > From Ant documentation:
> > " Indicates whether token filtering using the global build-file filters
> should
> > take place during the copy. Note: Nested <filterset> elements will
> always be
> > used, even if this attribute is not specified, or its value is false
> (no, or
> > off). "
> >
> > I looked at Jelly's AntTag.java off and on over the past month
> > trying to figure
> > out
> > how to fix this, but no luck so far. This one haunts me.
> >
> > ( Attention Maven users: Any proposed fix should also consider what
> > happens when
> > the filterset is defined in a prereq goal and referenced inside a
> > goal inside an
> > jelly script imported into the script which defines the filterset. :) )
> >
> > Any Jelly gurus know what is up?
> >
> > -Peter
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
>
> > ForwardSourceID:NT00090B1A
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Ant in jelly script issues

Posted by di...@multitask.com.au.
Peter,

do filtersets nested in the <copy> work ok?
--
dIon Gillard, Multitask Consulting
Blog:      http://www.freeroller.net/page/dion/Weblog
Work:      http://www.multitask.com.au


"Peter Lynch" <pe...@mindspring.com> wrote on 20/11/2002 05:33:25 PM:

> Hello,
> 
> I tried to write a Jelly Unit test case for Ant filtersets. Thanks James
> Strachan for the pointers.
> 
> Here is my test case I used:
> 
> <!-- test case to show how filtersets are broken -->
> <test:case name="antFilterset">
> 
>   <ant:filterset id="maven.webserver.filterset.default">
>       <ant:filter token="maven.webserver.home" value="some dir" />
>   </ant:filterset>
>   <ant:copy 
file="src/test/org/apache/commons/jelly/ant/AntFilterset.txt"
> tofile="src/test/org/apache/commons/jelly/ant/AntFilterset.properties">
>     <ant:filterset refid="maven.webserver.filterset.default" />
>   </ant:copy>
> </test:case>
> 
> 
> [java] [ERROR] AntTag - -Class 
org.apache.commons.jelly.tags.junit.CaseTag
> doesn't support the nested "filterset" element.
>     [java]      [echo]
>     [java]      [echo]
>     [java]      [copy] Copying 1 file to
> G:\cygwin\home\plynch\dev\apache\jakarta-commons-
> sandbox\jelly\src\test\org\apac
> he\commons\jelly\ant
> 
> 
> Before the copy AntFilterset.txt file contains simply:
> 
> maven.webserver.home=@maven.webserver.home@
> 
> After the copy, u guessed it:
> 
> maven.webserver.home=@maven.webserver.home@
> 
> 
> Needless to say the filter token was not replaced in the copied 
> file. Something
> needs to be done in order for the filterset to be nested in the case tag 
for
> starters.
> 
> To assert if the filter succeeds, I was going to read in the copied 
property
> file and then test the property in the AntFilterset.properties for it's 
value.
> 
> Please note...
> 
> This failed case has been around in Maven for a long time. To reproduce 
in
> Maven, define a goal similar to this one, assuming all properties are 
set in a
> plugin.properties:
> 
> <goal name="testFilterset">
> 
>     <ant:filterset id="maven.webserver.filterset.default">
>       <ant:filter token="maven.webserver.home" 
value="${maven.webserver.home}"
> />
>       <ant:filter token="maven.webserver.name" 
value="${maven.webserver.name}"
> />
>       <ant:filter token="maven.webserver.version"
> value="${maven.webserver.version}" />
>       <ant:filter token="maven.webserver.port.http"
> value="${maven.webserver.port.http}" />
>       <ant:filter token="maven.webserver.port.https"
> value="${maven.webserver.port.https}" />
>       <ant:filter token="maven.webserver.port.one"
> value="${maven.webserver.port.one}" />
>       <ant:filter token="maven.webserver.port.two"
> value="${maven.webserver.port.two}" />
>       <ant:filter token="maven.webserver.port.three"
> value="${maven.webserver.port.three}" />
>       <ant:filter token="maven.webserver.conf.dir"
> value="${maven.webserver.conf.dir}" />
>       <ant:filter token="maven.webserver.host" 
value="${maven.webserver.host}"
> />
>     </ant:filterset>
> 
> 
>     <!-- copy any user configuration files w/ filtering by forcing copy 
-->
>     <!-- expecting at least a httpd.conf -->
>     <ant:copy todir="${maven.webserver.dir}" overwrite="true">
>           <ant:fileset dir="${maven.webserver.conf.dir}" />
>           <ant:filterset refid="maven.webserver.filterset.default" />
>           <ant:filterset refid="maven.webserver.filterset" />
>     </ant:copy>
> </goal>
> 
> Any files copied that contain any tokens do not get filtered with 
> their property
> value.
> 
> The only case I have found filtersets to work is demonstrated by Maven 
Cactus
> plugin. Here is an example from Maven's Cactus plugin:
> 
> <copy todir="${maven.cactus.build.resources.dir}"
>       file="${maven.cactus.configFile}" filtering="on">
>       <filterset>
>         <filter token="maven.cactus.port" value="${maven.cactus.port}"/>
>       </filterset>
> </copy>
> 
> Poor Vincent ( Cactus plugin developer ) seems to be fooling himself 
that
> filtersets are playing happily, and by rights he does get the token 
> replaced in
> his copied file. ( Hi Vincent :)
> 
> In this case the port number from plugin.properties gets replaced, but 
only
> because the attribute filtering="on" is there and the nested filterset 
is not
> using a refid. Not to mention that the nested filterset should work 
without
> filtering="on" as per the Ant docs re that attribute of the copy task:
> 
> From Ant documentation:
> " Indicates whether token filtering using the global build-file filters 
should
> take place during the copy. Note: Nested <filterset> elements will 
always be
> used, even if this attribute is not specified, or its value is false 
(no, or
> off). "
> 
> I looked at Jelly's AntTag.java off and on over the past month 
> trying to figure
> out
> how to fix this, but no luck so far. This one haunts me.
> 
> ( Attention Maven users: Any proposed fix should also consider what 
> happens when
> the filterset is defined in a prereq goal and referenced inside a 
> goal inside an
> jelly script imported into the script which defines the filterset. :) )
> 
> Any Jelly gurus know what is up?
> 
> -Peter
> 
> 
> 
> 
> --
> To unsubscribe, e-mail: 
<ma...@jakarta.apache.org>
> For additional commands, e-mail: 
<ma...@jakarta.apache.org>
> 

> ForwardSourceID:NT00090B1A 

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


[Jelly] Ant in jelly script issues

Posted by Peter Lynch <pe...@mindspring.com>.
Hello,

I tried to write a Jelly Unit test case for Ant filtersets. Thanks James
Strachan for the pointers.

Here is my test case I used:

<!-- test case to show how filtersets are broken -->
<test:case name="antFilterset">

  <ant:filterset id="maven.webserver.filterset.default">
      <ant:filter token="maven.webserver.home" value="some dir" />
  </ant:filterset>
  <ant:copy file="src/test/org/apache/commons/jelly/ant/AntFilterset.txt"
    tofile="src/test/org/apache/commons/jelly/ant/AntFilterset.properties">
    <ant:filterset refid="maven.webserver.filterset.default" />
  </ant:copy>
</test:case>


[java] [ERROR] AntTag - -Class org.apache.commons.jelly.tags.junit.CaseTag
doesn't support the nested "filterset" element.
    [java]      [echo]
    [java]      [echo]
    [java]      [copy] Copying 1 file to
G:\cygwin\home\plynch\dev\apache\jakarta-commons-sandbox\jelly\src\test\org\apac
he\commons\jelly\ant


Before the copy AntFilterset.txt file contains simply:

maven.webserver.home=@maven.webserver.home@

After the copy, u guessed it:

maven.webserver.home=@maven.webserver.home@


Needless to say the filter token was not replaced in the copied file. Something
needs to be done in order for the filterset to be nested in the case tag for
starters.

To assert if the filter succeeds, I was going to read in the copied property
file and then test the property in the AntFilterset.properties for it's value.

Please note...

This failed case has been around in Maven for a long time. To reproduce in
Maven, define a goal similar to this one, assuming all properties are set in a
plugin.properties:

<goal name="testFilterset">

    <ant:filterset id="maven.webserver.filterset.default">
      <ant:filter token="maven.webserver.home" value="${maven.webserver.home}"
/>
      <ant:filter token="maven.webserver.name" value="${maven.webserver.name}"
/>
      <ant:filter token="maven.webserver.version"
value="${maven.webserver.version}" />
      <ant:filter token="maven.webserver.port.http"
value="${maven.webserver.port.http}" />
      <ant:filter token="maven.webserver.port.https"
value="${maven.webserver.port.https}" />
      <ant:filter token="maven.webserver.port.one"
value="${maven.webserver.port.one}" />
      <ant:filter token="maven.webserver.port.two"
value="${maven.webserver.port.two}" />
      <ant:filter token="maven.webserver.port.three"
value="${maven.webserver.port.three}" />
      <ant:filter token="maven.webserver.conf.dir"
value="${maven.webserver.conf.dir}" />
      <ant:filter token="maven.webserver.host" value="${maven.webserver.host}"
/>
    </ant:filterset>


    <!-- copy any user configuration files w/ filtering by forcing copy -->
    <!-- expecting at least a httpd.conf -->
    <ant:copy todir="${maven.webserver.dir}" overwrite="true">
          <ant:fileset dir="${maven.webserver.conf.dir}" />
          <ant:filterset refid="maven.webserver.filterset.default" />
          <ant:filterset refid="maven.webserver.filterset" />
    </ant:copy>
</goal>

Any files copied that contain any tokens do not get filtered with their property
value.

The only case I have found filtersets to work is demonstrated by Maven Cactus
plugin. Here is an example from Maven's Cactus plugin:

<copy todir="${maven.cactus.build.resources.dir}"
      file="${maven.cactus.configFile}" filtering="on">
      <filterset>
        <filter token="maven.cactus.port" value="${maven.cactus.port}"/>
      </filterset>
</copy>

Poor Vincent ( Cactus plugin developer ) seems to be fooling himself that
filtersets are playing happily, and by rights he does get the token replaced in
his copied file. ( Hi Vincent :)

In this case the port number from plugin.properties gets replaced, but only
because the attribute filtering="on" is there and the nested filterset is not
using a refid. Not to mention that the nested filterset should work without
filtering="on" as per the Ant docs re that attribute of the copy task:

>From Ant documentation:
" Indicates whether token filtering using the global build-file filters should
take place during the copy. Note: Nested <filterset> elements will always be
used, even if this attribute is not specified, or its value is false (no, or
off). "

I looked at Jelly's AntTag.java off and on over the past month trying to figure
out
how to fix this, but no luck so far. This one haunts me.

( Attention Maven users: Any proposed fix should also consider what happens when
the filterset is defined in a prereq goal and referenced inside a goal inside an
jelly script imported into the script which defines the filterset. :) )

Any Jelly gurus know what is up?

-Peter




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: [Jelly] Jelly script unit tests

Posted by James Strachan <ja...@yahoo.co.uk>.
From: "Peter Lynch" <pe...@mindspring.com>
> Hi,
>
> Occasionally I discover scenarios where my jelly scripts appear broken.
>
> I want to write some jelly script test cases and commit then to jelly cvs
but I
> am not sure where I put those cases ( ie. which files ) and how/when they
get
> run. Most of my problems revolve around using Ant tasks in Maven jelly
scripts.
>
> Could someone point me in the right direction?

Probably the trickiest part is testing that an Ant task really did what you
think it did. I guess it depends on the Ant task as to how easy that'll be.

The way unit testing of Jelly scripts and libraries works is typically using
JellyUnit. You can always just use straight Java code if you like but
typically for testing the behaviour of tags, expressions and libraries its
often easier to just use them inside a Jelly script.

There's some rudimentary documentation here...

http://jakarta.apache.org/commons/sandbox/jelly/jellyunit.html

Its usually easier to learn this kinda stuff via an example. Lets take a
look here...

http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/src/test/org/apa
che/commons/jelly/dynabean/

this directory contains a JellyUnit test suite for the DynaBean library for
Jelly. Most of the work goes into writing a JellyUnit script. Up to now
we've been using the naming convention of suite.jelly but it can be called
anything you like. If your test cases are very large, by all means refactor
this file into lots of scripts. Either include them at specific points in
the suite.jelly or use Ant FileSets and iterate over the sub-scripts etc.

Looking at the suite.jelly should seem pretty self explanatory I hope; it
defines a <test:suite> containing one or more <test:case>s which mirrors
normal JUnit. Inside a <test:case> you can use various assertions and such
like <test:assert> for performing boolean assertions using Jexl or XPath
expressions and <test:assertEquals> for performing comparisons.

http://jakarta.apache.org/commons/sandbox/jelly/tags.html#jelly:junit

You can also perform XML validations of the output of a piece of Jelly
script against a certain schema (DTD, XML Schema, RelaxNG, Relax, Trex)
using the validate library and the <validate:assertValid> tag in
particular...

http://jakarta.apache.org/commons/sandbox/jelly/tags.html#jelly:validate


When the script runs it actually creates a real JUnit TestSuite and
TestCase(s) which can be ran as part of a regular JUnit test run.

Typically all your unit test cases get run as part of the standard Ant/Maven
build. One day hopefully, JellyUnit scripts could be integrated into
Ant/Maven so that they get created and ran as part of the normal unit test
run. However thats not there right now, so there's a simple adapter class
which allows JellyUnit to be included in a standard Ant/Maven JUnit test
run. If you look at the TestJelly.java class in the dynabean test
directory...

http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/jelly/src/test/org/apa
che/commons/jelly/dynabean/TestJelly.java?rev=HEAD

you'll see the adapter. This serves 2 purposes; it provides a main() that
can be ran from the command line to create and run the JellyUnit test case.
Also it creates a TestSuite class which has a static suite() method that any
JUnit TestRunner can use to create and invoke the JellyUnit test cases.

To check that the above is true, from inside the Jelly CVS checkout
directory, you can type

    maven test:ui

and you'll get a standard JUnit Swing test runner (which works like this for
any Maven project) which can invoke any of the JellyUnit test cases inside
the Jelly project.

I hope all that helps...

James
-------
http://radio.weblogs.com/0112098/

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>