1 23 24 package com.sun.enterprise.tools.verifier.tests.ejb.runtime.beancache; 25 26 import com.sun.enterprise.deployment.EjbDescriptor; 27 import com.sun.enterprise.tools.verifier.Result; 28 import com.sun.enterprise.tools.verifier.Verifier; 29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 30 31 32 44 45 public class ASEjbBCResizeQuantity extends ASEjbBeanCache 46 { 47 48 public Result check(EjbDescriptor descriptor) 49 { 50 Result result = getInitializedResult(); 51 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 52 String beanCache = null; 53 String resizeQty = null; 54 String maxCacheSize = null; 55 try{ 56 beanCache = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache"); 57 if(beanCache!=null) 58 { 59 try 60 { 61 resizeQty = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache/resize-quantity"); 62 if (resizeQty!=null) 63 { 64 resizeQty = resizeQty.trim(); 65 if (resizeQty.length()==0) 66 { 67 addErrorDetails(result, compName); 68 result.failed(smh.getLocalString(getClass().getName()+".failed", 69 "FAILED [AS-EJB bean-cache] : resize-quantity cannot be empty")); 70 71 }else 72 { 73 int resizeQtyVal = Integer.valueOf(resizeQty).intValue(); 74 if (resizeQtyVal < 1 || resizeQtyVal > Integer.MAX_VALUE) 75 { 76 addErrorDetails(result, compName); 77 result.failed(smh.getLocalString(getClass().getName()+".failed1", 78 "FAILED [AS-EJB bean-cache] : resize-quantity cannot be less than 1 or greater than {0}", new Object []{new Integer (Integer.MAX_VALUE)})); 79 }else 80 { 81 int cacheSizeVal=0; 82 maxCacheSize = getXPathValue("/sun-ejb-jar/enterprise-beans/ejb[ejb-name=\""+descriptor.getName()+"\"]/bean-cache/max-cache-size"); 83 if (maxCacheSize!=null) 84 { 85 try{ 86 cacheSizeVal = Integer.valueOf(maxCacheSize).intValue(); 87 88 }catch(NumberFormatException nfe){ 89 addErrorDetails(result, compName); 90 result.failed(smh.getLocalString(getClass().getName()+".failed2", 91 "FAILED [AS-EJB bean-cache] : The value [ {0} ] for max-cache-size is not a valid Integer number", 92 new Object []{maxCacheSize})); 93 return result; 94 } 95 if (cacheSizeVal >= 1 && cacheSizeVal <= Integer.MAX_VALUE) 96 { 97 if (resizeQtyVal <= cacheSizeVal) 98 { 99 addGoodDetails(result, compName); 100 result.passed(smh.getLocalString(getClass().getName()+".passed", 101 "PASSED [AS-EJB bean-cache] : resize-quantity is {0} and is less than max-cache-size {1}", 102 new Object []{(new Integer (resizeQty)),new Integer (maxCacheSize)})); 103 } 104 else 105 { 106 addErrorDetails(result, compName); 107 result.failed(smh.getLocalString(getClass().getName()+".failed3", 108 "FAILED[AS-EJB bean-cache] : resize-quantity {0} should be less than max-cache-size {1}", 109 new Object []{new Integer (resizeQty), new Integer (maxCacheSize)})); 110 } 111 }else 112 { 113 addErrorDetails(result, compName); 114 result.failed(smh.getLocalString(getClass().getName()+".failed4", 115 "FAILED [AS-EJB" +"bean-cache] : resize-quantity should be less than max-cache-size and max-cache-size is not a valid integer")); 116 117 } 118 }else 119 { 120 addGoodDetails(result, compName); 121 result.passed(smh.getLocalString(getClass().getName()+".passed1", 122 "PASSED [AS-EJB bean-cache] : resize-quantity is {0}", 123 new Object []{(new Integer (resizeQty))})); 124 } 125 } 126 } 127 128 }else { 130 addNaDetails(result, compName); 131 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", 132 "NOT APPLICABLE [AS-EJB bean-cache] : resize-quantity element is not defined")); 133 134 } 135 }catch(NumberFormatException nfex) 136 { 137 Verifier.debug(nfex); 138 addErrorDetails(result, compName); 139 result.failed(smh.getLocalString(getClass().getName()+".failed5", 140 "FAILED [AS-EJB bean-cache] : The value [ {0} ] for resize-quantity is not a valid Integer number", 141 new Object []{resizeQty})); 142 143 144 } 145 }else { 147 addNaDetails(result, compName); 148 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1", 149 "NOT APPLICABLE [AS-EJB] : bean-cache element not defined")); 150 151 } 152 }catch(Exception ex) 153 { 154 addErrorDetails(result, compName); 155 result.addErrorDetails(smh.getLocalString 156 (getClass().getName() + ".notRun", 157 "NOT RUN [AS-EJB] : Could not create the descriptor object")); 158 } 159 return result; 160 } 161 } 162 | Popular Tags |