1 23 package com.sun.enterprise.tools.verifier.tests.ejb; 24 25 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import java.lang.ClassLoader ; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 31 35 public class JarFileContainsProperEJBClasses extends EjbTest implements EjbCheck { 36 37 38 39 47 public Result check(EjbDescriptor descriptor) { 48 49 Result result = getInitializedResult(); 50 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 51 52 try { 53 Context context = getVerifierContext(); 54 Class c = Class.forName(descriptor.getEjbClassName(), false, 55 getVerifierContext().getClassLoader()); 56 if (descriptor instanceof EjbEntityDescriptor) { 58 String persistentType = 59 ((EjbEntityDescriptor)descriptor).getPersistenceType(); 60 if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistentType)) { 61 if (EjbCMPEntityDescriptor.CMP_1_1!=((EjbCMPEntityDescriptor) descriptor).getCMPVersion()) { 62 result.addGoodDetails(smh.getLocalString 63 ("tests.componentNameConstructor", 64 "For [ {0} ]", 65 new Object [] {compName.toString()})); 66 67 result.passed(smh.getLocalString 68 (getClass().getName() + ".passed", 69 "Bean class [ {0} ] exists and it's supporting classes exist.", 70 new Object [] {descriptor.getEjbClassName()})); 71 return result; 72 } 73 } 74 } 75 76 try { 77 c.newInstance(); 78 result.addGoodDetails(smh.getLocalString 79 ("tests.componentNameConstructor", 80 "For [ {0} ]", 81 new Object [] {compName.toString()})); 82 83 result.passed(smh.getLocalString 84 (getClass().getName() + ".passed", 85 "Bean class [ {0} ] exists and it's supporting classes exist.", 86 new Object [] {descriptor.getEjbClassName()})); 87 } catch (InstantiationException e) { 88 Verifier.debug(e); 89 result.addErrorDetails(smh.getLocalString 90 ("tests.componentNameConstructor", 91 "For [ {0} ]", 92 new Object [] {compName.toString()})); 93 94 result.failed(smh.getLocalString 95 (getClass().getName() + ".failedException", 96 "Error: Could not instantiate [ {0} ] within bean [ {1} ]", 97 new Object [] {descriptor.getEjbClassName(),descriptor.getName()})); 98 } catch (IllegalAccessException e) { 99 Verifier.debug(e); 100 result.addErrorDetails(smh.getLocalString 101 ("tests.componentNameConstructor", 102 "For [ {0} ]", 103 new Object [] {compName.toString()})); 104 105 result.failed(smh.getLocalString 106 (getClass().getName() + ".failedException1", 107 "Error: Illegal Access while trying to instantiate [ {0} ] within bean [ {1} ]", 108 new Object [] {descriptor.getEjbClassName(),descriptor.getName()})); 109 } 110 } catch (ClassNotFoundException e) { 111 Verifier.debug(e); 112 result.addErrorDetails(smh.getLocalString 113 ("tests.componentNameConstructor", 114 "For [ {0} ]", 115 new Object [] {compName.toString()})); 116 117 result.failed(smh.getLocalString 118 (getClass().getName() + ".failedException2", 119 "Error: Can't find class [ {0} ] within bean [ {1} ]", 120 new Object [] {descriptor.getEjbClassName(),descriptor.getName()})); 121 } catch (Throwable t) { 122 Verifier.debug(t); 123 result.addNaDetails(smh.getLocalString 124 ("tests.componentNameConstructor", 125 "For [ {0} ]", 126 new Object [] {compName.toString()})); 127 128 result.notApplicable(smh.getLocalString 129 (getClass().getName() + ".notApplicable", 130 "Not Applicable: [ {0} ] class encountered [ {1} ]. Cannot create instance of class [ {2} ] becuase [ {3} ] is not accessible within [ {4} ].", 131 new Object [] {(descriptor).getEjbClassName(),t.toString(), descriptor.getEjbClassName(), t.getMessage(), descriptor.getEjbBundleDescriptor().getModuleDescriptor().getArchiveUri()})); 132 } 133 return result; 134 } 135 } 136 | Popular Tags |