1 23 package com.sun.enterprise.tools.verifier.tests.ejb.session.createmethod; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.deployment.EjbDescriptor; 27 import com.sun.enterprise.deployment.EjbSessionDescriptor; 28 import java.lang.ClassLoader ; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 import java.util.*; 31 import java.lang.reflect.*; 32 import com.sun.enterprise.tools.verifier.*; 33 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 34 import com.sun.enterprise.tools.verifier.tests.ejb.EjbUtils; 35 36 46 public class HomeInterfaceCreateMethodExceptionRemote extends EjbTest implements EjbCheck { 47 48 49 63 public Result check(EjbDescriptor descriptor) { 64 65 Result result = getInitializedResult(); 66 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 67 68 if (descriptor instanceof EjbSessionDescriptor) { 69 boolean oneFailed = false; 70 boolean foundAtLeastOneRemote = false; 71 if(descriptor.getHomeClassName() == null || "".equals(descriptor.getHomeClassName())) { 74 result.addNaDetails(smh.getLocalString 75 ("tests.componentNameConstructor", 76 "For [ {0} ]", 77 new Object [] {compName.toString()})); 78 result.addNaDetails(smh.getLocalString 79 (getClass().getName() + ".notApplicable1", 80 "No Remote Home Interface for this ejb", 81 new Object [] {})); 82 return result; 83 } 84 try { 85 Context context = getVerifierContext(); 86 ClassLoader jcl = context.getClassLoader(); 87 Class c = Class.forName(descriptor.getHomeClassName(), false, getVerifierContext().getClassLoader()); 88 Method methods[] = c.getDeclaredMethods(); 89 Class [] methodExceptionTypes; 90 boolean throwsRemoteException = false; 91 92 93 for (int i=0; i< methods.length; i++) { 94 throwsRemoteException = false; 96 97 if (methods[i].getName().startsWith("create")) { 98 if (!foundAtLeastOneRemote) { 103 foundAtLeastOneRemote = true; 104 } 105 106 methodExceptionTypes = methods[i].getExceptionTypes(); 107 108 if (EjbUtils.isValidRemoteException(methodExceptionTypes)) { 110 throwsRemoteException = true; 111 } 112 113 if (throwsRemoteException ) { 117 result.addGoodDetails(smh.getLocalString 118 ("tests.componentNameConstructor", 119 "For [ {0} ]", 120 new Object [] {compName.toString()})); 121 result.addGoodDetails(smh.getLocalString 122 (getClass().getName() + ".debug1", 123 "For Home Interface [ {0} ] Method [ {1} ]", 124 new Object [] {c.getName(),methods[i].getName()})); 125 result.addGoodDetails(smh.getLocalString 126 (getClass().getName() + ".passed", 127 "The create method which must throw java.rmi.RemoteException was found.")); 128 } else if (!throwsRemoteException) { 129 oneFailed = true; 130 result.addErrorDetails(smh.getLocalString 131 ("tests.componentNameConstructor", 132 "For [ {0} ]", 133 new Object [] {compName.toString()})); 134 result.addErrorDetails(smh.getLocalString 135 (getClass().getName() + ".debug1", 136 "For Home Interface [ {0} ] Method [ {1} ]", 137 new Object [] {c.getName(),methods[i].getName()})); 138 result.addErrorDetails(smh.getLocalString 139 (getClass().getName() + ".failed", 140 "Error: A create method was found, but did not throw java.rmi.RemoteException." )); 141 } } } 145 146 } catch (ClassNotFoundException e) { 147 Verifier.debug(e); 148 result.addErrorDetails(smh.getLocalString 149 ("tests.componentNameConstructor", 150 "For [ {0} ]", 151 new Object [] {compName.toString()})); 152 result.failed(smh.getLocalString 153 (getClass().getName() + ".failedException", 154 "Error: Home interface [ {0} ] does not exist or is not loadable within bean [ {1} ]", 155 new Object [] {descriptor.getHomeClassName(), descriptor.getName()})); 156 } 157 158 if (!foundAtLeastOneRemote) { 159 result.addErrorDetails(smh.getLocalString 160 ("tests.componentNameConstructor", 161 "For [ {0} ]", 162 new Object [] {compName.toString()})); 163 result.addErrorDetails(smh.getLocalString 164 (getClass().getName() + ".debug3", 165 "For Home Interface [ {0} ]", 166 new Object [] {descriptor.getHomeClassName()})); 167 result.addErrorDetails(smh.getLocalString 168 (getClass().getName() + ".failed1", 169 "No create method was found in [ {0} ]", 170 new Object [] {descriptor.getHomeClassName()})); 171 result.setStatus(result.FAILED); 172 } else { 173 if (oneFailed) { 174 result.setStatus(result.FAILED); 175 } else { 176 result.setStatus(result.PASSED); 177 } 178 } 179 180 return result; 181 182 } else { 183 result.addErrorDetails(smh.getLocalString 184 ("tests.componentNameConstructor", 185 "For [ {0} ]", 186 new Object [] {compName.toString()})); 187 result.notApplicable(smh.getLocalString 188 (getClass().getName() + ".notApplicable", 189 "[ {0} ] expected {1} bean, but called with {2} bean.", 190 new Object [] {getClass(),"Session","Entity"})); 191 return result; 192 } 193 } 194 } 195 | Popular Tags |