Project

General

Profile

« Previous | Next » 

Revision 9105

Added by Jing Tao over 9 years ago

Add the code to make sure that the event, ip address, principal and userAgent were recorded.

View differences:

test/edu/ucsb/nceas/metacattest/EventLogTest.java
58 58
    /**
59 59
     * Test whether the log method can properly insert a log record.
60 60
     */
61
    public void testLog()
61
    public void testLog() throws Exception
62 62
    {
63
        EventLog.getInstance().log("192.168.1.103", "Mozilla", "public", "test.2.1", "read");
64
        assertTrue(1 == 1);
63
        
64
        long time = System.nanoTime();
65
        String id = "test-1934-wemewen-3-2"+time+".1";
66
        EventLog.getInstance().log("192.168.1.103", "Mozilla", "public", id, "read");
67
        Thread.sleep(2000);
68
        Timestamp startDate = null;
69
        Timestamp endDate = null;
70
        boolean anonymous = false;
71
        String[] principals = {"public", "someone"};
72
        String[] ipList = {"192.168.1.103", "192.168.1.104"};
73
        String[] docList = {id};
74
        String[] eventList = {"read", "insert", "update"};
75
        String report = EventLog.getInstance().getReport(ipList, principals, docList, 
76
                eventList, startDate, endDate, anonymous);
77
        //System.out.println("the report is "+report);
78
        assertTrue(report.contains("<event>read</event>"));
79
        assertTrue(report.contains("<ipAddress>192.168.1.103</ipAddress>"));
80
        assertTrue(report.contains("<userAgent>Mozilla</userAgent>"));
81
        assertTrue(report.contains("<principal>public</principal>"));
82
        assertTrue(report.contains("<docid>"+id+"</docid>"));
65 83
    }
66 84

  
67 85
    /**
......
95 113
     */
96 114
    public void testIsDeleted() throws Exception{
97 115
        long time = System.nanoTime();
98
        String id = "test-1934-weme123-3.1"+time;
116
        String id = "test-1934-weme123-3-1"+time+".1";
99 117
        EventLog.getInstance().log("192.168.1.103", "Mozilla", "public", id, "read");
100 118
        Thread.sleep(2000);
101 119
        boolean deleted = EventLog.getInstance().isDeleted(id);

Also available in: Unified diff