[weld-commits] Weld SVN: r5223 - in java-se/trunk/src: test/java/org/jboss/weld/environment/se/test and 1 other directory.
weld-commits at lists.jboss.org
weld-commits at lists.jboss.org
Tue Dec 8 07:12:30 EST 2009
Author: peteroyle
Date: 2009-12-08 07:12:29 -0500 (Tue, 08 Dec 2009)
New Revision: 5223
Modified:
java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java
java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java
Log:
WELDX-57: Removed proprietary shutdown event, replaced with standard BeforeShutdown. Also added shutdown() to Weld, and set Weld.class up as a managed bean for use when observing the ContainerInitialized event.
Modified: java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java
===================================================================
--- java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java 2009-12-08 07:00:33 UTC (rev 5222)
+++ java-se/trunk/src/main/java/org/jboss/weld/environment/se/WeldSEBeanRegistrant.java 2009-12-08 12:12:29 UTC (rev 5223)
@@ -35,6 +35,7 @@
event.addAnnotatedType(beanManager.createAnnotatedType(ShutdownManager.class));
event.addAnnotatedType(beanManager.createAnnotatedType(ParametersFactory.class));
event.addAnnotatedType(beanManager.createAnnotatedType(InstanceManager.class));
+ event.addAnnotatedType(beanManager.createAnnotatedType(Weld.class));
}
}
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java 2009-12-08 07:00:33 UTC (rev 5222)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/DecoratorsTest.java 2009-12-08 12:12:29 UTC (rev 5223)
@@ -17,11 +17,10 @@
package org.jboss.weld.environment.se.test;
import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.util.AnnotationLiteral;
+import org.jboss.weld.environment.se.ShutdownManager;
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
-import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.decorators.CarDoor;
import org.jboss.weld.environment.se.test.decorators.Door;
import org.jboss.weld.environment.se.test.decorators.CarDoorAlarm;
@@ -37,59 +36,52 @@
public class DecoratorsTest
{
- /**
- * Test that decorators work as expected in SE.
- */
- @Test
- public void testDecorators()
- {
+ /**
+ * Test that decorators work as expected in SE.
+ */
+ @Test
+ public void testDecorators()
+ {
- WeldContainer weld = new Weld().initialize();
- BeanManager manager = weld.getBeanManager();
-
- CarDoor carDoor = WeldManagerUtils.getInstanceByType(manager, CarDoor.class);
- Assert.assertNotNull(carDoor);
+ WeldContainer weld = new Weld().initialize();
+ BeanManager manager = weld.getBeanManager();
- // the car door is alarmed
- CarDoorAlarm.alarmActivated = false;
- Assert.assertFalse(CarDoorAlarm.alarmActivated);
- testDoor(carDoor);
- Assert.assertTrue(CarDoorAlarm.alarmActivated);
+ CarDoor carDoor = WeldManagerUtils.getInstanceByType(manager, CarDoor.class);
+ Assert.assertNotNull(carDoor);
- HouseDoor houseDoor = WeldManagerUtils.getInstanceByType(manager, HouseDoor.class);
- Assert.assertNotNull(carDoor);
+ // the car door is alarmed
+ CarDoorAlarm.alarmActivated = false;
+ Assert.assertFalse(CarDoorAlarm.alarmActivated);
+ testDoor(carDoor);
+ Assert.assertTrue(CarDoorAlarm.alarmActivated);
- // the house door is not alarmed
- CarDoorAlarm.alarmActivated = false;
- Assert.assertFalse(CarDoorAlarm.alarmActivated);
- testDoor(houseDoor);
- Assert.assertFalse(CarDoorAlarm.alarmActivated);
+ HouseDoor houseDoor = WeldManagerUtils.getInstanceByType(manager, HouseDoor.class);
+ Assert.assertNotNull(carDoor);
- shutdownManager(manager);
- }
+ // the house door is not alarmed
+ CarDoorAlarm.alarmActivated = false;
+ Assert.assertFalse(CarDoorAlarm.alarmActivated);
+ testDoor(houseDoor);
+ Assert.assertFalse(CarDoorAlarm.alarmActivated);
- private void testDoor(Door door)
- {
- Assert.assertTrue(door.open());
- Assert.assertTrue(door.isOpen());
- Assert.assertFalse(door.close());
- Assert.assertFalse(door.isOpen());
- Assert.assertTrue(door.lock());
- Assert.assertTrue(door.isLocked());
- Assert.assertFalse(door.open());
- Assert.assertFalse(door.isOpen());
- }
+ shutdownManager(weld);
+ }
- private void shutdownManager(BeanManager manager)
- {
- manager.fireEvent(manager, new ShutdownAnnotation());
- }
+ private void testDoor(Door door)
+ {
+ Assert.assertTrue(door.open());
+ Assert.assertTrue(door.isOpen());
+ Assert.assertFalse(door.close());
+ Assert.assertFalse(door.isOpen());
+ Assert.assertTrue(door.lock());
+ Assert.assertTrue(door.isLocked());
+ Assert.assertFalse(door.open());
+ Assert.assertFalse(door.isOpen());
+ }
- private static class ShutdownAnnotation extends AnnotationLiteral<Shutdown>
- {
-
- public ShutdownAnnotation()
- {
- }
- }
+ private void shutdownManager(WeldContainer weld)
+ {
+ ShutdownManager shutdownManager = weld.instance().select(ShutdownManager.class).get();
+ shutdownManager.shutdown();
+ }
}
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java 2009-12-08 07:00:33 UTC (rev 5222)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/InterceptorsTest.java 2009-12-08 12:12:29 UTC (rev 5223)
@@ -17,11 +17,10 @@
package org.jboss.weld.environment.se.test;
import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.util.AnnotationLiteral;
+import org.jboss.weld.environment.se.ShutdownManager;
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
-import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.beans.InterceptorTestBean;
import org.jboss.weld.environment.se.test.interceptors.AggregatingInterceptor;
import org.jboss.weld.environment.se.test.interceptors.RecordingInterceptor;
@@ -36,42 +35,35 @@
public class InterceptorsTest
{
- /**
- * Test that interceptors work as expected in SE.
- */
- @Test
- public void testInterceptors()
- {
- WeldContainer weld = new Weld().initialize();
- BeanManager manager = weld.getBeanManager();
+ /**
+ * Test that interceptors work as expected in SE.
+ */
+ @Test
+ public void testInterceptors()
+ {
+ WeldContainer weld = new Weld().initialize();
+ BeanManager manager = weld.getBeanManager();
- InterceptorTestBean intTestBean = WeldManagerUtils.getInstanceByType(manager, InterceptorTestBean.class);
- Assert.assertNotNull(intTestBean);
+ InterceptorTestBean intTestBean = WeldManagerUtils.getInstanceByType(manager, InterceptorTestBean.class);
+ Assert.assertNotNull(intTestBean);
- intTestBean.doSomethingRecorded();
- System.out.println(RecordingInterceptor.methodsRecorded);
- System.out.println(AggregatingInterceptor.methodsCalled);
- Assert.assertTrue(RecordingInterceptor.methodsRecorded.contains("doSomethingRecorded"));
+ intTestBean.doSomethingRecorded();
+ System.out.println(RecordingInterceptor.methodsRecorded);
+ System.out.println(AggregatingInterceptor.methodsCalled);
+ Assert.assertTrue(RecordingInterceptor.methodsRecorded.contains("doSomethingRecorded"));
- intTestBean.doSomethingRecordedAndAggregated();
- System.out.println(RecordingInterceptor.methodsRecorded);
- System.out.println(AggregatingInterceptor.methodsCalled);
+ intTestBean.doSomethingRecordedAndAggregated();
+ System.out.println(RecordingInterceptor.methodsRecorded);
+ System.out.println(AggregatingInterceptor.methodsCalled);
- Assert.assertEquals(1, AggregatingInterceptor.methodsCalled);
+ Assert.assertEquals(1, AggregatingInterceptor.methodsCalled);
- shutdownManager(manager);
- }
+ shutdownManager(weld);
+ }
- private void shutdownManager(BeanManager manager)
- {
- manager.fireEvent(manager, new ShutdownAnnotation());
- }
-
- private static class ShutdownAnnotation extends AnnotationLiteral<Shutdown>
- {
-
- public ShutdownAnnotation()
- {
- }
- }
+ private void shutdownManager(WeldContainer weld)
+ {
+ ShutdownManager shutdownManager = weld.instance().select(ShutdownManager.class).get();
+ shutdownManager.shutdown();
+ }
}
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java 2009-12-08 07:00:33 UTC (rev 5222)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/StartMainTest.java 2009-12-08 12:12:29 UTC (rev 5223)
@@ -17,11 +17,10 @@
package org.jboss.weld.environment.se.test;
import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.util.AnnotationLiteral;
+import org.jboss.weld.environment.se.ShutdownManager;
import org.jboss.weld.environment.se.StartMain;
import org.jboss.weld.environment.se.WeldContainer;
-import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.beans.CustomEvent;
import org.jboss.weld.environment.se.test.beans.InitObserverTestBean;
import org.jboss.weld.environment.se.test.beans.MainTestBean;
@@ -67,7 +66,7 @@
Assert.assertNotNull(paramsBean.getParameters().get(2));
Assert.assertEquals(ARGS[2], paramsBean.getParameters().get(2));
- shutdownManager(manager);
+ shutdownManager(weld);
}
/**
@@ -87,7 +86,7 @@
Assert.assertNotNull(paramsBean);
Assert.assertNotNull(paramsBean.getParameters());
- shutdownManager(manager);
+ shutdownManager(weld);
}
@Test
@@ -107,17 +106,10 @@
Assert.assertTrue(InitObserverTestBean.isInitObserved());
}
- private void shutdownManager(BeanManager manager)
+ private void shutdownManager(WeldContainer weld)
{
- manager.fireEvent(manager, new ShutdownAnnotation());
+ ShutdownManager shutdownManager = weld.instance().select(ShutdownManager.class).get();
+ shutdownManager.shutdown();
}
- private static class ShutdownAnnotation extends AnnotationLiteral<Shutdown>
- {
-
- public ShutdownAnnotation()
- {
- }
- }
-
}
Modified: java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java
===================================================================
--- java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java 2009-12-08 07:00:33 UTC (rev 5222)
+++ java-se/trunk/src/test/java/org/jboss/weld/environment/se/test/WeldMainTest.java 2009-12-08 12:12:29 UTC (rev 5223)
@@ -16,12 +16,9 @@
*/
package org.jboss.weld.environment.se.test;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.util.AnnotationLiteral;
-
+import org.jboss.weld.environment.se.ShutdownManager;
import org.jboss.weld.environment.se.Weld;
import org.jboss.weld.environment.se.WeldContainer;
-import org.jboss.weld.environment.se.events.Shutdown;
import org.jboss.weld.environment.se.test.beans.CustomEvent;
import org.jboss.weld.environment.se.test.beans.InitObserverTestBean;
import org.jboss.weld.environment.se.test.beans.MainTestBean;
@@ -53,7 +50,7 @@
Assert.assertNotNull(paramsBean);
Assert.assertNotNull(paramsBean.getParameters());
- shutdownManager(weld.getBeanManager());
+ shutdownManager(weld);
}
/**
@@ -76,16 +73,9 @@
Assert.assertFalse(InitObserverTestBean.isInitObserved());
}
- private void shutdownManager(BeanManager manager)
+ private void shutdownManager(WeldContainer weld)
{
- manager.fireEvent(manager, new ShutdownAnnotation());
+ ShutdownManager shutdownManager = weld.instance().select(ShutdownManager.class).get();
+ shutdownManager.shutdown();
}
-
- private static class ShutdownAnnotation extends AnnotationLiteral<Shutdown>
- {
-
- public ShutdownAnnotation()
- {
- }
- }
}
More information about the weld-commits
mailing list