FileDocCategorySizeDatePackage
ResourceRefName.javaAPI DocGlassfish v2 API5248Fri May 04 22:34:10 BST 2007com.sun.enterprise.tools.verifier.tests.web

ResourceRefName

public class ResourceRefName extends WebTest implements WebCheck
Resource ref name exists test.
author
Arun Jain

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)
Resource Ref Name must be of finite length.

param
descriptor the Web deployment descriptor
return
Result the results for this assertion


        Set resourceRefs;
        ResourceReferenceDescriptor resrefDes;
        Iterator itr;
        String resrefName;
	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
        //boolean foundIt = false;
        boolean oneFailed = false;
        boolean notApp = false;
        
	if (!descriptor.getResourceReferenceDescriptors().isEmpty()) {
            
	    // get the Resource Reference Descriptors set
	    resourceRefs = descriptor.getResourceReferenceDescriptors();
	    itr = resourceRefs.iterator();
	    // test the Resource Reference Descriptor
	    while (itr.hasNext()) {
		resrefDes = (ResourceReferenceDescriptor)itr.next();
		resrefName = resrefDes.getName();
                if (resrefName.length() != 0) {
                    //                 foundIt  = true;
		    result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
                    result.addGoodDetails(smh.getLocalString
                                          (getClass().getName() + ".passed",
                                           "Resource Reference exists in the web application."));
                } else {
                    if (!oneFailed)
                        oneFailed = true;
		    result.addErrorDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
                    result.addErrorDetails(smh.getLocalString
                                           (getClass().getName() + ".failed",
                                            "Error: Resource reference entry must be of finite length."));
                }
            }
            
        } else {
            notApp = true;
	    result.addNaDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
	    result.notApplicable(smh.getLocalString
                                 (getClass().getName() + ".notApplicable",
                                  "There are no resource references defined within the web archive [ {0} ]",
                                  new Object[] {descriptor.getName()}));
        }
        if (oneFailed) {
            result.setStatus(Result.FAILED);
        } else if(notApp) {
            result.setStatus(Result.NOT_APPLICABLE);
        }else {
            result.setStatus(Result.PASSED);
        }
	return result;