1 23 package com.sun.enterprise.tools.verifier.tests.webservices; 24 25 import com.sun.enterprise.deployment.*; 26 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 27 import com.sun.enterprise.tools.verifier.Result; 28 import com.sun.enterprise.tools.verifier.Verifier; 29 30 import java.lang.reflect.Method ; 31 32 35 36 46 47 public class EjbRemoveMethodNameExistInSLSB extends WSTest implements WSCheck { 48 49 53 public Result check (WebServiceEndpoint wsdescriptor) { 54 55 Result result = getInitializedResult(); 56 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 57 boolean foundFailure=false; 58 if (wsdescriptor.implementedByEjbComponent()) { 59 EjbDescriptor ejbdesc = wsdescriptor.getEjbComponentImpl(); 60 if (ejbdesc != null && (ejbdesc instanceof EjbSessionDescriptor)) { 61 EjbSessionDescriptor descriptor = (EjbSessionDescriptor)ejbdesc; 62 if (EjbSessionDescriptor.STATELESS.equals(descriptor.getSessionType())) { 63 try { 64 ClassLoader jcl = getVerifierContext().getClassLoader(); 66 Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader()); 67 int foundAtLeastOne = 0; 68 69 do { 70 Method [] methods = c.getDeclaredMethods(); 71 for (int i = 0; i < methods.length; i++) { 72 if (methods[i].getName().startsWith("ejbRemove")) { 74 foundAtLeastOne++; 75 result.addGoodDetails(smh.getLocalString 76 ("tests.componentNameConstructor", 77 "For [ {0} ]", 78 new Object [] {compName.toString()})); 79 result.addGoodDetails(smh.getLocalString 80 (getClass().getName() + ".passed", 81 "[ {0} ] declares [ {1} ] method.", 82 new Object [] {descriptor.getEjbClassName(),methods[i].getName()})); 83 } 84 } 85 } while (((c = c.getSuperclass()) != null) && (foundAtLeastOne == 0)); 86 if (foundAtLeastOne == 0){ 87 foundFailure = true; 88 result.addErrorDetails(smh.getLocalString 89 ("tests.componentNameConstructor", 90 "For [ {0} ]", 91 new Object [] {compName.toString()})); 92 result.failed(smh.getLocalString 93 (getClass().getName() + ".failed", 94 "Error: [ {0} ] does not properly declare at least one ejbRemove() method. [ {1} ] is not a valid bean.", 95 new Object [] {descriptor.getEjbClassName(),descriptor.getEjbClassName()})); 96 } 97 } catch (ClassNotFoundException e) { 98 Verifier.debug(e); 99 result.addErrorDetails(smh.getLocalString 100 ("tests.componentNameConstructor", 101 "For [ {0} ]", 102 new Object [] {compName.toString()})); 103 result.failed(smh.getLocalString 104 (getClass().getName() + ".failedException", 105 "Error: [ {0} ] class not found.", 106 new Object [] {descriptor.getEjbClassName()})); 107 return result; 108 } 109 } else { 110 result.addNaDetails(smh.getLocalString 111 ("tests.componentNameConstructor", "For [ {0} ]", 112 new Object [] {compName.toString()})); 113 result.notApplicable(smh.getLocalString 114 (getClass().getName() + ".notApplicable", 115 "NOT APPLICABLE :Service Implementation bean is not a stateless Session Bean")); 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() + ".notApplicable1", 125 "NOT APPLICABLE:Service Implementation bean is null or not a session bean descriptor ")); 126 return result; 127 } 128 129 if (foundFailure) { 130 result.setStatus(result.FAILED); 131 } else { 132 result.setStatus(result.PASSED); 133 } 134 return result; 135 136 } else { 137 result.addNaDetails(smh.getLocalString 138 ("tests.componentNameConstructor", 139 "For [ {0} ]", 140 new Object [] {compName.toString()})); 141 result.notApplicable(smh.getLocalString 142 (getClass().getName() + ".notApplicable2", 143 "Not Applicable: Service Implementation bean is not implemented by Ejb.")); 144 return result; 145 } 146 } 147 } 148 | Popular Tags |