KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hivemind > test > TestHiveMindFindLocation


1 // Copyright 2004, 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 hivemind.test;
16
17 import org.apache.hivemind.HiveMind;
18 import org.apache.hivemind.Locatable;
19 import org.apache.hivemind.Location;
20 import org.apache.hivemind.impl.LocationImpl;
21
22 /**
23  * Tests the method {@link org.apache.hivemind.HiveMind#findLocation(Object[])}.
24  *
25  * @author Howard Lewis Ship
26  *
27  */

28 public class TestHiveMindFindLocation extends FrameworkTestCase
29 {
30     public void testEmpty()
31     {
32         assertNull(HiveMind.findLocation(new Object JavaDoc[] {
33         }));
34     }
35
36     public void testAllNull()
37     {
38         assertNull(HiveMind.findLocation(new Object JavaDoc[] { null, null, null }));
39     }
40
41     public void testOrdering()
42     {
43         Location l1 = new LocationImpl(null);
44         Location l2 = new LocationImpl(null);
45
46         assertSame(l1, HiveMind.findLocation(new Object JavaDoc[] { l1, l2 }));
47     }
48
49     public void testLocatable()
50     {
51         Location l1 = new LocationImpl(null);
52         Locatable l2 = new LocatableFixture(l1);
53
54         assertSame(l1, HiveMind.findLocation(new Object JavaDoc[] { l2 }));
55     }
56
57     public void testNullLocatable()
58     {
59         Location l1 = new LocationImpl(null);
60         Locatable l2 = new LocatableFixture(null);
61         Locatable l3 = new LocatableFixture(l1);
62
63         assertSame(l1, HiveMind.findLocation(new Object JavaDoc[] { l2, l3 }));
64     }
65
66     public void testSkipOther()
67     {
68         Location l1 = new LocationImpl(null);
69
70         assertSame(l1, HiveMind.findLocation(new Object JavaDoc[] { this, "Hello", l1, "Goodbye" }));
71     }
72
73     public void testToLocationStringNull()
74     {
75         assertEquals("unknown location", HiveMind.getLocationString(null));
76     }
77
78 }
79
Popular Tags