@@ -0,0 +1,3352 @@
+/*%0D%0A * Licensed to the Apache Software Foundation (ASF) under one%0D%0A * or more contributor license agreements.  See the NOTICE file%0D%0A * distributed with this work for additional information%0D%0A * regarding copyright ownership.  The ASF licenses this file%0D%0A * to you under the Apache License, Version 2.0 (the%0D%0A * %22License%22); you may not use this file except in compliance%0D%0A * with the License.  You may obtain a copy of the License at%0D%0A *%0D%0A * http://www.apache.org/licenses/LICENSE-2.0%0D%0A *%0D%0A * Unless required by applicable law or agreed to in writing,%0D%0A * software distributed under the License is distributed on an%0D%0A * %22AS IS%22 BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY%0D%0A * KIND, either express or implied.  See the License for the%0D%0A * specific language governing permissions and limitations%0D%0A * under the License.%0D%0A */%0D%0Apackage org.apache.webbeans.test.portable.events;%0D%0A%0D%0Aimport org.apache.webbeans.test.AbstractUnitTest;%0D%0Aimport org.junit.Test;%0D%0A%0D%0Aimport javax.enterprise.event.Observes;%0D%0Aimport javax.enterprise.inject.spi.AfterBeanDiscovery;%0D%0Aimport javax.enterprise.inject.spi.AnnotatedType;%0D%0Aimport javax.enterprise.inject.spi.BeanManager;%0D%0Aimport javax.enterprise.inject.spi.Extension;%0D%0Aimport javax.inject.Inject;%0D%0Aimport java.util.Collections;%0D%0A%0D%0Aimport static org.junit.Assert.assertNotNull;%0D%0A%0D%0Apublic class AfterBeanDiscoveryEventTest extends AbstractUnitTest %7B%0D%0A    @Inject%0D%0A    private MyWrapper wrapper;%0D%0A%0D%0A    @Test%0D%0A    public void validCase()%0D%0A    %7B%0D%0A        addExtension(new MyExtension());%0D%0A        startContainer(Collections.%3CClass%3C?%3E%3EemptyList(), Collections.%3CString%3EemptyList(), true);%0D%0A        wrapper.check();%0D%0A    %7D%0D%0A%0D%0A    public static class MyExtension implements Extension%0D%0A    %7B%0D%0A        public void createBeans(@Observes final AfterBeanDiscovery afterBeanDiscovery, final BeanManager beanManager)%0D%0A        %7B%0D%0A            // 1. shouldn't throw IllegalStateException at this stage%0D%0A            beanManager.getBeans(Object.class);%0D%0A%0D%0A            // 2. create a bean with an injection before adding the injection bean (concurrent extensions case)%0D%0A            %7B%0D%0A                final AnnotatedType%3CMyWrapper%3E annotatedType = beanManager.createAnnotatedType(MyWrapper.class);%0D%0A                // injections point can't be validated yet, should be after the whole phase%0D%0A                beanManager.createInjectionTarget(annotatedType);%0D%0A%0D%0A                // add the bean%0D%0A                afterBeanDiscovery.addBean(beanManager.createBean(%0D%0A                        beanManager.createBeanAttributes(annotatedType), MyWrapper.class,%0D%0A                        beanManager.getInjectionTargetFactory(annotatedType)));%0D%0A            %7D%0D%0A%0D%0A            // 3. add the injected bean%0D%0A            %7B%0D%0A                final AnnotatedType%3CMyInjection%3E annotatedType = beanManager.createAnnotatedType(MyInjection.class);%0D%0A                afterBeanDiscovery.addBean(beanManager.createBean(%0D%0A                        beanManager.createBeanAttributes(annotatedType), MyInjection.class,%0D%0A                        beanManager.getInjectionTargetFactory(annotatedType)));%0D%0A            %7D%0D%0A        %7D%0D%0A    %7D%0D%0A%0D%0A    public static class MyInjection%0D%0A    %7B%0D%0A    %7D%0D%0A%0D%0A    public static class MyWrapper%0D%0A    %7B%0D%0A        @Inject%0D%0A        private MyInjection inj;%0D%0A%0D%0A        public void check()%0D%0A        %7B%0D%0A            assertNotNull(inj);%0D%0A        %7D%0D%0A    %7D%0D%0A%7D%0D%0A

test for last commit