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.common.*; 32 33 36 38 public class ASResourceEnvRef extends WebTest implements WebCheck { 39 40 public Result check(WebBundleDescriptor descriptor) { 41 42 String resName; 43 Result result = getInitializedResult(); 44 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 45 boolean oneFailed = false; 46 boolean notApp = false; 47 try{ 48 ResourceEnvRef[] envRefs= (descriptor.getSunDescriptor()).getResourceEnvRef(); 49 50 if (envRefs != null && envRefs.length > 0) { 51 52 for (int rep=0; rep<envRefs.length; rep++ ) { 53 resName = envRefs[rep].getResourceEnvRefName(); 54 55 if (validResEnvRefName(resName,descriptor)) { 56 addGoodDetails(result, compName); 57 result.passed(smh.getLocalString 58 (getClass().getName() + ".passed", 59 "PASSED [AS-WEB sun-web-app] resource-env-ref [ {0} ] properly defined in the war file.", 60 new Object [] {resName})); 61 } else { 62 oneFailed = true; 63 addErrorDetails(result, compName); 64 result.failed(smh.getLocalString 65 (getClass().getName() + ".failed", 66 "FAILED [AS-WEB sun-web-app] resource-env-ref name [ {0} ] is not valid, either empty or not defined in web.xml.", 67 new Object [] {resName})); 68 } 69 70 } 71 72 } else { 73 notApp = true; 74 addNaDetails(result, compName); 75 result.notApplicable(smh.getLocalString 76 (getClass().getName() + ".notApplicable", 77 "NOT APPLICABLE [AS-WEB sun-web-app] resource-env-ref element not defined in the web archive [ {0} ].", 78 new Object [] {descriptor.getName()})); 79 } 80 if (oneFailed) { 81 result.setStatus(Result.FAILED); 82 } else if(notApp) { 83 result.setStatus(Result.NOT_APPLICABLE); 84 }else { 85 result.setStatus(Result.PASSED); 86 addGoodDetails(result, compName); 87 result.passed 88 (smh.getLocalString 89 (getClass().getName() + ".passed2", 90 "PASSED [AS-WEB sun-web-app] resource-env-ref element(s) are valid within the web archive [ {0} ].", 91 new Object [] {descriptor.getName()} )); 92 } 93 }catch(Exception ex){ 94 oneFailed=true; 95 addErrorDetails(result, compName); 96 result.failed(smh.getLocalString 97 (getClass().getName() + ".failed2", "FAILED [AS-WEB resource-env-ref] Could not create the resource-env-ref")); 98 99 100 } 101 102 return result; 103 } 104 105 106 boolean validResEnvRefName(String name,WebBundleDescriptor descriptor){ 107 boolean valid =true; 108 if(name !=null && name.length()!=0) { 109 try{ 110 descriptor.getJmsDestinationReferenceByName(name); 111 } 112 catch(IllegalArgumentException e){ 113 valid=false; 114 } 115 } else{ 116 valid=false; 117 118 } 119 return valid; 120 } 121 122 } 123 | Popular Tags |