001package org.picocontainer.behaviors;
002
003import static org.junit.Assert.assertNotNull;
004import static org.junit.Assert.assertNull;
005import static org.picocontainer.Characteristics.LOCK;
006import static org.picocontainer.Characteristics.NO_LOCK;
007
008import org.junit.Test;
009import org.picocontainer.ComponentFactory;
010import org.picocontainer.MutablePicoContainer;
011import org.picocontainer.PicoBuilder;
012import org.picocontainer.injectors.AdaptingInjection;
013import org.picocontainer.tck.AbstractComponentFactoryTest;
014
015
016public class LockingTestCase extends AbstractComponentFactoryTest {
017
018        private final ComponentFactory locking = new Locking().wrap(new AdaptingInjection());
019
020
021        @Test
022        public void testPicocontainerPropertiesIntegration() {
023                MutablePicoContainer mpc = new PicoBuilder().withBehaviors(new Locking()).build();
024                mpc.as(LOCK).addComponent("locked","It is locked");
025                mpc.as(NO_LOCK).addComponent("not locked", "It is not locked");
026                
027                assertNotNull(mpc.getComponentAdapter("locked").findAdapterOfType(Locked.class));
028                assertNull(mpc.getComponentAdapter("not locked").findAdapterOfType(Locked.class));
029                
030        }
031
032        @Override
033        protected ComponentFactory createComponentFactory() {
034                return locking;
035        }
036
037}