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 |
| 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 | |
| 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 Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame^] | 28 | helper().getContext().getAuditingProvider().audit(record); |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 29 | } |
| 30 | } |
| 31 | |
| 32 | @Test(expected = UnsupportedOperationException.class) |
| 33 | public void testRetrieval() { |
Michael Hanl | daf8660 | 2016-05-12 14:31:52 +0200 | [diff] [blame^] | 34 | helper().getContext().getAuditingProvider() |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 35 | .retrieveRecords(new LocalDate(new Date().getTime()), 10); |
| 36 | } |
| 37 | |
| 38 | } |