001package org.picocontainer.defaults.issues;
002
003import org.junit.Test;import static org.junit.Assert.assertFalse;
004import org.picocontainer.Startable;
005import org.picocontainer.DefaultPicoContainer;
006import org.picocontainer.ComponentAdapter;
007import org.picocontainer.Characteristics;
008import org.picocontainer.behaviors.Cached;
009
010public class Issue0353TestCase {
011
012    public static class FooStartable implements Startable {
013                public void start() {
014                        // empty
015                }
016
017                public void stop() {
018                        // empty
019                }
020        }
021
022        @Test
023        public void testIsStartedShouldNotThrowOnNonStartedComponent() {
024                DefaultPicoContainer cont = new DefaultPicoContainer();
025                cont.as(Characteristics.CACHE).addComponent(FooStartable.class);
026                ComponentAdapter<?> adapter = cont.getComponentAdapter(FooStartable.class);
027                Cached cached = adapter.findAdapterOfType(Cached.class);
028
029               // this line throws - instead of returning false
030                assertFalse(cached.isStarted());
031        }
032
033}