|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| RequestDirectives.java | 50% | 77.8% | 85.7% | 77.8% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 2003-2004 The Apache Software Foundation.
|
|
| 5 |
*
|
|
| 6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 7 |
* you may not use this file except in compliance with the License.
|
|
| 8 |
* You may obtain a copy of the License at
|
|
| 9 |
*
|
|
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 11 |
*
|
|
| 12 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 13 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 15 |
* See the License for the specific language governing permissions and
|
|
| 16 |
* limitations under the License.
|
|
| 17 |
*
|
|
| 18 |
* ========================================================================
|
|
| 19 |
*/
|
|
| 20 |
package org.apache.cactus.internal;
|
|
| 21 |
|
|
| 22 |
import org.apache.cactus.WebRequest;
|
|
| 23 |
|
|
| 24 |
/**
|
|
| 25 |
* Encapsulates the Cactus-specific parameters added to a request.
|
|
| 26 |
*
|
|
| 27 |
* @version $Id: RequestDirectives.java 238991 2004-05-22 11:34:50Z vmassol $
|
|
| 28 |
*/
|
|
| 29 |
public class RequestDirectives |
|
| 30 |
{
|
|
| 31 |
/**
|
|
| 32 |
* The WebRequest that the directives modifies.
|
|
| 33 |
*/
|
|
| 34 |
private WebRequest underlyingRequest;
|
|
| 35 |
|
|
| 36 |
/**
|
|
| 37 |
* @param theRequest The WebRequest to read directives from or
|
|
| 38 |
* apply directives to.
|
|
| 39 |
*/
|
|
| 40 | 48 |
public RequestDirectives(WebRequest theRequest)
|
| 41 |
{
|
|
| 42 | 48 |
this.underlyingRequest = theRequest;
|
| 43 |
} |
|
| 44 |
|
|
| 45 |
/**
|
|
| 46 |
* @param theName name of the test class.
|
|
| 47 |
*/
|
|
| 48 | 24 |
public void setClassName(String theName) |
| 49 |
{
|
|
| 50 | 24 |
addDirective(HttpServiceDefinition.CLASS_NAME_PARAM, theName); |
| 51 |
} |
|
| 52 |
|
|
| 53 |
/**
|
|
| 54 |
* @param theName The name of the wrapped test.
|
|
| 55 |
*/
|
|
| 56 | 0 |
public void setWrappedTestName(String theName) |
| 57 |
{
|
|
| 58 | 0 |
addDirective(HttpServiceDefinition.WRAPPED_CLASS_NAME_PARAM, theName); |
| 59 |
} |
|
| 60 |
|
|
| 61 |
/**
|
|
| 62 |
* @param theName name of the test method to execute.
|
|
| 63 |
*/
|
|
| 64 | 24 |
public void setMethodName(String theName) |
| 65 |
{
|
|
| 66 | 24 |
addDirective(HttpServiceDefinition.METHOD_NAME_PARAM, theName); |
| 67 |
} |
|
| 68 |
|
|
| 69 |
/**
|
|
| 70 |
* @param theService The service to request of the redirector.
|
|
| 71 |
*/
|
|
| 72 | 24 |
public void setService(ServiceEnumeration theService) |
| 73 |
{
|
|
| 74 | 24 |
addDirective(HttpServiceDefinition.SERVICE_NAME_PARAM, |
| 75 |
theService.toString()); |
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
/**
|
|
| 79 |
* @param isAutoSession A "boolean string" indicating
|
|
| 80 |
* whether or not to use the
|
|
| 81 |
* autoSession option.
|
|
| 82 |
*/
|
|
| 83 | 24 |
public void setAutoSession(String isAutoSession) |
| 84 |
{
|
|
| 85 | 24 |
addDirective(HttpServiceDefinition.AUTOSESSION_NAME_PARAM, |
| 86 |
isAutoSession); |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
/**
|
|
| 90 |
* Adds a cactus-specific command to the URL of the WebRequest
|
|
| 91 |
* The URL is used to allow the user to send whatever he wants
|
|
| 92 |
* in the request body. For example a file, ...
|
|
| 93 |
*
|
|
| 94 |
* @param theName The name of the directive to add
|
|
| 95 |
* @param theValue The directive value
|
|
| 96 |
* @throws IllegalArgumentException If the directive name is invalid
|
|
| 97 |
*/
|
|
| 98 | 96 |
private void addDirective(String theName, String theValue) |
| 99 |
throws IllegalArgumentException
|
|
| 100 |
{
|
|
| 101 | 96 |
if (!theName.startsWith(HttpServiceDefinition.COMMAND_PREFIX))
|
| 102 |
{
|
|
| 103 | 0 |
throw new IllegalArgumentException("Cactus directives must begin" |
| 104 |
+ " with [" + HttpServiceDefinition.COMMAND_PREFIX
|
|
| 105 |
+ "]. The offending directive was [" + theName + "]"); |
|
| 106 |
} |
|
| 107 | 96 |
underlyingRequest.addParameter(theName, theValue, |
| 108 |
WebRequest.GET_METHOD); |
|
| 109 |
} |
|
| 110 |
|
|
| 111 |
} |
|
| 112 |
|
|
||||||||||