Revision 2111
Added by Matt Jones about 20 years ago
EventLogTest.java | ||
---|---|---|
26 | 26 |
import java.io.File; |
27 | 27 |
import java.io.FileNotFoundException; |
28 | 28 |
import java.io.IOException; |
29 |
import java.sql.Timestamp; |
|
30 |
import java.text.ParseException; |
|
31 |
import java.text.SimpleDateFormat; |
|
32 |
import java.util.Date; |
|
29 | 33 |
|
30 | 34 |
import edu.ucsb.nceas.metacat.DBConnectionPool; |
31 | 35 |
import edu.ucsb.nceas.metacat.EventLog; |
... | ... | |
67 | 71 |
assertTrue(logger != null); |
68 | 72 |
} |
69 | 73 |
|
74 |
/** |
|
75 |
* Test whether the log method can properly insert a log record. |
|
76 |
*/ |
|
70 | 77 |
public void testLog() |
71 | 78 |
{ |
72 |
EventLog.getInstance().log("192.168.1.103", "public", "test.1", "read"); |
|
79 |
EventLog.getInstance().log("192.168.1.103", "public", "test.2.1", "read");
|
|
73 | 80 |
assertTrue(1 == 1); |
74 | 81 |
} |
75 | 82 |
|
83 |
/** |
|
84 |
* Test whether getReport returns correct reports. |
|
85 |
*/ |
|
86 |
public void testGetReport() |
|
87 |
{ |
|
88 |
String[] principals = {"jones", "public", "someone"}; |
|
89 |
String[] ipList = {"192.168.1.103", "192.168.1.104"}; |
|
90 |
String[] docList = {"test.2.1", "test.2"}; |
|
91 |
String[] eventList = {"read", "insert", "update"}; |
|
92 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
|
93 |
Timestamp startDate = null; |
|
94 |
Timestamp endDate = null; |
|
95 |
try { |
|
96 |
startDate = new Timestamp((format.parse("2004-04-07 09:32:00")).getTime()); |
|
97 |
endDate = new Timestamp((format.parse("2004-04-07 09:50:00")).getTime()); |
|
98 |
} catch (ParseException e) { |
|
99 |
System.out.println("Failed to created endDate from format."); |
|
100 |
} |
|
101 |
String report = EventLog.getInstance().getReport(ipList, principals, docList, |
|
102 |
eventList, null, null); |
|
103 |
System.out.println(report); |
|
104 |
report = EventLog.getInstance().getReport(null, null, null, |
|
105 |
null, startDate, endDate); |
|
106 |
System.out.println(report); |
|
107 |
} |
|
76 | 108 |
} |
Also available in: Unified diff
Partial implementation of a query facility for the access log. Need to fix problems with the date filtering, and tie this into the servlet action when completed and tested.