Clover coverage report - Code Coverage for hivemind release 1.1.1
Coverage timestamp: Sat Jan 28 2006 10:19:31 PST
file stats: LOC: 54   Methods: 2
NCLOC: 25   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
RegexpMatcher.java - 100% 100% 100%
coverage
 1    // Copyright 2004, 2005 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   
 22    /**
 23    * A {@link org.apache.hivemind.test.ArgumentMatcher} implementation that treats the expected
 24    * value (provided while training the mock object) as a Perl5 Regular expression, which is matched
 25    * against the actual value.
 26    *
 27    * @author Howard Lewis Ship
 28    * @since 1.1
 29    */
 30    public class RegexpMatcher extends AbstractArgumentMatcher
 31    {
 32    private static Perl5Compiler _compiler = new Perl5Compiler();
 33   
 34    private static Perl5Matcher _matcher = new Perl5Matcher();
 35   
 36  3 public boolean compareArguments(Object expected, Object actual)
 37    {
 38  3 return matchRegexp((String) expected, (String) actual);
 39    }
 40   
 41  3 private boolean matchRegexp(String expectedRegexp, String actualString)
 42    {
 43  3 try
 44    {
 45  3 Pattern p = _compiler.compile(expectedRegexp);
 46   
 47  2 return _matcher.matches(actualString, p);
 48    }
 49    catch (Exception ex)
 50    {
 51  1 throw new ApplicationRuntimeException(ex);
 52    }
 53    }
 54    }