1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.goetz.domino.log4j;
18
19 import java.util.Vector;
20
21 import junit.framework.TestCase;
22 import lotus.domino.Database;
23 import lotus.domino.Document;
24 import lotus.domino.DocumentCollection;
25 import lotus.domino.NotesFactory;
26 import lotus.domino.NotesThread;
27 import lotus.domino.Session;
28
29 import org.apache.log4j.helpers.LogLog;
30
31 /***
32 * Verify field sizes of all log documents.
33 *
34 * @author Bernd Götz
35 */
36 public class VerifyFieldSizeTest extends TestCase {
37
38 public void testGetLastDocument() throws Exception {
39
40 NotesThread.sinitThread();
41
42 Session session = NotesFactory.createSession();
43
44 String databaseName = "DOMAPP/applog00.nsf";
45 String serverName = "dominotest";
46 Database db = session.getDatabase(serverName, databaseName);
47 if (!db.isOpen()) {
48 LogLog.debug("Log databaseName is closed. Trying to open it.");
49 db.open();
50 }
51
52
53 String f = "Form = \"frmEvents\" & " +
54 "AppName = \"RemoteTestServlet1\"";
55
56
57
58
59 DocumentCollection dc = db.search(f);
60
61 System.out.println("No of docs: " + dc.getCount());
62
63 Document d = dc.getFirstDocument();
64 int j = 1;
65 int maxbytes = 0;
66 while (d != null) {
67 Vector ve = d.getItemValue("Events");
68
69
70 int len = 0;
71 for (int i = 0; i < ve.size(); i++) {
72 String l = (String)ve.elementAt(i);
73 len += l.length();
74 }
75
76 if (len > maxbytes) {
77 maxbytes = len;
78 }
79 d = dc.getNextDocument();
80 j++;
81 }
82 System.out.println("maxbytes: " + maxbytes);
83
84 db.recycle();
85 session.recycle();
86 NotesThread.stermThread();
87
88 }
89
90 }