Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 1 | import de.ids_mannheim.korap.auditing.AuditRecord; |
| 2 | import de.ids_mannheim.korap.config.BeanConfiguration; |
| 3 | import de.ids_mannheim.korap.exceptions.StatusCodes; |
| 4 | import org.joda.time.LocalDate; |
| 5 | import org.junit.AfterClass; |
| 6 | import org.junit.BeforeClass; |
| 7 | import org.junit.Test; |
| 8 | |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 9 | import java.util.Date; |
| 10 | |
| 11 | /** |
| 12 | * @author hanl |
| 13 | * @date 27/07/2015 |
| 14 | */ |
| 15 | //todo: test audit commit in thread and that no concurrency issue arrises |
| 16 | public class FileAuditingTest { |
| 17 | |
| 18 | @BeforeClass |
| 19 | public static void init() { |
| 20 | BeanConfiguration.loadClasspathContext(); |
| 21 | } |
| 22 | |
| 23 | @AfterClass |
| 24 | public static void finish() { |
| 25 | BeanConfiguration.closeApplication(); |
Michael Hanl | c8729b9 | 2015-09-02 12:37:36 +0200 | [diff] [blame] | 26 | } |
| 27 | |
| 28 | @Test |
| 29 | public void testAdd() { |
| 30 | for (int i = 0; i < 20; i++) { |
| 31 | AuditRecord record = AuditRecord |
| 32 | .serviceRecord("MichaelHanl", StatusCodes.ILLEGAL_ARGUMENT, |
| 33 | String.valueOf(i), "string value"); |
| 34 | BeanConfiguration.getBeans().getAuditingProvider().audit(record); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | @Test(expected = UnsupportedOperationException.class) |
| 39 | public void testRetrieval() { |
| 40 | BeanConfiguration.getBeans().getAuditingProvider() |
| 41 | .retrieveRecords(new LocalDate(new Date().getTime()), 10); |
| 42 | } |
| 43 | |
| 44 | } |