1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    *
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   *
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.commons.functor.core.composite;
18  
19  import static org.junit.Assert.assertEquals;
20  import static org.junit.Assert.assertFalse;
21  import static org.junit.Assert.assertNotNull;
22  import static org.junit.Assert.assertTrue;
23  
24  import org.apache.commons.functor.BaseFunctorTest;
25  import org.apache.commons.functor.Predicate;
26  import org.apache.commons.functor.Procedure;
27  import org.apache.commons.functor.core.Constant;
28  import org.apache.commons.functor.core.NoOp;
29  import org.junit.Test;
30  
31  /**
32   * @version $Revision: 1171267 $ $Date: 2011-09-15 22:46:08 +0200 (Thu, 15 Sep 2011) $
33   * @author Rodney Waldhoff
34   */
35  public class TestAbstractLoopProcedure extends BaseFunctorTest {
36  
37      // Functor Testing Framework
38      // ------------------------------------------------------------------------
39  
40      protected Object makeFunctor() {
41          return new MockLoopProcedure(Constant.FALSE, NoOp.INSTANCE);
42      }
43  
44      // tests
45      // ------------------------------------------------------------------------
46      @Test
47      public void testEqualsAndHashCodeWithNullArgs() {
48          Procedure p = new MockLoopProcedure(null,null);
49          assertNotNull(p.toString());
50          assertFalse(p.equals(null));
51          assertTrue(p.equals(p));
52          assertEquals(p.hashCode(),p.hashCode());
53      }
54  
55  }
56  
57  class MockLoopProcedure extends AbstractLoopProcedure {
58      public MockLoopProcedure(Predicate condition, Procedure action) {
59          super(condition,action);
60      }
61  
62      public void run() {
63      }
64  }