001 package org.picocontainer.behaviors; 002 003 import static org.junit.Assert.assertNotNull; 004 import static org.junit.Assert.assertNull; 005 import static org.picocontainer.Characteristics.LOCK; 006 import static org.picocontainer.Characteristics.NO_LOCK; 007 008 import org.junit.Test; 009 import org.picocontainer.ComponentFactory; 010 import org.picocontainer.MutablePicoContainer; 011 import org.picocontainer.PicoBuilder; 012 import org.picocontainer.injectors.AdaptingInjection; 013 import org.picocontainer.tck.AbstractComponentFactoryTest; 014 015 016 public 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 }