1 32 33 package com.jeantessier.classreader; 34 35 import java.io.*; 36 import java.util.*; 37 38 import junit.framework.*; 39 40 import org.apache.log4j.*; 41 42 public class TestAggregatingClassfileLoader extends TestCase { 43 public static final String TEST_CLASS = "test"; 44 public static final String TEST_FILENAME = "classes" + File.separator + "test.class"; 45 46 private AggregatingClassfileLoader loader; 47 48 protected void setUp() throws Exception { 49 Logger.getLogger(getClass()).info("Starting test: " + getName()); 50 51 loader = new AggregatingClassfileLoader(); 52 } 53 54 protected void tearDown() throws Exception { 55 Logger.getLogger(getClass()).info("End of " + getName()); 56 } 57 58 public void testCreate() { 59 assertEquals("Different number of class names", 60 0, 61 loader.getAllClassNames().size()); 62 assertNull(TEST_CLASS + " should have been null", 63 loader.getClassfile(TEST_CLASS)); 64 } 65 66 public void testStart() throws IOException { 67 assertEquals("Different number of class names", 68 0, 69 loader.getAllClassNames().size()); 70 assertNull(TEST_CLASS + " should have been null", 71 loader.getClassfile(TEST_CLASS)); 72 73 loader.load(new DataInputStream(new FileInputStream(TEST_FILENAME))); 74 75 assertEquals("Different number of class names", 76 1, 77 loader.getAllClassNames().size()); 78 assertTrue("Missing class name \"" + TEST_CLASS + "\"", 79 loader.getAllClassNames().contains(TEST_CLASS)); 80 assertNotNull(TEST_CLASS + " should not have been null", 81 loader.getClassfile(TEST_CLASS)); 82 } 83 84 public void testClassfile() throws IOException { 85 loader.load(Collections.singleton(TEST_FILENAME)); 86 87 assertNotNull("No Classfile from " + TEST_FILENAME, loader.getClassfile(TEST_CLASS)); 88 } 89 } 90 | Popular Tags |