1 17 package org.apache.geronimo.gbean.runtime; 18 19 import junit.framework.TestCase; 20 import org.apache.geronimo.gbean.AbstractName; 21 import org.apache.geronimo.gbean.GBeanData; 22 import org.apache.geronimo.gbean.ReferencePatterns; 23 import org.apache.geronimo.kernel.Kernel; 24 import org.apache.geronimo.kernel.KernelFactory; 25 import org.apache.geronimo.kernel.MockGBean; 26 import org.apache.geronimo.kernel.management.State; 27 import org.apache.geronimo.kernel.repository.Artifact; 28 29 32 public class GBeanDependencyTest extends TestCase { 33 private Kernel kernel; 34 35 public void testGBeanDependency() throws Exception { 36 AbstractName parentName = kernel.getNaming().createRootName(new Artifact("test", "foo", "1", "car"), "parent", "parent"); 37 GBeanData gbeanDataParent = new GBeanData(parentName, MockGBean.getGBeanInfo()); 38 GBeanData gbeanDataChild = new GBeanData(kernel.getNaming().createChildName(parentName, "child", "child"), MockGBean.getGBeanInfo()); 39 gbeanDataChild.addDependency(new ReferencePatterns(parentName)); 40 kernel.loadGBean(gbeanDataChild, MockGBean.class.getClassLoader()); 41 kernel.startGBean(gbeanDataChild.getAbstractName()); 42 assertEquals(State.STARTING_INDEX, kernel.getGBeanState(gbeanDataChild.getAbstractName())); 43 kernel.loadGBean(gbeanDataParent, MockGBean.class.getClassLoader()); 44 assertEquals(State.STARTING_INDEX, kernel.getGBeanState(gbeanDataChild.getAbstractName())); 45 kernel.startGBean(parentName); 46 assertEquals(State.RUNNING_INDEX, kernel.getGBeanState(gbeanDataChild.getAbstractName())); 47 } 48 49 protected void setUp() throws Exception { 50 super.setUp(); 51 kernel = KernelFactory.newInstance().createKernel("test"); 52 kernel.boot(); 53 } 54 55 protected void tearDown() throws Exception { 56 kernel.shutdown(); 57 super.tearDown(); 58 } 59 } 60 | Popular Tags |