hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind/framework/src/test/org/apache/hivemind/test TestRegexpMatcher.java TestArrayMatcher.java
Date Mon, 04 Apr 2005 14:08:50 GMT
hlship      2005/04/04 07:08:50

  Modified:    framework/src/java/org/apache/hivemind/test
                        RegexpMatcher.java ArrayMatcher.java
                        AggregateArgumentsMatcher.java EqualsMatcher.java
                        ArgumentMatcher.java TypeMatcher.java
               framework/src/test/org/apache/hivemind/schema/rules
                        TestCreateObjectRule.java
               .        status.xml
               framework/src/test/org/apache/hivemind/test
                        TestRegexpMatcher.java TestArrayMatcher.java
  Added:       framework/src/java/org/apache/hivemind/test
                        AbstractArgumentMatcher.java
  Log:
  Add an AbstractArgumentMatcher that allows ArgumentMatcher to be used as ArgumentsMatcher
(that is, comparing all arguments). <
  
  Revision  Changes    Path
  1.4       +5 -4      jakarta-hivemind/framework/src/java/org/apache/hivemind/test/RegexpMatcher.java
  
  Index: RegexpMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/RegexpMatcher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- RegexpMatcher.java	5 Jan 2005 18:05:14 -0000	1.3
  +++ RegexpMatcher.java	4 Apr 2005 14:08:50 -0000	1.4
  @@ -20,19 +20,20 @@
   import org.apache.oro.text.regex.Perl5Matcher;
   
   /**
  - * A {@link org.apache.hivemind.test.ArgumentMatcher}implementation treates the expected
value as a
  - * Perl5 Regular expression, which is matched against the actual value.
  + * A {@link org.apache.hivemind.test.ArgumentMatcher}&nbsp;implementation that treats
the expected
  + * value (provided while training the mock object) as a Perl5 Regular expression, which
is matched
  + * against the actual value.
    * 
    * @author Howard Lewis Ship
    * @since 1.1
    */
  -public class RegexpMatcher implements ArgumentMatcher
  +public class RegexpMatcher extends AbstractArgumentMatcher
   {
       private static Perl5Compiler _compiler = new Perl5Compiler();
   
       private static Perl5Matcher _matcher = new Perl5Matcher();
   
  -    public boolean matches(Object expected, Object actual)
  +    public boolean compareArguments(Object expected, Object actual)
       {
           return matchRegexp((String) expected, (String) actual);
       }
  
  
  
  1.3       +4 -2      jakarta-hivemind/framework/src/java/org/apache/hivemind/test/ArrayMatcher.java
  
  Index: ArrayMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/ArrayMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArrayMatcher.java	5 Jan 2005 18:05:14 -0000	1.2
  +++ ArrayMatcher.java	4 Apr 2005 14:08:50 -0000	1.3
  @@ -14,16 +14,18 @@
   
   package org.apache.hivemind.test;
   
  +import org.easymock.AbstractMatcher;
  +
   /**
    * Used when the arguments to compare are a non-primitive array type.
    * 
    * @author Howard M. Lewis Ship
    * @since 1.1
    */
  -public class ArrayMatcher implements ArgumentMatcher
  +public class ArrayMatcher extends AbstractArgumentMatcher
   {
   
  -    public boolean matches(Object expected, Object actual)
  +    public boolean compareArguments(Object expected, Object actual)
       {
           Object[] e = (Object[]) expected;
           Object[] a = (Object[]) actual;
  
  
  
  1.4       +1 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/test/AggregateArgumentsMatcher.java
  
  Index: AggregateArgumentsMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/AggregateArgumentsMatcher.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- AggregateArgumentsMatcher.java	5 Jan 2005 18:05:14 -0000	1.3
  +++ AggregateArgumentsMatcher.java	4 Apr 2005 14:08:50 -0000	1.4
  @@ -69,7 +69,7 @@
   
           ArgumentMatcher am = getArgumentMatcher(argumentIndex);
   
  -        return am.matches(expected, actual);
  +        return am.compareArguments(expected, actual);
       }
   
       private ArgumentMatcher getArgumentMatcher(int argumentIndex)
  
  
  
  1.3       +2 -2      jakarta-hivemind/framework/src/java/org/apache/hivemind/test/EqualsMatcher.java
  
  Index: EqualsMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/EqualsMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- EqualsMatcher.java	5 Jan 2005 18:05:14 -0000	1.2
  +++ EqualsMatcher.java	4 Apr 2005 14:08:50 -0000	1.3
  @@ -18,13 +18,13 @@
    * @author Howard M. Lewis Ship
    * @since 1.1
    */
  -public class EqualsMatcher implements ArgumentMatcher
  +public class EqualsMatcher extends AbstractArgumentMatcher
   {
   
       /**
        * Simple matcher based on <code>equals()</code>.
        */
  -    public boolean matches(Object expected, Object actual)
  +    public boolean compareArguments(Object expected, Object actual)
       {
           return expected.equals(actual);
       }
  
  
  
  1.3       +5 -4      jakarta-hivemind/framework/src/java/org/apache/hivemind/test/ArgumentMatcher.java
  
  Index: ArgumentMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/ArgumentMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ArgumentMatcher.java	5 Jan 2005 18:05:14 -0000	1.2
  +++ ArgumentMatcher.java	4 Apr 2005 14:08:50 -0000	1.3
  @@ -24,15 +24,16 @@
   public interface ArgumentMatcher
   {
       /**
  -     * Returns true if the two objects are considered the same. This method is only invoked
if both
  -     * arguments are non-null and not the same object (identity comparison, not
  -     * <code>equals()</code>).
  +     * Compares an expected argument value (provided when training the mock object), against
the
  +     * actual argument value. This method is only invoked if both arguments are non-null
and not the
  +     * same object (based on identity comparison, not <code>equals()</code>).
        * 
        * @param expected
        *            The expected argument value
        * @param actual
        *            The actual argument value
  +     * @returns true if the two objects can be considered the same, false otherwise.
        */
   
  -    public boolean matches(Object expected, Object actual);
  +    public boolean compareArguments(Object expected, Object actual);
   }
  \ No newline at end of file
  
  
  
  1.3       +2 -2      jakarta-hivemind/framework/src/java/org/apache/hivemind/test/TypeMatcher.java
  
  Index: TypeMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/TypeMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TypeMatcher.java	5 Jan 2005 18:05:14 -0000	1.2
  +++ TypeMatcher.java	4 Apr 2005 14:08:50 -0000	1.3
  @@ -23,9 +23,9 @@
    * 
    * @author Howard Lewis Ship
    */
  -public class TypeMatcher implements ArgumentMatcher
  +public class TypeMatcher extends AbstractArgumentMatcher
   {
  -    public boolean matches(Object expected, Object actual)
  +    public boolean compareArguments(Object expected, Object actual)
       {
           return expected.getClass().equals(actual.getClass());
       }
  
  
  
  1.1                  jakarta-hivemind/framework/src/java/org/apache/hivemind/test/AbstractArgumentMatcher.java
  
  Index: AbstractArgumentMatcher.java
  ===================================================================
  // Copyright 2005 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;
  
  /**
   * Base class that bridges from EasyMock's {@link org.easymock.AbstractMatcher}&nbsp;to
HiveMind's
   * {@link org.apache.hivemind.test.ArgumentMatcher}. Since all the {@link ArgumentMatcher}
   * &nbsp;implementations extend this class, each can be used with {@link AbstractArgumentMatcher}
   * &nbsp;to compare a <em>single</em> argument, or on its own to match <em>all</em>
arguments.
   * 
   * @author Howard M. Lewis Ship
   * @since 3.1
   */
  public abstract class AbstractArgumentMatcher extends AbstractMatcher implements ArgumentMatcher
  {
  
      protected boolean argumentMatches(Object expected, Object actual)
      {
          return compareArguments(expected, actual);
      }
  }
  
  
  1.2       +1 -1      jakarta-hivemind/framework/src/test/org/apache/hivemind/schema/rules/TestCreateObjectRule.java
  
  Index: TestCreateObjectRule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/schema/rules/TestCreateObjectRule.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestCreateObjectRule.java	19 Feb 2005 17:57:40 -0000	1.1
  +++ TestCreateObjectRule.java	4 Apr 2005 14:08:50 -0000	1.2
  @@ -68,7 +68,7 @@
           processor.push(new Bean());
           control.setMatcher(new AggregateArgumentsMatcher(new ArgumentMatcher()
           {
  -            public boolean matches(Object expected, Object actual)
  +            public boolean compareArguments(Object expected, Object actual)
               {
                   Bean b = (Bean) actual;
   
  
  
  
  1.120     +1 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.119
  retrieving revision 1.120
  diff -u -r1.119 -r1.120
  --- status.xml	31 Mar 2005 16:07:03 -0000	1.119
  +++ status.xml	4 Apr 2005 14:08:50 -0000	1.120
  @@ -37,6 +37,7 @@
         <action type="update" dev="HLS"> Make the interface attribute of &lt;service-point&gt;
optional, and default to the service point's id. </action>
         <action type="fix" dev="HLS" fixes-bug="HIVEMIND-104">Remove a potential deadlock
related to the pooled service model.</action>
         <action type="fix" dev="HLS" fixes-bug="HIVEMIND-83"> Allow for running with
multiple Registries. </action>
  +      <action type="add" dev="HLS"> Add an AbstractArgumentMatcher that allows ArgumentMatcher
to be used as ArgumentsMatcher (that is, comparing all arguments). </action>
       </release>
       <release version="1.1-alpha-3" date="Mar 22 2005">
         <action type="fix" dev="JC" fixes-bug="HIVEMIND-96" >Interceptors can now be
ordered by name rather than interceptor factory id.</action>
  
  
  
  1.3       +3 -3      jakarta-hivemind/framework/src/test/org/apache/hivemind/test/TestRegexpMatcher.java
  
  Index: TestRegexpMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/test/TestRegexpMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestRegexpMatcher.java	5 Jan 2005 18:04:06 -0000	1.2
  +++ TestRegexpMatcher.java	4 Apr 2005 14:08:50 -0000	1.3
  @@ -28,8 +28,8 @@
       {
           RegexpMatcher m = new RegexpMatcher();
   
  -        assertEquals(true, m.matches("f.*bar", "foobar"));
  -        assertEquals(false, m.matches("zip.*zap", "zoop"));
  +        assertEquals(true, m.compareArguments("f.*bar", "foobar"));
  +        assertEquals(false, m.compareArguments("zip.*zap", "zoop"));
       }
   
       public void testBadPattern()
  @@ -38,7 +38,7 @@
   
           try
           {
  -            m.matches("[missing", "foobar");
  +            m.compareArguments("[missing", "foobar");
               unreachable();
           }
           catch (ApplicationRuntimeException ex)
  
  
  
  1.3       +4 -4      jakarta-hivemind/framework/src/test/org/apache/hivemind/test/TestArrayMatcher.java
  
  Index: TestArrayMatcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/test/TestArrayMatcher.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestArrayMatcher.java	5 Jan 2005 18:04:08 -0000	1.2
  +++ TestArrayMatcher.java	4 Apr 2005 14:08:50 -0000	1.3
  @@ -29,24 +29,24 @@
   
       public void testActualIsNull()
       {
  -        assertEquals(false, _matcher.matches(_expected, null));
  +        assertEquals(false, _matcher.compareArguments(_expected, null));
       }
   
       public void testWrongElementCount()
       {
  -        assertEquals(false, _matcher.matches(_expected, new Object[]
  +        assertEquals(false, _matcher.compareArguments(_expected, new Object[]
           { "barney", "wilma" }));
       }
   
       public void testMismatch()
       {
  -        assertEquals(false, _matcher.matches(_expected, new Object[]
  +        assertEquals(false, _matcher.compareArguments(_expected, new Object[]
           { "barney" }));
       }
   
       public void testMatch()
       {
  -        assertEquals(true, _matcher.matches(_expected, new Object[]
  +        assertEquals(true, _matcher.compareArguments(_expected, new Object[]
           { "fred" }));
       }
   }
  \ No newline at end of file
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message