Clover coverage report - Code Coverage for hivemind release 1.0
Coverage timestamp: Wed Sep 22 2004 08:05:25 EDT
file stats: LOC: 56   Methods: 2
NCLOC: 29   Classes: 1
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
RegexpArgumentsMatcher.java 0% 0% 0% 0%
coverage
 1   
 //  Copyright 2004 The Apache Software Foundation
 2   
 //
 3   
 // Licensed under the Apache License, Version 2.0 (the "License");
 4   
 // you may not use this file except in compliance with the License.
 5   
 // You may obtain a copy of the License at
 6   
 //
 7   
 //     http://www.apache.org/licenses/LICENSE-2.0
 8   
 //
 9   
 // Unless required by applicable law or agreed to in writing, software
 10   
 // distributed under the License is distributed on an "AS IS" BASIS,
 11   
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12   
 // See the License for the specific language governing permissions and
 13   
 // limitations under the License.
 14   
 
 15   
 package org.apache.hivemind.test;
 16   
 
 17   
 import org.apache.hivemind.ApplicationRuntimeException;
 18   
 import org.apache.oro.text.regex.Pattern;
 19   
 import org.apache.oro.text.regex.Perl5Compiler;
 20   
 import org.apache.oro.text.regex.Perl5Matcher;
 21   
 import org.easymock.AbstractMatcher;
 22   
 
 23   
 /**
 24   
  * An EasyMock ArgumentsMatcher implementation that treats expected strings
 25   
  * as regular expressions.
 26   
  *
 27   
  * @author Howard Lewis Ship
 28   
  */
 29   
 public class RegexpArgumentsMatcher extends AbstractMatcher
 30   
 {
 31   
     private static Perl5Compiler _compiler = new Perl5Compiler();
 32   
     private static Perl5Matcher _matcher = new Perl5Matcher();
 33   
 
 34  0
     protected boolean argumentMatches(Object expected, Object actual)
 35   
     {
 36  0
         if (expected instanceof String)
 37  0
             return matchRegexp((String) expected, (String) actual);
 38   
 
 39  0
         return super.argumentMatches(expected, actual);
 40   
     }
 41   
 
 42  0
     private boolean matchRegexp(String expectedRegexp, String actualString)
 43   
     {
 44  0
         try
 45   
         {
 46  0
             Pattern p = _compiler.compile(expectedRegexp);
 47   
 
 48  0
             return _matcher.matches(actualString, p);
 49   
         }
 50   
         catch (Exception ex)
 51   
         {
 52  0
             throw new ApplicationRuntimeException(ex);
 53   
         }
 54   
     }
 55   
 }
 56