commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kadamban, Sivasankari" <sivasank...@ti.com>
Subject RE: [jelly] anteater forEach
Date Thu, 10 Jul 2008 21:51:03 GMT
Paul,

Thanks. I used the jelly script from anteater to get the list of URLs from the file.

read_file.jelly reads the file and creates a list of URLs delimited by "," and stores it in
environment variable "URLS".
Read_file.jelly
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly xmlns:j="jelly:core">
  <j:new className="java.io.FileReader" var="fIn">
    <j:arg value="url-list.properties"/>
  </j:new>
  <j:new className="java.io.LineNumberReader" var="input">
    <j:arg value="${fIn}"/>
  </j:new>
  <j:set var="line" value="${input.readLine()}"/>
  <j:set var="urls" value="${line}" />

  <j:while test="${not(empty(line))}">
    <j:set var="line" value="${input.readLine()}"/>
    <j:set var="urls" value="${urls},${line}" />
  </j:while>

  <ant:jelly xmlns:ant="jelly:ant">
      <ant:property environment="env"/>
      <ant:property name="env.URLS" value="${urls}" />
  </ant:jelly>
</j:jelly>

I modified my anteater script to call the jelly script. It fetches the environment variable
"URLS" and uses it in the "for" loop.
<target name="verify">
  <httpRequest group="server" path="${url}" method="GET">
      <match>
        <responseCode value="200"/>
      </match>
    </httpRequest>
 </target>
<target name="main">
<property environment="env" />
<jelly script="read_file.jelly" />
 <foreach list="${env.URLS}" target="verify" param="url">
</foreach>
</target>

Please let me know if any of you have a better approach.

Thanks,
Siva

-----Original Message-----
From: Paul Libbrecht [mailto:paul@activemath.org]
Sent: Tuesday, July 08, 2008 4:01 AM
To: Commons Developers List
Cc: Kadamban, Sivasankari
Subject: Re: [jelly] anteater forEach

Siva,

anteater is not very close to commons to my knowledge, as sebb pointed
out somewhat quickly.

I looked a bit at the documentation and saw they have jelly support as
well which provides much of your expectations. The foreach tag,
however, seems to be theirs.

So, if you allow, here's a jelly answer, all in jelly namespace, which
is quite close to java itself, I suppose this was your intent of
posting to this list. This programme reads the lines from "path-to-
file" and outputs them to output... you should be able to do something
useful out of it provided you can embed this into anteater.

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly xmlns:j="jelly:core">
  <j:new className="java.io.FileReader" var="fIn">
    <j:arg value="path-to-file"/>
  </j:new>
  <j:new className="java.io.LineNumberReader" var="input">
    <j:arg value="${fIn}"/>
  </j:new>

  <j:set var="line" value="${input.readLine()}"/>
  <j:while test="${not(empty(line))}">
  Here is a line: ${line}
  <j:set var="line" value="${input.readLine()}"/>
  </j:while>
</j:jelly>


Here I have only used the core tag-library of jelly... there's a whole
lot more you can do with other tag-libraries.
The util tag library (see http://commons.apache.org/jelly/libs/util/tags.html
  and examples at http://svn.apache.org/viewvc/commons/proper/jelly/trunk/jelly-tags/util/src/test/org/apache/commons/jelly/tags/util/)
  might actually do the job easier provided you do not have zillions
of URLs.

paul

Le 07-juil.-08 à 22:12, Kadamban, Sivasankari a écrit :

> Hi,
>
> I am trying to use anteater for verifying various URLs in our
> application using foreach.
>
> <target name="verify">
>   <httpRequest group="server" path="${url}" method="GET">
>       <match>
>         <responseCode value="200"/>
>       </match>
>     </httpRequest>
> </target>
>
> <foreach list="url1,url2,url3,url4" target="verify" param="url"> </
> foreach>
>
> Is there any way that I can specify the list of URLs in a file and
> read them through one by one in the "for loop"?
>
> Thanks,
> Siva
>



Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message