1 23 24 25 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 public class ASLocaleCharsetInfo extends WebTest implements WebCheck { 44 45 46 public Result check(WebBundleDescriptor descriptor) { 47 Result result = getInitializedResult(); 48 WebComponentNameConstructor compName = new WebComponentNameConstructor(descriptor); 49 boolean oneFailed = false; 50 boolean notApp = false; 51 52 String defaultLocale; 53 String locale; 54 String charset; 55 String formHintField; 56 LocaleCharsetMap[] localeCharMaps; 57 LocaleCharsetInfo nlsInfo = descriptor.getIasWebApp().getLocaleCharsetInfo(); 59 if (nlsInfo != null) { 61 62 defaultLocale=nlsInfo.getAttributeValue(MetaData.DEFAULT_LOCALE); 63 localeCharMaps= nlsInfo.getLocaleCharsetMap(); 64 if (defaultLocale!=null || defaultLocale.length() != 0) { 66 result.passed(smh.getLocalString 67 (getClass().getName() + ".passed", 68 "PASSED [AS-WEB locale-charset-info] Proper "+ MetaData.DEFAULT_LOCALE+" [ {0} ] defined in the war file.", 69 new Object [] {defaultLocale})); 70 71 } else{ 72 if (!oneFailed) 73 oneFailed = true; 74 result.failed(smh.getLocalString 75 (getClass().getName() + ".failed", 76 "FAILED [AS-WEB local-charset-info] Empty "+ MetaData.DEFAULT_LOCALE+" [ {0} ] is not valid.", 77 new Object [] {defaultLocale})); 78 } 79 80 for (int rep=0; rep<localeCharMaps.length; rep++ ) { 81 locale = localeCharMaps[rep].getAttributeValue(MetaData.LOCALE); 82 charset = localeCharMaps[rep].getAttributeValue(MetaData.CHARSET); 83 if (locale!=null && charset!=null && locale.length() != 0 && charset.length() != 0) { 85 result.passed(smh.getLocalString 86 (getClass().getName() + ".passed1", 87 "PASSED [AS-WEB locale-charset-map] attributes locale [ {0} ] and charset [ {1} ] properly defined.", 88 new Object [] {locale, charset})); 89 } else { 90 if (!oneFailed) 91 oneFailed = true; 92 result.failed(smh.getLocalString 93 (getClass().getName() + ".failed1", 94 "FAILED [AS-WEB local-charset-map] attributes locale [ {0} ] and charset [ {1} ] must be of finite length.", 95 new Object [] {locale, charset})); 96 } 97 } 98 99 100 102 } else { 103 notApp = true; 105 result.notApplicable(smh.getLocalString 106 (getClass().getName() + ".notApplicable", 107 "NOT APPLICABLE [AS-WEB sun-web-app] locale-charset-info element not defined in this web archive [ {0} ].", 108 new Object [] {descriptor.getName()})); 109 } 110 if (oneFailed) { 111 result.setStatus(Result.FAILED); 112 } else if(notApp) { 113 result.setStatus(Result.NOT_APPLICABLE); 114 }else { 115 result.setStatus(Result.PASSED); 116 result.passed 117 (smh.getLocalString 118 (getClass().getName() + ".passed2", 119 "PASSED [AS-WEB sun-web-app] locale-charset-info elements are valid within the web archive [ {0} ] .", 120 new Object [] {descriptor.getName()} )); 121 } 122 return result; 123 } 124 } 125 126 | Popular Tags |