FileDocCategorySizeDatePackage
JspFileName.javaAPI DocGlassfish v2 API6381Fri May 04 22:34:16 BST 2007com.sun.enterprise.tools.verifier.tests.web.spec22

JspFileName

public class JspFileName extends com.sun.enterprise.tools.verifier.tests.web.WebTest implements com.sun.enterprise.tools.verifier.tests.web.WebCheck
Jsp file element contains the full path to Jsp file within web application test.

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)
Jsp file in Servlet 2.2 applications must start with a leading /

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


	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
    String specVersion = descriptor.getSpecVersion();
    Float specVer = new Float(specVersion);
	if (!descriptor.getJspDescriptors().isEmpty()) {
	    boolean oneFailed = false;
        int count = getNonRuntimeCountNodeSet("/web-app/servlet");
        for(int i=1;i<=count;i++){
            String jspFilename = getXPathValueForNonRuntime("/web-app/servlet["+i+"]/jsp-file");
            if(jspFilename!=null){
                if (jspFilename.startsWith("/")){
                    if(specVer.compareTo(new Float("2.3"))<0){
                        result.addGoodDetails(smh.getLocalString
                                ("tests.componentNameConstructor",
                                        "For [ {0} ]",
                                        new Object[] {compName.toString()}));
                        result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed",
                                " PASSED : Jsp Name [ {0} ] is valid",
                                new Object[] { jspFilename }));

                    }else{
                        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor",
                                "For [ {0} ]",
                                new Object[] {compName.toString()}));
                        result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed1",
                                " Jsp Name [ {0} ] is valid and starts with a leading '/'",
                                new Object[] { jspFilename }));

                    }
                }else{
                    if(specVer.compareTo(new Float("2.3"))<0){
                        result.addGoodDetails(smh.getLocalString("tests.componentNameConstructor",
                                "For [ {0} ]",
                                new Object[] {compName.toString()}));
                        result.addGoodDetails(smh.getLocalString(getClass().getName() + ".passed",
                                " PASSED Jsp Name [ {0} ] is valid",
                                new Object[] { jspFilename }));

                    }else{
                        result.addErrorDetails(smh.getLocalString
                                ("tests.componentNameConstructor",
                                        "For [ {0} ]",
                                        new Object[] {compName.toString()}));
                        result.addErrorDetails(smh.getLocalString(getClass().getName() + ".failed",
                                " Error : Jsp Name [ {0} ] in invalid as it does not start with a leading '/'",
                                new Object[] { jspFilename }));
                        oneFailed=true;
                    }
                }

            }
        }
        if (oneFailed) {
            result.setStatus(Result.FAILED);
        } else {
            result.setStatus(Result.PASSED);
        }
    } else {
        result.addNaDetails(smh.getLocalString
                ("tests.componentNameConstructor",
                        "For [ {0} ]",
                        new Object[] {compName.toString()}));
        result.notApplicable(smh.getLocalString
                (getClass().getName() + ".notApplicable",
                        "There are no Jsp components within the web archive [ {0} ]",
                        new Object[] {descriptor.getName()}));
    }
        return result;