commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject cvs commit: jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/http http.jelly
Date Fri, 27 Sep 2002 02:18:34 GMT
dion        2002/09/26 19:18:34

  Added:       jelly/src/test/org/apache/commons/jelly/http http.jelly
  - Added sample file (later to be used in a test suite) showing the tags
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/jelly/src/test/org/apache/commons/jelly/http/http.jelly
  Index: http.jelly
  <?xml version="1.0"?>
      <!-- a session holds shared http state info 
      <session> -->
  Tests for Get tag
          <get var="mtc" uri=""/>
          <j:if test='${mtc.statusCode == 200}'>
              request ok
              Results for mtc url are:
              http return code = ${mtc.statusCode}
              http status text = '${mtc.statusText}'
              size of result = ${mtc.responseBodyAsString.length()}
              response time = ${mtc.responseTime}
          <j:forEach items="${mtc.responseHeaders}" var="header" indexVar="i">
              header[${i}] = ${header}
          <!-- test parameters and headers -->
          <get var="mtc2" uri="">
              <parameter name="page" value="mt @News"/>
              <parameter name="page2" value="junk"/>
              <header name="Content-Type" value="text/plain"/>
          queryString = ${mtc2.queryString}, length = ${mtc2.responseBodyAsString.length()}
          response time = ${mtc2.responseTime}
          <j:forEach items="${mtc2.requestHeaders}" var="rHeader" indexVar="i">
              reqHeader[${i}] = ${rHeader}
          <!-- test a 404 -->
          <get var="badurl" uri=""/>
          http return code = ${badurl.statusCode}
          bad response time = ${badurl.responseTime} in msec
  Tests for Post tag
          <post var="jdc" uri="">
              <parameter name="action" value="login" />
              <parameter name="url" value="/developer/index.jshtml" />
              <parameter name="UserId" value="XXXX" />
              <parameter name="Password" value="XXXX" />
          jdc login result = ${jdc.statusCode}
          good login = ${jdc.responseBodyAsString.indexOf("Sorry!") == "-1"}
          jdc response time = ${jdc.responseTime} in msec
          <j:forEach items="${jdc.responseHeaders}" var="header" indexVar="i">
              jdc.header[${i}] = ${header}
  Tests for Head tag
          <head var="jakarta" uri=""/>
          <j:forEach items="${jakarta.responseHeaders}" var="header" indexVar="i">
              header[${i}] = ${header}
  Tests for Options tag
          <options var="ms" uri=""/>
          <j:forEach items="${ms.responseHeaders}" var="header" indexVar="i">
              header[${i}] = ${header}
  Tests for Body tag
          <j:set var="googleKey" value="00000000000000000000000000000000" />
          <post var="google" uri="">
              <header name="Content-Type" value="text/xml"/>
                  <ns1:doGoogleSearch xmlns:ns1="urn:GoogleSearch"
                    <ns1:key xsi:type="xsd:string">${googleKey}</ns1:key>
                    <ns1:q xsi:type="xsd:string">jelly java xml</ns1:q>
                    <ns1:start xsi:type="xsd:int">0</ns1:start>
                    <ns1:maxResults xsi:type="xsd:int">10</ns1:maxResults>
                    <ns1:filter xsi:type="xsd:boolean">true</ns1:filter>
                    <ns1:restrict xsi:type="xsd:string"></ns1:restrict>
                    <ns1:safeSearch xsi:type="xsd:boolean">false</ns1:safeSearch>
                    <ns1:lr xsi:type="xsd:string"></ns1:lr>
                    <ns1:ie xsi:type="xsd:string">latin1</ns1:ie>
                    <ns1:oe xsi:type="xsd:string">latin1</ns1:oe>
          <j:forEach items="${google.requestHeaders}" var="rHeader" indexVar="i">
              reqHeader[${i}] = ${rHeader}
          google response = ${google.statusCode}, ${google.statusText}
  Tests for Cookie tag
          <post var="ph" uri="">
              <parameter name="username" value="xxx"/>
              <parameter name="password" value="xxx"/>
              <parameter name="actionToDo" value="continue"/>
              <parameter name="target" value="registration"/>
          SC: ${ph.getResponseHeader("Set-Cookie")}
          <!-- show how to dump cookie name/value pairse -->
          <j:forEach items='${ph.getResponseHeader("Set-Cookie").values}'
              var="element" indexVar="i">
              element[${i}] = ${element}
      <get var="nosessionBad" uri=""/>
      outside session get - ${nosessionBad.statusText}
      <get var="nosessionGood" uri=""/>
      outside session get good - ${nosessionGood.statusText}

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message