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 @Override
014 public void start() {
015 // empty
016 }
017
018 @Override
019 public void stop() {
020 // empty
021 }
022 }
023
024 @Test
025 public void testIsStartedShouldNotThrowOnNonStartedComponent() {
026 DefaultPicoContainer cont = new DefaultPicoContainer();
027 cont.as(Characteristics.CACHE).addComponent(FooStartable.class);
028 ComponentAdapter<?> adapter = cont.getComponentAdapter(FooStartable.class);
029 Cached cached = adapter.findAdapterOfType(Cached.class);
030
031 // this line throws - instead of returning false
032 assertFalse(cached.isStarted());
033 }
034
035 }