1 23 package com.sun.enterprise.tools.verifier.tests.ejb.entity.ejbcreatemethod; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import java.lang.ClassLoader ; 27 import com.sun.enterprise.tools.verifier.tests.*; 28 import javax.ejb.EntityBean ; 29 import java.lang.reflect.*; 30 import com.sun.enterprise.deployment.*; 31 import com.sun.enterprise.tools.verifier.*; 32 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 33 import com.sun.enterprise.tools.verifier.tests.ejb.RmiIIOPUtils; 34 35 46 public class EjbCreateMethodArgs extends EjbTest implements EjbCheck { 47 48 49 63 public Result check(EjbDescriptor descriptor) { 64 65 Result result = getInitializedResult(); 66 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 67 if (descriptor instanceof EjbEntityDescriptor) { 68 boolean oneFailed = false; 69 int foundAtLeastOne = 0; 70 boolean remote_exists = false; 71 try { 72 Context context = getVerifierContext(); 73 ClassLoader jcl = context.getClassLoader(); 74 Class c = Class.forName(descriptor.getEjbClassName(), false, getVerifierContext().getClassLoader()); 75 76 if (descriptor.getRemoteClassName() == null || 78 descriptor.getRemoteClassName().equals("")) { 79 result.addNaDetails(smh.getLocalString 80 ("tests.componentNameConstructor", "For [ {0} ]", 81 new Object [] {compName.toString()})); 82 result.notApplicable(smh.getLocalString 83 ("com.sun.enterprise.tools.verifier.tests.ejb.localinterfaceonly.notapp", 84 "Not Applicable because, EJB [ {0} ] has Local Interfaces only.", 85 new Object [] {descriptor.getEjbClassName()})); 86 87 return result; 88 } 89 90 if (descriptor.getRemoteClassName() != null && 91 !descriptor.getRemoteClassName().equals("")) 92 remote_exists = true; 93 94 Class [] ejbCreateMethodParameterTypes; 95 boolean ejbCreateFound = false; 96 boolean isLegalRMIIIOP = false; 97 do { 99 Method [] methods = c.getDeclaredMethods(); 100 for (int i = 0; i < methods.length; i++) { 101 ejbCreateFound = false; 103 isLegalRMIIIOP = false; 104 105 if (methods[i].getName().startsWith("ejbCreate")) { 107 foundAtLeastOne++; 108 ejbCreateFound = true; 109 110 if (remote_exists == true) { 111 ejbCreateMethodParameterTypes = methods[i].getParameterTypes(); 113 if (RmiIIOPUtils.isValidRmiIIOPParameters(ejbCreateMethodParameterTypes)) { 114 isLegalRMIIIOP = true; 116 } 117 } else isLegalRMIIIOP = true; 122 if (ejbCreateFound && !isLegalRMIIIOP) { 123 oneFailed = true; 124 result.addErrorDetails(smh.getLocalString 125 ("tests.componentNameConstructor", 126 "For [ {0} ]", 127 new Object [] {compName.toString()})); 128 result.addErrorDetails(smh.getLocalString 129 (getClass().getName() + ".debug1", 130 "For EJB Class [ {0} ] method [ {1} ]", 131 new Object [] {descriptor.getEjbClassName(),methods[i].getName()})); 132 result.addErrorDetails(smh.getLocalString 133 (getClass().getName() + ".failed", 134 "Error: An [ {0} ] method was found, but [ {1} ] method has illegal parameter values. [ {2} ] methods arguments types must be legal types for RMI-IIOP.", 135 new Object [] {methods[i].getName(),methods[i].getName(),methods[i].getName()})); 136 break; 137 } 138 } 139 } 140 if (oneFailed == true) 141 break; 142 } while (((c = c.getSuperclass()) != null) && (foundAtLeastOne == 0)); 143 144 if (foundAtLeastOne == 0) { 145 result.addNaDetails(smh.getLocalString 146 ("tests.componentNameConstructor", 147 "For [ {0} ]", 148 new Object [] {compName.toString()})); 149 result.notApplicable(smh.getLocalString 150 (getClass().getName() + ".notApplicable1", 151 "[ {0} ] does not declare any ejbCreate(...) methods.", 152 new Object [] {descriptor.getEjbClassName()})); 153 } 154 155 if (oneFailed == false && foundAtLeastOne > 0) { 156 result.addGoodDetails(smh.getLocalString 157 ("tests.componentNameConstructor", 158 "For [ {0} ]", 159 new Object [] {compName.toString()})); 160 result.addGoodDetails(smh.getLocalString 161 (getClass().getName() + ".debug1", 162 "For EJB Class [ {0} ]", 163 new Object [] {descriptor.getEjbClassName()})); 164 result.addGoodDetails(smh.getLocalString 165 (getClass().getName() + ".passed", 166 "[ {0} ] properly declares ejbCreate<method> method with arguments that are legal types for RMI-IIOP.", 167 new Object [] {descriptor.getEjbClassName()})); 168 } 169 } catch (ClassNotFoundException e) { 170 Verifier.debug(e); 171 result.addErrorDetails(smh.getLocalString 172 ("tests.componentNameConstructor", 173 "For [ {0} ]", 174 new Object [] {compName.toString()})); 175 result.failed(smh.getLocalString 176 (getClass().getName() + ".failedException", 177 "Error: [ {0} ] class not found.", 178 new Object [] {descriptor.getEjbClassName()})); 179 oneFailed = true; 180 } 181 182 if (oneFailed) { 183 result.setStatus(result.FAILED); 184 } else if (foundAtLeastOne == 0) { 185 result.setStatus(result.NOT_APPLICABLE); 186 } else { 187 result.setStatus(result.PASSED); 188 } 189 190 return result; 191 192 } else { 193 result.addNaDetails(smh.getLocalString 194 ("tests.componentNameConstructor", 195 "For [ {0} ]", 196 new Object [] {compName.toString()})); 197 result.notApplicable(smh.getLocalString 198 (getClass().getName() + ".notApplicable", 199 "[ {0} ] expected {1} bean, but called with {2} bean.", 200 new Object [] {getClass(),"Entity","Session"})); 201 return result; 202 } 203 } 204 } 205 | Popular Tags |