Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@apache.org Received: (qmail 18959 invoked from network); 3 May 2002 19:08:09 -0000 Received: from unknown (HELO nagoya.betaversion.org) (192.18.49.131) by daedalus.apache.org with SMTP; 3 May 2002 19:08:09 -0000 Received: (qmail 3963 invoked by uid 97); 3 May 2002 19:08:13 -0000 Delivered-To: qmlist-jakarta-archive-commons-dev@nagoya.betaversion.org Received: (qmail 3883 invoked by alias); 3 May 2002 19:08:13 -0000 Delivered-To: jakarta-archive-commons-dev@jakarta.apache.org Received: (qmail 3868 invoked by uid 97); 3 May 2002 19:08:12 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 3817 invoked by alias); 3 May 2002 19:08:11 -0000 X-Antivirus: nagoya (v4198 created Apr 24 2002) Date: 3 May 2002 19:08:02 -0000 Message-ID: <20020503190802.94469.qmail@icarus.apache.org> From: morgand@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/latka/src/java/org/apache/commons/latka/validators RegexpValidator.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N morgand 02/05/03 12:08:02 Modified: latka/src/java/org/apache/commons/latka/validators RegexpValidator.java Log: Validator would throw NullPointerException when it encountered a null HTTP body response. Revision Changes Path 1.9 +20 -3 jakarta-commons/latka/src/java/org/apache/commons/latka/validators/RegexpValidator.java Index: RegexpValidator.java =================================================================== RCS file: /home/cvs/jakarta-commons/latka/src/java/org/apache/commons/latka/validators/RegexpValidator.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- RegexpValidator.java 2 May 2002 22:25:44 -0000 1.8 +++ RegexpValidator.java 3 May 2002 19:08:02 -0000 1.9 @@ -70,11 +70,16 @@ import org.apache.regexp.RESyntaxException; /** - * FIXME: Docs - * + * Perform regular expression matches on the body of + * the HTTP response. Setting the "condition" attribute + * of the test indicates whether or not a match + * is expected. If the server returns a null + * (e.g. in the case of an empty HEAD response), the + * match will always return false. + * * @author Morgan Delagrange * @author dIon Gillard - * @version $Id: RegexpValidator.java,v 1.8 2002/05/02 22:25:44 morgand Exp $ + * @version $Id: RegexpValidator.java,v 1.9 2002/05/03 19:08:02 morgand Exp $ */ public class RegexpValidator extends BaseConditionalValidator implements Validator { @@ -82,6 +87,7 @@ protected String _pattern = null; protected boolean _ignoreCase = false; + protected boolean _wasResponseBodyNull = false; protected static final String BARE_EXCEPTION_MESSAGE = " TO MATCH PATTERN: "; @@ -114,6 +120,12 @@ public boolean assertTrue(Response response) throws ValidationException { + String responseBody = response.getResource(); + if (responseBody == null) { + _wasResponseBodyNull = true; + return false; + } + RE r = null; try { r = new RE(_pattern); // Compile expression @@ -133,6 +145,11 @@ } public String generateBareExceptionMessage() { + if (_wasResponseBodyNull == true) { + return BARE_EXCEPTION_MESSAGE + _pattern + + " (HTTP response body was null.)"; + } + return BARE_EXCEPTION_MESSAGE + _pattern; } -- To unsubscribe, e-mail: For additional commands, e-mail: