FileDocCategorySizeDatePackage
StaticArchiveTest.javaAPI DocGlassfish v2 API8366Fri May 04 22:34:20 BST 2007org.apache.tools.ant.taskdefs.optional.sun.verification

StaticArchiveTest

public class StaticArchiveTest extends AVKTasks
This is the implementation for verifier invocation through Ant task. This task runs the following two classses - Invokes Verifier by passing the appropriate arguments, Invokes the GenReportTool class to generate the reports.

The attributes of this task are:
appName ="REQUIRED"
partitionOpts ="OPTIONAL"
jvmArgs ="OPTIONAL" (default: "Xss512k -Xms128m -Xmx256m")
failOnError="OPTIONAL" (default: true)

These tasks require javke-ant.jar and sunone-appserv-ant.jar to be in AVK_HOME/lib and APPSERVER_HOME/lib diroctries respectively.

author
Vikas Awasthi.

Fields Summary
private File
appName
private String
partitionOpts
private String
reportingOpts
Constructors Summary
Methods Summary
private java.lang.StringaddPartitionOptions()
Parse and add the partitioning options. It add "--" to the options.

return
List

        StringTokenizer options = new StringTokenizer(partitionOpts, ",");
        String args = "";
        while(options.hasMoreTokens()) {
            String option = options.nextToken().trim();
            if(!(option.equals("ejb") || 
                option.equals("web") ||
                option.equals("webservices") ||
                option.equals("connector") ||
                option.equals("app") ||
                option.equals("appclient") ||
                option.equals("webservicesclient")))
                throw new BuildException("Provide a valid parititioning option. " +
                                         "Valid options are [ejb, web, app, webservices, " +
                                         "webservicesclient, connector, appclient]");
            args += " --"+option;
        }
        return args;
    
private voidcheckArgs()

        if(appName == null || !appName.exists())
            throw new BuildException("Provide a valid fully qualified " +
                                     "path of the application: appName="+appName);
    
public voidexecute()
This is called by the ant framework.

throws
BuildException

        
        checkArgs();
        getInstallHomes();
        invokeVerifier();
            
        if(invokeGenReportTool(createJavaTask()) != 0 && failOnError)
            throw new BuildException("Problem in executing GenReportTool command");
        
        echo.setMessage("See \""+resultDir+File.separator+"verifierSummary.html\" for results.");
        echo.execute();
    
private intinvokeGenReportTool(org.apache.tools.ant.taskdefs.Java java)
Invokes the com.sun.enterprise.appverification.tools.GenReportTool

return
integer denoting the return status of the command. 1 is failure

        List<String> list = new ArrayList<String>();
        
        list.add(resultDir + File.separator + appName.getName() + ".xml");
        list.add(resultDir);
        String[] xsls = {"verifierSummary", "appFailureDetail", "appPassedDetail", 
                         "appWarningDetail", "appNADetail", "ejbFailureDetail",
                         "ejbPassedDetail", "ejbWarningDetail", "ejbNADetail",
                         "acFailureDetail", "acPassedDetail", "acWarningDetail",
                         "acNADetail", "conFailureDetail", "conPassedDetail",
                         "conWarningDetail", "conNADetail", "errFailureDetail",
                         "webFailureDetail", "webPassedDetail", "webWarningDetail",
                         "webNADetail"};
        for (int i = 0; i < xsls.length; i++) 
            list.add(xsls[i]);
        String[] args = (String[])list.toArray(new String[1]);

        // clear the args set in the invokeVerifier call.
        java.clearArgs();
        java.setClassname("com.sun.enterprise.appverification.tools.GenReportTool");
        setArgs(java, args);

        return java.executeJava();
    
private voidinvokeVerifier()
Invokes the com.sun.enterprise.tools.verifier.Verifier

        ExecTask exec = (ExecTask)project.createTask("exec");
        String argument = "";
        //adding the partitioning options
        if(partitionOpts != null) 
            argument = addPartitionOptions();
        //adding the fail/warning reporting option
        if ((reportingOpts == null) || (reportingOpts.equals(""))) 
            argument += " -rw";
        else {// check for valid options a, w and f
            if ( reportingOpts.equals("f") || reportingOpts.equals("w")
                || reportingOpts.equals("a") )
                argument += " -r"+reportingOpts;
            else
                throw new BuildException("Provide a valid reporting option. " +
                                             "Valid options are [f, w, a] ");
        }
        createResultDir("static");
        //adding the result directory option
        argument += " -d "+resultDir;
        //do not run the runtime tests
        argument += " -R";
        // finally adding the application name in the options
        argument += " "+appName.getAbsolutePath();
        
        Commandline.Argument arg = exec.createArg();
        arg.setLine(argument);
        exec.setExecutable(j2ee_home+"/bin/verifier");
        exec.setDir(new File(j2ee_home,"bin"));
        exec.setVMLauncher(false);
        //the exit status is non-zero if any assertion failed but
        // we want to continue to invokeGenReportTool
        exec.setFailonerror(false);
        exec.execute();
    
public voidsetAppName(java.io.File appName)


        
        this.appName = appName;
    
public voidsetPartitionOpts(java.lang.String partitionOpts)

        this.partitionOpts = partitionOpts;
    
public voidsetReportingOpts(java.lang.String reportingOpts)

	this.reportingOpts = reportingOpts;
    
public voidsetResultDir(java.lang.String resultDir)

        super.setResultDir(resultDir);