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 *****************************************************************************/ 010 package org.picocontainer.behaviors; 011 012 013 import static org.junit.Assert.assertNotNull; 014 import static org.junit.Assert.assertNull; 015 import static org.picocontainer.Characteristics.NO_SYNCHRONIZE; 016 import static org.picocontainer.Characteristics.SYNCHRONIZE; 017 018 import org.junit.Test; 019 import org.picocontainer.ComponentFactory; 020 import org.picocontainer.MutablePicoContainer; 021 import org.picocontainer.PicoBuilder; 022 import org.picocontainer.injectors.AdaptingInjection; 023 import org.picocontainer.tck.AbstractComponentFactoryTest; 024 025 public 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 }