| <?xml version="1.0"?> |
| <!-- |
| Copyright 2002,2004 The Apache Software Foundation. |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| <j:jelly |
| xmlns:j="jelly:core" |
| xmlns="jelly:jetty" |
| xmlns:http="jelly:http" |
| trim="false"> |
| |
| <j:set var="contextPathVar" value="/resourceHandlerTest"/> |
| <j:set var="testPort1" value="8100"/> |
| <j:set var="testPort2" value="8200"/> |
| <j:set var="testUri" value="http://localhost:${testPort1}${contextPathVar}/resourceHandlerTest.txt"/> |
| <j:set var="bogusUri" value="http://localhost:${testPort1}${contextPathVar}/zzz"/> |
| <j:set var="testUriHeadOnly" value="http://localhost:${testPort2}${contextPathVar}/resourceHandlerTest.txt"/> |
| |
| <jettyHttpServer var="httpServerDefault"> |
| <socketListener port="${testPort1}"/> |
| <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest"> |
| <resourceHandler/> |
| </httpContext> |
| </jettyHttpServer> |
| |
| <jettyHttpServer var="httpServerHeadOnly"> |
| <socketListener port="${testPort2}"/> |
| <httpContext contextPath="${contextPathVar}" resourceBase="./docRoot/resourceHandlerTest"> |
| <resourceHandler allowedMethods="OPTIONS,DELETE, HEAD"/> |
| </httpContext> |
| </jettyHttpServer> |
| |
| <http:get var="mtc1" uri="${testUri}"/> |
| |
| <!-- if get to default works and bogus uri returns 404 |
| and a head request to the head only resource handler works |
| when a get fails then all is ok --> |
| <j:if test='${mtc1.statusCode == 200}'> |
| <http:get var="mtc2" uri="${bogusUri}"/> |
| <j:if test='${mtc2.statusCode == 404}'> |
| <http:head var="mtc3" uri="${testUriHeadOnly}"/> |
| <j:if test='${mtc3.statusCode == 200}'> |
| <http:get var="mtc4" uri="${testUriHeadOnly}"/> |
| <j:if test='${mtc4.statusCode == 405}'> |
| It works! |
| </j:if> |
| </j:if> |
| </j:if> |
| <j:if test='${mtc2.statusCode != 404}'> |
| Results for mtc2 url are: |
| http return code = ${mtc2.statusCode} |
| http status text = '${mtc2.statusText}' |
| size of result = ${mtc2.responseBodyAsString.length()} |
| response time = ${mtc2.responseTime} |
| |
| <j:forEach items="${mtc2.responseHeaders}" var="header" indexVar="i"> |
| header[${i}] = ${header} |
| </j:forEach> |
| </j:if> |
| </j:if> |
| <j:if test='${mtc1.statusCode != 200}'> |
| Results for mtc1 url are: |
| http return code = ${mtc1.statusCode} |
| http status text = '${mtc1.statusText}' |
| size of result = ${mtc1.responseBodyAsString.length()} |
| response time = ${mtc1.responseTime} |
| |
| <j:forEach items="${mtc1.responseHeaders}" var="header" indexVar="i"> |
| header[${i}] = ${header} |
| </j:forEach> |
| </j:if> |
| ${httpServerHeadOnly.stop(false)} |
| ${httpServerDefault.stop(false)} |
| |
| </j:jelly> |