openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gerdo...@apache.org
Subject svn commit: r940251 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test: annotation/binding/ component/event/normal/ unittests/event/component/
Date Sun, 02 May 2010 16:02:34 GMT
Author: gerdogdu
Date: Sun May  2 16:02:34 2010
New Revision: 940251

URL: http://svn.apache.org/viewvc?rev=940251&view=rev
Log:
[OWB-367] Add a unit test for IF_EXISTS, thanks to Paul J. Reder

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAny.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAnyLiteral.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfExists.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfNonExists.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingNormal.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves3.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves4.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves5.java
  (with props)
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves6.java
  (with props)
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAny.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAny.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAny.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAny.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.test.annotation.binding;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER
})
+public @interface NotAny {
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAny.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAnyLiteral.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAnyLiteral.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAnyLiteral.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAnyLiteral.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,21 @@
+/*
+ * 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.test.annotation.binding;
+
+import javax.enterprise.util.AnnotationLiteral;
+
+public class NotAnyLiteral extends AnnotationLiteral<NotAny> implements NotAny
+{
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/NotAnyLiteral.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfExists.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfExists.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfExists.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfExists.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.test.annotation.binding;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER
})
+public @interface TestingIfExists {
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfExists.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfNonExists.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfNonExists.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfNonExists.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfNonExists.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.test.annotation.binding;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER
})
+public @interface TestingIfNonExists {
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingIfNonExists.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingNormal.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingNormal.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingNormal.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingNormal.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,28 @@
+/*
+ * 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.test.annotation.binding;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+import javax.inject.Qualifier;
+
+
+@Qualifier
+@Retention(RetentionPolicy.RUNTIME)
+@Target( { ElementType.FIELD, ElementType.METHOD, ElementType.TYPE, ElementType.PARAMETER
})
+public @interface TestingNormal {
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/annotation/binding/TestingNormal.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves3.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves3.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves3.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves3.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,43 @@
+/*
+ * 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.test.component.event.normal;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
+import javax.inject.Inject;
+
+import org.apache.webbeans.test.annotation.binding.NotAny;
+import org.apache.webbeans.test.annotation.binding.TestingIfNonExists;
+import org.apache.webbeans.test.event.LoggedInEvent;
+
+@RequestScoped
+public class ComponentWithObserves3
+{
+    private String userName;
+    private @Inject @TestingIfNonExists Event<LoggedInEvent> myLIE;
+
+    public void afterLoggedIn(@Observes(notifyObserver=Reception.IF_EXISTS) @NotAny LoggedInEvent
event)
+    {
+        this.userName = event.getUserName();
+        myLIE.fire(new LoggedInEvent("INE" + this.userName));
+    }
+
+    public String getUserName()
+    {
+        return this.userName;
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves3.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves4.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves4.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves4.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves4.java
Sun May  2 16:02:34 2010
@@ -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.test.component.event.normal;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+
+import org.apache.webbeans.test.annotation.binding.NotAny;
+import org.apache.webbeans.test.annotation.binding.TestingNormal;
+import org.apache.webbeans.test.event.LoggedInEvent;
+
+@RequestScoped
+public class ComponentWithObserves4
+{
+    private String userName;
+    private @Inject @TestingNormal Event<LoggedInEvent> myLIE;
+
+    public void afterLoggedIn(@Observes @NotAny LoggedInEvent event)
+    {
+        this.userName = event.getUserName();
+        myLIE.fire(new LoggedInEvent(this.userName));
+    }
+
+    public String getUserName()
+    {
+        return this.userName;
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves4.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves5.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves5.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves5.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves5.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,43 @@
+/*
+ * 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.test.component.event.normal;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Event;
+import javax.enterprise.event.Observes;
+import javax.enterprise.event.Reception;
+import javax.inject.Inject;
+
+import org.apache.webbeans.test.annotation.binding.NotAny;
+import org.apache.webbeans.test.annotation.binding.TestingIfExists;
+import org.apache.webbeans.test.event.LoggedInEvent;
+
+@RequestScoped
+public class ComponentWithObserves5
+{
+    private String userName;
+    private @Inject @TestingIfExists Event<LoggedInEvent> myLIE;
+
+    public void afterLoggedIn(@Observes(notifyObserver=Reception.IF_EXISTS) @NotAny LoggedInEvent
event)
+    {
+        this.userName = event.getUserName();
+        myLIE.fire(new LoggedInEvent("IE" + this.userName));
+    }
+
+    public String getUserName()
+    {
+        return this.userName;
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves5.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves6.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves6.java?rev=940251&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves6.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves6.java
Sun May  2 16:02:34 2010
@@ -0,0 +1,61 @@
+/*
+ * 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.test.component.event.normal;
+
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+
+import org.apache.webbeans.test.annotation.binding.TestingIfExists;
+import org.apache.webbeans.test.annotation.binding.TestingIfNonExists;
+import org.apache.webbeans.test.annotation.binding.TestingNormal;
+import org.apache.webbeans.test.event.LoggedInEvent;
+
+@RequestScoped
+public class ComponentWithObserves6
+{
+    private String userName = null;
+    private String userIEName = null;
+    private String userNIEName = null;
+
+    public void afterLoggedIn(@Observes @TestingNormal LoggedInEvent event)
+    {
+        this.userName = event.getUserName();
+    }
+
+    public void afterLoggedIn2(@Observes @TestingIfExists LoggedInEvent event)
+    {
+        this.userIEName = event.getUserName();
+    }
+
+    public void afterLoggedIn3(@Observes @TestingIfNonExists LoggedInEvent event)
+    {
+        this.userNIEName = event.getUserName();
+    }
+
+    public String getUserName()
+    {
+        return this.userName;
+    }
+
+    public String getUserIEName()
+    {
+        return this.userIEName;
+    }
+
+    public String getUserNIEName()
+    {
+        return this.userNIEName;
+    }
+
+}

Propchange: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/event/normal/ComponentWithObserves6.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java?rev=940251&r1=940250&r2=940251&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/event/component/ObserversComponentTest.java
Sun May  2 16:02:34 2010
@@ -27,6 +27,7 @@ import org.apache.webbeans.component.Abs
 import org.apache.webbeans.context.ContextFactory;
 import org.apache.webbeans.test.TestContext;
 import org.apache.webbeans.test.annotation.binding.Check;
+import org.apache.webbeans.test.annotation.binding.NotAnyLiteral;
 import org.apache.webbeans.test.annotation.binding.Role;
 import org.apache.webbeans.test.component.CheckWithCheckPayment;
 import org.apache.webbeans.test.component.CheckWithMoneyPayment;
@@ -34,6 +35,10 @@ import org.apache.webbeans.test.componen
 import org.apache.webbeans.test.component.event.normal.ComponentWithObservable1;
 import org.apache.webbeans.test.component.event.normal.ComponentWithObserves1;
 import org.apache.webbeans.test.component.event.normal.ComponentWithObserves2;
+import org.apache.webbeans.test.component.event.normal.ComponentWithObserves3;
+import org.apache.webbeans.test.component.event.normal.ComponentWithObserves4;
+import org.apache.webbeans.test.component.event.normal.ComponentWithObserves5;
+import org.apache.webbeans.test.component.event.normal.ComponentWithObserves6;
 import org.apache.webbeans.test.component.event.normal.TransactionalInterceptor;
 import org.apache.webbeans.test.event.LoggedInEvent;
 import org.apache.webbeans.util.WebBeansUtil;
@@ -94,6 +99,40 @@ public class ObserversComponentTest exte
     }
 
     @Test
+    public void testObservesIfExists()
+    {
+        clear();
+        
+        getManager().addBean(WebBeansUtil.getEventBean());
+
+        AbstractOwbBean<ComponentWithObserves3> component3 = defineManagedBean(ComponentWithObserves3.class);
+        AbstractOwbBean<ComponentWithObserves4> component4 = defineManagedBean(ComponentWithObserves4.class);
+        AbstractOwbBean<ComponentWithObserves5> component5 = defineManagedBean(ComponentWithObserves5.class);
+        AbstractOwbBean<ComponentWithObserves6> component6 = defineManagedBean(ComponentWithObserves6.class);
+
+        ContextFactory.initRequestContext(null);
+
+        /*
+         * DO NOT CALL getInstance FOR component3! IF_EXISTS NEEDS TO FAIL FOR THAT OBJECT.
+         */
+        ComponentWithObserves4 instance = getManager().getInstance(component4);
+        ComponentWithObserves5 instanceIE = getManager().getInstance(component5);
+        ComponentWithObserves6 outstance = getManager().getInstance(component6);
+        instanceIE.getUserName();  // This causes the observer to exist in the context, therefore
IF_EXISTS is true.
+        
+        LoggedInEvent event = new LoggedInEvent("Gurkan");
+
+        Annotation[] anns = new Annotation[1];
+        anns[0] = new NotAnyLiteral();
+
+        getManager().fireEvent(event, anns);
+        
+        Assert.assertEquals("IEGurkan", outstance.getUserIEName());
+        Assert.assertEquals("Gurkan", outstance.getUserName());
+        Assert.assertNull(outstance.getUserNIEName());
+    }
+
+    @Test
     public void testObservesWithBindingMember()
     {
         clear();



Mime
View raw message