01: package org.drools.base;
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 org.drools.spi.FieldValue;
20:
21: import junit.framework.Assert;
22: import junit.framework.TestCase;
23:
24: public class FieldValueTest extends TestCase {
25: FieldValue field1;
26: FieldValue field2;
27: FieldValue field3;
28: FieldValue field4;
29: FieldValue field5;
30:
31: protected void setUp() throws Exception {
32: super .setUp();
33: this .field1 = FieldFactory.getFieldValue(null);
34: this .field2 = FieldFactory.getFieldValue(null);
35: this .field3 = FieldFactory.getFieldValue("A");
36: this .field4 = FieldFactory.getFieldValue("A");
37: this .field5 = FieldFactory.getFieldValue("B");
38:
39: }
40:
41: protected void tearDown() throws Exception {
42: super .tearDown();
43: }
44:
45: /*
46: * Test method for 'org.drools.base.FieldValue.hashCode()'
47: */
48: public void testHashCode() {
49: Assert.assertEquals(this .field1.hashCode(), this .field1
50: .hashCode());
51: Assert.assertEquals(this .field1.hashCode(), this .field2
52: .hashCode());
53: Assert.assertEquals(this .field3.hashCode(), this .field3
54: .hashCode());
55: Assert.assertEquals(this .field3.hashCode(), this .field4
56: .hashCode());
57: Assert.assertFalse(this .field1.hashCode() == this .field3
58: .hashCode());
59: Assert.assertFalse(this .field3.hashCode() == this .field1
60: .hashCode());
61: Assert.assertFalse(this .field3.hashCode() == this .field5
62: .hashCode());
63: }
64:
65: /*
66: * Test method for 'org.drools.base.FieldValue.equals(Object)'
67: */
68: public void testEqualsObject() {
69: Assert.assertEquals(this.field1, this.field1);
70: Assert.assertEquals(this.field1, this.field2);
71: Assert.assertEquals(this.field3, this.field3);
72: Assert.assertEquals(this.field3, this.field4);
73: Assert.assertFalse(this.field1.equals(this.field3));
74: Assert.assertFalse(this.field3.equals(this.field1));
75: Assert.assertFalse(this.field3.equals(this.field5));
76: }
77:
78: }
|