1 45 package org.openejb.test.stateless; 46 47 import org.openejb.test.object.OperationsPolicy; 48 49 92 public class BMTStatelessAllowedOperationsTests extends BasicStatelessTestClient{ 93 94 public BMTStatelessAllowedOperationsTests(){ 95 super("BMTAllowedOperations."); 96 } 97 98 protected void setUp() throws Exception { 99 super.setUp(); 100 Object obj = initialContext.lookup("client/tests/stateless/BeanManagedBasicStatelessHome"); 101 ejbHome = (BasicStatelessHome)javax.rmi.PortableRemoteObject.narrow( obj, BasicStatelessHome.class); 102 ejbObject = ejbHome.create(); 103 ejbHandle = ejbObject.getHandle(); 104 ejbObject.businessMethod("let's go!"); 105 113 } 114 115 protected void tearDown() throws Exception { 116 try { 117 ejbObject.remove(); 118 } catch (Exception e){ 119 throw e; 120 } finally { 121 super.tearDown(); 122 } 123 } 124 125 139 public void test01_setSessionContext(){ 140 try{ 141 OperationsPolicy policy = new OperationsPolicy(); 142 policy.allow( policy.Context_getEJBHome ); 143 policy.allow( policy.JNDI_access_to_java_comp_env ); 144 145 Object expected = policy; 146 Object actual = ejbObject.getAllowedOperationsReport("setSessionContext"); 147 148 assertNotNull("The OperationsPolicy is null", actual ); 149 assertEquals( expected, actual ); 150 } catch (Exception e){ 151 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 152 } 153 } 154 167 public void test02_ejbCreate(){ 168 try{ 169 OperationsPolicy policy = new OperationsPolicy(); 170 policy.allow( policy.Context_getEJBHome ); 171 policy.allow( policy.Context_getEJBObject ); 172 policy.allow( policy.Context_getUserTransaction ); 173 policy.allow( policy.JNDI_access_to_java_comp_env ); 174 175 Object expected = policy; 176 Object actual = ejbObject.getAllowedOperationsReport("ejbCreate"); 177 178 assertNotNull("The OperationsPolicy is null", actual ); 179 assertEquals( expected, actual ); 180 } catch (Exception e){ 181 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 182 } 183 } 184 197 public void TODO_test03_ejbRemove(){ 198 try{ 199 200 OperationsPolicy policy = new OperationsPolicy(); 201 policy.allow( policy.Context_getEJBHome ); 202 policy.allow( policy.Context_getEJBObject ); 203 policy.allow( policy.Context_getUserTransaction ); 204 policy.allow( policy.JNDI_access_to_java_comp_env ); 205 206 Object expected = policy; 207 Object actual = ejbObject.getAllowedOperationsReport("ejbRemove"); 208 209 assertNotNull("The OperationsPolicy is null", actual ); 210 assertEquals( expected, actual ); 211 } catch (Exception e){ 212 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 213 } 214 } 215 216 233 public void test04_businessMethod(){ 234 try{ 235 OperationsPolicy policy = new OperationsPolicy(); 236 policy.allow( policy.Context_getEJBHome ); 237 policy.allow( policy.Context_getCallerPrincipal ); 238 policy.allow( policy.Context_isCallerInRole ); 239 policy.allow( policy.Context_getEJBObject ); 240 policy.allow( policy.Context_getUserTransaction ); 241 policy.allow( policy.JNDI_access_to_java_comp_env ); 242 policy.allow( policy.Resource_manager_access ); 243 policy.allow( policy.Enterprise_bean_access ); 244 245 Object expected = policy; 246 Object actual = ejbObject.getAllowedOperationsReport("businessMethod"); 247 248 assertNotNull("The OperationsPolicy is null", actual ); 249 assertEquals( expected, actual ); 250 } catch (Exception e){ 251 fail("Received Exception "+e.getClass()+ " : "+e.getMessage()); 252 } 253 } 254 } 258 259 260 | Popular Tags |