blob: 98041072a59e9e6d346ce3c5973209f609c85977 [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
Michael Hanl8abaf9e2016-05-23 16:46:35 +020018 public void initMethod () throws KustvaktException {
Michael Hanlc8729b92015-09-02 12:37:36 +020019
Michael Hanlc8729b92015-09-02 12:37:36 +020020 }
21
Michael Hanl8abaf9e2016-05-23 16:46:35 +020022
Michael Hanlc8729b92015-09-02 12:37:36 +020023 @Test
Michael Hanl8abaf9e2016-05-23 16:46:35 +020024 public void testAdd () {
Michael Hanlc8729b92015-09-02 12:37:36 +020025 for (int i = 0; i < 20; i++) {
Michael Hanl8abaf9e2016-05-23 16:46:35 +020026 AuditRecord record = AuditRecord.serviceRecord("MichaelHanl",
27 StatusCodes.ILLEGAL_ARGUMENT, String.valueOf(i),
28 "string value");
Michael Hanldaf86602016-05-12 14:31:52 +020029 helper().getContext().getAuditingProvider().audit(record);
Michael Hanlc8729b92015-09-02 12:37:36 +020030 }
31 }
32
Michael Hanl8abaf9e2016-05-23 16:46:35 +020033
Michael Hanlc8729b92015-09-02 12:37:36 +020034 @Test(expected = UnsupportedOperationException.class)
Michael Hanl8abaf9e2016-05-23 16:46:35 +020035 public void testRetrieval () {
Michael Hanldaf86602016-05-12 14:31:52 +020036 helper().getContext().getAuditingProvider()
Michael Hanlc8729b92015-09-02 12:37:36 +020037 .retrieveRecords(new LocalDate(new Date().getTime()), 10);
38 }
39
40}