hlship      2004/07/20 10:26:26

  Modified:    framework/src/test/hivemind/test/services
                        TestBuilderFactory.java
               framework/src/conf log4j.properties
               framework/src/test/org/apache/hivemind/order
                        TestOrderer.java
  Added:       framework/src/java/org/apache/hivemind/test
                        RegexpArgumentsMatcher.java
                        ExceptionAwareArgumentsMatcher.java
  Removed:     framework/src/test/org/apache/hivemind
                        ExceptionAwareArgumentsMatcher.java
  Log:
  Move some EasyMock ArgumentMatcher implementations into the framework proper.
  
  Revision  Changes    Path
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/test/RegexpArgumentsMatcher.java
  
  Index: RegexpArgumentsMatcher.java
  ===================================================================
  package org.apache.hivemind.test;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.oro.text.regex.Pattern;
  import org.apache.oro.text.regex.Perl5Compiler;
  import org.apache.oro.text.regex.Perl5Matcher;
  import org.easymock.AbstractMatcher;
  
  /**
   * An EasyMock ArgumentsMatcher implementation that treats expected strings
   * as regular expressions.
   *
   * @author Howard Lewis Ship
   */
  public class RegexpArgumentsMatcher extends AbstractMatcher
  {
      private static Perl5Compiler _compiler = new Perl5Compiler();
      private static Perl5Matcher _matcher = new Perl5Matcher();
  
      protected boolean argumentMatches(Object expected, Object actual)
      {
          if (expected instanceof String)
              return matchRegexp((String) expected, (String) actual);
  
          return super.argumentMatches(expected, actual);
      }
  
      private boolean matchRegexp(String expectedRegexp, String actualString)
      {
          try
          {
              Pattern p = _compiler.compile(expectedRegexp);
  
              return _matcher.matches(actualString, p);
          }
          catch (Exception ex)
          {
              throw new ApplicationRuntimeException(ex);
          }
      }
  }
  
  
  
  1.1                  
jakarta-hivemind/framework/src/java/org/apache/hivemind/test/ExceptionAwareArgumentsMatcher.java
  
  Index: ExceptionAwareArgumentsMatcher.java
  ===================================================================
  //  Copyright 2004 The Apache Software Foundation
  //
  // Licensed under the Apache License, Version 2.0 (the "License");
  // you may not use this file except in compliance with the License.
  // You may obtain a copy of the License at
  //
  //     http://www.apache.org/licenses/LICENSE-2.0
  //
  // Unless required by applicable law or agreed to in writing, software
  // distributed under the License is distributed on an "AS IS" BASIS,
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  // See the License for the specific language governing permissions and
  // limitations under the License.
  
  package org.apache.hivemind.test;
  
  import org.easymock.AbstractMatcher;
  
  /**
   * An EasyMock ArgumentsMatcher that is savvy about Throwables ... it just 
compares
   * the type (since exceptions don't compare well). This allows a check that 
the
   * right type of exception was thrown (even if it doesn't check that
   * the exception's message and other properties are correct).
   *
   * @author Howard Lewis Ship
   */
  public class ExceptionAwareArgumentsMatcher extends AbstractMatcher
  {
      protected boolean argumentMatches(Object expected, Object actual)
      {
          if (expected instanceof Throwable)
              return expected.getClass().equals(actual.getClass());
  
          return super.argumentMatches(expected, actual);
      }
  
  }
  
  
  1.12      +1 -1      
jakarta-hivemind/framework/src/test/hivemind/test/services/TestBuilderFactory.java
  
  Index: TestBuilderFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/services/TestBuilderFactory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestBuilderFactory.java   19 Jul 2004 13:46:02 -0000      1.11
  +++ TestBuilderFactory.java   20 Jul 2004 17:26:25 -0000      1.12
  @@ -23,7 +23,6 @@
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.ClassResolver;
   import org.apache.hivemind.ErrorHandler;
  -import org.apache.hivemind.ExceptionAwareArgumentsMatcher;
   import org.apache.hivemind.Messages;
   import org.apache.hivemind.Registry;
   import org.apache.hivemind.impl.DefaultClassResolver;
  @@ -38,6 +37,7 @@
   import org.apache.hivemind.service.impl.BuilderMessagesFacet;
   import org.apache.hivemind.service.impl.BuilderParameter;
   import org.apache.hivemind.service.impl.BuilderServiceIdFacet;
  +import org.apache.hivemind.test.ExceptionAwareArgumentsMatcher;
   import org.apache.hivemind.test.HiveMindTestCase;
   import org.easymock.MockControl;
   
  
  
  
  1.5       +15 -1     jakarta-hivemind/framework/src/conf/log4j.properties
  
  Index: log4j.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/conf/log4j.properties,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- log4j.properties  9 Jun 2004 14:47:44 -0000       1.4
  +++ log4j.properties  20 Jul 2004 17:26:25 -0000      1.5
  @@ -1,4 +1,18 @@
  -# $Id$
  +#
  +# Copyright 2004 The Apache Software Foundation
  +#
  +# Licensed under the Apache License, Version 2.0 (the "License");
  +# you may not use this file except in compliance with the License.
  +# You may obtain a copy of the License at
  +#
  +#     http://www.apache.org/licenses/LICENSE-2.0
  +#
  +# Unless required by applicable law or agreed to in writing, software
  +# distributed under the License is distributed on an "AS IS" BASIS,
  +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  +# See the License for the specific language governing permissions and
  +# limitations under the License.
  +
   log4j.rootCategory=WARN, A1
   
   # A1 is set to be a ConsoleAppender. 
  
  
  
  1.9       +1 -1      
jakarta-hivemind/framework/src/test/org/apache/hivemind/order/TestOrderer.java
  
  Index: TestOrderer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/order/TestOrderer.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestOrderer.java  18 Jul 2004 14:43:12 -0000      1.8
  +++ TestOrderer.java  20 Jul 2004 17:26:26 -0000      1.9
  @@ -22,8 +22,8 @@
   import org.apache.commons.logging.LogFactory;
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.ErrorHandler;
  -import org.apache.hivemind.ExceptionAwareArgumentsMatcher;
   import org.apache.hivemind.impl.DefaultErrorHandler;
  +import org.apache.hivemind.test.ExceptionAwareArgumentsMatcher;
   import org.easymock.MockControl;
   
   /**
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to