FileDocCategorySizeDatePackage
UrlElement.javaAPI DocGlassfish v2 API4838Fri May 04 22:34:14 BST 2007com.sun.enterprise.tools.verifier.tests.web.elements

UrlElement

public class UrlElement extends com.sun.enterprise.tools.verifier.tests.web.WebTest implements com.sun.enterprise.tools.verifier.tests.web.WebCheck
Servlet url element defines a url location to a resource external to this web application.

Fields Summary
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)
Servlet url element defines a url location to a resource external to this web application.

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


	Result result = getInitializedResult();
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();

	if (descriptor.getLocalizedContentDescriptors().hasMoreElements()) {
	    boolean oneFailed = false;
	    boolean foundIt = false;
	    // get the url's in this .war
	    for (Enumeration e = descriptor.getLocalizedContentDescriptors() ; e.hasMoreElements() ;) {
		foundIt = false;
		LocalizedContentDescriptorImpl urls = (LocalizedContentDescriptorImpl)e.nextElement();
		String url = urls.getUrl();
		if (url.length() > 0) {
		    foundIt = true;
		} else {
		    foundIt = false;
		} 
   
		if (foundIt) {
		    result.addGoodDetails(smh.getLocalString
				       ("tests.componentNameConstructor",
					"For [ {0} ]",
					new Object[] {compName.toString()}));
		    result.addGoodDetails(smh.getLocalString
					  (getClass().getName() + ".passed",
					   "Servlet url [ {0} ] defines a url location to a resource external to this web application.",
					   new Object[] {url}));
		} 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: Servlet url [ {0} ] does not define a url location to a resource external to this web application.",
					    new Object[] {url}));
		}
	    }
	    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 url elements within the web archive [ {0} ]",
				  new Object[] {descriptor.getName()}));
	}
	return result;