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 30 import java.lang.reflect.Method ; 31 import java.util.logging.Level ; 32 33 41 abstract public class InterfaceMatchMethodReturn extends InterfaceMethodTest { 42 52 protected boolean runIndividualMethodTest(EjbDescriptor descriptor, Method method, Result result) { 53 54 boolean businessMethodFound, returnMatch; 55 ComponentNameConstructor compName = null; 56 57 try { 58 compName = getVerifierContext().getComponentNameConstructor(); 59 Class methodReturnType = method.getReturnType(); 60 ClassLoader jcl = getVerifierContext().getClassLoader(); 62 Class EJBClass = Class.forName(descriptor.getEjbClassName(), false, jcl); 63 64 do { 66 Method [] businessMethods = EJBClass.getDeclaredMethods(); 67 68 businessMethodFound = false; 70 returnMatch = false; 71 for (Method businessMethod : businessMethods) { 72 if (method.getName().equals(businessMethod.getName())) { 73 businessMethodFound = true; 74 Class businessMethodReturnType = businessMethod.getReturnType(); 75 if (methodReturnType.equals(businessMethodReturnType)) { 76 returnMatch = true; 77 break; 78 } } else { 80 continue; 81 82 } } 85 if (businessMethodFound && returnMatch) { 88 addGoodDetails(result, compName); 89 result.addGoodDetails(smh.getLocalString 90 (getClass().getName() + ".passed", 91 "The corresponding business method with a matching " + 92 "return type was found.")); 93 return true; 94 } else if(businessMethodFound && !returnMatch) { 95 logger.log(Level.FINE, getClass().getName() + ".debug1", 96 new Object [] {method.getDeclaringClass().getName(),method.getName()}); 97 logger.log(Level.FINE, getClass().getName() + ".debug3", 98 new Object [] {method.getName()}); 99 logger.log(Level.FINE, getClass().getName() + ".debug2"); 100 } 101 102 } while (((EJBClass = EJBClass.getSuperclass()) != null) && (!(businessMethodFound && returnMatch))); 103 104 105 if (!returnMatch) { 106 addErrorDetails(result, compName); 107 result.addErrorDetails(smh.getLocalString 108 (getClass().getName() + ".failed", 109 "Error: No corresponding business method with matching " + 110 "return type was found for method [ {0} ].", 111 new Object [] {method.getName()})); 112 } 113 } catch (ClassNotFoundException e) { 114 Verifier.debug(e); 115 addErrorDetails(result, compName); 116 result.failed(smh.getLocalString 117 (getClass().getName() + ".failedException", 118 "Error: "+ getInterfaceType() +"interface [ {0} ] does not " + 119 "exist or is not loadable within bean [ {1} ]", 120 new Object [] {getClassName(descriptor),descriptor.getName()})); 121 } 122 123 return false; 124 } 125 126 private String getClassName(EjbDescriptor descriptor) { 127 return getInterfaceName(descriptor); 128 } 129 } 130 | Popular Tags |