KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > hivemind > TestOccurances


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 org.apache.hivemind;
16
17 import org.apache.hivemind.definition.Occurances;
18
19 import junit.framework.TestCase;
20
21 /**
22  * Tests {@link org.apache.hivemind.definition.Occurances#inRange(int)} for different
23  * types of occurances.
24  *
25  * @author Howard Lewis Ship
26  */

27 public class TestOccurances extends TestCase
28 {
29     public void testNone()
30     {
31         Occurances o = Occurances.NONE;
32
33         assertEquals(true, o.inRange(0));
34         assertEquals(false, o.inRange(1));
35     }
36
37     public void testOnePlus()
38     {
39         Occurances o = Occurances.ONE_PLUS;
40         assertEquals(false, o.inRange(0));
41         assertEquals(true, o.inRange(1));
42         assertEquals(true, o.inRange(2));
43     }
44
45     public void testRequired()
46     {
47         Occurances o = Occurances.REQUIRED;
48
49         assertEquals(false, o.inRange(0));
50         assertEquals(true, o.inRange(1));
51         assertEquals(false, o.inRange(2));
52     }
53
54     public void testUnbounded()
55     {
56         Occurances o = Occurances.UNBOUNDED;
57
58         assertEquals(true, o.inRange(0));
59         assertEquals(true, o.inRange(1));
60         assertEquals(true, o.inRange(2));
61     }
62
63     public void testOptional()
64     {
65         Occurances o = Occurances.OPTIONAL;
66
67         assertEquals(true, o.inRange(0));
68         assertEquals(true, o.inRange(1));
69         assertEquals(false, o.inRange(2));
70     }
71 }
72
Popular Tags