Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 1 | import de.ids_mannheim.korap.auditing.AuditRecord; |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 2 | import de.ids_mannheim.korap.config.BeanConfigTest; |
| 3 | import de.ids_mannheim.korap.exceptions.KustvaktException; |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 4 | import de.ids_mannheim.korap.exceptions.StatusCodes; |
| 5 | import org.joda.time.LocalDate; |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 6 | import org.junit.Test; |
| 7 | |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 8 | import 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 Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 15 | public class FileAuditingTest extends BeanConfigTest { |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 16 | |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 17 | @Override |
Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 18 | public void initMethod () throws KustvaktException { |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 19 | |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 20 | } |
| 21 | |
Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 22 | |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 23 | @Test |
Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 24 | public void testAdd () { |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 25 | for (int i = 0; i < 20; i++) { |
Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 26 | AuditRecord record = AuditRecord.serviceRecord("MichaelHanl", |
| 27 | StatusCodes.ILLEGAL_ARGUMENT, String.valueOf(i), |
| 28 | "string value"); |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 29 | helper().getContext().getAuditingProvider().audit(record); |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 30 | } |
| 31 | } |
| 32 | |
Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 33 | |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 34 | @Test(expected = UnsupportedOperationException.class) |
Michael Hanl | 8abaf9e | 2016-05-23 16:46:35 +0200 | [diff] [blame] | 35 | public void testRetrieval () { |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame] | 36 | helper().getContext().getAuditingProvider() |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 37 | .retrieveRecords(new LocalDate(new Date().getTime()), 10); |
| 38 | } |
| 39 | |
| 40 | } |