1 package junitx.util; 2 3 import junit.framework.Test; 4 import junit.framework.TestCase; 5 6 import java.util.zip.ZipFile ; 7 8 12 public abstract class AbstractArchiveSuiteBuilderTest extends TestCase { 13 14 protected ZipFile file; 15 16 public AbstractArchiveSuiteBuilderTest(String name) { 17 super(name); 18 } 19 20 public void setUp() throws Exception { 21 this.file = new ZipFile (getFilename()); 22 } 23 24 public void tearDown() throws Exception { 25 this.file.close(); 26 } 27 28 abstract protected String getFilename(); 29 30 33 public void testBuildSampleA() throws Exception { 34 ArchiveSuiteBuilder builder = new ArchiveSuiteBuilder(); 35 TestFilter filter = new SimpleTestFilter() { 36 public boolean include(String classpath) { 37 return super.include(classpath) && 38 SimpleTestFilter.getClassName(classpath).startsWith("SampleA"); 39 } 40 }; 41 builder.setFilter(filter); 42 43 Test suite = builder.suite(getFilename()); 44 assertNotNull(suite); 45 assertEquals(1, suite.countTestCases()); 46 } 47 48 54 public void testBuildSampleB() throws Exception { 55 ArchiveSuiteBuilder builder = new ArchiveSuiteBuilder(); 56 TestFilter filter = new SimpleTestFilter() { 57 public boolean include(String classpath) { 58 return super.include(classpath) && 59 SimpleTestFilter.getClassName(classpath).startsWith("SampleB"); 60 } 61 }; 62 builder.setFilter(filter); 63 64 Test suite = builder.suite(getFilename()); 65 assertNotNull(suite); 66 assertEquals(2, suite.countTestCases()); 67 } 68 69 public void testBuildSamples() throws Exception { 70 ArchiveSuiteBuilder builder = new ArchiveSuiteBuilder(); 71 72 Test suite = builder.suite(getFilename()); 73 assertNotNull(suite); 74 assertEquals(3, suite.countTestCases()); 75 } 76 77 } 78 | Popular Tags |