01: package pygmy.nntp.test;
02:
03: import junit.framework.TestCase;
04:
05: import java.io.File;
06: import java.io.IOException;
07: import java.io.ByteArrayOutputStream;
08:
09: import pygmy.nntp.Forum;
10: import pygmy.nntp.Article;
11: import pygmy.core.InternetOutputStream;
12:
13: public abstract class NntpHandlerTestCase extends TestCase {
14: Forum forum;
15:
16: protected void setUp() throws Exception {
17: forum = NntpTestUtil.createTestForum();
18: }
19:
20: protected void tearDown() throws Exception {
21: File[] list = forum.getRootRepository().listFiles();
22: if (list != null) {
23: for (int i = 0; i < list.length; i++) {
24: File file = list[i];
25: if (file.isDirectory())
26: NntpTestUtil.deleteTree(file);
27: }
28: }
29: }
30:
31: protected byte[] getArticleBytes(String filename)
32: throws IOException {
33: Article article = NntpTestUtil.createArticle(filename);
34: ByteArrayOutputStream articleBaos = new ByteArrayOutputStream();
35: article.save(new InternetOutputStream(articleBaos));
36: return articleBaos.toByteArray();
37: }
38: }
|