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

ListenerClass

public abstract class ListenerClass extends WebTest implements WebCheck
Super class for all Listener tests.
author
Jerome Dochez
version
1.0

Fields Summary
Constructors Summary
Methods Summary
public com.sun.enterprise.tools.verifier.Resultcheck(com.sun.enterprise.deployment.WebBundleDescriptor descriptor)
Listener class must implement a no arg constructor.

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

        
        AppListenerDescriptor listener = null;
        Enumeration listenerEnum;
        Result result;
        boolean oneFailed = false;
        Class listenerClass = null;   
	ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
	
	listenerEnum = descriptor.getAppListenerDescriptors().elements();
	if (listenerEnum.hasMoreElements()) {
            result = loadWarFile(descriptor);
            while (listenerEnum.hasMoreElements()) {
		listener = (AppListenerDescriptor)listenerEnum.nextElement();

                if (listener.getListener().equals(smh.getLocalString("JAXRPCContextListener","com.sun.xml.rpc.server.http.JAXRPCContextListener"))) {
	            result.addGoodDetails(smh.getLocalString
				("tests.componentNameConstructor",
				 "For [ {0} ]",
				 new Object[] {compName.toString()}));
                    result.passed(smh.getLocalString (getClass().getName() + ".passed1",
                    "Listener Class Name is [ {0} ], make sure it is available in classpath at runtime.", 
		       new Object[] {listener.getListener()}));
                  continue;
                }

                if ("".equals(listener.getListener())) {
	          result.addErrorDetails(smh.getLocalString
				("tests.componentNameConstructor",
				 "For [ {0} ]",
				 new Object[] {compName.toString()}));
                  result.failed(smh.getLocalString (getClass().getName() + ".failed",
                    "Empty or Null String specified for Listener Class Name in [ {0} ].", 
		       new Object[] {compName.toString()}));
                  oneFailed = true;
                  continue;
                }

                listenerClass = loadClass(result, listener.getListener());                
                if (!runIndividualListenerTest(result, listenerClass)) 
                    oneFailed=true;                
 	    }
	    if (oneFailed) {
		result.setStatus(Result.FAILED);
	    } else {
		result.setStatus(Result.PASSED);
	    }
	} else {
            result = getInitializedResult();
            result.setStatus(Result.NOT_APPLICABLE);
	    result.addNaDetails(smh.getLocalString
				("tests.componentNameConstructor",
				 "For [ {0} ]",
				 new Object[] {compName.toString()}));
	    result.notApplicable(smh.getLocalString
                ("com.sun.enterprise.tools.verifier.tests.web.ListenerClass" + ".notApplicable",
		 "There are no listener components within the web archive [ {0} ]",
		 new Object[] {descriptor.getName()}));
	}

	return result;
    
protected abstract booleanrunIndividualListenerTest(com.sun.enterprise.tools.verifier.Result result, java.lang.Class listenerClass)

Run the verifier test against a declared individual listener class

param
result is used to put the test results in
param
listenerClass is the individual listener class object to test
return
true if the test pass