KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > roller > presentation > ArchiveParserTest


1 /*
2  * Created on May 4, 2004
3  */

4 package org.roller.presentation;
5
6 import java.io.File JavaDoc;
7
8 import junit.framework.Test;
9 import junit.framework.TestSuite;
10
11 import org.roller.RollerException;
12 import org.roller.RollerTestBase;
13 import org.roller.business.FileManagerTest;
14 import org.roller.pojos.RollerConfigData;
15 import org.roller.presentation.velocity.ExportRssTest;
16
17 import com.mockrunner.mock.web.MockServletContext;
18  
19 /**
20  * TODO: revisit this class once Atom 1.0 support comes to Rome
21  * @author lance.lavandowska
22  */

23 public class ArchiveParserTest extends RollerTestBase
24 {
25     MockServletContext mContext = null;
26     RollerConfigData rollerConfig = null;
27     
28     private static String JavaDoc FILE_LOCATION = "./build/junk/";
29     private static String JavaDoc RSS_ARCHIVE = "export-test.rss.xml";
30     private static String JavaDoc ATOM_ARCHIVE = "export-test.atom.xml";
31     
32     public void _testAtomParsing() throws RollerException
33     {
34         File JavaDoc archiveFile = new File JavaDoc(FILE_LOCATION +
35                                     mWebsite.getUser().getUserName() +
36                                     "/" + ATOM_ARCHIVE);
37         parseFile(archiveFile);
38     }
39     
40     public void _testRssParsing() throws RollerException
41     {
42         File JavaDoc archiveFile = new File JavaDoc(FILE_LOCATION +
43                                     mWebsite.getUser().getUserName() +
44                                     "/" + RSS_ARCHIVE);
45         parseFile(archiveFile);
46     }
47     
48     /**
49      * @param archiveFile
50      * @throws RollerException
51      */

52     private void parseFile(File JavaDoc archiveFile) throws RollerException
53     {
54         if (archiveFile.exists())
55         {
56             //ArchiveParser parser = new ArchiveParser(getRoller(), mWebsite, archiveFile);
57
//getRoller().begin(UserData.SYSTEM_USER);
58
String JavaDoc result = null; // parser.parse();
59
getRoller().commit();
60             assertTrue(result.length() > 0);
61             System.out.println(result);
62         }
63         else
64         {
65             //try again, use export test to create necessary files
66
ExportRssTest exportTest = new ExportRssTest();
67             try
68             {
69                 exportTest.setUp();
70                 exportTest.testExportRecent();
71                 exportTest.tearDown();
72                 
73                 parseFile(archiveFile);
74             }
75             catch (Exception JavaDoc e)
76             {
77                 // TODO Auto-generated catch block
78
e.printStackTrace();
79             }
80             
81             // if it *still* isn't there, then fail
82
if (!archiveFile.exists())
83             {
84                 fail(archiveFile.getAbsolutePath() + " does not exist.");
85             }
86         }
87     }
88
89     /*
90      * Need to change the UploadPath location for testing.
91      * @see junit.framework.TestCase#setUp()
92      */

93     public void setUp() throws Exception JavaDoc
94     {
95         super.setUp();
96
97         //rollerConfig = rollerContext.getRollerConfig();
98
}
99
100     /*
101      * Need to reset the UploadPath after testing.
102      * @see junit.framework.TestCase#tearDown()
103      */

104     public void tearDown() throws Exception JavaDoc
105     {
106         super.tearDown();
107     }
108
109     public static Test suite()
110     {
111         return new TestSuite(ArchiveParserTest.class);
112     }
113 }
114
Popular Tags