1 23 24 package com.sun.enterprise.tools.verifier.tests.web.runtime; 25 26 import com.sun.enterprise.deployment.*; 27 import com.sun.enterprise.tools.verifier.*; 28 import com.sun.enterprise.tools.verifier.tests.*; 29 import com.sun.enterprise.deployment.WebBundleDescriptor; 30 import com.sun.enterprise.tools.verifier.tests.web.*; 31 import com.sun.enterprise.deployment.runtime.web.*; 32 33 36 38 public class ASWebProperty extends WebTest implements WebCheck{ 39 40 41 public Result check(WebBundleDescriptor descriptor) { 42 43 Result result = getInitializedResult(); 44 45 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 46 47 boolean oneFailed = false; 48 boolean notApp = false; 49 50 try{ 51 WebProperty[] webProps = (descriptor.getSunDescriptor()).getWebProperty(); 52 if (webProps.length > 0){ 53 oneFailed=checkWebProperties(webProps,result ,descriptor, this ) ; 54 }else{ 55 notApp = true; 56 addNaDetails(result, compName); 57 result.notApplicable(smh.getLocalString 58 (getClass().getName() + ".notApplicable", 59 "NOT APPLICABLE [AS-WEB sun-web-app] web property element not defined within the web archive [ {0} ].", 60 new Object [] {descriptor.getName()})); 61 } 62 if (oneFailed) { 63 result.setStatus(Result.FAILED); 64 } else if(notApp) { 65 result.setStatus(Result.NOT_APPLICABLE); 66 }else { 67 result.setStatus(Result.PASSED); 68 } 69 70 }catch(Exception ex){ 71 oneFailed = true; 72 addErrorDetails(result, compName); 73 result.failed(smh.getLocalString 74 (getClass().getName() + ".failed", 75 "FAILED [AS-WEB sun-web-app] could not create the web-property object")); 76 } 77 78 return result; 79 } 80 public static boolean checkWebProperties(WebProperty[] webProps, Result result ,WebBundleDescriptor descriptor, Object obj ) { 81 String compName = result.getComponentName(); 82 String name; 83 String value; 84 boolean oneFailed = false; 85 String [] names=null; 86 if (webProps.length > 0){ 87 names=new String [webProps.length]; 88 for (int rep=0; rep<webProps.length; rep++ ){ 89 name = webProps[rep].getAttributeValue(WebProperty.NAME); value = webProps[rep].getAttributeValue(WebProperty.VALUE); 91 names[rep]=name; 92 if (name !=null && value !=null && name.length() != 0 && value.length() != 0){ 93 boolean isDuplicate=false; 95 for(int rep1=0;rep1<rep;rep1++) 96 { 97 if(name.equals(names[rep1])){ 98 isDuplicate=true; 99 break; 100 } 101 102 } 103 104 if(!isDuplicate){ 105 result.addGoodDetails(smh.getLocalString 106 ("tests.componentNameConstructor", 107 "For [ {0} ]", 108 new Object [] {compName})); 109 result.passed(smh.getLocalString 110 (obj.getClass().getName() + ".passed", 111 "PASSED [AS-WEB property] Proper web property with name [ {0} ] and value [ {1} ] defined.", 112 new Object [] {name, value})); 113 }else{ 114 if (!oneFailed) 115 oneFailed = true; 116 result.addErrorDetails(smh.getLocalString 117 ("tests.componentNameConstructor", 118 "For [ {0} ]", 119 new Object [] {compName})); 120 result.failed(smh.getLocalString 121 (obj.getClass().getName() + ".failed2", 122 "FAILED [AS-WEB property] name [ {0} ] and value [ {1} ], the name must be unique in the entire list of web property.", 123 new Object [] {name, value})); 124 } 125 126 }else{ 127 if (!oneFailed) 128 oneFailed = true; 129 result.addErrorDetails(smh.getLocalString 130 ("tests.componentNameConstructor", 131 "For [ {0} ]", 132 new Object [] {compName})); 133 result.failed(smh.getLocalString 134 (obj.getClass().getName() + ".failed1", 135 "FAILED [AS-WEB property] name [ {0} ] and value [ {1} ], attributes must be of finite length.", 136 new Object [] {name, value})); 137 } 138 } 139 140 } 141 142 return oneFailed; 143 144 } 145 146 } 147 148 | Popular Tags |