1 23 package com.sun.enterprise.tools.verifier.tests.web; 24 25 import java.util.*; 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.ResourceReferenceDescriptor; 30 import com.sun.enterprise.deployment.WebBundleDescriptor; 31 32 33 37 public class ResourceRefName extends WebTest implements WebCheck { 38 39 40 47 public Result check(WebBundleDescriptor descriptor) { 48 49 Set resourceRefs; 50 ResourceReferenceDescriptor resrefDes; 51 Iterator itr; 52 String resrefName; 53 Result result = getInitializedResult(); 54 ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor(); 55 boolean oneFailed = false; 57 boolean notApp = false; 58 59 if (!descriptor.getResourceReferenceDescriptors().isEmpty()) { 60 61 resourceRefs = descriptor.getResourceReferenceDescriptors(); 63 itr = resourceRefs.iterator(); 64 while (itr.hasNext()) { 66 resrefDes = (ResourceReferenceDescriptor)itr.next(); 67 resrefName = resrefDes.getName(); 68 if (resrefName.length() != 0) { 69 result.addGoodDetails(smh.getLocalString 71 ("tests.componentNameConstructor", 72 "For [ {0} ]", 73 new Object [] {compName.toString()})); 74 result.addGoodDetails(smh.getLocalString 75 (getClass().getName() + ".passed", 76 "Resource Reference exists in the web application.")); 77 } else { 78 if (!oneFailed) 79 oneFailed = true; 80 result.addErrorDetails(smh.getLocalString 81 ("tests.componentNameConstructor", 82 "For [ {0} ]", 83 new Object [] {compName.toString()})); 84 result.addErrorDetails(smh.getLocalString 85 (getClass().getName() + ".failed", 86 "Error: Resource reference entry must be of finite length.")); 87 } 88 } 89 90 } else { 91 notApp = true; 92 result.addNaDetails(smh.getLocalString 93 ("tests.componentNameConstructor", 94 "For [ {0} ]", 95 new Object [] {compName.toString()})); 96 result.notApplicable(smh.getLocalString 97 (getClass().getName() + ".notApplicable", 98 "There are no resource references defined within the web archive [ {0} ]", 99 new Object [] {descriptor.getName()})); 100 } 101 if (oneFailed) { 102 result.setStatus(Result.FAILED); 103 } else if(notApp) { 104 result.setStatus(Result.NOT_APPLICABLE); 105 }else { 106 result.setStatus(Result.PASSED); 107 } 108 return result; 109 } 110 } 111 | Popular Tags |