| margaretha | 9cfb73e | 2017-09-11 17:41:28 +0200 | [diff] [blame] | 1 | package de.ids_mannheim.korap.misc; |
| margaretha | 5c67dd5 | 2018-12-18 17:27:05 +0100 | [diff] [blame] | 2 | |
| margaretha | f68daa6 | 2017-09-21 02:11:24 +0200 | [diff] [blame] | 3 | import java.util.Date; |
| 4 | |
| Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 5 | import org.joda.time.LocalDate; |
| Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 6 | import org.junit.Test; |
| 7 | |
| margaretha | f68daa6 | 2017-09-21 02:11:24 +0200 | [diff] [blame] | 8 | import de.ids_mannheim.korap.auditing.AuditRecord; |
| margaretha | f68daa6 | 2017-09-21 02:11:24 +0200 | [diff] [blame] | 9 | import de.ids_mannheim.korap.exceptions.StatusCodes; |
| margaretha | 5c67dd5 | 2018-12-18 17:27:05 +0100 | [diff] [blame] | 10 | import de.ids_mannheim.korap.interfaces.db.AuditingIface; |
| 11 | import de.ids_mannheim.korap.interfaces.defaults.DefaultAuditing; |
| Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 12 | |
| 13 | /** |
| 14 | * @author hanl |
| 15 | * @date 27/07/2015 |
| 16 | */ |
| margaretha | 5c67dd5 | 2018-12-18 17:27:05 +0100 | [diff] [blame] | 17 | // todo: test audit commit in thread and that no concurrency issue |
| 18 | // arrises |
| 19 | public class FileAuditingTest { |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 20 | |
| Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 21 | @Test |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 22 | public void testAdd () { |
| margaretha | 5c67dd5 | 2018-12-18 17:27:05 +0100 | [diff] [blame] | 23 | AuditingIface auditor = new DefaultAuditing(); |
| Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 24 | for (int i = 0; i < 20; i++) { |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 25 | AuditRecord record = AuditRecord.serviceRecord("MichaelHanl", |
| 26 | StatusCodes.ILLEGAL_ARGUMENT, String.valueOf(i), |
| 27 | "string value"); |
| margaretha | 5c67dd5 | 2018-12-18 17:27:05 +0100 | [diff] [blame] | 28 | auditor.audit(record); |
| Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 29 | } |
| 30 | } |
| 31 | |
| margaretha | 5c67dd5 | 2018-12-18 17:27:05 +0100 | [diff] [blame] | 32 | @Test(expected = UnsupportedOperationException.class) |
| Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 33 | public void testRetrieval () { |
| margaretha | 5c67dd5 | 2018-12-18 17:27:05 +0100 | [diff] [blame] | 34 | AuditingIface auditor = new DefaultAuditing(); |
| 35 | auditor.retrieveRecords(new LocalDate(new Date().getTime()), 10); |
| Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | } |