All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.picocontainer.lifecycle.CompositeLifecycleStrategyTestCase Maven / Gradle / Ivy

There is a newer version: 2.15
Show newest version
package org.picocontainer.lifecycle;

import org.junit.Test;
import static org.junit.Assert.assertEquals;
import org.picocontainer.DefaultPicoContainer;
import static org.picocontainer.Characteristics.CACHE;
import org.picocontainer.containers.EmptyPicoContainer;
import org.picocontainer.monitors.NullComponentMonitor;

public class CompositeLifecycleStrategyTestCase {
    
    @Test
    public void testMixOfThirdPartyAndBuiltInStartableAndDisposable() {
        DefaultPicoContainer pico = new DefaultPicoContainer(new CompositeLifecycleStrategy(
                    new MyStartableLifecycleStrategy(),
                    new StartableLifecycleStrategy(new NullComponentMonitor())),
                new EmptyPicoContainer());
        StringBuilder sb = new StringBuilder();
        pico.addComponent(sb);
        pico.as(CACHE).addComponent(ThirdPartyStartableComponent.class);
        pico.as(CACHE).addComponent(BuiltInStartableComponent.class);
        pico.start();
        pico.stop();
        pico.dispose();
        assertEquals("<<>>!!", sb.toString());
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy