    001    package org.picocontainer.defaults.issues;
    002
    003    import org.picocontainer.DefaultPicoContainer;
    004    import org.picocontainer.parameters.CollectionComponentParameter;
    005    import static org.junit.Assert.assertEquals;
    006    import org.junit.Test;
    007
    008    import java.util.List;
    009
    010    public class Issue0343TestCase {
    011
    012        @Test
    013        public void testRegisteringSubsetOfGenericCollectionParameters() {
    014            DefaultPicoContainer pico = new DefaultPicoContainer();
    015            pico.addComponent(Cod.class);
    016            pico.addComponent(Shark.class);
    017            pico.addComponent(GenericBowl.class, GenericBowl.class,
    018                    new CollectionComponentParameter(Cod.class, false));
    019
    020            GenericBowl bowl = pico.getComponent(GenericBowl.class);
    021            // FAILS with PicoContainer 2.7-SNAPSHOT, returns 2
    022            assertEquals(1, bowl.fishes.size());
    023        }
    024
    025        public static interface Fish {
    026        }
    027
    028        public static class Cod implements Fish {
    029        }
    030
    031        public static class Shark implements Fish {
    032        }
    033
    034        public static class GenericBowl {
    035            List<Fish> fishes;
    036
    037            public GenericBowl(List<Fish> fishes) {
    038                this.fishes = fishes;
    039            }
    040        }
    041
    042    }