JUnit-addons
version 1.4

junitx.util
Class ArchiveSuiteBuilder

java.lang.Object
  |
  +--junitx.util.AbstractSuiteBuilder
        |
        +--junitx.util.ArchiveSuiteBuilder

public class ArchiveSuiteBuilder
extends junitx.util.AbstractSuiteBuilder

Extracts the testcases from a zip or jar achive. Use the TestFilter to specify the pattern of the classes to load.

Note

The jar archive is handled like a zip archive: information located in the manifest (like a classpath) are ignored.

Examples

Returns a suite containing all classes matching the pattern "*Test.class":

     ArchiveSuiteBuilder builder = new ArchiveSuiteBuilder();
     Test suite = builer.suite("myarchive.zip");
 
Returns a suite containing AllTests.class classes:

     ArchiveSuiteBuilder builder = new ArchiveSuiteBuilder();
     builder.setFilter(new TestFilter() {

          public boolean include(String classpath) {
              return super.include(classpath) && 
                  SimpleTestFilter.getClassName(classpath).equals("AllTests");
          }
 
     });
 
     Test suite = builer.suite("myjar.jar");
 

Version:
$Revision: 1.6 $ $Date: 2003/04/28 05:18:28 $
Author:
Vladimir R. Bossicard, Naidu Purushotham

Constructor Summary
ArchiveSuiteBuilder()
          Constructs an empty ArchiveSuiteBuilder object.
ArchiveSuiteBuilder(TestFilter filter)
          Constructs an ArchiveSuiteBuilder object with the given filter.
 
Method Summary
protected  java.util.List browse(java.util.zip.ZipFile file)
          Returns the list of test classes contained in the ZipFile.
protected  boolean isTestClass(java.lang.String path)
          Returns true if the given path refers a test class.
protected  void merge(java.util.List classenames, junit.framework.TestSuite suite)
          Populates the suite with test cases extracted from the classnames list.
 void setFilter(TestFilter filter)
          Sets the filter defining the test classes to be included.
 junit.framework.Test suite(java.lang.String filename)
          Constructs a TestSuite by extracting all test classes from an archive specified by the filename.
 junit.framework.Test suite(java.util.zip.ZipFile file)
          Constructs a TestSuite by extracting all test classes from the given file archive.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArchiveSuiteBuilder

public ArchiveSuiteBuilder()
Constructs an empty ArchiveSuiteBuilder object.


ArchiveSuiteBuilder

public ArchiveSuiteBuilder(TestFilter filter)
Constructs an ArchiveSuiteBuilder object with the given filter.

Method Detail

suite

public junit.framework.Test suite(java.util.zip.ZipFile file)
                           throws java.lang.Exception
Constructs a TestSuite by extracting all test classes from the given file archive.

java.lang.Exception

suite

public junit.framework.Test suite(java.lang.String filename)
                           throws java.lang.Exception
Constructs a TestSuite by extracting all test classes from an archive specified by the filename.

java.lang.Exception

browse

protected java.util.List browse(java.util.zip.ZipFile file)
Returns the list of test classes contained in the ZipFile. Method defined for testing only: no support guarantee.

See Also:
AbstractSuiteBuilder.isTestClass(java.lang.String)

setFilter

public void setFilter(TestFilter filter)
Sets the filter defining the test classes to be included.


isTestClass

protected boolean isTestClass(java.lang.String path)
Returns true if the given path refers a test class.


merge

protected void merge(java.util.List classenames,
                     junit.framework.TestSuite suite)
              throws java.lang.ClassNotFoundException,
                     java.lang.IllegalAccessException,
                     java.lang.reflect.InvocationTargetException
Populates the suite with test cases extracted from the classnames list.

java.lang.ClassNotFoundException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException

JUnit-addons
version 1.4

Copyright © 2002-2003 Vladimir R. Bossicard. All Rights Reserved.