1 23 24 package com.sun.enterprise.tools.verifier.tests.ejb.entity.ejbql; 25 26 import com.sun.jdo.spi.persistence.support.ejb.ejbqlc.EJBQLException; 27 import com.sun.enterprise.deployment.IASEjbCMPEntityDescriptor; 28 import com.sun.enterprise.deployment.EjbDescriptor; 29 import com.sun.enterprise.tools.verifier.Result; 30 import com.sun.enterprise.tools.verifier.tests.ejb.EjbCheck; 31 import com.sun.enterprise.tools.verifier.tests.ejb.EjbTest; 32 import com.sun.enterprise.tools.verifier.tests.*; 33 import com.sun.jdo.spi.persistence.support.ejb.ejbc.JDOCodeGenerator; 34 import java.util.Collection ; 35 import java.util.Iterator ; 36 37 38 39 46 public class EjbQLFromCmpEntityDescriptor extends EjbTest implements EjbCheck { 47 48 54 public Result check(EjbDescriptor descriptor) { 55 56 Result result = getInitializedResult(); 57 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 58 try { 59 60 if (descriptor instanceof IASEjbCMPEntityDescriptor) { 61 Collection col = null; 62 if(getVerifierContext().getJDOException()!=null){ 63 result.addErrorDetails(smh.getLocalString 64 ("tests.componentNameConstructor", 65 "For [ {0} ]", 66 new Object [] {compName.toString()})); 67 result.failed (smh.getLocalString(getClass().getName() + ".failed1", 68 "Error: Exception [ {0} ] while initialising JDO code generator.", 69 new Object [] {getVerifierContext().getJDOException().getMessage()})); 70 71 return result; 72 }else{ 73 try{ 74 JDOCodeGenerator jdc= getVerifierContext().getJDOCodeGenerator(); 75 col = jdc.validate((IASEjbCMPEntityDescriptor)descriptor); 76 }catch(Exception ex){ 77 result.addErrorDetails(smh.getLocalString 78 ("tests.componentNameConstructor", 79 "For [ {0} ]", 80 new Object [] {compName.toString()})); 81 result.failed (smh.getLocalString(getClass().getName() + ".failed", 82 "Error: Exception [ {0} ] when calling JDOCodeGenerator.validate().", 83 new Object [] {ex.getMessage()})); 84 return result; 85 } 86 } 87 if (col.isEmpty()){ 88 result.addGoodDetails(smh.getLocalString 89 ("tests.componentNameConstructor", 90 "For [ {0} ]", 91 new Object [] {compName.toString()})); 92 result.passed(smh.getLocalString(getClass().getName() + ".passed", 93 "Syntax and Semantics of EJBQL Queries (if any) are correct.")); 94 95 }else{ 96 String allErrors = null; 98 Iterator it = col.iterator(); 99 while (it.hasNext()) { 100 Exception e = (Exception )it.next(); 101 if (e instanceof EJBQLException) { 102 allErrors = e.getMessage() + "\n\n"; 103 } 104 } 105 106 if (allErrors != null) { 107 result.addErrorDetails(smh.getLocalString 108 ("tests.componentNameConstructor", 109 "For [ {0} ]", 110 new Object [] {compName.toString()})); 111 result.failed(smh.getLocalString(getClass().getName() + ".parseError", 112 "Error: Entity bean [ {0} ] has the following EJBQL error(s) [ {1} ]." 113 , new Object [] {descriptor.getEjbClassName(), "\n" + allErrors} )); 114 115 } 116 else { 117 result.addGoodDetails(smh.getLocalString 118 ("tests.componentNameConstructor", 119 "For [ {0} ]", 120 new Object [] {compName.toString()})); 121 result.passed(smh.getLocalString(getClass().getName() + ".passed", 122 "Syntax and Semantics of EJBQL Queries (if any) are correct.")); 123 } 124 } 125 126 } else { 127 result.addNaDetails(smh.getLocalString 128 ("tests.componentNameConstructor", 129 "For [ {0} ]", 130 new Object [] {compName.toString()})); 131 result.notApplicable( 132 smh.getLocalString(getClass().getName() + ".notApplicable", 133 "Not applicable: Test only applies to container managed EJBs")); 134 } 135 } catch(Exception e) { 136 result.addErrorDetails(smh.getLocalString 137 ("tests.componentNameConstructor", 138 "For [ {0} ]", 139 new Object [] {compName.toString()})); 140 result.failed (smh.getLocalString(getClass().getName() + ".failed", 141 "Error: Exception [ {0} ] when calling JDOCodeGenerator.validate().", 142 new Object [] {e.getMessage()})); 143 } 144 return result; 145 } 146 } 147 | Popular Tags |