[weld-commits] Weld SVN: r4213 - core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver.

weld-commits at lists.jboss.org weld-commits at lists.jboss.org
Wed Oct 21 11:22:22 EDT 2009


Author: kabir.khan at jboss.com
Date: 2009-10-21 11:22:22 -0400 (Wed, 21 Oct 2009)
New Revision: 4213

Added:
   core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java
Log:
[WELD-220] Bad name

Copied: core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java (from rev 4212, core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManager.java)
===================================================================
--- core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java	                        (rev 0)
+++ core/trunk/tests/src/test/java/org/jboss/weld/test/unit/clearresolver/PreinstantiateBeanManagerTest.java	2009-10-21 15:22:22 UTC (rev 4213)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, 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.weld.test.unit.clearresolver;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+
+import org.jboss.weld.mock.MockEELifecycle;
+import org.jboss.weld.mock.TestContainer;
+import org.testng.annotations.Test;
+
+/**
+ * @author kkhan
+ *
+ */
+public class PreinstantiateBeanManagerTest
+{
+
+   @Test
+   public void test()
+   {
+      //Start the container, but do not deploy weld yet
+      List<Class<?>> classes = new ArrayList<Class<?>>();
+      classes.add(WeldBean.class);
+      TestContainer container = new TestContainer(new MockEELifecycle(), classes, null);
+      container.startContainer(false);
+      
+      BeanManager bootstrapManager = container.getBeanManager();
+      assert bootstrapManager != null;
+
+      //Check the bean is null since it is not there yet
+      Set<Bean<?>> beans = bootstrapManager.getBeans(WeldBean.class);
+      assert beans == null || beans.size() == 0;
+      
+      
+      //Start the application
+      container.beginApplication();
+      container.ensureRequestActive();
+      
+      //Check the manager is the same as before
+      BeanManager manager = container.getBeanManager();
+      assert manager != null;
+      assert bootstrapManager == manager;
+      
+      //Check we can get the bean
+      Bean<? extends Object> bean = manager.resolve(manager.getBeans(WeldBean.class));
+      WeldBean weldBean = (WeldBean) manager.getReference(bean, WeldBean.class, manager.createCreationalContext(bean));
+      assert weldBean != null;
+      
+      container.stopContainer();
+   }
+   
+}



More information about the weld-commits mailing list