1 22 package org.jboss.ejb3.test.dependency.unit; 23 24 import org.jboss.ejb3.test.dependency.NoDependencies; 25 import org.jboss.ejb3.test.dependency.Stateless; 26 import org.jboss.ejb3.test.dependency.HasMBeanDependency; 27 import org.jboss.ejb3.test.dependency.HasXmlMBeanDependency; 28 import org.jboss.ejb3.test.dependency.Stateless2; 29 import org.jboss.test.JBossTestCase; 30 import junit.framework.Test; 31 32 38 39 public class DependencyUnitTestCase 40 extends JBossTestCase 41 { 42 org.jboss.logging.Logger log = getLog(); 43 44 static boolean deployed = false; 45 static int test = 0; 46 47 public DependencyUnitTestCase(String name) 48 { 49 50 super(name); 51 52 } 53 54 public void testNonDependencies() throws Exception 55 { 56 NoDependencies nada = (NoDependencies) getInitialContext().lookup("dependency-test/NoDependenciesBean/remote"); 57 nada.noop(); 58 } 59 60 public void testDatasourceDependencies() throws Exception 61 { 62 Stateless test = null; 63 test = (Stateless) getInitialContext().lookup("dependency-test/StatelessBean/remote"); 64 test.createCustomer(); 65 } 66 67 public void testPUDependencies() throws Exception 68 { 69 try 70 { 71 super.deploy("ejbdepends.jar"); 72 } 73 catch (Exception e) 74 { 75 } 77 try 78 { 79 Stateless2 test = null; 80 boolean exceptionThrown = false; 81 try 82 { 83 test = (Stateless2) getInitialContext().lookup("Stateless2Bean/remote"); 84 test.createCustomer(); 85 } 86 catch (Exception ex) 87 { 88 exceptionThrown = true; 89 } 90 assertTrue(exceptionThrown); 91 92 super.deploy("yetanother.sar"); 93 try 94 { 95 test = (Stateless2) getInitialContext().lookup("Stateless2Bean/remote"); 96 test.createCustomer(); 97 } 98 finally 99 { 100 super.undeploy("yetanother.sar"); 101 } 102 } 103 finally 104 { 105 super.undeploy("ejbdepends.jar"); 106 } 107 108 } 109 110 public void testDepends() throws Exception 111 { 112 boolean exceptionThrown = false; 113 try 114 { 115 HasMBeanDependency dependency = (HasMBeanDependency) getInitialContext().lookup("dependency-test/HasMBeanDependencyBean/remote"); 116 } 117 catch (Exception e) 118 { 119 exceptionThrown = true; 120 } 121 assertTrue(exceptionThrown); 122 exceptionThrown = false; 123 try 124 { 125 HasXmlMBeanDependency dependency = (HasXmlMBeanDependency) getInitialContext().lookup("dependency-test/HasXmlMBeanDependencyBean/remote"); 126 } 127 catch (Exception e) 128 { 129 exceptionThrown = true; 130 } 131 assertTrue(exceptionThrown); 132 exceptionThrown = false; 133 super.deploy("dependedon.sar"); 134 try 135 { 136 try 137 { 138 HasMBeanDependency dependency = (HasMBeanDependency) getInitialContext().lookup("dependency-test/HasMBeanDependencyBean/remote"); 139 } 140 catch (Exception e) 141 { 142 exceptionThrown = true; 143 } 144 assertTrue(exceptionThrown); 145 146 HasXmlMBeanDependency dependency = (HasXmlMBeanDependency) getInitialContext().lookup("dependency-test/HasXmlMBeanDependencyBean/remote"); 148 dependency.noop(); 149 150 super.deploy("anotherdependedon.sar"); 151 try 152 { 153 HasMBeanDependency dependency2 = (HasMBeanDependency) getInitialContext().lookup("dependency-test/HasMBeanDependencyBean/remote"); 154 dependency2.testNotNull(); 155 } 156 finally 157 { 158 super.undeploy("anotherdependedon.sar"); 159 } 160 } 161 finally 162 { 163 super.undeploy("dependedon.sar"); 164 } 165 } 166 167 public static Test suite() throws Exception 168 { 169 return getDeploySetup(DependencyUnitTestCase.class, "dependency-test.ear"); 170 } 171 172 } 173 | Popular Tags |