    001    package org.picocontainer.lifecycle;
    002
    003    import org.junit.Test;
    004    import static org.junit.Assert.assertEquals;
    005    import org.picocontainer.DefaultPicoContainer;
    006    import static org.picocontainer.Characteristics.CACHE;
    007    import org.picocontainer.containers.EmptyPicoContainer;
    008    import org.picocontainer.monitors.NullComponentMonitor;
    009
    010    public class CompositeLifecycleStrategyTestCase {
    011
    012        @Test
    013        public void testMixOfThirdPartyAndBuiltInStartableAndDisposable() {
    014            DefaultPicoContainer pico = new DefaultPicoContainer(new CompositeLifecycleStrategy(
    015                        new MyStartableLifecycleStrategy(),
    016                        new StartableLifecycleStrategy(new NullComponentMonitor())),
    017                    new EmptyPicoContainer());
    018            StringBuilder sb = new StringBuilder();
    019            pico.addComponent(sb);
    020            pico.as(CACHE).addComponent(ThirdPartyStartableComponent.class);
    021            pico.as(CACHE).addComponent(BuiltInStartableComponent.class);
    022            pico.start();
    023            pico.stop();
    024            pico.dispose();
    025            assertEquals("<<>>!!", sb.toString());
    026        }
    027
    028    }