001/*****************************************************************************
002 * Copyright (C) PicoContainer Organization. All rights reserved.            *
003 * ------------------------------------------------------------------------- *
004 * The software in this package is published under the terms of the BSD      *
005 * style license a copy of which has been included with this distribution in *
006 * the LICENSE.txt file.                                                     *
007 *                                                                           *
008 * Original code by                                                          *
009 *****************************************************************************/
010package org.picocontainer.behaviors;
011
012
013import static org.junit.Assert.assertNotNull;
014import static org.junit.Assert.assertNull;
015import static org.picocontainer.Characteristics.NO_SYNCHRONIZE;
016import static org.picocontainer.Characteristics.SYNCHRONIZE;
017
018import org.junit.Test;
019import org.picocontainer.ComponentFactory;
020import org.picocontainer.MutablePicoContainer;
021import org.picocontainer.PicoBuilder;
022import org.picocontainer.injectors.AdaptingInjection;
023import org.picocontainer.tck.AbstractComponentFactoryTest;
024
025public class SynchronizingTestCase extends AbstractComponentFactoryTest {
026
027        private final ComponentFactory synchronizing = new Synchronizing().wrap(new AdaptingInjection());
028        
029
030        @Override
031        protected ComponentFactory createComponentFactory() {
032                return synchronizing;           
033        }
034        
035        @Test
036        public void testPicoContainerPropertiesIntegration() {
037                MutablePicoContainer mpc = new PicoBuilder().withBehaviors(new Synchronizing()).build();
038                mpc.as(SYNCHRONIZE).addComponent("a", "This is a test");
039                mpc.as(NO_SYNCHRONIZE).addComponent("b","This is a test");
040                
041                assertNotNull(mpc.getComponentAdapter("a").findAdapterOfType(Synchronized.class));
042                assertNull(mpc.getComponentAdapter("b").findAdapterOfType(Synchronized.class));
043        }
044        
045        
046
047}