1 23 package com.sun.enterprise.tools.verifier.tests.ejb.intf; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 27 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 28 import com.sun.enterprise.tools.verifier.Result; 29 import com.sun.enterprise.tools.verifier.Verifier; 30 import com.sun.enterprise.deployment.EjbDescriptor; 31 import com.sun.enterprise.deployment.EjbSessionDescriptor; 32 import com.sun.enterprise.deployment.EjbEntityDescriptor; 33 34 42 abstract public class ExtendsRightInterface extends EjbTest implements EjbCheck { 43 47 abstract protected String getInterfaceName(EjbDescriptor descriptor); 48 abstract protected String getSuperInterface(); 49 abstract protected String getInterfaceType(); 50 51 60 public Result check(EjbDescriptor descriptor) { 61 62 Result result = getInitializedResult(); 63 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 64 String str = null; 65 66 if (!(descriptor instanceof EjbSessionDescriptor) && 67 !(descriptor instanceof EjbEntityDescriptor)) { 68 addNaDetails(result, compName); 69 result.notApplicable(smh.getLocalString 70 ("com.sun.enterprise.tools.verifier.tests.ejb.homeintf.HomeMethodTest.notApplicable1", 71 "Test apply only to session or entity beans.")); 72 return result; 73 } 74 75 if(getInterfaceName(descriptor) == null || "".equals(getInterfaceName(descriptor))) { 76 addNaDetails(result, compName); 77 result.notApplicable(smh.getLocalString 78 ("com.sun.enterprise.tools.verifier.tests.ejb.intf.InterfaceTest.notApplicable", 79 "Not Applicable because, EJB [ {0} ] does not have {1} Interface.", 80 new Object [] {descriptor.getEjbClassName(), getInterfaceType()})); 81 return result; 82 } 83 84 try { 85 ClassLoader jcl = getVerifierContext().getClassLoader(); 86 Class c = Class.forName(getClassName(descriptor), false, jcl); 87 str = getSuperInterface(); 88 89 if (isImplementorOf(c, str)) { 90 addGoodDetails(result, compName); 91 result.passed(smh.getLocalString 92 (getClass().getName() + ".passed", 93 "[ {0} ] " + getInterfaceType() +" interface properly extends the" + str + " interface.", 94 new Object [] {getClassName(descriptor)})); 95 } else { 96 addErrorDetails(result, compName); 97 result.failed(smh.getLocalString 98 (getClass().getName() + ".failed", 99 "Error: [ {0} ] does not properly extend the EJBObject interface. "+ 100 " All enterprise bean" + getInterfaceType() + " interfaces must extend the" + str + " interface."+ 101 " [ {1} ] is not a valid "+ getInterfaceType() + "interface within bean [ {2} ]", 102 new Object [] {getClassName(descriptor),getClassName(descriptor),descriptor.getName()})); 103 } 104 } catch (ClassNotFoundException e) { 105 Verifier.debug(e); 106 addErrorDetails(result, compName); 107 result.failed(smh.getLocalString 108 (getClass().getName() + ".failedException", 109 "Error: [ {0} ] class not found.", 110 new Object [] {getClassName(descriptor)})); 111 } 112 return result; 113 } 114 private String getClassName(EjbDescriptor descriptor) { 116 return getInterfaceName(descriptor); 117 } 118 } 119 | Popular Tags |