Coverage Report - org.apache.commons.latka.validators.StatusTextValidator
 
Classes in this File Line Coverage Branch Coverage Complexity
StatusTextValidator
0%
0/12
0%
0/2
1.25
 
 1  
 /*
 2  
  * Copyright 1999-2002,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.validators;
 18  
 
 19  
 import org.apache.commons.latka.ValidationException;
 20  
 
 21  
 import org.apache.commons.latka.http.Response;
 22  
 
 23  
 /**
 24  
  * Validates a Response according to its HTTP status text
 25  
  * (the text portion of the status line, eg typically 
 26  
  * 'OK' for 200 responses).  The status text is not
 27  
  * strictly standardizes the way status codes are; in most
 28  
  * cases, you are better off checking just the
 29  
  * status code.  
 30  
  * 
 31  
  * @author Morgan Delagrange
 32  
  * @author dIon Gillard
 33  
  * @version $Id: StatusTextValidator.java 155424 2005-02-26 13:09:29Z dirkv $
 34  
  */
 35  
 public class StatusTextValidator extends BaseValidator {
 36  
 
 37  
     // --------------------------------------------------------------- Attributes
 38  
 
 39  0
     protected String _statusText = null;
 40  
 
 41  
     // ------------------------------------------------------------- Constructors
 42  
 
 43  
     public StatusTextValidator() {
 44  0
         this(null,null);
 45  0
     }
 46  
 
 47  
     public StatusTextValidator(String label, String text) {
 48  0
         super(label);
 49  0
         _statusText = text;
 50  0
     }
 51  
 
 52  
     // ------------------------------------------------------------------ Methods
 53  
 
 54  
     public void setStatusText(String text) {
 55  0
         _statusText = text;
 56  0
     }
 57  
 
 58  
     public void validate(Response response)
 59  
     throws ValidationException {
 60  
 
 61  0
         String responseStatusText = response.getStatusText();
 62  0
         if (!_statusText.equals(responseStatusText)) {
 63  0
             fail("EXPECTED STATUS TEXT '" + _statusText + "', FOUND '" + responseStatusText +
 64  
                  "'");
 65  
         }
 66  0
     }
 67  
 }