blob: fecc33850860819323b85b6f5c9c5b73547951ca [file] [log] [blame]
Michael Hanlc8729b92015-09-02 12:37:36 +02001import de.ids_mannheim.korap.auditing.AuditRecord;
Michael Hanldaf86602016-05-12 14:31:52 +02002import de.ids_mannheim.korap.config.BeanConfigTest;
3import de.ids_mannheim.korap.exceptions.KustvaktException;
Michael Hanlc8729b92015-09-02 12:37:36 +02004import de.ids_mannheim.korap.exceptions.StatusCodes;
5import org.joda.time.LocalDate;
Michael Hanlc8729b92015-09-02 12:37:36 +02006import org.junit.Test;
7
Michael Hanlc8729b92015-09-02 12:37:36 +02008import java.util.Date;
9
10/**
11 * @author hanl
12 * @date 27/07/2015
13 */
14//todo: test audit commit in thread and that no concurrency issue arrises
Michael Hanldaf86602016-05-12 14:31:52 +020015public class FileAuditingTest extends BeanConfigTest {
Michael Hanlc8729b92015-09-02 12:37:36 +020016
Michael Hanldaf86602016-05-12 14:31:52 +020017 @Override
18 public void initMethod() throws KustvaktException {
Michael Hanlc8729b92015-09-02 12:37:36 +020019
Michael Hanlc8729b92015-09-02 12:37:36 +020020 }
21
22 @Test
23 public void testAdd() {
24 for (int i = 0; i < 20; i++) {
25 AuditRecord record = AuditRecord
26 .serviceRecord("MichaelHanl", StatusCodes.ILLEGAL_ARGUMENT,
27 String.valueOf(i), "string value");
Michael Hanldaf86602016-05-12 14:31:52 +020028 helper().getContext().getAuditingProvider().audit(record);
Michael Hanlc8729b92015-09-02 12:37:36 +020029 }
30 }
31
32 @Test(expected = UnsupportedOperationException.class)
33 public void testRetrieval() {
Michael Hanldaf86602016-05-12 14:31:52 +020034 helper().getContext().getAuditingProvider()
Michael Hanlc8729b92015-09-02 12:37:36 +020035 .retrieveRecords(new LocalDate(new Date().getTime()), 10);
36 }
37
38}