001 /*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved. *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file. *
007 *****************************************************************************/
008 package org.picocontainer.lifecycle;
009
010 import static org.junit.Assert.assertFalse;
011 import static org.junit.Assert.assertTrue;
012 import static org.picocontainer.lifecycle.LifecycleState.CONSTRUCTED;
013 import static org.picocontainer.lifecycle.LifecycleState.DISPOSED;
014 import static org.picocontainer.lifecycle.LifecycleState.STARTED;
015 import static org.picocontainer.lifecycle.LifecycleState.STOPPED;
016
017 import org.junit.Test;
018
019 /**
020 * @author Michael Rimov
021 */
022 public class LifecycleStateTestCase {
023
024 @Test public void testIsStartAllowedOptions() {
025 assertTrue(CONSTRUCTED.isStartAllowed());
026 assertFalse(STARTED.isStartAllowed());
027 assertTrue(STOPPED.isStartAllowed());
028 assertFalse(DISPOSED.isStartAllowed());
029 }
030
031 @Test public void testIsStopAllowedOptions() {
032 assertFalse(CONSTRUCTED.isStopAllowed());
033 assertTrue(STARTED.isStopAllowed());
034 assertFalse(STOPPED.isStopAllowed());
035 assertFalse(DISPOSED.isStopAllowed());
036 }
037
038 @Test public void testIsDisposeAllowedOptions() {
039 assertTrue(CONSTRUCTED.isDisposedAllowed());
040 assertFalse(STARTED.isDisposedAllowed());
041 assertTrue(STOPPED.isDisposedAllowed());
042 assertFalse(DISPOSED.isDisposedAllowed());
043 }
044
045 }