KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > record > TestChangeKey


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.record;
16
17 import org.apache.hivemind.test.HiveMindTestCase;
18
19 /**
20  * Tests for {@link org.apache.tapestry.record.ChangeKey}.
21  *
22  * @author Howard M. Lewis Ship
23  * @since 4.0
24  */

25 public class TestChangeKey extends HiveMindTestCase
26 {
27     public void testSetters()
28     {
29         ChangeKey key = new ChangeKey("path", "name");
30
31         assertEquals("path", key.getComponentPath());
32         assertEquals("name", key.getPropertyName());
33
34         key = new ChangeKey(null, "foo");
35
36         assertNull(key.getComponentPath());
37         assertEquals("foo", key.getPropertyName());
38     }
39
40     public void testHashCode()
41     {
42         ChangeKey key1 = new ChangeKey("path", "name1");
43         ChangeKey key2 = new ChangeKey("path", "name1");
44         ChangeKey key3 = new ChangeKey(null, "name2");
45
46         assertEquals(key1.hashCode(), key2.hashCode());
47         assertTrue(key1.hashCode() != key3.hashCode());
48     }
49
50     public void testEquals()
51     {
52         ChangeKey key1 = new ChangeKey("path", "name1");
53         ChangeKey key2 = new ChangeKey("path", "name1");
54         ChangeKey key3 = new ChangeKey(null, "name2");
55
56         assertTrue(key1.equals(key2));
57         assertFalse(key1.equals(key3));
58
59         assertFalse(key1.equals(null));
60         assertTrue(key1.equals(key1));
61         assertFalse(key1.equals("foo"));
62     }
63 }
Popular Tags