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 public methods of the RefEntryServlet class using the
* JUnit test framework.
* @author <a href="mailto:mark@mcraig.org">Mark Craig</a>
*/
public class TestRefEntryServlet extends TestCase {
protected RefEntryServlet servlet = new RefEntryServlet();
protected Properties config;
protected RefEntryBackEnd backend;
protected File infile;
protected File outfile;
protected Properties xslt;
protected RefEntry refentry;
protected void setUp() throws Exception {
try {
backend = new RefEntryBackEnd(new HashSet());
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);
backend.add(refentry);
ObjectOutputStream os =
new ObjectOutputStream(
new FileOutputStream(
new File("be")));
os.writeObject(backend);
os.close();
config = new Properties();
config.setProperty("CommonWords", "the and you");
config.setProperty("DefaultPage", "test-test");
config.setProperty("test-test", "src/test/test.xml");
} catch (Exception e) {
throw e;
}
}
protected void tearDown() throws Exception {
try {
outfile.delete();
File backend = new File("be");
backend.delete();
} catch (Exception e) {
throw e;
}
}
public void testGetServletInfo() {
assertTrue(servlet.getServletInfo() != null);
}
public void testInit() {
// If the init method breaks, the servlet
// cannot start, so other tests implicitly
// get at this one.
return;
}
public void testDoGet() {
// Test this with ServletUnit.
return;
}
public void testDoPost() {
// Test this with ServletUnit.
return;
}
public void testGetTokens() {
// Test this with ServletUnit.
return;
}
public void runTest() {
testGetServletInfo();
testInit();
testDoGet();
testDoPost();
testGetTokens();
}
} |