1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.lang.reflect.*; 27 import java.util.*; 28 import java.rmi.*; 29 import com.sun.enterprise.deployment.*; 30 import com.sun.enterprise.tools.verifier.*; 31 import java.lang.ClassLoader ; 32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 33 34 39 public class EjbUtils { 40 41 42 43 57 public static boolean isFieldSubsetOfCMP(Field field, Set CMPFields) { 58 if (CMPFields.contains(new FieldDescriptor(field))) { 59 return true; 60 } else { 61 return false; 62 } 63 } 64 65 66 79 public static boolean isPKFieldMatchingBeanFields(Field field, Vector beanFields) { 80 81 for (int i = 0; i < beanFields.size(); i++) { 82 if (((FieldDescriptor)beanFields.elementAt(i)).getName().equals(field.getName())) { 83 return true; 84 } else { 85 continue; 86 } 87 } 88 return false; 90 } 91 92 93 108 public static boolean isValidCreateException(Class [] methodExceptions) { 109 boolean throwsCreateException = false; 111 for (int kk = 0; kk < methodExceptions.length; ++kk) { 112 if ((methodExceptions[kk].getName().equals("javax.ejb.CreateException")) || 113 (methodExceptions[kk].getName().equals("CreateException"))) { 114 throwsCreateException = true; 115 break; 116 } 117 } 118 return throwsCreateException; 119 120 } 121 122 123 124 139 public static boolean isValidRemoteException(Class [] methodExceptions) { 140 boolean throwsRemoteException = false; 142 for (int kk = 0; kk < methodExceptions.length; ++kk) { 143 if ((methodExceptions[kk].getName().equals("java.rmi.RemoteException")) || 144 (methodExceptions[kk].getName().equals("RemoteException"))) { 145 throwsRemoteException = true; 146 break; 147 } 148 } 149 return throwsRemoteException; 150 151 } 152 153 154 155 173 public static boolean isValidObjectNotFoundExceptionException(Class [] methodExceptions) { 174 boolean throwsObjectNotFoundException = false; 176 for (int kk = 0; kk < methodExceptions.length; ++kk) { 177 if ((methodExceptions[kk].getName().equals("javax.ejb.ObjectNotFoundException")) || 178 (methodExceptions[kk].getName().equals("ObjectNotFoundException"))) { 179 throwsObjectNotFoundException = true; 180 break; 181 } 182 } 183 return throwsObjectNotFoundException; 184 } 185 186 187 188 189 204 public static boolean isValidFinderException(Class [] methodExceptions) { 205 boolean throwsFinderException = false; 207 for (int kk = 0; kk < methodExceptions.length; ++kk) { 208 if ((methodExceptions[kk].getName().equals("javax.ejb.FinderException")) || 209 (methodExceptions[kk].getName().equals("FinderException"))) { 210 throwsFinderException = true; 211 break; 212 } 213 } 214 return throwsFinderException; 215 216 } 217 218 219 230 public static boolean isValidSerializableType(Class serClass) { 231 232 if (java.io.Serializable .class.isAssignableFrom(serClass)) 233 return true; 234 else 235 return false; 236 237 277 } 278 279 280 281 300 public static boolean isValidApplicationException(Class [] methodExceptions) { 301 for (int kk = 0; kk < methodExceptions.length; ++kk) { 302 Class ex=methodExceptions[kk]; 303 if (java.rmi.RemoteException .class != ex) { 305 if (!java.lang.Exception .class.isAssignableFrom(ex)) return false; 307 if(java.rmi.RemoteException .class.isAssignableFrom(ex) || java.lang.RuntimeException .class.isAssignableFrom(ex)) { 309 return false; 310 } 311 } 312 } 313 return true; 314 } 315 } 316 | Popular Tags |