1 23 package com.sun.enterprise.tools.verifier.tests.ejb.homeintf; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.lang.ClassLoader ; 27 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 28 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 29 import com.sun.enterprise.tools.verifier.Result; 30 import com.sun.enterprise.tools.verifier.Context; 31 import com.sun.enterprise.tools.verifier.Verifier; 32 import com.sun.enterprise.deployment.EjbDescriptor; 33 import com.sun.enterprise.deployment.EjbSessionDescriptor; 34 import com.sun.enterprise.deployment.EjbEntityDescriptor; 35 36 40 abstract public class HomeInterfaceExtendsRightInterface extends EjbTest implements EjbCheck { 41 42 44 abstract protected String getHomeInterfaceName(EjbDescriptor descriptor); 45 abstract protected String getSuperInterface(); 46 47 55 56 57 public Result check(EjbDescriptor descriptor) { 58 59 Result result = getInitializedResult(); 60 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 61 String str = null; 62 63 if(getHomeInterfaceName(descriptor) == null || "".equals(getHomeInterfaceName(descriptor))){ 64 result.addNaDetails(smh.getLocalString 65 ("tests.componentNameConstructor", "For [ {0} ]", 66 new Object [] {compName.toString()})); 67 result.notApplicable(smh.getLocalString 68 ("com.sun.enterprise.tools.verifier.tests.ejb.localinterfaceonly.notapp", 69 "Not Applicable because, EJB [ {0} ] has Local Interfaces only.", 70 new Object [] {descriptor.getEjbClassName()})); 71 72 return result; 73 } 74 75 if ((descriptor instanceof EjbSessionDescriptor) || 76 (descriptor instanceof EjbEntityDescriptor)) { 77 78 try { 79 Context context = getVerifierContext(); 80 ClassLoader jcl = context.getClassLoader(); 81 Class c = Class.forName(getClassName(descriptor), false, jcl); 82 str = getSuperInterface(); 83 if (isImplementorOf(c, str)) { 84 result.addGoodDetails(smh.getLocalString 86 ("tests.componentNameConstructor", 87 "For [ {0} ]", 88 new Object [] {compName.toString()})); 89 result.passed(smh.getLocalString 90 (getClass().getName() + ".passed", 91 "[ {0} ] properly extends the " + str + "interface.", 92 new Object [] {getClassName(descriptor)})); 93 } else { 94 result.addErrorDetails(smh.getLocalString 95 ("tests.componentNameConstructor", 96 "For [ {0} ]", 97 new Object [] {compName.toString()})); 98 result.failed(smh.getLocalString 99 (getClass().getName() + ".failed", 100 "Error: [ {0} ] does not properly extend the " + str + 101 " interface. All enterprise beans home interfaces must extend the " + str + 102 " interface. [ {1} ] is not a valid home interface.", 103 new Object [] {getClassName(descriptor),getClassName(descriptor)})); 104 } 105 } catch (ClassNotFoundException e) { 106 Verifier.debug(e); 107 result.addErrorDetails(smh.getLocalString 108 ("tests.componentNameConstructor", 109 "For [ {0} ]", 110 new Object [] {compName.toString()})); 111 result.failed(smh.getLocalString 112 (getClass().getName() + ".failedException", 113 "Error: [ {0} ] class not found.", 114 new Object [] {getClassName(descriptor)})); 115 } 116 return result; 117 118 } else { 119 result.addNaDetails(smh.getLocalString 120 ("tests.componentNameConstructor", 121 "For [ {0} ]", 122 new Object [] {compName.toString()})); 123 result.notApplicable(smh.getLocalString 124 (getClass().getName() + ".notApplicable", 125 "[ {0} ] expected {1} bean or {2} bean, but called with {3}.", 126 new Object [] {getClass(),"Session","Entity",descriptor.getName()})); 127 return result; 128 } 129 } 130 131 private String getClassName(EjbDescriptor descriptor) { 132 return getHomeInterfaceName(descriptor); 133 } 134 } 135 | Popular Tags |