KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > enterprise > deploy > shared > CommandTypeTest


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

17
18 //
19
// This source code implements specifications defined by the Java
20
// Community Process. In order to remain compliant with the specification
21
// DO NOT add / change / or delete method signatures!
22
//
23

24 package javax.enterprise.deploy.shared;
25
26 import junit.framework.TestCase;
27
28 public class CommandTypeTest extends TestCase {
29     public void testValues() {
30         assertEquals(0, CommandType.DISTRIBUTE.getValue());
31         assertEquals(1, CommandType.START.getValue());
32         assertEquals(2, CommandType.STOP.getValue());
33         assertEquals(3, CommandType.UNDEPLOY.getValue());
34         assertEquals(4, CommandType.REDEPLOY.getValue());
35     }
36
37     public void testToString() {
38         assertEquals("distribute", CommandType.DISTRIBUTE.toString());
39         assertEquals("start", CommandType.START.toString());
40         assertEquals("stop", CommandType.STOP.toString());
41         assertEquals("undeploy", CommandType.UNDEPLOY.toString());
42         assertEquals("redeploy", CommandType.REDEPLOY.toString());
43         // only possible due to package local access
44
assertEquals("10", new ActionType(10).toString());
45         assertEquals("-1", new ActionType(-1).toString());
46     }
47
48     public void testValueToSmall() {
49         try {
50             CommandType.getCommandType(-1);
51             fail("Expected AIOOBE");
52         } catch (ArrayIndexOutOfBoundsException aioobe) {
53         }
54     }
55
56     public void testValueToLarge() {
57         try {
58             CommandType.getCommandType(10);
59             fail("Expected AIOOBE");
60         } catch (ArrayIndexOutOfBoundsException aioobe) {
61         }
62     }
63 }
64
Popular Tags