openwebbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r1664610 - in /openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test: component/portable/ component/portable/events/ portable/ portable/events/ portable/events/beans/ portable/events/extensions/ unittests/portable/
Date Fri, 06 Mar 2015 13:08:11 GMT
Author: struberg
Date: Fri Mar  6 13:08:09 2015
New Revision: 1664610

URL: http://svn.apache.org/r1664610
Log:
add a test for custom messages sent from one Extension to the other

Added:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/PortableTests.java
      - copied, changed from r1664603, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/PortableTests.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ExtensionTest.java
      - copied, changed from r1664603, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/PortableType1.java
      - copied, changed from r1664603, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/PortableType1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageReceiverExtension.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageSenderExtension.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MyExtension.java
Removed:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/PortableType1.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/events/MyExtension.java
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/
Modified:
    openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/PortableTests.java
(from r1664603, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/PortableTests.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/PortableTests.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/PortableTests.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/PortableTests.java&r1=1664603&r2=1664610&rev=1664610&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/PortableTests.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/PortableTests.java
Fri Mar  6 13:08:09 2015
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.test.unittests.portable;
+package org.apache.webbeans.test.portable;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.ParameterizedType;
@@ -45,7 +45,7 @@ import org.apache.webbeans.test.componen
 import org.apache.webbeans.test.component.IPayment;
 import org.apache.webbeans.test.component.inject.parametrized.Dao;
 import org.apache.webbeans.test.component.library.Book;
-import org.apache.webbeans.test.component.portable.PortableType1;
+import org.apache.webbeans.test.portable.events.beans.PortableType1;
 import org.apache.webbeans.test.xml.annot.BindingType1;
 import org.apache.webbeans.test.xml.annot.BindingType2;
 import org.junit.Test;

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ExtensionTest.java
(from r1664603, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ExtensionTest.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ExtensionTest.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java&r1=1664603&r2=1664610&rev=1664610&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/unittests/portable/events/ExtensionTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/ExtensionTest.java
Fri Mar  6 13:08:09 2015
@@ -16,9 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.test.unittests.portable.events;
+package org.apache.webbeans.test.portable.events;
 
-import java.lang.annotation.Annotation;
 import java.util.ArrayList;
 import java.util.Collection;
 
@@ -31,8 +30,8 @@ import org.apache.webbeans.container.Bea
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.portable.events.discovery.BeforeShutdownImpl;
 import org.apache.webbeans.test.component.library.BookShop;
-import org.apache.webbeans.test.component.portable.events.MyExtension;
 import org.apache.webbeans.test.component.producer.primitive.PrimitiveProducer;
+import org.apache.webbeans.test.portable.events.extensions.MyExtension;
 import org.junit.Test;
 
 /**
@@ -59,8 +58,6 @@ public class ExtensionTest extends Abstr
         
         startContainer(classes);
 
-        getWebBeansContext().getContextFactory().initApplicationContext(null);
-
         Bean<MyExtension> extension = (Bean<MyExtension>) getBeanManager().getBeans(MyExtension.class,
new DefaultLiteral()).iterator().next();
         
         MyExtension ext = (MyExtension) getBeanManager().getReference(extension, MyExtension.class,
getBeanManager().createCreationalContext(extension));
@@ -79,7 +76,7 @@ public class ExtensionTest extends Abstr
         //Fire shut down
         BeanManagerImpl.class.cast(getBeanManager()).fireEvent(new BeforeShutdownImpl(),
true);
 
-        getWebBeansContext().getContextFactory().destroyApplicationContext(null);
+        shutDownContainer();
 
         Assert.assertNotNull(MyExtension.beforeShutdownEvent);
     }

Modified: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java?rev=1664610&r1=1664609&r2=1664610&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/PortableEventTest.java
Fri Mar  6 13:08:09 2015
@@ -26,6 +26,8 @@ import junit.framework.Assert;
 import org.apache.webbeans.test.AbstractUnitTest;
 import org.apache.webbeans.test.portable.events.beans.Apple;
 import org.apache.webbeans.test.portable.events.extensions.AppleExtension;
+import org.apache.webbeans.test.portable.events.extensions.MessageReceiverExtension;
+import org.apache.webbeans.test.portable.events.extensions.MessageSenderExtension;
 import org.apache.webbeans.test.portable.events.extensions.NotAppleExtnsion;
 import org.apache.webbeans.test.portable.events.extensions.RawTypeExtension;
 import org.apache.webbeans.test.portable.events.extensions.TypeVariableExtension;
@@ -155,4 +157,13 @@ public class PortableEventTest extends A
         shutDownContainer();
     }
 
+    @Test
+    public void testCustomMessagesInExtensions()
+    {
+        addExtension(new MessageSenderExtension());
+        addExtension(new MessageReceiverExtension());
+
+        startContainer();
+    }
+
 }

Copied: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/PortableType1.java
(from r1664603, openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/PortableType1.java)
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/PortableType1.java?p2=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/PortableType1.java&p1=openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/PortableType1.java&r1=1664603&r2=1664610&rev=1664610&view=diff
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/component/portable/PortableType1.java
(original)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/beans/PortableType1.java
Fri Mar  6 13:08:09 2015
@@ -16,7 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-package org.apache.webbeans.test.component.portable;
+package org.apache.webbeans.test.portable.events.beans;
 
 import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Default;

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageReceiverExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageReceiverExtension.java?rev=1664610&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageReceiverExtension.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageReceiverExtension.java
Fri Mar  6 13:08:09 2015
@@ -0,0 +1,45 @@
+/*
+ * 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.portable.events.extensions;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.Extension;
+
+import junit.framework.Assert;
+
+/**
+ * Test that an Extension can send  any message to another Extension.
+ *
+ * @see org.apache.webbeans.test.portable.events.extensions.MessageSenderExtension
+ */
+public class MessageReceiverExtension implements Extension
+{
+    private MessageSenderExtension.ExtensionPayload payload;
+
+    public void catchMessagePayload(@Observes MessageSenderExtension.ExtensionPayload payload)
+    {
+        this.payload = payload;
+    }
+
+    public void adv(@Observes AfterDeploymentValidation adv)
+    {
+        Assert.assertNotNull(payload);
+    }
+
+
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageSenderExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageSenderExtension.java?rev=1664610&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageSenderExtension.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MessageSenderExtension.java
Fri Mar  6 13:08:09 2015
@@ -0,0 +1,45 @@
+/*
+ * 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.portable.events.extensions;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+
+import junit.framework.Assert;
+
+/**
+ * Test that an Extension can send  any message to another Extension.
+ *
+ * @see org.apache.webbeans.test.portable.events.extensions.MessageReceiverExtension
+ */
+public class MessageSenderExtension implements Extension
+{
+    public static class ExtensionPayload
+    {
+        // no content needed
+    }
+
+    public void bbd(@Observes BeforeBeanDiscovery beforeBeanDiscovery, BeanManager beanManager)
+    {
+        Assert.assertNotNull(beforeBeanDiscovery);
+        Assert.assertNotNull(beanManager);
+
+        beanManager.fireEvent(new ExtensionPayload());
+    }
+}

Added: openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MyExtension.java
URL: http://svn.apache.org/viewvc/openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MyExtension.java?rev=1664610&view=auto
==============================================================================
--- openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MyExtension.java
(added)
+++ openwebbeans/trunk/webbeans-impl/src/test/java/org/apache/webbeans/test/portable/events/extensions/MyExtension.java
Fri Mar  6 13:08:09 2015
@@ -0,0 +1,112 @@
+/*
+ * 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.portable.events.extensions;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.BeforeShutdown;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.ProcessBean;
+import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import javax.enterprise.inject.spi.ProcessObserverMethod;
+import javax.enterprise.inject.spi.ProcessProducer;
+
+/**
+ * Test extension which only sets a few static members which will be validated in a test
case.
+ */
+public class MyExtension implements Extension
+{
+    public static ProcessAnnotatedType<?> processAnnotatedTypeEvent;
+    public static BeforeBeanDiscovery lastBeforeBeanDiscovery;
+    public static AfterBeanDiscovery lastAfterBeanDiscovery;
+    public static BeforeShutdown beforeShutdownEvent;
+    public static AfterDeploymentValidation afterDeploymentValidation;
+    public static ProcessInjectionTarget<?> processInjectionTarget;
+    public static ProcessProducer<?,?> processProducer;
+    public static ProcessBean<?> processBean;
+    public static ProcessObserverMethod<?, ?> processObserverMethod;
+
+
+    /**
+     * Reset all static fields before the test starts
+     */
+    public static void reset() {
+        processAnnotatedTypeEvent = null;
+        lastBeforeBeanDiscovery = null;
+        lastAfterBeanDiscovery = null;
+        beforeShutdownEvent = null;
+        afterDeploymentValidation = null;
+        processInjectionTarget = null;
+        processProducer = null;
+        processBean = null;
+        processObserverMethod = null;
+    }
+
+    public MyExtension()
+    {
+    }
+
+    public void observeBeforeBeanDiscovery(@Observes BeforeBeanDiscovery beforeBean)
+    {
+        lastBeforeBeanDiscovery = beforeBean;
+    }
+
+    public void observeAfterBeanDiscovery(@Observes AfterBeanDiscovery afterBean, BeanManager
beanManager)
+    {
+        lastAfterBeanDiscovery = afterBean;
+    }
+
+    public void observeAfterDeploymentValidation(@Observes AfterDeploymentValidation adv,
BeanManager bm)
+    {
+        afterDeploymentValidation = adv;
+    }
+
+    public void observeShutdownEvent(@Observes BeforeShutdown bs, BeanManager bm)
+    {
+        beforeShutdownEvent = bs;
+    }
+
+    public void observeProcessAnnotatedTypeEvent(@Observes ProcessAnnotatedType<?>
annotatedType)
+    {
+        processAnnotatedTypeEvent = annotatedType;
+    }
+
+    public <T> void observeProcessInjectionTarget(@Observes ProcessInjectionTarget<T>
pit)
+    {
+        processInjectionTarget = pit;
+    }
+
+    public <T, X> void observeProcessProducer(@Observes ProcessProducer<T, X>
pp)
+    {
+        processProducer = pp;
+    }
+
+    public <X> void observeProcessBean(@Observes ProcessBean<X> pb)
+    {
+        processBean = pb;
+    }
+
+    public <X, T> void processObserverMethod(@Observes ProcessObserverMethod<X,
T> pom)
+    {
+        processObserverMethod = pom;
+    }
+
+}



Mime
View raw message