1 23 package com.sun.enterprise.tools.verifier.tests.ejb.intf; 24 25 import com.sun.enterprise.deployment.EjbDescriptor; 26 import com.sun.enterprise.tools.verifier.Result; 27 import com.sun.enterprise.tools.verifier.Verifier; 28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 29 import com.sun.enterprise.tools.verifier.tests.ejb.RmiIIOPUtils; 30 31 import java.lang.reflect.Method ; 32 import java.util.logging.Level ; 33 34 44 abstract public class InterfaceMatchMethodException extends InterfaceMethodTest { 45 55 56 protected boolean runIndividualMethodTest(EjbDescriptor descriptor, Method method, Result result) { 57 58 boolean businessMethodFound, exceptionsMatch; 59 ComponentNameConstructor compName = null; 60 61 try { 62 compName = getVerifierContext().getComponentNameConstructor(); 63 ClassLoader jcl = getVerifierContext().getClassLoader(); 65 Class EJBClass = Class.forName(descriptor.getEjbClassName(), false, jcl); 66 Class [] methodExceptionTypes = method.getExceptionTypes(); 67 68 do { 70 Method [] businessMethods = EJBClass.getDeclaredMethods(); 71 72 businessMethodFound = false; 74 exceptionsMatch = false; 75 for (Method businessMethod : businessMethods) { 76 if (method.getName().equals(businessMethod.getName())) { 77 businessMethodFound = true; 78 Class [] businessMethodExceptionTypes = businessMethod.getExceptionTypes(); 80 if (RmiIIOPUtils.isEjbFindMethodExceptionsSubsetOfFindMethodExceptions(businessMethodExceptionTypes,methodExceptionTypes)) { 81 exceptionsMatch = true; 82 break; 83 } } else { 85 continue; 86 } 87 } 89 if (businessMethodFound && exceptionsMatch) { 92 addGoodDetails(result, compName); 93 result.addGoodDetails(smh.getLocalString 94 (getClass().getName() + ".passed", 95 "The corresponding business method with matching " + 96 "exceptions was found.")); 97 return true; 98 } else if (businessMethodFound && !exceptionsMatch) { 99 logger.log(Level.FINE, getClass().getName() + ".debug1", 100 new Object [] {method.getDeclaringClass().getName(),method.getName()}); 101 logger.log(Level.FINE, getClass().getName() + ".debug3", 102 new Object [] {method.getName()}); 103 logger.log(Level.FINE, getClass().getName() + ".debug2"); 104 } 105 106 } while (((EJBClass = EJBClass.getSuperclass()) != null) && (!(businessMethodFound && exceptionsMatch))); 107 108 109 if (!exceptionsMatch) { 110 addErrorDetails(result, compName); 111 result.addErrorDetails(smh.getLocalString 112 (getClass().getName() + ".failed", 113 "Error: No corresponding business method with matching exceptions was found for method [ {0} ].", 114 new Object [] {method.getName()})); 115 } 116 } catch (ClassNotFoundException e) { 117 Verifier.debug(e); 118 addErrorDetails(result, compName); 119 result.failed(smh.getLocalString 120 (getClass().getName() + ".failedException", 121 "Error: "+ getInterfaceType() +"interface [ {0} ] does not " + 122 "exist or is not loadable within bean [ {1} ]", 123 new Object [] {getClassName(descriptor),descriptor.getName()})); 124 } 125 return false; 126 } 127 128 private String getClassName(EjbDescriptor descriptor) { 129 return getInterfaceName(descriptor); 130 } 131 } 132 | Popular Tags |