blob: 56465902f4d91a7f7d9cca4b6a34f619c426b136 [file] [log] [blame]
Michael Hanlc8729b92015-09-02 12:37:36 +02001import de.ids_mannheim.korap.auditing.AuditRecord;
2import de.ids_mannheim.korap.config.BeanConfiguration;
3import de.ids_mannheim.korap.exceptions.StatusCodes;
4import org.joda.time.LocalDate;
5import org.junit.AfterClass;
6import org.junit.BeforeClass;
7import org.junit.Test;
8
9import java.io.File;
10import java.util.Date;
11
12/**
13 * @author hanl
14 * @date 27/07/2015
15 */
16//todo: test audit commit in thread and that no concurrency issue arrises
17public class FileAuditingTest {
18
19 @BeforeClass
20 public static void init() {
21 BeanConfiguration.loadClasspathContext();
22 }
23
24 @AfterClass
25 public static void finish() {
26 BeanConfiguration.closeApplication();
27 File f = new File("logs/default_audit.log");
28 assert f.length() > 0;
29 }
30
31 @Test
32 public void testAdd() {
33 for (int i = 0; i < 20; i++) {
34 AuditRecord record = AuditRecord
35 .serviceRecord("MichaelHanl", StatusCodes.ILLEGAL_ARGUMENT,
36 String.valueOf(i), "string value");
37 BeanConfiguration.getBeans().getAuditingProvider().audit(record);
38 }
39 }
40
41 @Test(expected = UnsupportedOperationException.class)
42 public void testRetrieval() {
43 BeanConfiguration.getBeans().getAuditingProvider()
44 .retrieveRecords(new LocalDate(new Date().getTime()), 10);
45 }
46
47}