1 23 24 package com.sun.enterprise.tools.verifier.tests.web.runtime; 25 26 27 import com.sun.enterprise.deployment.*; 28 import com.sun.enterprise.tools.verifier.*; 29 import com.sun.enterprise.tools.verifier.tests.*; 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 import com.sun.enterprise.tools.verifier.tests.web.*; 32 import com.sun.enterprise.deployment.runtime.web.*; 33 34 36 39 41 42 public class ASCache extends WebTest implements WebCheck{ 43 44 public Result check(WebBundleDescriptor descriptor) { 45 46 Result result = getInitializedResult(); 47 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 48 boolean oneFailed = false; 49 boolean notApp = false; 50 String maxEntries=null; 51 String timeout=null; 52 int intMaxEntries; 53 long longTimeout; 54 String enabled=null; 55 56 try{ 57 Cache cache = (descriptor.getSunDescriptor()).getCache(); 58 59 if (cache != null) 60 { 61 maxEntries = cache.getAttributeValue(Cache.MAX_ENTRIES); 62 timeout = cache.getAttributeValue(Cache.TIMEOUT_IN_SECONDS); 63 enabled = cache.getAttributeValue(Cache.ENABLED); 64 if (!(enabled.equalsIgnoreCase("true")) && !(enabled.equalsIgnoreCase("false"))) 65 { 66 67 addErrorDetails(result, compName); 68 result.failed(smh.getLocalString 69 (getClass().getName() + ".failed3", 70 "FAILED [AS-WEB cache] enabled [ {0} ], attribute must be a proper boolean value. ", 71 new Object [] {enabled})); 72 oneFailed = true; 73 } 74 else 75 { 76 addGoodDetails(result, compName); 77 result.passed(smh.getLocalString 78 (getClass().getName() + ".passed3", 79 "PASSED [AS-WEB cache] enabled [ {0} ] defined properly.", 80 new Object [] {enabled})); 81 } 82 83 84 boolean validMaxEntriesValue=true; 85 boolean validTimeOutValue=true; 86 try 87 { 88 if(maxEntries !=null && maxEntries.length() != 0) { 90 intMaxEntries=Integer.parseInt(maxEntries); 91 if(intMaxEntries >0 && intMaxEntries < Integer.MAX_VALUE) 92 validMaxEntriesValue=true; 93 else 94 validMaxEntriesValue=false; 95 } 96 } 97 catch(NumberFormatException exception) 98 { 99 validMaxEntriesValue=false; 100 if (!oneFailed) 101 oneFailed = true; 102 } 103 if(validMaxEntriesValue) 104 { 105 addGoodDetails(result, compName); 106 result.passed(smh.getLocalString 107 (getClass().getName() + ".passed", 108 "PASSED [AS-WEB cache] max-entries [ {0} ] defined properly.", 109 new Object [] {maxEntries})); 110 }else 111 { 112 addErrorDetails(result, compName); 113 result.failed(smh.getLocalString 114 (getClass().getName() + ".failed", 115 "FAILED [AS-WEB cache] max-entries [ {0} ], attribute must be a proper integer value. "+ 116 "Its range should be 1 to MAX_INT.", 117 new Object [] {maxEntries})); 118 oneFailed = true; 119 } 120 try 121 { 122 if(timeout != null && timeout.length() != 0 ) { 124 longTimeout=Long.parseLong(timeout); 125 if(longTimeout >= -1 && longTimeout <= Long.MAX_VALUE) 126 validTimeOutValue=true; 127 else 128 validTimeOutValue=false; 129 } 130 131 }catch(NumberFormatException exception) 132 { 133 validTimeOutValue=false; 134 oneFailed = true; 135 } 136 if(validTimeOutValue) 137 { 138 addGoodDetails(result, compName); 139 result.passed(smh.getLocalString 140 (getClass().getName() + ".passed1", 141 "PASSED [AS-WEB cache] timeout-in-seconds [ {0} ] defined properly.", 142 new Object [] {timeout})); 143 } 144 else 145 { 146 addErrorDetails(result, compName); 147 result.failed(smh.getLocalString 148 (getClass().getName() + ".failed1", 149 "FAILED [AS-WEB cache] timeout-in-seconds value [ {0} ], attribute must be a proper long value. " + 150 "Its range should be between -1 and MAX_LONG.", 151 new Object [] {timeout})); 152 oneFailed = true; 153 } 154 155 }else 156 { 157 notApp = true; 158 addNaDetails(result, compName); 159 result.notApplicable(smh.getLocalString 160 (getClass().getName() + ".notApplicable", 161 "NOT APPLICABLE [AS-WEB cache] Element not defined for the web application.", 162 new Object [] {descriptor.getName()})); 163 } 164 165 if (oneFailed) { 166 result.setStatus(Result.FAILED); 167 } else if(notApp) { 168 result.setStatus(Result.NOT_APPLICABLE); 169 }else { 170 result.setStatus(Result.PASSED); 171 } 172 }catch(Exception ex){ 173 oneFailed=true; 174 addErrorDetails(result, compName); 175 result.failed(smh.getLocalString 176 (getClass().getName() + ".failed2", 177 "FAILED [AS-WEB cache] Could not create the cache object")); 178 } 179 return result; 180 } 181 } 182 | Popular Tags |