1 23 24 25 package com.sun.enterprise.tools.verifier.tests.web.runtime; 26 27 import com.sun.enterprise.tools.verifier.tests.web.WebTest; 28 import com.sun.enterprise.tools.verifier.tests.web.WebCheck; 29 import com.sun.enterprise.tools.verifier.tests.ComponentNameConstructor; 30 import com.sun.enterprise.tools.verifier.Result; 31 import com.sun.enterprise.deployment.WebBundleDescriptor; 32 33 36 37 public class ASConstraintField extends WebTest implements WebCheck { 38 39 public Result check(WebBundleDescriptor descriptor) { 40 41 Result result = getInitializedResult(); 42 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 43 String value = null; 44 int count = 0; 45 boolean oneFailed = false; 46 try{ 47 count = getCountNodeSet("sun-web-app/cache/cache-mapping/constraint-field"); 48 if (count>0){ 49 for(int i=1;i<=count;i++){ 50 value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field["+i+"]/@name"); 52 if (value==null || value.length()==0){ 53 oneFailed = true; 54 result.addErrorDetails(smh.getLocalString 55 ("tests.componentNameConstructor", 56 "For [ {0} ]", 57 new Object [] {compName.toString()})); 58 result.failed(smh.getLocalString 59 (getClass().getName() + ".failed", 60 "FAILED [AS-WEB constraint-field] : name attribute is required", 61 new Object [] {descriptor.getName()})); 62 }else{ 63 result.addGoodDetails(smh.getLocalString 64 ("tests.componentNameConstructor", 65 "For [ {0} ]", 66 new Object [] {compName.toString()})); 67 result.passed(smh.getLocalString( getClass().getName() + ".passed", 68 "PASSED [AS-WEB constraint-field] : name attribute is {1}", 69 new Object [] {descriptor.getName(),value})); 70 } 71 72 value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field["+i+"]/@scope"); 74 if (value==null || value.length()==0){ 75 result.addNaDetails(smh.getLocalString 76 ("tests.componentNameConstructor", 77 "For [ {0} ]", 78 new Object [] {compName.toString()})); 79 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable", 80 "NOT APPLICABLE [AS-WEB constraint-field] : scope attribute not defined")); 81 }else{ 82 String scopeValue[] = {"context.attribute", "request.header", "request.parameter", "request.cookie", "request.attribute", "session.attribute" }; 83 boolean found = false; 84 for (int j=0;j<scopeValue.length;j++){ 85 if (scopeValue[j].compareTo(value) ==0){ 86 found = true; 87 } 88 } 89 if (found){ 90 result.addGoodDetails(smh.getLocalString 91 ("tests.componentNameConstructor", 92 "For [ {0} ]", new Object [] {compName.toString()})); 93 result.passed(smh.getLocalString( getClass().getName() + ".passed1", 94 "PASSED [AS-WEB constraint-field] : scope attribute is {1}", 95 new Object [] {descriptor.getName(),value})); 96 }else{ 97 oneFailed = true; 98 result.addErrorDetails(smh.getLocalString 99 ("tests.componentNameConstructor", 100 "For [ {0} ]", 101 new Object [] {compName.toString()})); 102 result.failed(smh.getLocalString 103 (getClass().getName() + ".failed1", 104 "FAILED [AS-WEB constraint-field] : scope attribute must be one of context.attribute, request.header, request.parameter, request.cookie, request.attribute, session.attribute", 105 new Object [] {descriptor.getName()})); 106 } 107 } 108 value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field["+i+"]/@cache-on-match"); 110 if (value==null || value.length()==0){ 111 result.addNaDetails(smh.getLocalString 112 ("tests.componentNameConstructor", 113 "For [ {0} ]", 114 new Object [] {compName.toString()})); 115 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable1", 116 "NOT APPLICABLE [AS-WEB constraint-field] : cache-on-match attribute not defined")); 117 }else{ 118 String cacheOnMatchValue[] = {"yes", "no", "on", "off", "1", "0", "true", "false" }; 119 boolean foundCacheOnMatch = false; 120 for (int j=0;j<cacheOnMatchValue.length;j++){ 121 if (cacheOnMatchValue[j].compareTo(value) ==0){ 122 foundCacheOnMatch = true; 123 } 124 } 125 if (foundCacheOnMatch){ 126 result.addGoodDetails(smh.getLocalString 127 ("tests.componentNameConstructor", 128 "For [ {0} ]", new Object [] {compName.toString()})); 129 result.passed(smh.getLocalString( getClass().getName() + ".passed2", 130 "PASSED [AS-WEB constraint-field] : cache-on-match attribute is {1}", 131 new Object [] {descriptor.getName(),value})); 132 }else{ 133 oneFailed = true; 134 result.addErrorDetails(smh.getLocalString 135 ("tests.componentNameConstructor", 136 "For [ {0} ]", 137 new Object [] {compName.toString()})); 138 result.failed(smh.getLocalString 139 (getClass().getName() + ".failed2", 140 "FAILED [AS-WEB constraint-field] : cache-on-match attribute must be one of yes, no, on, off, 1, 0, true, false", 141 new Object [] {descriptor.getName()})); 142 } 143 } 144 145 value = getXPathValue("sun-web-app/cache/cache-mapping/constraint-field["+i+"]/@cache-on-match-failure"); 147 if (value==null || value.length()==0){ 148 result.addNaDetails(smh.getLocalString 149 ("tests.componentNameConstructor", 150 "For [ {0} ]", 151 new Object [] {compName.toString()})); 152 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable2", 153 "NOT APPLICABLE [AS-WEB constraint-field] : cache-on-match-failure attribute not defined")); 154 }else{ 155 String cacheOnMatchFailureValue[] = {"yes", "no", "on", "off", "1", "0", "true", "false" }; 156 boolean found = false; 157 for (int j=0;j<cacheOnMatchFailureValue.length;j++){ 158 if (cacheOnMatchFailureValue[j].compareTo(value) ==0){ 159 found = true; 160 } 161 } 162 if (found){ 163 result.addGoodDetails(smh.getLocalString 164 ("tests.componentNameConstructor", 165 "For [ {0} ]", new Object [] {compName.toString()})); 166 result.passed(smh.getLocalString( getClass().getName() + ".passed3", 167 "PASSED [AS-WEB constraint-field] : cache-on-match-failure attribute is {1}", 168 new Object [] {descriptor.getName(),value})); 169 }else{ 170 oneFailed = true; 171 result.addErrorDetails(smh.getLocalString 172 ("tests.componentNameConstructor", 173 "For [ {0} ]", 174 new Object [] {compName.toString()})); 175 result.failed(smh.getLocalString 176 (getClass().getName() + ".failed3", 177 "FAILED [AS-WEB constraint-field] : cache-on-match-failure attribute must be one of yes, no, on, off, 1, 0, true, false", 178 new Object [] {descriptor.getName()})); 179 } 180 } 181 } 182 }else{ 183 result.addNaDetails(smh.getLocalString 184 ("tests.componentNameConstructor", 185 "For [ {0} ]", 186 new Object [] {compName.toString()})); 187 result.notApplicable(smh.getLocalString(getClass().getName()+".notApplicable3", 188 "NOT APPLICABLE [AS-WEB sun-web-app] : constraint-field Element not defined")); 189 } 190 if(oneFailed) 191 result.setStatus(Result.FAILED); 192 }catch(Exception ex){ 193 result.failed(smh.getLocalString 194 (getClass().getName() + ".failed4", 195 "FAILED [AS-WEB sun-web-app] could not create the constraint-field object")); 196 } 197 return result; 198 } 199 200 } 201 | Popular Tags |