package org.mcraig.cs445.refentry;
import java.io.*;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Properties;
import junit.framework.TestCase;
/**
* Test friendly methods of the RefEntryIndex class using the
* JUnit test framework.
* @author <a href="mailto:mark@mcraig.org">Mark Craig</a>
*/
public class TestRefEntryIndex extends TestCase {
protected RefEntryIndex index;
protected File infile;
protected File outfile;
protected Properties xslt;
protected RefEntry refentry;
protected void setUp() throws Exception {
try {
index = new RefEntryIndex();
infile = new File("src/test/test.xml");
outfile = File.createTempFile("test", ".html");
xslt = new Properties();
xslt.load(
new BufferedInputStream(
new FileInputStream("src/conf/xslt.props")));
refentry = new RefEntry(infile, outfile, xslt);
} catch (Exception e) {
throw e;
}
}
protected void tearDown() throws Exception {
try {
outfile.delete();
} catch (Exception e) {
throw e;
}
}
public void testAdd() {
boolean test = index.add("Test", refentry);
assertTrue(test);
}
public void testMatch() {
HashSet test = index.match("tesT");
Iterator iter = test.iterator();
RefEntry re = (RefEntry)iter.next();
assertEquals(re, refentry);
}
public void runTest() {
testAdd();
testMatch();
}
} |