1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import java.lang.reflect.Method ; 26 27 import com.sun.enterprise.deployment.EjbDescriptor; 28 import com.sun.enterprise.deployment.EjbEntityDescriptor; 29 import com.sun.enterprise.deployment.EjbSessionDescriptor; 30 import com.sun.enterprise.tools.verifier.Result; 31 import com.sun.enterprise.tools.verifier.Verifier; 32 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 33 34 46 public class ApplicationExceptionHomeInterfaceMethods extends EjbTest implements EjbCheck { 47 48 Result result = null; 49 ComponentNameConstructor compName = null; 50 51 67 public Result check(EjbDescriptor descriptor) { 68 69 result = getInitializedResult(); 70 compName = getVerifierContext().getComponentNameConstructor(); 71 if ((descriptor instanceof EjbSessionDescriptor) || 72 (descriptor instanceof EjbEntityDescriptor)) { 73 if(descriptor.getHomeClassName() != null) 74 commonToBothInterfaces(descriptor.getHomeClassName(),descriptor); 75 if(descriptor.getLocalHomeClassName() != null) 76 commonToBothInterfaces(descriptor.getLocalHomeClassName(), descriptor); 77 } 78 79 if(result.getStatus() != Result.FAILED) { 80 addGoodDetails(result, compName); 81 result.passed(smh.getLocalString 82 (getClass().getName() + ".passed", 83 "All the methods of Home interface are defined properly")); 84 } 85 return result; 86 } 87 88 89 95 96 private void commonToBothInterfaces (String home, EjbDescriptor descriptor) { 97 98 try { 99 Class c = Class.forName(home, false, getVerifierContext().getClassLoader()); 100 Class [] methodExceptionTypes; 101 102 for(Method methods : c.getDeclaredMethods()) { 103 methodExceptionTypes = methods.getExceptionTypes(); 104 if (!(EjbUtils.isValidApplicationException(methodExceptionTypes))) { 106 addErrorDetails(result, compName); 107 result.failed(smh.getLocalString 108 (getClass().getName() + ".failed", 109 "For the Interface [ {0} ] Method [ {1} ] does" + 110 " not throw valid application exceptions", 111 new Object [] {home, methods.getName()})); 112 } 113 } 115 } catch (Exception e) { 116 Verifier.debug(e); 117 addErrorDetails(result, compName); 118 result.failed(smh.getLocalString 119 (getClass().getName() + ".failedException", 120 "Error: Home interface [ {0} ] does not exist or is" + 121 " not loadable within bean [ {1} ]", 122 new Object [] {home, descriptor.getName()})); 123 } 124 } 125 } 126 | Popular Tags |