blob: 23b589c1e07ce8eccfd3ea1059f966d826b0b755 [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
Michael Hanlc8729b92015-09-02 12:37:36 +02009import java.util.Date;
10
11/**
12 * @author hanl
13 * @date 27/07/2015
14 */
15//todo: test audit commit in thread and that no concurrency issue arrises
16public class FileAuditingTest {
17
18 @BeforeClass
19 public static void init() {
20 BeanConfiguration.loadClasspathContext();
21 }
22
23 @AfterClass
24 public static void finish() {
25 BeanConfiguration.closeApplication();
Michael Hanl19390652016-01-16 11:01:24 +010026// File f = new File("logs/default_audit.log");
27// System.out.println("------------------------------------------------------");
28// System.out.println("FILE LENGTH "+f.length());
29// assert f.length() > 0;
Michael Hanlc8729b92015-09-02 12:37:36 +020030 }
31
32 @Test
33 public void testAdd() {
34 for (int i = 0; i < 20; i++) {
35 AuditRecord record = AuditRecord
36 .serviceRecord("MichaelHanl", StatusCodes.ILLEGAL_ARGUMENT,
37 String.valueOf(i), "string value");
38 BeanConfiguration.getBeans().getAuditingProvider().audit(record);
39 }
40 }
41
42 @Test(expected = UnsupportedOperationException.class)
43 public void testRetrieval() {
44 BeanConfiguration.getBeans().getAuditingProvider()
45 .retrieveRecords(new LocalDate(new Date().getTime()), 10);
46 }
47
48}