01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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: */package org.apache.geronimo.kernel.management;
17:
18: import junit.framework.TestCase;
19:
20: /**
21: * Unit test for org.apache.geronimo.common.State class
22: *
23: * @version $Rev: 476049 $ $Date: 2006-11-16 20:35:17 -0800 (Thu, 16 Nov 2006) $
24: */
25:
26: public class StateTest extends TestCase {
27:
28: public void testValues() {
29:
30: assertEquals(0, State.STARTING_INDEX);
31: assertEquals(1, State.RUNNING_INDEX);
32: assertEquals(2, State.STOPPING_INDEX);
33: assertEquals(3, State.STOPPED_INDEX);
34: assertEquals(4, State.FAILED_INDEX);
35:
36: assertEquals(0, State.STARTING.toInt());
37: assertEquals(1, State.RUNNING.toInt());
38: assertEquals(2, State.STOPPING.toInt());
39: assertEquals(3, State.STOPPED.toInt());
40: assertEquals(4, State.FAILED.toInt());
41: }
42:
43: public void testLessThanMin() {
44: assertNull(State.fromInt(-1));
45: }
46:
47: public void testGreaterThanMax() {
48: assertNull(State.fromInt(5));
49: }
50:
51: public void testName() {
52: assertEquals("starting", State.STARTING.toString());
53: assertEquals("running", State.RUNNING.toString());
54: assertEquals("stopping", State.STOPPING.toString());
55: assertEquals("stopped", State.STOPPED.toString());
56: assertEquals("failed", State.FAILED.toString());
57: }
58:
59: public void testEventTypeValue() {
60: assertEquals("j2ee.state.starting", State.STARTING
61: .getEventTypeValue());
62: assertEquals("j2ee.state.running", State.RUNNING
63: .getEventTypeValue());
64: assertEquals("j2ee.state.stopping", State.STOPPING
65: .getEventTypeValue());
66: assertEquals("j2ee.state.stopped", State.STOPPED
67: .getEventTypeValue());
68: assertEquals("j2ee.state.failed", State.FAILED
69: .getEventTypeValue());
70: }
71: }
|