01: package org.drools.reteoo;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import junit.framework.TestCase;
20:
21: import org.drools.common.DefaultFactHandle;
22:
23: public class FactHandleTest extends TestCase {
24: /*
25: * Class under test for void FactHandleImpl(long)
26: */
27: public void testFactHandleImpllong() {
28: final DefaultFactHandle f0 = new DefaultFactHandle(134,
29: "cheese");
30: assertEquals(134, f0.getId());
31: assertEquals(134, f0.getRecency());
32: }
33:
34: /*
35: * Class under test for void FactHandleImpl(long, long)
36: */
37: public void testFactHandleImpllonglong() {
38: final DefaultFactHandle f0 = new DefaultFactHandle(134,
39: "cheese", 678);
40: assertEquals(134, f0.getId());
41: assertEquals(678, f0.getRecency());
42: }
43:
44: /*
45: * Class under test for boolean equals(Object)
46: */
47: public void testEqualsObject() {
48: final DefaultFactHandle f0 = new DefaultFactHandle(134,
49: "cheese");
50: final DefaultFactHandle f1 = new DefaultFactHandle(96, "cheese");
51: final DefaultFactHandle f3 = new DefaultFactHandle(96, "cheese");
52:
53: assertFalse("f0 should not equal f1", f0.equals(f1));
54: assertEquals(f1, f3);
55: assertNotSame(f1, f3);
56: }
57:
58: public void testHashCode() {
59: final DefaultFactHandle f0 = new DefaultFactHandle(234,
60: "cheese");
61: assertEquals("cheese".hashCode(), f0.getObjectHashCode());
62:
63: assertEquals(234, f0.hashCode());
64: }
65:
66: public void testInvalidate() {
67: final DefaultFactHandle f0 = new DefaultFactHandle(134,
68: "cheese");
69: assertEquals(134, f0.getId());
70:
71: f0.invalidate();
72: assertEquals(-1, f0.getId());
73: }
74:
75: }
|