Revision 9108
Added by Jing Tao almost 10 years ago
test/edu/ucsb/nceas/metacattest/EventLogTest.java | ||
---|---|---|
38 | 38 |
*/ |
39 | 39 |
public class EventLogTest extends MCTestCase |
40 | 40 |
{ |
41 |
|
|
41 |
private static final String USERAGENT="useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-"+ |
|
42 |
"useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-"+ |
|
43 |
"useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-"+ |
|
44 |
"useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-"+ |
|
45 |
"useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-useragent-"+ |
|
46 |
"useragent-12"; |
|
42 | 47 |
protected void setUp() throws Exception |
43 | 48 |
{ |
44 | 49 |
super.setUp(); |
... | ... | |
80 | 85 |
assertTrue(report.contains("<userAgent>Mozilla</userAgent>")); |
81 | 86 |
assertTrue(report.contains("<principal>public</principal>")); |
82 | 87 |
assertTrue(report.contains("<docid>"+id+"</docid>")); |
88 |
|
|
89 |
//test a case with a user-agent which length is greater than 512. |
|
90 |
time = System.nanoTime(); |
|
91 |
id = "test-1934-wemewen-3-3"+time+".1"; |
|
92 |
EventLog.getInstance().log("192.168.1.103", USERAGENT+"extral characters", "public", id, "read"); |
|
93 |
Thread.sleep(2000); |
|
94 |
|
|
95 |
String[] docs = {id}; |
|
96 |
report = EventLog.getInstance().getReport(ipList, principals, docs, |
|
97 |
eventList, startDate, endDate, anonymous); |
|
98 |
System.out.println("the report is "+report); |
|
99 |
assertTrue(report.contains("<event>read</event>")); |
|
100 |
assertTrue(report.contains("<ipAddress>192.168.1.103</ipAddress>")); |
|
101 |
assertTrue(report.contains("<userAgent>"+USERAGENT+"</userAgent>")); |
|
102 |
assertTrue(report.contains("<principal>public</principal>")); |
|
103 |
assertTrue(report.contains("<docid>"+id+"</docid>")); |
|
83 | 104 |
} |
84 | 105 |
|
85 | 106 |
/** |
Also available in: Unified diff
Add the code to test only 512 characters can be written to db.