Debian Codegraph @

jdbm1/src/test/java/jdbm/recman/LocationTest.java

raw
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20 package jdbm.recman;
21
22
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertFalse;
25
26 import org.junit.BeforeClass;
27 import org.junit.Ignore;
28 import org.junit.Test;
29 import org.junit.runner.RunWith;
30
31 import com.mycila.junit.concurrent.ConcurrentJunitRunner;
32
33
34 /**
35 * Unit tests class LocationEntry.
36 *
37 * @author <a href="mailto:[email protected]">Apache Directory Project</a>
38 */
39 @RunWith(ConcurrentJunitRunner.class)
40 public class LocationTest
41 {
42 private static Location clonedServerEntryA;
43 private static Location clonedServerEntryACopy;
44 private static Location clonedServerEntryB;
45 private static Location clonedServerEntryA1;
46 private static Location clonedServerEntryACopy1;
47 private static Location clonedServerEntryB1;
48 private static Location clonedServerEntryC1;
49 private static Location clonedServerEntryD1;
50
51
52 /**
53 * Initialize name instances
54 */
55 @BeforeClass
56 public static void initNames() throws Exception
57 {
58 clonedServerEntryA = new Location( 1L );
59 clonedServerEntryACopy = new Location( 1L );
60 clonedServerEntryB = new Location( 1L );
61 clonedServerEntryA1 = new Location( 1L, ( short ) 1 );
62 clonedServerEntryACopy1 = new Location( 1L, ( short ) 1 );
63 clonedServerEntryB1 = new Location( 1L, ( short ) 1 );
64 clonedServerEntryC1 = new Location( 1L, ( short ) 2 );
65 clonedServerEntryD1 = new Location( 2L, ( short ) 1 );
66 }
67
68
69 @Test
70 public void testEqualsNull() throws Exception
71 {
72 assertFalse( clonedServerEntryA.equals( null ) );
73 assertFalse( clonedServerEntryA1.equals( null ) );
74 }
75
76
77 @Test
78 public void testEqualsReflexive() throws Exception
79 {
80 assertEquals( clonedServerEntryA, clonedServerEntryA );
81 assertEquals( clonedServerEntryA1, clonedServerEntryA1 );
82 }
83
84
85 @Test
86 public void testHashCodeReflexive() throws Exception
87 {
88 assertEquals( clonedServerEntryA.hashCode(), clonedServerEntryA.hashCode() );
89 assertEquals( clonedServerEntryA1.hashCode(), clonedServerEntryA1.hashCode() );
90 }
91
92
93 @Test
94 public void testEqualsSymmetric() throws Exception
95 {
96 assertEquals( clonedServerEntryA, clonedServerEntryACopy );
97 assertEquals( clonedServerEntryACopy, clonedServerEntryA );
98 assertEquals( clonedServerEntryA1, clonedServerEntryACopy1 );
99 assertEquals( clonedServerEntryACopy1, clonedServerEntryA1 );
100 }
101
102
103 @Test
104 @Ignore
105 public void testHashCodeSymmetric() throws Exception
106 {
107 assertEquals( clonedServerEntryA.hashCode(), clonedServerEntryACopy.hashCode() );
108 assertEquals( clonedServerEntryACopy.hashCode(), clonedServerEntryA.hashCode() );
109 assertEquals( clonedServerEntryA1.hashCode(), clonedServerEntryACopy1.hashCode() );
110 assertEquals( clonedServerEntryACopy1.hashCode(), clonedServerEntryA1.hashCode() );
111 }
112
113
114 @Test
115 public void testEqualsTransitive() throws Exception
116 {
117 assertEquals( clonedServerEntryA, clonedServerEntryACopy );
118 assertEquals( clonedServerEntryACopy, clonedServerEntryB );
119 assertEquals( clonedServerEntryA, clonedServerEntryB );
120 assertEquals( clonedServerEntryA1, clonedServerEntryACopy1 );
121 assertEquals( clonedServerEntryACopy1, clonedServerEntryB1 );
122 assertEquals( clonedServerEntryA1, clonedServerEntryB1 );
123 }
124
125
126 @Test
127 @Ignore
128 public void testHashCodeTransitive() throws Exception
129 {
130 assertEquals( clonedServerEntryA.hashCode(), clonedServerEntryACopy.hashCode() );
131 assertEquals( clonedServerEntryACopy.hashCode(), clonedServerEntryB.hashCode() );
132 assertEquals( clonedServerEntryA.hashCode(), clonedServerEntryB.hashCode() );
133 assertEquals( clonedServerEntryA1.hashCode(), clonedServerEntryACopy1.hashCode() );
134 assertEquals( clonedServerEntryACopy1.hashCode(), clonedServerEntryB1.hashCode() );
135 assertEquals( clonedServerEntryA1.hashCode(), clonedServerEntryB1.hashCode() );
136 }
137
138
139 @Test
140 public void testNotEqualDiffValue() throws Exception
141 {
142 assertFalse( clonedServerEntryA1.equals( clonedServerEntryC1 ) );
143 assertFalse( clonedServerEntryC1.equals( clonedServerEntryA1 ) );
144 assertFalse( clonedServerEntryA1.equals( clonedServerEntryD1 ) );
145 assertFalse( clonedServerEntryD1.equals( clonedServerEntryA1 ) );
146 }
147 }