    001    package org.picocontainer.defaults.issues;
    002
    003    import org.junit.Test;import static org.junit.Assert.assertFalse;import static org.junit.Assert.assertSame;
    004    import org.picocontainer.Startable;
    005    import org.picocontainer.DefaultPicoContainer;
    006    import org.picocontainer.ComponentAdapter;
    007    import org.picocontainer.Characteristics;
    008    import org.picocontainer.injectors.ConstructorInjector;
    009    import org.picocontainer.injectors.SingleMemberInjector;
    010    import org.picocontainer.behaviors.Cached;
    011    import org.picocontainer.behaviors.Stored;
    012
    013    public class Issue0352TestCase {
    014
    015        public static class Foo {
    016            }
    017
    018            // This test failed before patch (see revision #5396)
    019            @Test
    020            public void testShouldFindSupertypeOfAdapterOnAbstractAdapterDerivative() {
    021                    ConstructorInjector<Foo> injector = new ConstructorInjector<Foo>("key", Foo.class);
    022                    assertSame(injector, injector.findAdapterOfType(SingleMemberInjector.class));
    023            }
    024
    025            // This test works
    026            @Test
    027            public void testShouldFindSupertypeOfAdapterOnAbstractBehaviorDerivative() {
    028                    ConstructorInjector<Foo> injector = new ConstructorInjector<Foo>("key", Foo.class);
    029                    Cached<Foo> adapter = new Cached<Foo>(injector);
    030                    assertSame(adapter, adapter.findAdapterOfType(Stored.class));
    031                    assertSame(injector, adapter.findAdapterOfType(SingleMemberInjector.class));
    032            }
    033
    034    }