blob: 0e62e128e23303ffeb9810bff57d6381d3748d93 [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 Hanlc8729b92015-09-02 12:37:36 +020026 }
27
28 @Test
29 public void testAdd() {
30 for (int i = 0; i < 20; i++) {
31 AuditRecord record = AuditRecord
32 .serviceRecord("MichaelHanl", StatusCodes.ILLEGAL_ARGUMENT,
33 String.valueOf(i), "string value");
34 BeanConfiguration.getBeans().getAuditingProvider().audit(record);
35 }
36 }
37
38 @Test(expected = UnsupportedOperationException.class)
39 public void testRetrieval() {
40 BeanConfiguration.getBeans().getAuditingProvider()
41 .retrieveRecords(new LocalDate(new Date().getTime()), 10);
42 }
43
44}