Return-Path: X-Original-To: apmail-openwebbeans-commits-archive@www.apache.org Delivered-To: apmail-openwebbeans-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 71AA599C4 for ; Sun, 1 Apr 2012 16:31:23 +0000 (UTC) Received: (qmail 50669 invoked by uid 500); 1 Apr 2012 16:31:23 -0000 Delivered-To: apmail-openwebbeans-commits-archive@openwebbeans.apache.org Received: (qmail 50647 invoked by uid 500); 1 Apr 2012 16:31:23 -0000 Mailing-List: contact commits-help@openwebbeans.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@openwebbeans.apache.org Delivered-To: mailing list commits@openwebbeans.apache.org Received: (qmail 50635 invoked by uid 99); 1 Apr 2012 16:31:23 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Apr 2012 16:31:23 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 01 Apr 2012 16:31:19 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 4A5EC238899C for ; Sun, 1 Apr 2012 16:30:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1308149 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives: common/YetAnotherPencil.java tests/AlternativeBeanResolvingTest.java tests/AlternativeProducerMethodTest.java Date: Sun, 01 Apr 2012 16:30:58 -0000 To: commits@openwebbeans.apache.org From: struberg@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20120401163058.4A5EC238899C@eris.apache.org> Author: struberg Date: Sun Apr 1 16:30:57 2012 New Revision: 1308149 URL: http://svn.apache.org/viewvc?rev=1308149&view=rev Log: OWB-658 test for InjectionResolver fix which slipped into r1308123 already Please note that the behaviour might still not be 100% deterministic for such cases as the spec leaves too much room for interpretation. I'll take that to the CDI EG and come back with a solution and final fix later. Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/YetAnotherPencil.java openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeBeanResolvingTest.java Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/YetAnotherPencil.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/YetAnotherPencil.java?rev=1308149&view=auto ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/YetAnotherPencil.java (added) +++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/common/YetAnotherPencil.java Sun Apr 1 16:30:57 2012 @@ -0,0 +1,27 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.webbeans.newtests.concepts.alternatives.common; + +import javax.enterprise.context.RequestScoped; + +@Pen +@RequestScoped +public class YetAnotherPencil +{ +} Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeBeanResolvingTest.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeBeanResolvingTest.java?rev=1308149&view=auto ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeBeanResolvingTest.java (added) +++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeBeanResolvingTest.java Sun Apr 1 16:30:57 2012 @@ -0,0 +1,73 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.webbeans.newtests.concepts.alternatives.tests; + +import javax.enterprise.inject.spi.Bean; +import javax.enterprise.util.AnnotationLiteral; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Set; + +import org.apache.webbeans.newtests.AbstractUnitTest; +import org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeOnClassAndProducerMethodBean; +import org.apache.webbeans.newtests.concepts.alternatives.common.AlternativeOnClassOnlyBean; +import org.apache.webbeans.newtests.concepts.alternatives.common.DefaultBeanProducerWithoutDisposes; +import org.apache.webbeans.newtests.concepts.alternatives.common.Pen; +import org.apache.webbeans.newtests.concepts.alternatives.common.Pencil; +import org.apache.webbeans.newtests.concepts.alternatives.common.PencilProducerBean; +import org.apache.webbeans.newtests.concepts.alternatives.common.YetAnotherPencil; +import org.junit.Test; +import org.junit.Assert; + +/** + * Test bean resolving if @Alternative annotated beans are involved + * See OWB-658 for the original problem. + */ +public class AlternativeBeanResolvingTest extends AbstractUnitTest +{ + private static final String PACKAGE_NAME = AlternativeProducerMethodTest.class.getPackage().getName(); + + /** + * see OWB-658 + */ + @Test + public void testObjectBeanQuery() + { + Collection beanXmls = new ArrayList(); + beanXmls.add(getXmlPath(PACKAGE_NAME, "AlternativeOnProducerFieldTest")); + + Collection> beanClasses = new ArrayList>(); + beanClasses.add(Pen.class); + beanClasses.add(Pencil.class); + beanClasses.add(PencilProducerBean.class); + beanClasses.add(DefaultBeanProducerWithoutDisposes.class); + beanClasses.add(AlternativeOnClassAndProducerMethodBean.class); + beanClasses.add(YetAnotherPencil.class); + + // available but not enabled in beans.xml + beanClasses.add(AlternativeOnClassOnlyBean.class); + + startContainer(beanClasses, null); + + Set> beans = getBeanManager().getBeans(Object.class, new AnnotationLiteral(){}); + Assert.assertNotNull(beans); + Assert.assertEquals(2, beans.size()); + } + +} Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java?rev=1308149&r1=1308148&r2=1308149&view=diff ============================================================================== --- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java (original) +++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/concepts/alternatives/tests/AlternativeProducerMethodTest.java Sun Apr 1 16:30:57 2012 @@ -104,12 +104,7 @@ public class AlternativeProducerMethodTe startContainer(beanClasses, beanXmls); - Annotation[] anns = new Annotation[1]; - anns[0] = new AnnotationLiteral() - { - }; - - IProducedBean producedBean = getInstance(IProducedBean.class, anns); + IProducedBean producedBean = getInstance(IProducedBean.class, new AnnotationLiteral(){}); Assert.assertNotNull(producedBean); Assert.assertEquals("AlternativeOnClassAndProducerMethodBean", producedBean.getProducerType());