1 23 24 26 package com.sun.enterprise.tools.verifier.tests.web.ias; 27 28 29 import java.util.*; 30 import com.sun.enterprise.deployment.*; 31 import com.sun.enterprise.tools.verifier.*; 32 import com.sun.enterprise.tools.verifier.tests.*; 33 import com.sun.enterprise.deployment.ResourceReferenceDescriptor; 34 import com.sun.enterprise.deployment.WebBundleDescriptor; 35 import com.sun.enterprise.tools.verifier.tests.web.*; 36 import com.sun.enterprise.tools.common.dd.webapp.*; 37 38 41 43 44 public class ASCache extends WebTest implements WebCheck { 45 46 47 public Result check(WebBundleDescriptor descriptor) { 48 49 50 Result result = getInitializedResult(); 51 WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor); 52 53 boolean oneFailed = false; 54 boolean notApp = false; 55 String maxEntries=null; 56 String timeout=null; 57 int intMaxEntries; 58 long longTimeout; 61 63 Cache cache = getCache(descriptor); 64 65 if (cache != null) { 66 67 maxEntries = cache.getAttributeValue("max-entries"); 71 timeout = cache.getAttributeValue("timeout-in-seconds"); 72 boolean validMaxEntriesValue=true; 74 boolean validTimeOutValue=true; 75 76 try{ 77 if(maxEntries !=null && maxEntries.length() != 0){ intMaxEntries=Integer.parseInt(maxEntries); 79 80 if(intMaxEntries >0 && intMaxEntries < Integer.MAX_VALUE) 81 validMaxEntriesValue=true; 82 else 83 validMaxEntriesValue=false; 84 85 } 86 87 } catch(NumberFormatException exception){ 88 validMaxEntriesValue=false; 89 if (!oneFailed) 90 oneFailed = true; 91 92 } 93 94 if(validMaxEntriesValue){ 95 result.passed(smh.getLocalString 96 (getClass().getName() + ".passed", 97 "PASSED [AS-WEB cache] max-entries [ {0} ] defined properly.", 98 new Object [] {maxEntries})); 99 }else{ 100 result.failed(smh.getLocalString 101 (getClass().getName() + ".failed", 102 "FAILED [AS-WEB cache] max-entries [ {0} ], attribute must be a proper integer value. "+ 103 "Its range should be 1 to MAX_INT.", 104 new Object [] {maxEntries})); 105 oneFailed = true; 106 } 107 108 try{ 109 117 if(timeout != null && timeout.length() != 0 ){ longTimeout=Long.parseLong(timeout); 119 if(longTimeout >= -1 && longTimeout <= Long.MAX_VALUE) 120 validTimeOutValue=true; 121 else 122 validTimeOutValue=false; 123 } 124 126 } catch(NumberFormatException exception) { 127 validTimeOutValue=false; 128 oneFailed = true; 129 130 131 } 132 133 if(validTimeOutValue){ 134 result.passed(smh.getLocalString 135 (getClass().getName() + ".passed1", 136 "PASSED [AS-WEB cache] timeout-in-seconds [ {0} ] defined properly.", 137 new Object [] {timeout})); 138 139 }else{ 140 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 } 155 156 157 } else { 158 notApp = true; 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 if (oneFailed) { 165 result.setStatus(Result.FAILED); 166 } else if(notApp) { 167 result.setStatus(Result.NOT_APPLICABLE); 168 }else { 169 result.setStatus(Result.PASSED); 170 } 171 return result; 172 } 173 174 public Cache getCache(WebBundleDescriptor descriptor){ 175 176 Cache c= descriptor.getIasWebApp().getCache(); 177 return c; 178 179 } 180 } 181 | Popular Tags |