Author: arne
Date: Thu Oct 11 20:43:17 2012
New Revision: 1397297
URL: http://svn.apache.org/viewvc?rev=1397297&view=rev
Log:
OWB-711 Fix overriding rules for observer methods
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Bean.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/EventTest.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Superclass.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/TestEvent.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanC.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanD.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanE.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanF.java
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/observer/
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/observer/AlternativeSpecializes.xml
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/ObserverTest.java
Modified:
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java?rev=1397297&r1=1397296&r2=1397297&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/main/java/org/apache/webbeans/util/AnnotationUtil.java
Thu Oct 11 20:43:17 2012
@@ -18,23 +18,26 @@
*/
package org.apache.webbeans.util;
-import org.apache.webbeans.exception.WebBeansException;
-
-import javax.enterprise.inject.Any;
-import javax.enterprise.inject.spi.AnnotatedMethod;
-import javax.enterprise.inject.spi.AnnotatedParameter;
-import javax.enterprise.inject.spi.Bean;
-import javax.enterprise.util.Nonbinding;
import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.lang.reflect.Type;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Set;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.spi.AnnotatedMethod;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.util.Nonbinding;
+
+import org.apache.webbeans.exception.WebBeansException;
+
/**
* Utility class related with {@link Annotation} operations.
*
@@ -408,6 +411,46 @@ public final class AnnotationUtil
}
/**
+ * Checks if the specified method is overridden by another method from the
list.
+ *
+ * @param method the method to check
+ * @param overridingCandidates the collection of methods potentially
overriding the specified method
+ * @return
+ */
+ public static boolean isMethodOverridden(Method method, Collection<Method>
overridingCandidates)
+ {
+ if (overridingCandidates.isEmpty() ||
Modifier.isPrivate(method.getModifiers()))
+ {
+ return false;
+ }
+ Class<?>[] methodParameterTypes = method.getParameterTypes();
+ boolean isOverridden = false;
+ candidates:
+ for (Method candidate : overridingCandidates) {
+ if (!candidate.getName().equals(method.getName()))
+ {
+ continue;
+ }
+ Class<?>[] candidateParameterTypes = candidate.getParameterTypes();
+ if (candidateParameterTypes.length != methodParameterTypes.length)
+ {
+ continue;
+ }
+ for (int i = 0; i < methodParameterTypes.length; i++)
+ {
+ if
(!candidateParameterTypes[i].equals(methodParameterTypes[i]))
+ {
+ continue candidates;
+ }
+ }
+ // we don't need to check the return type as that is done by the
java compiler
+ isOverridden = true;
+ break;
+ }
+ return isOverridden;
+ }
+
+ /**
* Quecks if the two values are equal.
*
* @param value1
@@ -591,7 +634,7 @@ public final class AnnotationUtil
for (Method m : methods)
{
- if (hasMethodParameterAnnotation(m, annotation))
+ if (hasMethodParameterAnnotation(m, annotation) &&
!isMethodOverridden(m, list))
{
list.add(m);
}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Bean.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Bean.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Bean.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Bean.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,44 @@
+/*
+ * 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.events.observer;
+
+
+import java.io.Serializable;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+@ApplicationScoped
+public class Bean extends Superclass implements Serializable
+{
+ private static final long serialVersionUID = 821164664338581947L;
+
+ protected void observeTestEvent(@Observes TestEvent testEvent)
+ {
+ testEvent.addInvocation(getBeanName());
+ }
+
+ @Override
+ public String getBeanName()
+ {
+ return super.getBeanName() + ":[subclass]";
+ }
+}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/EventTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/EventTest.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/EventTest.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/EventTest.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,46 @@
+/*
+ * 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.events.observer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class EventTest extends AbstractUnitTest {
+
+ @Test
+ public void testObserverMethodsInSpecializedBeans()
+ {
+ Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+ beanClasses.add(Superclass.class);
+ beanClasses.add(Bean.class);
+ startContainer(beanClasses, null);
+
+ TestEvent testEvent = new TestEvent();
+ getBeanManager().fireEvent(testEvent);
+
+ Assert.assertEquals(1, testEvent.getCalledObservers().size());
+
Assert.assertTrue(testEvent.getCalledObservers().iterator().next().endsWith(":[subclass]"));
+
+ shutDownContainer();
+ }
+}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Superclass.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Superclass.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Superclass.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/Superclass.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,35 @@
+/*
+ * 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.events.observer;
+
+import javax.enterprise.event.Observes;
+
+public class Superclass
+{
+
+ protected void observeTestEvent(@Observes TestEvent testEvent)
+ {
+ testEvent.addInvocation(getBeanName());
+ }
+
+ public String getBeanName()
+ {
+ return getClass().getSimpleName();
+ }
+}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/TestEvent.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/TestEvent.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/TestEvent.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/events/observer/TestEvent.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,37 @@
+/*
+ * 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.events.observer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestEvent
+{
+ private List<String> calledObserverNames = new ArrayList<String>();
+
+ public void addInvocation(String observerName)
+ {
+ this.calledObserverNames.add(observerName);
+ }
+
+ public List<String> getCalledObservers()
+ {
+ return calledObserverNames;
+ }
+}
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanC.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanC.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanC.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanC.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,38 @@
+/*
+ * 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.specalization.observer;
+
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+@Alternative
+@ApplicationScoped
+public class BeanC extends BeanA
+{
+ private static final long serialVersionUID = 821164664338581947L;
+
+ @Override
+ public String getBeanName()
+ {
+ return super.getBeanName() + ":[alternative]:[specialize]";
+ }
+}
\ No newline at end of file
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanD.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanD.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanD.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanD.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,44 @@
+/*
+ * 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.specalization.observer;
+
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Alternative;
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+@Alternative
+@ApplicationScoped
+public class BeanD extends BeanA
+{
+ private static final long serialVersionUID = 821164664338581947L;
+
+ protected void observeTestEvent(@Observes TestEvent testEvent)
+ {
+ testEvent.addInvocation(getBeanName());
+ }
+
+ @Override
+ public String getBeanName()
+ {
+ return super.getBeanName() + ":[alternative]:[specialize]";
+ }
+}
\ No newline at end of file
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanE.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanE.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanE.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanE.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,36 @@
+/*
+ * 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.specalization.observer;
+
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+@ApplicationScoped
+public class BeanE extends BeanA
+{
+ private static final long serialVersionUID = 821164664338581947L;
+
+ @Override
+ public String getBeanName()
+ {
+ return super.getBeanName() + ":[specialize]";
+ }
+}
\ No newline at end of file
Added:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanF.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanF.java?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanF.java
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/BeanF.java
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,42 @@
+/*
+ * 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.specalization.observer;
+
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.Specializes;
+
+@Specializes
+@ApplicationScoped
+public class BeanF extends BeanA
+{
+ private static final long serialVersionUID = 821164664338581947L;
+
+ protected void observeTestEvent(@Observes TestEvent testEvent)
+ {
+ testEvent.addInvocation(getBeanName());
+ }
+
+ @Override
+ public String getBeanName()
+ {
+ return super.getBeanName() + ":[specialize]";
+ }
+}
\ No newline at end of file
Modified:
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/ObserverTest.java
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/ObserverTest.java?rev=1397297&r1=1397296&r2=1397297&view=diff
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/ObserverTest.java
(original)
+++
openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/newtests/specalization/observer/ObserverTest.java
Thu Oct 11 20:43:17 2012
@@ -18,18 +18,20 @@
*/
package org.apache.webbeans.newtests.specalization.observer;
-import org.apache.webbeans.newtests.AbstractUnitTest;
-import org.junit.Assert;
-import org.junit.Test;
-
-import javax.enterprise.inject.spi.Bean;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Set;
+import javax.enterprise.inject.spi.Bean;
+
+import org.apache.webbeans.newtests.AbstractUnitTest;
+import org.junit.Assert;
+import org.junit.Test;
+
public class ObserverTest extends AbstractUnitTest
{
+ private static final String PACKAGE_NAME =
ObserverTest.class.getPackage().getName();
@Test
public void testObserverMethodsInSpecializedBeans()
@@ -50,4 +52,48 @@ public class ObserverTest extends Abstra
shutDownContainer();
}
+
+ @Test
+ public void testOverrideObserverMethodsInAlternativeAndSpecializedBeans()
+ {
+ Collection<String> beanXmls = new ArrayList<String>();
+ beanXmls.add(getXmlPath(PACKAGE_NAME, "AlternativeSpecializes"));
+
+ Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+ beanClasses.add(BeanA.class);
+ beanClasses.add(BeanD.class);
+ startContainer(beanClasses, beanXmls);
+
+ Set<Bean<?>> beans = getBeanManager().getBeans(BeanA.class);
+ Assert.assertEquals(1, beans.size());
+
+ TestEvent testEvent = new TestEvent();
+ getBeanManager().fireEvent(testEvent);
+
+ Assert.assertEquals(1, testEvent.getCalledObservers().size());
+
Assert.assertTrue(testEvent.getCalledObservers().iterator().next().endsWith(":[alternative]:[specialize]"));
+
+ shutDownContainer();
+ }
+
+ @Test
+ public void testOverrideObserverMethodsInSpecializedBeans()
+ {
+ Collection<Class<?>> beanClasses = new ArrayList<Class<?>>();
+ beanClasses.add(BeanA.class);
+ beanClasses.add(BeanF.class);
+ startContainer(beanClasses, null);
+
+ Set<Bean<?>> beans = getBeanManager().getBeans(BeanA.class);
+ Assert.assertEquals(1, beans.size());
+
+ TestEvent testEvent = new TestEvent();
+ getBeanManager().fireEvent(testEvent);
+
+ Assert.assertEquals(BeanF.class, beans.toArray(new
Bean<?>[0])[0].getBeanClass());
+ Assert.assertEquals(1, testEvent.getCalledObservers().size());
+
Assert.assertTrue(testEvent.getCalledObservers().iterator().next().endsWith(":[specialize]"));
+
+ shutDownContainer();
+ }
}
Added:
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/observer/AlternativeSpecializes.xml
URL:
http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/observer/AlternativeSpecializes.xml?rev=1397297&view=auto
==============================================================================
---
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/observer/AlternativeSpecializes.xml
(added)
+++
openwebbeans/trunk/webbeans-impl/src/test/resources/org/apache/webbeans/newtests/specalization/observer/AlternativeSpecializes.xml
Thu Oct 11 20:43:17 2012
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+<beans>
+ <alternatives>
+
<class>org.apache.webbeans.newtests.specalization.observer.BeanC</class>
+
<class>org.apache.webbeans.newtests.specalization.observer.BeanD</class>
+ </alternatives>
+</beans>
\ No newline at end of file