1 22 package org.jboss.test.kernel.junit; 23 24 import java.net.URL ; 25 26 import org.jboss.dependency.spi.ControllerState; 27 import org.jboss.kernel.spi.dependency.KernelControllerContext; 28 import org.jboss.kernel.spi.deployment.KernelDeployment; 29 import org.jboss.test.AbstractTestCaseWithSetup; 30 import org.jboss.test.AbstractTestDelegate; 31 32 38 public class MicrocontainerTest extends AbstractTestCaseWithSetup 39 { 40 47 public static AbstractTestDelegate getDelegate(Class clazz) throws Exception 48 { 49 return new MicrocontainerTestDelegate(clazz); 50 } 51 52 57 public MicrocontainerTest(String name) 58 { 59 super(name); 60 } 61 62 protected void setUp() throws Exception 63 { 64 super.setUp(); 65 configureLogging(); 66 getMCDelegate().validate(); 68 } 69 70 77 protected Object getBean(Object name) 78 { 79 return getBean(name, ControllerState.INSTALLED); 80 } 81 82 90 protected Object getBean(Object name, ControllerState state) 91 { 92 return getMCDelegate().getBean(name, state); 93 } 94 95 102 protected KernelControllerContext getControllerContext(Object name) 103 { 104 return getControllerContext(name, ControllerState.INSTALLED); 105 } 106 107 115 protected KernelControllerContext getControllerContext(Object name, ControllerState state) 116 { 117 return getMCDelegate().getControllerContext(name, state); 118 } 119 120 127 protected KernelDeployment deploy(URL url) throws Exception 128 { 129 return getMCDelegate().deploy(url); 130 } 131 132 139 protected KernelDeployment deploy(String resource) throws Exception 140 { 141 URL url = getClass().getResource(resource); 142 if (url == null) 143 throw new IllegalArgumentException ("Resource not found: " + resource); 144 return getMCDelegate().deploy(url); 145 } 146 147 152 protected void undeploy(KernelDeployment deployment) 153 { 154 getMCDelegate().undeploy(deployment); 155 } 156 157 162 protected void undeploy(String resource) 163 { 164 URL url = getClass().getResource(resource); 165 if (url == null) 166 throw new IllegalArgumentException ("Resource not found: " + resource); 167 getMCDelegate().undeploy(url); 168 } 169 170 175 protected void validate() throws Exception 176 { 177 getMCDelegate().validate(); 178 } 179 180 185 protected MicrocontainerTestDelegate getMCDelegate() 186 { 187 return (MicrocontainerTestDelegate) getDelegate(); 188 } 189 } 190 | Popular Tags |