package org.picocontainer.doc.tutorial.blocks;

import junit.framework.TestCase;

import org.picocontainer.MutablePicoContainer;
import org.picocontainer.defaults.CachingComponentAdapter;
import org.picocontainer.defaults.ConstructorInjectionComponentAdapter;
import org.picocontainer.defaults.DefaultPicoContainer;
import org.picocontainer.defaults.InstanceComponentAdapter;
import org.picocontainer.doc.introduction.Apple;
import org.picocontainer.doc.introduction.Juicer;
import org.picocontainer.doc.introduction.Peeler;

/**
 * Test case for the snippets used in "Component Adapters and Factories"
 * @author J&ouml;rg Schaible
 */
public class BuildingBlocksTestCase extends TestCase {
    public void testRegisterConvenient() {
        // START SNIPPET: register-convenient
        MutablePicoContainer picoContainer = new DefaultPicoContainer();
        picoContainer.registerComponentImplementation(Juicer.class);
        picoContainer.registerComponentImplementation("My Peeler", Peeler.class);
        picoContainer.registerComponentInstance(new Apple());
        // END SNIPPET: register-convenient
        // START SNIPPET: register-direct
        picoContainer.registerComponent(new InstanceComponentAdapter("Another Apple", new Apple()));
        // END SNIPPET: register-direct
    }
    
    public void testRegisterEquivalentConvenient() {
        MutablePicoContainer picoContainer = new DefaultPicoContainer();
        // START SNIPPET: register-equivalent-convenient
        picoContainer.registerComponentImplementation(Juicer.class);
        // END SNIPPET: register-equivalent-convenient
    }
    
    public void testRegisterEquivalentAtLength() {
        MutablePicoContainer picoContainer = new DefaultPicoContainer();
        // START SNIPPET: register-equivalent-at-length
        picoContainer.registerComponent(
                new CachingComponentAdapter(
                        new ConstructorInjectionComponentAdapter(
                                Juicer.class, Juicer.class, null)));
        // END SNIPPET: register-equivalent-at-length
    }
}

Add first version of tutorial for CAs.