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

LibDirExists

public class LibDirExists extends com.sun.enterprise.tools.verifier.tests.web.WebTest implements WebCheck
Servlet lib directory resides in WEB-INF/lib directory test.

Fields Summary
final String
servletLibDirPath
Constructors Summary
Methods Summary
public Resultcheck(WebBundleDescriptor descriptor)
Servlet lib directory resides in WEB-INF/lib directory test.

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

      
                                   
        

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

	if (!descriptor.getServletDescriptors().isEmpty()) {
	    boolean oneFailed = false;
	    int na = 0;
	    boolean foundIt = false;
	    // get the servlets in this .war
	    Set servlets = descriptor.getServletDescriptors();
	    Iterator itr = servlets.iterator();
	    // test the servlets in this .war
	    while (itr.hasNext()) {
		foundIt = false;
		WebComponentDescriptor servlet = (WebComponentDescriptor)itr.next();
//		try {
                    File warfile = new File(System.getProperty("java.io.tmpdir"));
		    warfile = new File(warfile, "wartmp");
//                    File f = Verifier.getArchiveFile(
//                             descriptor.getModuleDescriptor().getArchiveUri());
		    File warLibDir = null;

//                    if (f != null) {
//                        VerifierUtils.copyArchiveToDir(f, warfile);
//		        warLibDir = new File(warfile, servletLibDirPath);
//                    }
//                    else {
                      String uri = getAbstractArchiveUri(descriptor);
		      warLibDir = new File(uri, servletLibDirPath);
//                    }

                    if (warLibDir.isDirectory()) {
		        foundIt = true;
                    } 
/*		} catch (IOException e) {
		    if (!oneFailed ) {
			oneFailed = true;
		    }
		    Verifier.debug(e);
		    result.addErrorDetails(smh.getLocalString
					   ("tests.componentNameConstructor",
					    "For [ {0} ]",
					    new Object[] {compName.toString()}));

		    result.addErrorDetails(smh.getLocalString
					   (getClass().getName() + ".IOException",
					    "Error: IOError trying to open [ {0} ], {1}",
					    new Object[] {Verifier.getArchiveFile(descriptor.getModuleDescriptor().getArchiveUri()), e.getMessage()}));
		}*/
   
		if (foundIt) {
		    result.addGoodDetails(smh.getLocalString
					   ("tests.componentNameConstructor",
					    "For [ {0} ]",
					    new Object[] {compName.toString()}));
		    result.addGoodDetails(smh.getLocalString
					  (getClass().getName() + ".passed",
					   "Servlet lib dir [ {0} ] resides in WEB-INF/lib directory of [ {1} ].",
					   new Object[] {servletLibDirPath,uri}));
		} else {
		    na++;
		    result.addNaDetails(smh.getLocalString
					("tests.componentNameConstructor",
					 "For [ {0} ]",
					 new Object[] {compName.toString()}));
		    result.addNaDetails(smh.getLocalString
					   (getClass().getName() + ".notApplicable2",
					    "Servlet lib dir [ {0} ] does not reside in [ {1} ].",
					    new Object[] {servletLibDirPath,uri}));
		}
	    }
            File wartmp = new File(System.getProperty("java.io.tmpdir"));
	    wartmp = new File(wartmp, "wartmp");
	    deleteDirectory(wartmp.getAbsolutePath());
	    if (na == descriptor.getServletDescriptors().size()) {
		result.setStatus(Result.NOT_APPLICABLE);
	    } else 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 servlet components within the web archive [ {0} ]",
				  new Object[] {descriptor.getName()}));
	}
	return result;