[webbeans-commits] Webbeans SVN: r3707 - in extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test: beans and 1 other directory.
webbeans-commits at lists.jboss.org
webbeans-commits at lists.jboss.org
Sat Sep 19 00:05:25 EDT 2009
Author: peteroyle
Date: 2009-09-19 00:05:25 -0400 (Sat, 19 Sep 2009)
New Revision: 3707
Added:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java
Modified:
extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
Log:
Added tests for custom and built-in event observers. Built-in events don't seem to be working for SE at the moment.
Modified: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-09-18 13:17:03 UTC (rev 3706)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/StartMainTest.java 2009-09-19 04:05:25 UTC (rev 3707)
@@ -21,7 +21,9 @@
import org.jboss.webbeans.environment.se.StartMain;
import org.jboss.webbeans.environment.se.events.Shutdown;
+import org.jboss.webbeans.environment.se.test.beans.CustomEvent;
import org.jboss.webbeans.environment.se.test.beans.MainTestBean;
+import org.jboss.webbeans.environment.se.test.beans.ObserverTestBean;
import org.jboss.webbeans.environment.se.test.beans.ParametersTestBean;
import org.jboss.webbeans.environment.se.util.WebBeansManagerUtils;
import org.testng.Assert;
@@ -82,6 +84,19 @@
shutdownManager(manager);
}
+ @Test
+ public void testObservers() {
+ BeanManager manager = new StartMain(ARGS_EMPTY).go();
+
+ manager.fireEvent( new CustomEvent() );
+
+ ObserverTestBean observerTestBean = WebBeansManagerUtils.getInstanceByType( manager, ObserverTestBean.class );
+ Assert.assertNotNull( observerTestBean );
+ Assert.assertTrue( observerTestBean.isCustomObserved() );
+ Assert.assertTrue( observerTestBean.isBuiltInObserved() );
+
+ }
+
private void shutdownManager( BeanManager manager )
{
manager.fireEvent( manager, new ShutdownAnnotation() );
Added: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java (rev 0)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/CustomEvent.java 2009-09-19 04:05:25 UTC (rev 3707)
@@ -0,0 +1,27 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.environment.se.test.beans;
+
+/**
+ * A custom event fired and observed by one of the tests, to test
+ * application-specific events.
+ *
+ * @author Peter Royle
+ */
+public class CustomEvent {
+
+}
Added: extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java
===================================================================
--- extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java (rev 0)
+++ extensions/trunk/se/src/test/java/org/jboss/webbeans/environment/se/test/beans/ObserverTestBean.java 2009-09-19 04:05:25 UTC (rev 3707)
@@ -0,0 +1,62 @@
+/**
+ * JBoss, Home of Professional Open Source
+ * Copyright 2009, Red Hat, Inc. and/or its affiliates, and individual
+ * contributors by the @authors tag. See the copyright.txt in the
+ * distribution for a full listing of individual contributors.
+ *
+ * Licensed 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.jboss.webbeans.environment.se.test.beans;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+
+/**
+ * Tests the observing of both built-in and application-specific events.
+ *
+ * @author Peter Royle
+ */
+ at ApplicationScoped
+public class ObserverTestBean {
+
+ private boolean builtInObserved = false;
+ private boolean customObserved = false;
+
+ public ObserverTestBean() {
+ }
+
+ public void observeBuiltInEvent(@Observes AfterDeploymentValidation after) {
+ this.builtInObserved = true;
+ }
+
+ public void observeCustomEvent(@Observes CustomEvent event) {
+ this.customObserved = true;
+
+ }
+
+ /**
+ * @return the observed
+ */
+ public boolean isBuiltInObserved() {
+ return builtInObserved;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isCustomObserved() {
+ return customObserved;
+ }
+
+
+
+}
More information about the weld-commits
mailing list