1   package org.paneris.jammyjoes.upload;
2   
3   import java.io.BufferedReader;
4   import java.io.File;
5   import java.io.FileReader;
6   import java.io.IOException;
7   
8   import junit.framework.TestCase;
9   
10  import org.melati.LogicalDatabase;
11  import org.melati.poem.AccessToken;
12  import org.melati.poem.PoemTask;
13  import org.paneris.jammyjoes.model.JammyjoesDatabase;
14  
15  public class TestCaseFunctionalFroogle extends TestCase {
16  
17    private String dir;
18    String filename = "jammyjoes.txt";
19  
20    public TestCaseFunctionalFroogle(String arg0) {
21      super(arg0);
22    }
23  
24    public void testGenerateFroogle() throws Exception {
25      final JammyjoesDatabase database = (JammyjoesDatabase) LogicalDatabase.getDatabase("jammyjoes");
26      database.inSession(AccessToken.root, new PoemTask() {
27  
28        public void run() {
29          Froogle froogle = new Froogle(database);
30          dir = database.getSettingTable().get("UploadDir") + "/../";
31          try {
32            froogle.writeFile(dir, filename);
33          } catch (IOException e1) {
34            throw new RuntimeException(e1);
35          }
36        }
37      });
38    }
39  
40    public void testReadFroogle() throws Exception {
41      BufferedReader file = new BufferedReader(new FileReader(new File("C:\\sandbox\\jammyjoes\\website", filename)));
42      int count = 0;
43      while (file.readLine() != null) {
44        count++;
45      }
46      assertTrue("count is: " + count, count > 600);
47    }
48  
49  }