001    package org.picocontainer.defaults.issues;
002    
003    import org.junit.Test;import static org.junit.Assert.assertFalse;
004    import org.picocontainer.Startable;
005    import org.picocontainer.DefaultPicoContainer;
006    import org.picocontainer.ComponentAdapter;
007    import org.picocontainer.Characteristics;
008    import org.picocontainer.behaviors.Cached;
009    
010    public 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    }