Coverage details for com.topcoder.testframework.web.PrepareTestEarTask

LineHitsSource
1 /*
2  * Copyright (C) 2006 TopCoder Inc., All Rights Reserved.
3  */
4 package com.topcoder.testframework.web;
5  
6 import org.apache.cactus.integration.ant.CactifyEarTask;
7 import org.apache.tools.ant.BuildException;
8 import org.apache.tools.ant.Task;
9 import org.apache.tools.ant.types.FileSet;
10  
11 import java.io.File;
12  
13  
14 /**
15  * This class represents an Ant task that injects elements necessary to run the tests into an existing EAR file. It can
16  * be used to prepare EARs for {@link DefaultWebApplicationServer} class.
17  * <p/>
18  * This class is mutable, i.e. not thread-safe.
19  *
20  * @author real_vg, TCSDEVELOPER
21  * @version 1.0
22  */
23 public class PrepareTestEarTask extends Task {
24  
25     /**
26      * This field stores a wrapped {@link org.apache.cactus.integration.ant.CactifyEarTask} instance. It is initialized
27      * in field initializer. The instance in this field is the delegate to which all implementation and functionality is
28      * delegated.
29      */
309    private final CactifyEarTask cactifyEarTask = new CactifyEarTask();
31  
32     /**
33      * Creates a new PrepareTestEarTask.
34      */
359    public PrepareTestEarTask() {
36         // This constructor is intentionally empty
379    }
38  
39     /**
40      * This method sets the value of <tt>srcfile</tt> attribute, which specifies the source archive to inject the
41      * elements required to run tests into.
42      *
43      * @param srcFile the source archive to inject the elements required to run tests into
44      */
45     public void setSrcFile(final File srcFile) {
465        cactifyEarTask.setSrcFile(srcFile);
475    }
48  
49     /**
50      * This method sets the value of <tt>destfile</tt> attribute, which specifies the destination file, archive with the
51      * injected elements required to run tests will be written to.
52      *
53      * @param destFile the destination file archive with the injected elements required to run tests will be written to
54      */
55     public void setDestFile(final File destFile) {
565        cactifyEarTask.setDestFile(destFile);
575    }
58  
59     /**
60      * This method adds a fileset to the preparation task. The fileset is used to specify additional files that are to
61      * be included in the prepared ear file.
62      *
63      * @param set the fileset specifying the files to be added
64      */
65     public void addFileset(final FileSet set) {
661        cactifyEarTask.addFileset(set);
671    }
68  
69     /**
70      * This method runs the preparation task.
71      *
72      * @throws org.apache.tools.ant.BuildException
73      * if any error happens
74      */
75     public void execute() {
764        cactifyEarTask.setProject(getProject());
77         try {
784            cactifyEarTask.execute();
793        } catch (Exception e) {
80             // Catch of Exception is normally discouraged by TC style, but as we want
81             // to 'shield' the caller from the internals of the wrapped implementation
82             // of cactus (which sometimes can throw NPEs) we simply wrap everything
83             // into BuildException to assure normal ant behavior
843            throw new BuildException("Error while preparing the ear file.", e);
851        }
861    }
87 }

this report was generated by version 1.0.5 of jcoverage.
visit www.jcoverage.com for updates.

copyright © 2003, jcoverage ltd. all rights reserved.
Java is a trademark of Sun Microsystems, Inc. in the United States and other countries.