| Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
| GoldenFileTag |
|
| 1.0;1 |
| 1 | /* | |
| 2 | * Copyright 1999-2001,2004 The Apache Software Foundation. | |
| 3 | * | |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); | |
| 5 | * you may not use this file except in compliance with the License. | |
| 6 | * You may obtain a copy of the License at | |
| 7 | * | |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 | |
| 9 | * | |
| 10 | * Unless required by applicable law or agreed to in writing, software | |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, | |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| 13 | * See the License for the specific language governing permissions and | |
| 14 | * limitations under the License. | |
| 15 | */ | |
| 16 | ||
| 17 | package org.apache.commons.latka.jelly.validators; | |
| 18 | ||
| 19 | import java.io.File; | |
| 20 | ||
| 21 | import org.apache.commons.latka.Validator; | |
| 22 | import org.apache.commons.latka.validators.GoldenFileValidator; | |
| 23 | ||
| 24 | import org.apache.log4j.Category; | |
| 25 | ||
| 26 | /** | |
| 27 | * A class to compare an HTTP response to a golden | |
| 28 | * file | |
| 29 | * | |
| 30 | * @author Morgan Delagrange | |
| 31 | * @version $Id: GoldenFileTag.java 155424 2005-02-26 13:09:29Z dirkv $ | |
| 32 | */ | |
| 33 | 0 | public class GoldenFileTag extends HttpValidatorTagSupport { |
| 34 | ||
| 35 | 0 | protected String _fileName = null; |
| 36 | 0 | protected boolean _ignoreWhitespace = false; |
| 37 | ||
| 38 | 0 | protected static final Category _log = Category.getInstance(GoldenFileTag.class); |
| 39 | ||
| 40 | /** | |
| 41 | * return the golden file validator | |
| 42 | * | |
| 43 | * @return golden file validator | |
| 44 | */ | |
| 45 | public Validator getValidator() { | |
| 46 | 0 | GoldenFileValidator validator = |
| 47 | new GoldenFileValidator(_label, new File(_fileName)); | |
| 48 | 0 | validator.setIgnoreWhitespace(_ignoreWhitespace); |
| 49 | ||
| 50 | 0 | return validator; |
| 51 | } | |
| 52 | ||
| 53 | /** | |
| 54 | * whether or not to ignore whitespace | |
| 55 | * | |
| 56 | * @param ignoreWhitespace | |
| 57 | * whether or not to ignore whitespace | |
| 58 | */ | |
| 59 | public void setIgnoreWhitespace(boolean ignoreWhitespace) { | |
| 60 | 0 | _ignoreWhitespace = ignoreWhitespace; |
| 61 | 0 | } |
| 62 | ||
| 63 | /** | |
| 64 | * set the file name for the golden file | |
| 65 | * | |
| 66 | * @param fileName golden file name | |
| 67 | */ | |
| 68 | public void setFileName(String fileName) { | |
| 69 | 0 | _fileName = fileName; |
| 70 | 0 | } |
| 71 | ||
| 72 | } |