diff --git a/bitrepository-alarm-service/pom.xml b/bitrepository-alarm-service/pom.xml index 60c6810c9..f2fec34d4 100644 --- a/bitrepository-alarm-service/pom.xml +++ b/bitrepository-alarm-service/pom.xml @@ -91,6 +91,15 @@ + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.build.directory}/allure-results + ${project.build.directory}/allure-report + + maven-assembly-plugin diff --git a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/AlarmExceptionTest.java b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/AlarmExceptionTest.java index ad69c2bd4..092cd1d57 100644 --- a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/AlarmExceptionTest.java +++ b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/AlarmExceptionTest.java @@ -5,28 +5,29 @@ * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ package org.bitrepository.alarm; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class AlarmExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; + +public class AlarmExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/handler/AlarmHandlerTest.java b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/handler/AlarmHandlerTest.java index 665f0e651..f773926cf 100644 --- a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/handler/AlarmHandlerTest.java +++ b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/handler/AlarmHandlerTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.alarm.handler; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.alarm.handling.AlarmHandler; import org.bitrepository.alarm.handling.AlarmMediator; import org.bitrepository.bitrepositorymessages.AlarmMessage; @@ -28,9 +29,13 @@ import org.bitrepository.protocol.IntegrationTest; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertEquals; +@ExtendWith(SuiteInfoParameterResolver.class) public class AlarmHandlerTest extends IntegrationTest { @Test @Tag("regressiontest") diff --git a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseExtractionModelTest.java b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseExtractionModelTest.java index b1db08e23..6d311b51e 100644 --- a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseExtractionModelTest.java +++ b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseExtractionModelTest.java @@ -22,19 +22,20 @@ package org.bitrepository.alarm.store; import org.bitrepository.bitrepositoryelements.AlarmCode; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; /** * Runs ExtendedTestCase with a regression test. */ -public class AlarmDatabaseExtractionModelTest extends ExtendedTestCase { +public class AlarmDatabaseExtractionModelTest { @Test @Tag("regressiontest") public void alarmExceptionTest() throws Exception { diff --git a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseTest.java b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseTest.java index 17224d0e0..65752cc14 100644 --- a/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseTest.java +++ b/bitrepository-alarm-service/src/test/java/org/bitrepository/alarm/store/AlarmDatabaseTest.java @@ -30,14 +30,7 @@ import org.bitrepository.service.database.DBConnector; import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; +import org.junit.jupiter.api.*; import java.io.File; import java.text.ParseException; @@ -47,11 +40,14 @@ import java.util.List; import java.util.Locale; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Sees if alarms are correctly stored in the database. */ @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class AlarmDatabaseTest extends ExtendedTestCase { +public class AlarmDatabaseTest { /** * The settings for the tests. Should be instantiated in the setup. */ diff --git a/bitrepository-audit-trail-service/pom.xml b/bitrepository-audit-trail-service/pom.xml index 4cccd3e94..50726245d 100644 --- a/bitrepository-audit-trail-service/pom.xml +++ b/bitrepository-audit-trail-service/pom.xml @@ -89,6 +89,15 @@ + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.basedir}/allure-results + ${project.basedir}/allure-report + + maven-assembly-plugin diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/AuditTrailServiceTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/AuditTrailServiceTest.java index 4980e4764..fd666d12b 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/AuditTrailServiceTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/AuditTrailServiceTest.java @@ -38,7 +38,6 @@ import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.service.contributor.ContributorMediator; import org.bitrepository.settings.repositorysettings.Collection; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -49,14 +48,19 @@ import java.math.BigInteger; import java.util.concurrent.ThreadFactory; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class AuditTrailServiceTest extends ExtendedTestCase { - /** - * The settings for the tests. Should be instantiated in the setup. - */ +public class AuditTrailServiceTest { + /** The settings for the tests. Should be instantiated in the setup. */ Settings settings; public static final String TEST_COLLECTION = "dummy-collection"; diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/AuditCollectorTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/AuditCollectorTest.java index af644c295..e372f4ccb 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/AuditCollectorTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/AuditCollectorTest.java @@ -33,20 +33,26 @@ import org.bitrepository.common.utils.SettingsUtils; import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.settings.repositorysettings.Collection; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.mockito.ArgumentCaptor; import javax.xml.datatype.DatatypeFactory; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class AuditCollectorTest extends ExtendedTestCase { - /** - * The settings for the tests. Should be instantiated in the setup. - */ +public class AuditCollectorTest { + /** The settings for the tests. Should be instantiated in the setup.*/ Settings settings; public static final String TEST_COLLECTION = "dummy-collection"; @@ -81,8 +87,8 @@ public void auditCollectorIntervalTest() throws Exception { ArgumentCaptor eventHandlerCaptor = ArgumentCaptor.forClass(EventHandler.class); verify(client, timeout(3000).times(1)).getAuditTrails(eq(TEST_COLLECTION), any(AuditTrailQuery[].class), isNull(), isNull(), eventHandlerCaptor.capture(), any(String.class)); - EventHandler eventHandler = eventHandlerCaptor.getValue(); - + EventHandler eventHandler = eventHandlerCaptor.getValue(); + Assertions.assertNotNull(eventHandler, "Should have an event handler"); eventHandler.handleEvent(new AuditTrailResult(DEFAULT_CONTRIBUTOR, TEST_COLLECTION, new ResultingAuditTrails(), false)); @@ -95,7 +101,7 @@ public void auditCollectorIntervalTest() throws Exception { eventHandler.handleEvent(new AuditTrailResult(DEFAULT_CONTRIBUTOR, TEST_COLLECTION, new ResultingAuditTrails(), false)); eventHandler.handleEvent(new CompleteEvent(TEST_COLLECTION, null)); - + collector.close(); } } diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/IncrementalCollectorTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/IncrementalCollectorTest.java index 4b7803d62..cd3392663 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/IncrementalCollectorTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/collector/IncrementalCollectorTest.java @@ -25,7 +25,12 @@ import org.bitrepository.access.getaudittrails.AuditTrailQuery; import org.bitrepository.access.getaudittrails.client.AuditTrailResult; import org.bitrepository.audittrails.store.AuditTrailStore; -import org.bitrepository.bitrepositoryelements.*; +import org.bitrepository.bitrepositoryelements.Alarm; +import org.bitrepository.bitrepositoryelements.AuditTrailEvent; +import org.bitrepository.bitrepositoryelements.AuditTrailEvents; +import org.bitrepository.bitrepositoryelements.FileAction; +import org.bitrepository.bitrepositoryelements.ResponseCode; +import org.bitrepository.bitrepositoryelements.ResultingAuditTrails; import org.bitrepository.client.eventhandler.CompleteEvent; import org.bitrepository.client.eventhandler.ContributorFailedEvent; import org.bitrepository.client.eventhandler.EventHandler; @@ -33,8 +38,11 @@ import org.bitrepository.common.DefaultThreadFactory; import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.service.AlarmDispatcher; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.mockito.ArgumentCaptor; import javax.xml.datatype.XMLGregorianCalendar; @@ -43,12 +51,21 @@ import java.util.Collection; import java.util.Date; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.ArgumentMatchers.isNull; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.timeout; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class IncrementalCollectorTest extends ExtendedTestCase { - +public class IncrementalCollectorTest{ + public static final String TEST_COLLECTION = "dummy-collection"; public static final String TEST_CONTRIBUTOR1 = "Contributor1"; public static final String TEST_CONTRIBUTOR2 = "Contributor2"; @@ -67,7 +84,7 @@ public void singleIncrementTest() throws InterruptedException { AuditTrailStore store = mock(AuditTrailStore.class); AlarmDispatcher alarmDispatcher = mock(AlarmDispatcher.class); - + addStep("Start a collection with two contributors", "A call should be made to the store to find out which " + "sequence number to continue from"); @@ -82,31 +99,31 @@ public void singleIncrementTest() throws InterruptedException { verify(client, timeout(3000).times(1)).getAuditTrails(eq(TEST_COLLECTION), any(AuditTrailQuery[].class), isNull(), isNull(), eventHandlerCaptor.capture(), any(String.class)); verify(store, timeout(3000).times(contributors.size())) - .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); + .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); addStep("Send a audit trail result from contributor 1", "A AddAuditTrails call should be made to the store"); EventHandler eventHandler = eventHandlerCaptor.getValue(); - eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR1, TEST_COLLECTION, + eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR1, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR1, new BigInteger("1")), false)); addStep("Send a audit trail result from contributor 2", "A AddAuditTrails call should be made to the " + "store, and the collector should finish"); - eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, + eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR2, new BigInteger("1")), false)); eventHandler.handleEvent(new CompleteEvent(TEST_COLLECTION, null)); verify(store, timeout(3000).times(contributors.size())) - .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); - + .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); + Thread.sleep(100); verify(store, timeout(3000).times(1)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR1)); + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR1)); verify(store, timeout(3000).times(1)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); - + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); + Assertions.assertTrue(collectionRunner.finished, "The collector should have finished after the complete event, as " + - "no partialResults where received"); + "no partialResults where received"); verifyNoMoreInteractions(store); verifyNoMoreInteractions(client); verifyNoInteractions(alarmDispatcher); @@ -116,30 +133,29 @@ public void singleIncrementTest() throws InterruptedException { @Tag("regressiontest") public void multipleIncrementTest() throws Exception { addDescription("Verifies the behaviour in the case where the adit trails needs to be reteived in multiple " + - "requests because of MaxNumberOfResults limits."); + "requests because of MaxNumberOfResults limits."); AuditTrailClient client = mock(AuditTrailClient.class); AuditTrailStore store = mock(AuditTrailStore.class); long callsToLargestSequenceNumber = 0L; when(store.largestSequenceNumber(any(String.class), eq(TEST_COLLECTION))) - .thenReturn(callsToLargestSequenceNumber++); - + .thenReturn(callsToLargestSequenceNumber++); + AlarmDispatcher alarmDispatcher = mock(AlarmDispatcher.class); addStep("Start a collection with two contributors", "A call should be made to the store to find out which " + "sequence number to continue from"); - IncrementalCollector collector = - new IncrementalCollector("dummy-collection", "Client1", client, store, - 1, alarmDispatcher); + IncrementalCollector collector = new IncrementalCollector("dummy-collection", "Client1", client, store, + 1, alarmDispatcher); Collection contributors = Arrays.asList(TEST_CONTRIBUTOR1, TEST_CONTRIBUTOR2); CollectionRunner collectionRunner = new CollectionRunner(collector, contributors); Thread t = threadFactory.newThread(collectionRunner); t.start(); verify(store, timeout(3000).times(contributors.size())) - .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); - + .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); + ArgumentCaptor eventHandlerCaptor = ArgumentCaptor.forClass(EventHandler.class); verify(client, timeout(3000).times(1)).getAuditTrails(eq(TEST_COLLECTION), any(AuditTrailQuery[].class), isNull(), isNull(), eventHandlerCaptor.capture(), any(String.class)); @@ -149,37 +165,37 @@ public void multipleIncrementTest() throws Exception { "Two AddAuditTrails calls should be made, but the collector should not have finished"); eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR1, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR1, new BigInteger("1")), true)); - eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, + eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR2, new BigInteger("1")), true)); eventHandler.handleEvent(new CompleteEvent(TEST_COLLECTION, null)); - + verify(store, timeout(3000).times(1)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR1)); + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR1)); verify(store, timeout(3000).times(1)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); Assertions.assertFalse(collectionRunner.finished, "The collector should not have finished after the complete " + "event, as partialResults where received"); addStep("Send another audit trail result from the contributors, now with PartialResults set to false", - "Two more AddAuditTrails calls should be made and the collector should finished"); - + "Two more AddAuditTrails calls should be made and the collector should finished"); + verify(store, timeout(3000).times(contributors.size() * 2)) - .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); - + .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); + verify(client, timeout(3000).times(2)).getAuditTrails(eq(TEST_COLLECTION), any(AuditTrailQuery[].class), isNull(), isNull(), eventHandlerCaptor.capture(), any(String.class)); eventHandler = eventHandlerCaptor.getValue(); - eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR1, TEST_COLLECTION, + eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR1, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR1, new BigInteger("2")), false)); - eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, + eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR2, new BigInteger("2")), false)); eventHandler.handleEvent(new CompleteEvent(TEST_COLLECTION, null)); verify(store, timeout(3000).times(2)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR1)); + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR1)); verify(store, timeout(3000).times(2)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); Thread.sleep(100); Assertions.assertTrue(collectionRunner.finished, @@ -195,7 +211,7 @@ public void multipleIncrementTest() throws Exception { @Tag("regressiontest") public void contributorFailureTest() throws Exception { addDescription("Tests that the collector is able to collect from the remaining contributors if a " + - "contributor fails."); + "contributor fails."); addStep("", ""); AuditTrailClient client = mock(AuditTrailClient.class); @@ -203,8 +219,8 @@ public void contributorFailureTest() throws Exception { long callsToLargestSequenceNumber = 0L; when(store.largestSequenceNumber(any(String.class), eq(TEST_COLLECTION))) - .thenReturn(callsToLargestSequenceNumber++); - + .thenReturn(callsToLargestSequenceNumber++); + AlarmDispatcher alarmDispatcher = mock(AlarmDispatcher.class); addStep("Start a collection with two contributors", @@ -223,22 +239,22 @@ public void contributorFailureTest() throws Exception { isNull(), isNull(), eventHandlerCaptor.capture(), any(String.class)); verify(store, timeout(3000).times(contributors.size())) - .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); - + .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); + addStep("Send a audit trail result from contributor 2 with the PartialResults boolean set to true " + "and a failed event from contributor 1", "Only one AddAuditTrails calls should be made, and the collector should not have finished"); EventHandler eventHandler = eventHandlerCaptor.getValue(); eventHandler.handleEvent(new ContributorFailedEvent(TEST_CONTRIBUTOR1, TEST_COLLECTION, ResponseCode.REQUEST_NOT_SUPPORTED)); - eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, + eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR2, new BigInteger("1")), true)); - + verify(store, timeout(3000).times(1)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); - + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); + eventHandler.handleEvent(new OperationFailedEvent(TEST_COLLECTION, "", null)); Assertions.assertFalse(collectionRunner.finished, "The collector should not have finished after the complete " + - "event, as partialResults where received"); + "event, as partialResults where received"); addStep("Send another audit trail result from contributor 2 with PartialResults set to false", "One more AddAuditTrails calls should be made and the collector should finished"); @@ -247,16 +263,16 @@ public void contributorFailureTest() throws Exception { eventHandler = eventHandlerCaptor.getValue(); verify(store, timeout(3000).times(contributors.size() + 1)) - .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); - - eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, + .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); + + eventHandler.handleEvent(new AuditTrailResult(TEST_CONTRIBUTOR2, TEST_COLLECTION, getResultingAuditTrailsWithSingleAudit(TEST_CONTRIBUTOR2, new BigInteger("2")), false)); eventHandler.handleEvent(new CompleteEvent(TEST_COLLECTION, null)); verify(store, timeout(3000).times(2)) - .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); + .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); verify(alarmDispatcher, timeout(3000)).error(any(Alarm.class)); - + Thread.sleep(100); Assertions.assertTrue(collectionRunner.finished); verifyNoMoreInteractions(store); @@ -275,8 +291,8 @@ public void collectionIDFailureTest() throws Exception { long callsToLargestSequenceNumber = 0L; when(store.largestSequenceNumber(any(String.class), eq(TEST_COLLECTION))) - .thenReturn(callsToLargestSequenceNumber++); - + .thenReturn(callsToLargestSequenceNumber++); + AlarmDispatcher alarmDispatcher = mock(AlarmDispatcher.class); addStep("Start a collection with two contributors", @@ -302,8 +318,8 @@ public void collectionIDFailureTest() throws Exception { true)); verify(store, timeout(3000).times(contributors.size())) - .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); - + .largestSequenceNumber(any(String.class), eq(TEST_COLLECTION)); + Thread.sleep(100); verifyNoInteractions(alarmDispatcher); verifyNoMoreInteractions(store); diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPackerTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPackerTest.java index d7c4d1bcc..9ca66c6e3 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPackerTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPackerTest.java @@ -5,7 +5,6 @@ import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.common.utils.SettingsUtils; import org.bitrepository.settings.referencesettings.AuditTrailPreservation; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -17,14 +16,16 @@ import java.util.List; import java.util.Map; +import static org.mockito.Mockito.mock; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) -class AuditPackerTest extends ExtendedTestCase { +public class AuditPackerTest { private String collectionID; private AuditTrailPreservation preservationSettings; private AuditTrailStore store; @BeforeAll - void setup() { + public void setup() { Settings settings = TestSettingsProvider.reloadSettings("LocalAuditPreservationUnderTest"); preservationSettings = settings.getReferenceSettings().getAuditTrailServiceSettings().getAuditTrailPreservation(); @@ -34,7 +35,7 @@ void setup() { } @Test - void testCreateNewPackage() throws IOException { + public void testCreateNewPackage() throws IOException { AuditPacker packer = new AuditPacker(store, preservationSettings, collectionID); Map seqNumsReached = packer.getSequenceNumbersReached(); Assertions.assertEquals(3, seqNumsReached.size()); diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPreservationEventHandlerTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPreservationEventHandlerTest.java index 7903455ff..a3fce743c 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPreservationEventHandlerTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/AuditPreservationEventHandlerTest.java @@ -23,13 +23,14 @@ import org.bitrepository.audittrails.store.AuditTrailStore; import org.bitrepository.client.eventhandler.CompleteEvent; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.HashMap; import java.util.Map; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.mockito.ArgumentMatchers.anyLong; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; @@ -37,7 +38,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -public class AuditPreservationEventHandlerTest extends ExtendedTestCase { +public class AuditPreservationEventHandlerTest { String PILLARID = "pillarID"; public static final String TEST_COLLECTION = "dummy-collection"; diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/LocalAuditPreservationTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/LocalAuditPreservationTest.java index a22207639..4db98e547 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/LocalAuditPreservationTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/preserver/LocalAuditPreservationTest.java @@ -34,7 +34,6 @@ import org.bitrepository.modify.putfile.PutFileClient; import org.bitrepository.protocol.FileExchange; import org.bitrepository.settings.repositorysettings.Collection; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.*; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; @@ -46,8 +45,11 @@ import java.io.FileInputStream; import java.net.URL; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class LocalAuditPreservationTest extends ExtendedTestCase { +public class LocalAuditPreservationTest { /** * The settings for the tests. Should be instantiated in the setup. */ @@ -72,7 +74,6 @@ public void setup() throws Exception { } - @Disabled("Temporarily disabled due to performance issues") @Test // Fragile test, fails occasionally. @SuppressWarnings("rawtypes") diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditDatabaseTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditDatabaseTest.java index 8fb76c1d1..c72c4fccc 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditDatabaseTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditDatabaseTest.java @@ -29,12 +29,10 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.service.database.DatabaseManager; import org.bitrepository.service.database.DerbyDatabaseDestroyer; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; - import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigInteger; import java.text.ParseException; @@ -44,10 +42,11 @@ import java.util.List; import java.util.Locale; -public class AuditDatabaseTest extends ExtendedTestCase { - /** - * The settings for the tests. Should be instantiated in the setup. - */ +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class AuditDatabaseTest { + /** The settings for the tests. Should be instantiated in the setup.*/ Settings settings; String fileID = "TEST-FILE-ID-" + new Date().getTime(); String fileID2 = "ANOTHER-FILE-ID" + new Date().getTime(); @@ -60,7 +59,6 @@ public class AuditDatabaseTest extends ExtendedTestCase { static final String fingerprint2 = "baba"; static final String operationID2 = "4321"; - @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("AuditDatabaseUnderTest"); @@ -73,7 +71,6 @@ public void setup() throws Exception { collectionID = settings.getCollections().get(0).getID(); } - @Test @Tag("regressiontest") @Tag("databasetest") @@ -437,7 +434,8 @@ public void AuditDatabaseGoodIngestTest() throws Exception { database.addAuditTrails(events, collectionID, pillarID); - + + } private AuditTrailEvents createEvents() { diff --git a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditServiceDatabaseMigrationTest.java b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditServiceDatabaseMigrationTest.java index 770892996..1e8b2f783 100644 --- a/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditServiceDatabaseMigrationTest.java +++ b/bitrepository-audit-trail-service/src/test/java/org/bitrepository/audittrails/store/AuditServiceDatabaseMigrationTest.java @@ -28,19 +28,17 @@ import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.AfterEach; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; import java.io.File; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + // TODO: cannot test migration of version 1 to 2, since it requires a collection id. // Therefore this is only tested with version 2 of the database. -public class AuditServiceDatabaseMigrationTest extends ExtendedTestCase { +public class AuditServiceDatabaseMigrationTest { protected Settings settings; static final String PATH_TO_DATABASE_UNPACKED = "target/test/audits/auditservicedb-v2"; diff --git a/bitrepository-client/pom.xml b/bitrepository-client/pom.xml index b8a876d54..1f2ce58fc 100644 --- a/bitrepository-client/pom.xml +++ b/bitrepository-client/pom.xml @@ -39,6 +39,15 @@ + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.basedir}/allure-results + ${project.basedir}/allure-report + + maven-assembly-plugin diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/MessageSenderStub.java b/bitrepository-client/src/test/java/org/bitrepository/access/MessageSenderStub.java index 66cb2483f..287d36a8b 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/MessageSenderStub.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/MessageSenderStub.java @@ -23,31 +23,38 @@ import org.bitrepository.bitrepositorymessages.Message; import org.bitrepository.protocol.messagebus.MessageSender; -import org.jaccept.TestEventManager; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.isTestRunning; + public class MessageSenderStub implements MessageSender { /** The TestEventManager used to manage the event for the associated test. */ - private final TestEventManager testEventManager; + /** The queue used to store the received messages. */ private final BlockingQueue messageQueue = new LinkedBlockingQueue<>(); /** The default time to wait for messages */ private static final long DEFAULT_WAIT_SECONDS = 10; - public MessageSenderStub(TestEventManager testEventManager) { - this.testEventManager = testEventManager; + public MessageSenderStub() { + } - + @Override public void sendMessage(Message content) { - testEventManager.addStimuli("Sent message: " + content); - messageQueue.add(content); + if (isTestRunning()) { + io.qameta.allure.Allure.step("Sent message: " + content.getClass().getSimpleName(), () -> { + io.qameta.allure.Allure.addAttachment("Message Content", content.toString()); + messageQueue.add(content); + }); + } else { + messageQueue.add(content); + } } - + public void clearMessages() { messageQueue.clear(); } diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientComponentTest.java index b01e1dade..ae378a0f6 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientComponentTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.access.getaudittrails; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.access.AccessComponentFactory; import org.bitrepository.access.getaudittrails.client.AuditTrailResult; import org.bitrepository.bitrepositoryelements.*; @@ -31,18 +32,20 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.protocol.bus.MessageReceiver; import org.bitrepository.settings.repositorysettings.Collection; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.math.BigInteger; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Test the default AuditTrailClient. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class AuditTrailClientComponentTest extends DefaultClientTest { private GetAuditTrailsMessageFactory testMessageFactory; private DatatypeFactory datatypeFactory; @@ -67,21 +70,23 @@ public void beforeMethodSetup() throws DatatypeConfigurationException { @Test @Tag("regressiontest") + @DisplayName("Tests that the AuditTrailClient can be created from the AccessComponentFactory.") public void verifyAuditTrailClientFromFactory() { Assertions.assertInstanceOf(ConversationBasedAuditTrailClient.class, AccessComponentFactory.getInstance().createAuditTrailClient( - settingsForCUT, securityManager, settingsForTestClient.getComponentID()), - "The default AuditTrailClient from the Access factory should be of the type '" + + settingsForCUT, securityManager, settingsForTestClient.getComponentID()), "The default " + + "AuditTrailClient from the Access factory should be of the type '" + ConversationBasedAuditTrailClient.class.getName() + "'."); } @Test @Tag("regressiontest") + @DisplayName("Tests that the AuditTrailClient can be created from the AccessComponentFactory.") public void getAllAuditTrailsTest() throws InterruptedException { addDescription("Tests the simplest case of getting all audit trail event for all contributors."); addStep("Create a AuditTrailClient.", ""); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); AuditTrailClient client = createAuditTrailClient(); addStep("Retrieve all audit trails from the collection by calling with a null componentQueries array", @@ -170,7 +175,7 @@ public void getAllAuditTrailsTest() throws InterruptedException { public void getSomeAuditTrailsTest() throws InterruptedException { addDescription("Tests the client maps a AuditTrail query correctly to a GetAuditTrail request."); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); AuditTrailClient client = createAuditTrailClient(); addStep("Request audit trails from pillar 1 with both min and max sequence number set.", @@ -232,7 +237,7 @@ public void negativeGetAuditTrailsResponseTest() throws InterruptedException { "GetAuditTrails response from one contributors."); addStep("Create a AuditTrailClient.", ""); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); AuditTrailClient client = createAuditTrailClient(); addStep("Retrieve all audit trails from the collection by calling with a null componentQueries array", @@ -307,7 +312,7 @@ public void progressEventsTest() throws InterruptedException { addDescription("Tests that progress events are handled correctly."); addStep("Create a AuditTrailClient.", ""); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); AuditTrailClient client = createAuditTrailClient(); addStep("Retrieve all audit trails from the collection by calling with a null componentQueries array", @@ -379,9 +384,8 @@ public void incompleteSetOfFinalResponsesTest() throws Exception { addStep("Configure 500 ms second timeout for the operation itself. " + "The default 2 contributors collection is used", ""); - settingsForCUT.getRepositorySettings().getClientSettings() - .setOperationTimeoutDuration(datatypeFactory.newDuration(500)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + settingsForCUT.getRepositorySettings().getClientSettings().setOperationTimeoutDuration(datatypeFactory.newDuration(500)); + TestEventHandler testEventHandler = new TestEventHandler(); AuditTrailClient client = createAuditTrailClient(); client.getAuditTrails(collectionID, null, null, null, testEventHandler, null); @@ -428,7 +432,7 @@ public void noFinalResponsesTest() throws Exception { addStep("Make the client ask for all audit trails.", "It should send a identify message"); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); client.getAuditTrails(collectionID, null, null, null, testEventHandler, null); IdentifyContributorsForGetAuditTrailsRequest identifyRequest = collectionReceiver.waitForMessage(IdentifyContributorsForGetAuditTrailsRequest.class); @@ -472,8 +476,7 @@ public void noFinalResponsesTest() throws Exception { */ private AuditTrailClient createAuditTrailClient() { return new AuditTrailClientTestWrapper(new ConversationBasedAuditTrailClient( - settingsForCUT, conversationMediator, messageBus, settingsForTestClient.getComponentID()), - testEventManager); + settingsForCUT, conversationMediator, messageBus, settingsForTestClient.getComponentID())); } private ResultingAuditTrails createTestResultingAuditTrails(String componentID) { diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientTestWrapper.java index cfe94ba35..e3d222683 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailClientTestWrapper.java @@ -22,29 +22,37 @@ package org.bitrepository.access.getaudittrails; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; import java.util.Arrays; public class AuditTrailClientTestWrapper implements AuditTrailClient { - private final AuditTrailClient auditTrailClient; - private final TestEventManager testEventManager; + private AuditTrailClient auditTrailClient; - - public AuditTrailClientTestWrapper(AuditTrailClient auditTrailClient, - TestEventManager testEventManager) { + public AuditTrailClientTestWrapper(AuditTrailClient auditTrailClient) { this.auditTrailClient = auditTrailClient; - this.testEventManager = testEventManager; + } @Override public void getAuditTrails(String collectionID, AuditTrailQuery[] componentQueries, String fileID, String urlForResult, - EventHandler eventHandler, String auditTrailInformation) { - testEventManager.addStimuli( - "Calling getAuditTrails(" + - (componentQueries == null ? "null" : Arrays.asList(componentQueries)) + - ", " + fileID + ", " + urlForResult + ")"); - auditTrailClient.getAuditTrails(collectionID, componentQueries, fileID, urlForResult, eventHandler, - auditTrailInformation); + EventHandler eventHandler, String auditTrailInformation) { + if (io.qameta.allure.Allure.getLifecycle().getCurrentTestCase().isPresent()) { + String stepName = "Calling getAuditTrails for: " + (fileID != null ? fileID : "all files"); + + StringBuilder details = new StringBuilder(); + details.append("Collection: ").append(collectionID).append("\n") + .append("Component Queries: ").append(componentQueries == null ? "null" : Arrays.asList(componentQueries)).append("\n") + .append("URL for Result: ").append(urlForResult).append("\n") + .append("Audit Info: ").append(auditTrailInformation); + + io.qameta.allure.Allure.step(stepName, () -> { + io.qameta.allure.Allure.addAttachment("AuditTrails Request Parameters", details.toString()); + auditTrailClient.getAuditTrails(collectionID, componentQueries, fileID, urlForResult, eventHandler, + auditTrailInformation); + }); + } else { + auditTrailClient.getAuditTrails(collectionID, componentQueries, fileID, urlForResult, eventHandler, + auditTrailInformation); + } } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailQueryTest.java b/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailQueryTest.java index 9fed69750..66d2395f0 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailQueryTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getaudittrails/AuditTrailQueryTest.java @@ -21,16 +21,16 @@ */ package org.bitrepository.access.getaudittrails; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; -public class AuditTrailQueryTest extends ExtendedTestCase { +public class AuditTrailQueryTest { private static final int DEFAULT_MAX_NUMBER_OF_RESULTS = 10000; String componentId = "componentId"; diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientComponentTest.java index bda35f318..c362153e7 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientComponentTest.java @@ -39,6 +39,7 @@ */ package org.bitrepository.access.getchecksums; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.access.AccessComponentFactory; import org.bitrepository.access.ContributorQuery; import org.bitrepository.bitrepositoryelements.*; @@ -52,6 +53,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.math.BigInteger; import java.net.URL; @@ -59,9 +61,12 @@ import java.util.Date; import java.util.LinkedList; +import static org.bitrepository.common.utils.AllureTestUtils.*; + /** * Test class for the 'GetFileClient'. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class GetChecksumsClientComponentTest extends DefaultClientTest { private TestGetChecksumsMessageFactory messageFactory; @@ -93,7 +98,7 @@ public void verifyGetChecksumsClientFromFactory() throws Exception { public void getChecksumsFromSinglePillar() throws Exception { addDescription("Tests that the client can retrieve checksums from a single pillar."); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetChecksumsClient getChecksumsClient = createGetChecksumsClient(); addStep("Request the delivery of the checksum of a file from pillar1.", @@ -165,7 +170,7 @@ public void getChecksumsDeliveredAtUrl() throws Exception { String deliveryFilename = "TEST-CHECKSUM-DELIVERY.xml"; - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetChecksumsClient getChecksumsClient = createGetChecksumsClient(); addStep("Ensure the delivery file isn't already present on the http server", @@ -241,7 +246,7 @@ public void testNoSuchFile() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID() .add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetChecksumsClient getChecksumsClient = createGetChecksumsClient(); addStep("Request the delivery of the checksum of a file from the pillar(s). A callback listener should be " + @@ -301,7 +306,6 @@ public void testNoSuchFile() throws Exception { @Tag("regressiontest") public void testPaging() throws Exception { addDescription("Tests the GetChecksums client correctly handles functionality for limiting results, either by" + - " " + "timestamp or result count."); GetChecksumsClient getChecksumsClient = createGetChecksumsClient(); @@ -319,8 +323,7 @@ public void testPaging() throws Exception { IdentifyPillarsForGetChecksumsRequest.class); addStep("Send a IdentifyPillarsForGetChecksumsResponse from both pillars.", - "A GetChecksumsRequest should be sent to both pillars with the appropriate MinTimestamp, " + - "MaxTimestamp, " + + "A GetChecksumsRequest should be sent to both pillars with the appropriate MinTimestamp, MaxTimestamp, " + "MaxNumberOfResults values."); messageBus.sendMessage(messageFactory.createIdentifyPillarsForGetChecksumsResponse( receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId)); @@ -367,7 +370,7 @@ public void getChecksumsFromOtherCollection() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getPillarIDs().getPillarID() .add(PILLAR2_ID); String otherCollection = settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getID(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetChecksumsClient client = createGetChecksumsClient(); addStep("Request the putting of a file through the PutClient for collection2", @@ -416,8 +419,7 @@ public void getChecksumsFromOtherCollection() throws Exception { */ private GetChecksumsClient createGetChecksumsClient() { return new GetChecksumsClientTestWrapper(new ConversationBasedGetChecksumsClient( - messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID()), - testEventManager); + messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID())); } diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientTestWrapper.java index b474699a2..bd3257c46 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getchecksums/GetChecksumsClientTestWrapper.java @@ -24,10 +24,11 @@ */ package org.bitrepository.access.getchecksums; +import io.qameta.allure.Allure; import org.bitrepository.access.ContributorQuery; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; + import java.net.URL; import java.util.Arrays; @@ -36,26 +37,31 @@ * Wraps the GetFileClient adding test event logging and functionality for handling blocking calls. */ public class GetChecksumsClientTestWrapper implements GetChecksumsClient { - private final GetChecksumsClient getChecksumsClientInstance; - private final TestEventManager testEventManager; + private GetChecksumsClient getChecksumsClientInstance; - public GetChecksumsClientTestWrapper(GetChecksumsClient createGetChecksumsClient, - TestEventManager testEventManager) { + public GetChecksumsClientTestWrapper(GetChecksumsClient createGetChecksumsClient) { this.getChecksumsClientInstance = createGetChecksumsClient; - this.testEventManager = testEventManager; + } @Override public void getChecksums(String collectionID, ContributorQuery[] contributorQueries, String fileID, ChecksumSpecTYPE checksumSpec, - URL addressForResult, EventHandler eventHandler, String auditTrailInformation) { - testEventManager.addStimuli("Calling getChecksums(" + - (contributorQueries == null ? "null" : Arrays.asList(contributorQueries)) + - ", " + fileID - + ", " + checksumSpec + ", " + addressForResult + ", " + eventHandler + ", " - + auditTrailInformation + ")"); - getChecksumsClientInstance.getChecksums(collectionID, contributorQueries, fileID, checksumSpec, - addressForResult, - eventHandler, auditTrailInformation); + URL addressForResult, EventHandler eventHandler, String auditTrailInformation) { + String stepName = "Calling getChecksums for: " + (fileID != null ? fileID : "all files"); + + StringBuilder details = new StringBuilder(); + details.append("Collection: ").append(collectionID).append("\n") + .append("Contributor Queries: ").append(contributorQueries == null ? "null" : Arrays.asList(contributorQueries)).append("\n") + .append("Checksum Spec: ").append(checksumSpec).append("\n") + .append("Address for Result: ").append(addressForResult).append("\n") + .append("Audit Info: ").append(auditTrailInformation); + + Allure.step(stepName, () -> { + Allure.addAttachment("GetChecksums Request Parameters", details.toString()); + getChecksumsClientInstance.getChecksums(collectionID, contributorQueries, fileID, checksumSpec, + addressForResult, + eventHandler, auditTrailInformation); + }); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientComponentTest.java index 3dd075443..6e03b0a31 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientComponentTest.java @@ -24,6 +24,7 @@ */ package org.bitrepository.access.getfile; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.access.AccessComponentFactory; import org.bitrepository.bitrepositoryelements.FilePart; import org.bitrepository.bitrepositoryelements.ResponseCode; @@ -38,6 +39,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; @@ -45,10 +47,12 @@ import java.net.URL; import static javax.xml.datatype.DatatypeFactory.newInstance; +import static org.bitrepository.common.utils.AllureTestUtils.*; /** * Test class for the 'GetFileClient'. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class GetFileClientComponentTest extends AbstractGetFileClientTest { private static final FilePart NO_FILE_PART = null; @@ -63,9 +67,11 @@ public void setUpFactory() throws DatatypeConfigurationException { @Test @Tag("regressiontest") public void verifyGetFileClientFromFactory() { - Assertions.assertInstanceOf(ConversationBasedGetFileClient.class, AccessComponentFactory.getInstance().createGetFileClient( - settingsForCUT, securityManager, settingsForTestClient.getComponentID()), "The default GetFileClient from the Access factory should be of the type '" + - ConversationBasedGetFileClient.class.getName() + "'."); + Assertions.assertInstanceOf(ConversationBasedGetFileClient.class, + AccessComponentFactory.getInstance().createGetFileClient( + settingsForCUT, securityManager, settingsForTestClient.getComponentID()), + "The default GetFileClient from the Access factory should be of the type '" + + ConversationBasedGetFileClient.class.getName() + "'."); } @Test @@ -73,13 +79,14 @@ public void verifyGetFileClientFromFactory() { public void getFileFromSpecificPillar() throws Exception { addDescription("Tests that the GetClient client works correctly when requesting a file from a specific pillar"); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetFileClient client = createGetFileClient(); addStep("Request the delivery of a file from pillar2.", "A IdentifyPillarsForGetFileRequest will be sent to the pillar with all the correct parameters."); String auditTrailInformation = "AuditTrailInfo for getFileFromSpecificPillarTest"; - client.getFileFromSpecificPillar(collectionID, DEFAULT_FILE_ID, null, httpServerConfiguration.getURL(DEFAULT_FILE_ID), + client.getFileFromSpecificPillar(collectionID, DEFAULT_FILE_ID, null, + httpServerConfiguration.getURL(DEFAULT_FILE_ID), PILLAR2_ID, testEventHandler, auditTrailInformation); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); @@ -88,8 +95,10 @@ public void getFileFromSpecificPillar() throws Exception { Assertions.assertEquals(settingsForCUT.getReceiverDestinationID(), receivedIdentifyRequestMessage.getReplyTo()); Assertions.assertEquals(DEFAULT_FILE_ID, receivedIdentifyRequestMessage.getFileID()); Assertions.assertEquals(settingsForTestClient.getComponentID(), receivedIdentifyRequestMessage.getFrom()); - Assertions.assertEquals(settingsForTestClient.getCollectionDestination(), receivedIdentifyRequestMessage.getDestination()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(settingsForTestClient.getCollectionDestination(), + receivedIdentifyRequestMessage.getDestination()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a response from pillar1", "Should be ignored, eg. nothing should happen"); IdentifyPillarsForGetFileResponse identifyResponse1 = messageFactory.createIdentifyPillarsForGetFileResponse( @@ -105,9 +114,11 @@ public void getFileFromSpecificPillar() throws Exception { receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId); messageBus.sendMessage(identifyResponse2); ContributorEvent componentIdentifiedEvent2 = (ContributorEvent) testEventHandler.waitForEvent(); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, componentIdentifiedEvent2.getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + componentIdentifiedEvent2.getEventType()); Assertions.assertEquals(PILLAR2_ID, componentIdentifiedEvent2.getContributorID()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); GetFileRequest receivedGetFileRequest = pillar2Receiver.waitForMessage(GetFileRequest.class); Assertions.assertEquals(collectionID, receivedGetFileRequest.getCollectionID()); @@ -117,7 +128,8 @@ public void getFileFromSpecificPillar() throws Exception { Assertions.assertEquals(auditTrailInformation, receivedGetFileRequest.getAuditTrailInformation()); Assertions.assertEquals(settingsForTestClient.getComponentID(), receivedGetFileRequest.getFrom()); Assertions.assertEquals(pillar2DestinationId, receivedGetFileRequest.getDestination()); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a GetFileProgressResponse.", "The client should generating a PROGRESS event."); @@ -135,9 +147,11 @@ public void getFileFromSpecificPillar() throws Exception { receivedGetFileRequest, PILLAR2_ID, pillar2DestinationId); messageBus.sendMessage(completeMsg); ContributorEvent componentCompleteEvent2 = (ContributorEvent) testEventHandler.waitForEvent(); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, componentCompleteEvent2.getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + componentCompleteEvent2.getEventType()); Assertions.assertEquals(PILLAR2_ID, componentCompleteEvent2.getContributorID()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -154,7 +168,7 @@ public void getFileFromSpecificPillarWithFilePart() throws Exception { filePart.setPartLength(BigInteger.TEN); filePart.setPartOffSet(BigInteger.ONE); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetFileClient client = createGetFileClient(); String chosenPillar = settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().get(0); @@ -165,7 +179,8 @@ public void getFileFromSpecificPillarWithFilePart() throws Exception { chosenPillar, testEventHandler, null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("The pillar sends a response to the identify message.", "The callback listener should notify of the response and the client should send a GetFileRequest message to " + @@ -179,8 +194,10 @@ public void getFileFromSpecificPillarWithFilePart() throws Exception { for (int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); } - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("The pillar sends a getFile response to the GetClient.", "The GetClient should notify about the response through the callback interface."); @@ -188,7 +205,8 @@ public void getFileFromSpecificPillarWithFilePart() throws Exception { receivedGetFileRequest, chosenPillar, pillar1DestinationId); messageBus.sendMessage(getFileProgressResponse); - Assertions.assertEquals(OperationEvent.OperationEventType.PROGRESS, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.PROGRESS, + testEventHandler.waitForEvent().getEventType()); addStep("The file is uploaded to the indicated url and the pillar sends a final response upload message", "The GetFileClient notifies that the file is ready through the callback listener and the uploaded " + @@ -198,8 +216,10 @@ public void getFileFromSpecificPillarWithFilePart() throws Exception { receivedGetFileRequest, chosenPillar, pillar1DestinationId); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -219,7 +239,7 @@ public void chooseFastestPillarGetFileClient() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(fastPillarID); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(slowPillarID); GetFileClient client = createGetFileClient(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); addStep("Defining the variables for the GetFileClient and defining them in the configuration", "It should be possible to change the values of the configurations."); @@ -231,7 +251,8 @@ public void chooseFastestPillarGetFileClient() throws Exception { testEventHandler, null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Three pillars send responses. First an average timeToDeliver, then a fast timeToDeliver and last a" + " slow timeToDeliver.", "The client should send a getFileRequest to the fast pillar. " + @@ -262,13 +283,17 @@ public void chooseFastestPillarGetFileClient() throws Exception { slowReply.setTimeToDeliver(slowTime); messageBus.sendMessage(slowReply); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); IdentificationCompleteEvent event = (IdentificationCompleteEvent) testEventHandler.waitForEvent(); Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, event.getEventType()); Assertions.assertEquals(fastPillarID, event.getContributorIDs().get(0)); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); pillar1Receiver.waitForMessage(GetFileRequest.class); } @@ -284,40 +309,49 @@ public void getFileClientWithIdentifyTimeout() throws Exception { addStep("Call getFile form fastest pillar.", "A IDENTIFY_REQUEST_SENT should be generate and an identification request should be sent."); GetFileClient client = createGetFileClient(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); client.getFileFromFastestPillar(collectionID, DEFAULT_FILE_ID, NO_FILE_PART, httpServerConfiguration.getURL(DEFAULT_FILE_ID), testEventHandler, null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send an identification response from pillar1.", "A COMPONENT_IDENTIFIED event should be generated."); - IdentifyPillarsForGetFileResponse identificationResponse1 = messageFactory.createIdentifyPillarsForGetFileResponse( - receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); + IdentifyPillarsForGetFileResponse identificationResponse1 = + messageFactory.createIdentifyPillarsForGetFileResponse( + receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(identificationResponse1); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); addStep("Wait 1 second.", "A IDENTIFY_TIMEOUT event should be generated, followed by an IDENTIFICATION_COMPLETE."); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); addStep("Verify that the client continues to the performing phase.", "A REQUEST_SENT event should be generated and a GetFileRequest should be sent to pillar1."); GetFileRequest getFileRequest = pillar1Receiver.waitForMessage(GetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a final response upload message", "A COMPONENT_COMPLETE event should be generated followed by at COMPLETE event."); GetFileFinalResponse completeMsg = messageFactory.createGetFileFinalResponse( getFileRequest, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, + testEventHandler.waitForEvent().getEventType()); } @@ -333,18 +367,23 @@ public void noIdentifyResponse() throws Exception { addStep("Make the GetClient ask for fastest pillar.", "It should send message to identify which pillar can respond fastest."); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); client.getFileFromFastestPillar(collectionID, DEFAULT_FILE_ID, NO_FILE_PART, httpServerConfiguration.getURL(DEFAULT_FILE_ID), testEventHandler, null); collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Wait for 1 seconds", "An IdentifyPillarTimeout event should be received followed by a FAILED event"); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -355,19 +394,20 @@ public void conversationTimeout() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); - DatatypeFactory factory = newInstance(); - settingsForCUT.getReferenceSettings().getClientSettings().setConversationTimeout(newInstance().newDuration(100)); + DatatypeFactory factory = DatatypeFactory.newInstance(); + settingsForCUT.getReferenceSettings().getClientSettings().setConversationTimeout(factory.newDuration(100)); GetFileClient client = createGetFileClient(); addStep("Request the delivery of a file from a specific pillar. A callback listener should be supplied.", "A IdentifyPillarsForGetFileRequest will be sent to the pillar."); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); client.getFileFromSpecificPillar(collectionID, DEFAULT_FILE_ID, NO_FILE_PART, httpServerConfiguration.getURL(DEFAULT_FILE_ID), PILLAR1_ID, testEventHandler, null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("The pillar sends a response to the identify message.", "The callback listener should notify of the response and the client should send a GetFileRequest message to " + @@ -379,12 +419,16 @@ public void conversationTimeout() throws Exception { messageBus.sendMessage(identifyResponse); pillar1Receiver.waitForMessage(GetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Wait for 1 second", "An failed event should be generated followed by a FAILED event"); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -395,7 +439,7 @@ public void testNoSuchFileSpecificPillar() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); String fileName = "ERROR-NO-SUCH-FILE-ERROR"; - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); URL url = httpServerConfiguration.getURL(DEFAULT_FILE_ID); addStep("Call getFileFromSpecificPillar.", @@ -406,7 +450,8 @@ public void testNoSuchFileSpecificPillar() throws Exception { null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("The specified pillars sends a FILE_NOT_FOUND response", "The client should generate 1 PillarIdentified event followed by an operation failed event."); @@ -417,8 +462,10 @@ public void testNoSuchFileSpecificPillar() throws Exception { receivedIdentifyRequestMessage.getFileID() + " not present on this pillar " + PILLAR1_ID); messageBus.sendMessage(pillar1Response); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -428,7 +475,7 @@ public void testNoSuchFileMultiplePillars() throws Exception { String fileName = "ERROR-NO-SUCH-FILE-ERROR"; GetFileClient client = createGetFileClient(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); URL url = httpServerConfiguration.getURL(DEFAULT_FILE_ID); addStep("Use the default 2 pillars.", ""); @@ -438,7 +485,8 @@ public void testNoSuchFileMultiplePillars() throws Exception { client.getFileFromFastestPillar(collectionID, fileName, NO_FILE_PART, url, testEventHandler, null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Both pillars sends a FILE_NOT_FOUND response", "The client should generate 2 PillarIdentified events followed by a Failed event."); @@ -457,9 +505,12 @@ public void testNoSuchFileMultiplePillars() throws Exception { receivedIdentifyRequestMessage.getFileID() + "not present on this pillar "); messageBus.sendMessage(pillar2Response); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -470,43 +521,51 @@ public void getFileClientWithChecksumPillarInvolved() throws Exception { addStep("Call getFile form fastest pillar.", "A IDENTIFY_REQUEST_SENT should be generate and an identification request should be sent."); GetFileClient client = createGetFileClient(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); client.getFileFromFastestPillar(collectionID, DEFAULT_FILE_ID, NO_FILE_PART, httpServerConfiguration.getURL(DEFAULT_FILE_ID), testEventHandler, null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send an identification response from pillar1 with a REQUEST_NOT_SUPPORTED response code.", "No events should be generated."); - IdentifyPillarsForGetFileResponse identificationResponse1 = messageFactory.createIdentifyPillarsForGetFileResponse( - receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); + IdentifyPillarsForGetFileResponse identificationResponse1 = + messageFactory.createIdentifyPillarsForGetFileResponse( + receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); identificationResponse1.getResponseInfo().setResponseCode(ResponseCode.REQUEST_NOT_SUPPORTED); messageBus.sendMessage(identificationResponse1); testEventHandler.verifyNoEventsAreReceived(); addStep("Send an identification response from pillar2 with an IDENTIFICATION_POSITIVE response code .", "A component COMPONENT_IDENTIFIED event should be generated followed by an IDENTIFICATION_COMPLETE."); - IdentifyPillarsForGetFileResponse identificationResponse2 = messageFactory.createIdentifyPillarsForGetFileResponse( - receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId); + IdentifyPillarsForGetFileResponse identificationResponse2 = + messageFactory.createIdentifyPillarsForGetFileResponse( + receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId); messageBus.sendMessage(identificationResponse2); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); addStep("Verify that the client continues to the performing phase.", "A REQUEST_SENT event should be generated and a GetFileRequest should be sent to pillar2."); GetFileRequest getFileRequest = pillar2Receiver.waitForMessage(GetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a final response upload message", "A COMPONENT_COMPLETE event should be generated followed by at COMPLETE event."); GetFileFinalResponse completeMsg = messageFactory.createGetFileFinalResponse( getFileRequest, PILLAR2_ID, pillar1DestinationId); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -518,43 +577,52 @@ public void singleComponentFailureDuringIdentify() throws Exception { addStep("Call getFile from the fastest pillar.", "A IDENTIFY_REQUEST_SENT should be generate and an identification request should be sent."); GetFileClient client = createGetFileClient(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); client.getFileFromFastestPillar(collectionID, DEFAULT_FILE_ID, NO_FILE_PART, httpServerConfiguration.getURL(DEFAULT_FILE_ID), testEventHandler, null); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send an identification response from pillar1 with an IDENTIFICATION_NEGATIVE response code .", "No events should be generated."); - IdentifyPillarsForGetFileResponse identificationResponse1 = messageFactory.createIdentifyPillarsForGetFileResponse( - receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); + IdentifyPillarsForGetFileResponse identificationResponse1 = + messageFactory.createIdentifyPillarsForGetFileResponse( + receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); identificationResponse1.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_NEGATIVE); messageBus.sendMessage(identificationResponse1); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); addStep("Send an identification response from pillar2 with an IDENTIFICATION_POSITIVE response code .", "A component COMPONENT_IDENTIFIED event should be generated followed by an IDENTIFICATION_COMPLETE."); - IdentifyPillarsForGetFileResponse identificationResponse2 = messageFactory.createIdentifyPillarsForGetFileResponse( - receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId); + IdentifyPillarsForGetFileResponse identificationResponse2 = + messageFactory.createIdentifyPillarsForGetFileResponse( + receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId); messageBus.sendMessage(identificationResponse2); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); addStep("Verify that the client continues to the performing phase.", "A REQUEST_SENT event should be generated and a GetFileRequest should be sent to pillar2."); GetFileRequest getFileRequest = pillar2Receiver.waitForMessage(GetFileRequest.class); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a final response upload message", "A COMPONENT_COMPLETE event should be generated followed by at COMPLETE event."); GetFileFinalResponse completeMsg = messageFactory.createGetFileFinalResponse( getFileRequest, PILLAR2_ID, pillar1DestinationId); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -566,7 +634,7 @@ public void failureDuringPerform() throws Exception { addStep("Request a getFile from the fastest pillar.", "A IDENTIFY_REQUEST_SENT should be generate and an identification request should be sent."); GetFileClient client = createGetFileClient(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); client.getFileFromFastestPillar(collectionID, DEFAULT_FILE_ID, NO_FILE_PART, httpServerConfiguration.getURL(DEFAULT_FILE_ID), testEventHandler, null); @@ -575,11 +643,13 @@ public void failureDuringPerform() throws Exception { addStep("Send an identification response from pillar1 and pillar2 with pillar1 the fastest.", "Pillar1 should be selected and a GetFileRequest should be sent."); - IdentifyPillarsForGetFileResponse identificationResponse1 = messageFactory.createIdentifyPillarsForGetFileResponse( - receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); + IdentifyPillarsForGetFileResponse identificationResponse1 = + messageFactory.createIdentifyPillarsForGetFileResponse( + receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(identificationResponse1); - IdentifyPillarsForGetFileResponse identificationResponse2 = messageFactory.createIdentifyPillarsForGetFileResponse( - receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId); + IdentifyPillarsForGetFileResponse identificationResponse2 = + messageFactory.createIdentifyPillarsForGetFileResponse( + receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId); TimeMeasureTYPE averageTime = new TimeMeasureTYPE(); averageTime.setTimeMeasureUnit(TimeMeasureUnit.HOURS); averageTime.setTimeMeasureValue(BigInteger.valueOf(10L)); @@ -594,8 +664,10 @@ public void failureDuringPerform() throws Exception { getFileRequest, PILLAR1_ID, pillar1DestinationId); completeMsg.getResponseInfo().setResponseCode(ResponseCode.FAILURE); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @@ -611,7 +683,7 @@ public void getFileFromOtherCollection() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getPillarIDs().getPillarID().add(PILLAR2_ID); String otherCollection = settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getID(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetFileClient client = createGetFileClient(); addStep("Request the getting of a file through the client for collection2", @@ -620,7 +692,8 @@ public void getFileFromOtherCollection() throws Exception { client.getFileFromFastestPillar(otherCollection, DEFAULT_FILE_ID, NO_FILE_PART, httpServerConfiguration.getURL(DEFAULT_FILE_ID), testEventHandler, null); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); Assertions.assertEquals(otherCollection, receivedIdentifyRequestMessage.getCollectionID()); @@ -630,9 +703,12 @@ public void getFileFromOtherCollection() throws Exception { "REQUEST_SENT. A GetFileIdsFileRequest should be sent to pillar2"); messageBus.sendMessage(messageFactory.createIdentifyPillarsForGetFileResponse( receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId)); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); GetFileRequest receivedRequest = pillar2Receiver.waitForMessage(GetFileRequest.class); Assertions.assertEquals(otherCollection, receivedRequest.getCollectionID()); @@ -641,8 +717,10 @@ public void getFileFromOtherCollection() throws Exception { GetFileFinalResponse putFileFinalResponse1 = messageFactory.createGetFileFinalResponse( receivedRequest, PILLAR2_ID, pillar2DestinationId); messageBus.sendMessage(putFileFinalResponse1); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPLETE, + testEventHandler.waitForEvent().getEventType()); } /** @@ -656,7 +734,6 @@ public void getFileFromOtherCollection() throws Exception { private GetFileClient createGetFileClient() { return new GetFileClientTestWrapper( new ConversationBasedGetFileClient(messageBus, conversationMediator, settingsForCUT, - settingsForTestClient.getComponentID()), - testEventManager); + settingsForTestClient.getComponentID())); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientTestWrapper.java index f22d8eeca..f2dd840ff 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getfile/GetFileClientTestWrapper.java @@ -26,7 +26,6 @@ import org.bitrepository.bitrepositoryelements.FilePart; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; import java.net.URL; @@ -34,31 +33,45 @@ * Wraps the GetFileClient adding test event logging and functionality for handling blocking calls. */ public class GetFileClientTestWrapper implements GetFileClient { - private final GetFileClient createGetFileClient; - private final TestEventManager testEventManager; + private GetFileClient createGetFileClient; - public GetFileClientTestWrapper(GetFileClient createGetFileClient, - TestEventManager testEventManager) { + public GetFileClientTestWrapper(GetFileClient createGetFileClient) { this.createGetFileClient = createGetFileClient; - this.testEventManager = testEventManager; + } @Override - public void getFileFromFastestPillar(String collectionID,String fileID, FilePart filePart, URL uploadUrl, + public void getFileFromFastestPillar(String collectionID, String fileID, FilePart filePart, URL uploadUrl, EventHandler eventHandler, String auditTrailInformation) { - testEventManager.addStimuli("Calling getFileFromFastestPillar(" + fileID + ", " + uploadUrl + ")"); - createGetFileClient.getFileFromFastestPillar(collectionID, - fileID, filePart, uploadUrl, eventHandler, auditTrailInformation); + String stepName = "Calling getFileFromFastestPillar for: " + fileID; + String details = "Collection: " + collectionID + "\n" + + "FilePart: " + filePart + "\n" + + "Upload URL: " + uploadUrl + "\n" + + "Audit Info: " + auditTrailInformation; + + io.qameta.allure.Allure.step(stepName, () -> { + io.qameta.allure.Allure.addAttachment("Request Parameters", details); + createGetFileClient.getFileFromFastestPillar(collectionID, + fileID, filePart, uploadUrl, eventHandler, auditTrailInformation); + }); } @Override - public void getFileFromSpecificPillar(String collectionID,String fileID, FilePart filePart, URL uploadUrl, + public void getFileFromSpecificPillar(String collectionID, String fileID, FilePart filePart, URL uploadUrl, String pillarID, EventHandler eventHandler, String auditTrailInformation) { - testEventManager.addStimuli("Calling getFileFromSpecificPillar(" + - fileID + ", " + uploadUrl + ", " + pillarID + ")"); - createGetFileClient.getFileFromSpecificPillar(collectionID, - fileID, filePart, uploadUrl, pillarID, eventHandler, auditTrailInformation); + String stepName = "Calling getFileFromSpecificPillar for: " + fileID + " on " + pillarID; + String details = "Collection: " + collectionID + "\n" + + "FilePart: " + filePart + "\n" + + "Upload URL: " + uploadUrl + "\n" + + "Pillar: " + pillarID + "\n" + + "Audit Info: " + auditTrailInformation; + + io.qameta.allure.Allure.step(stepName, () -> { + io.qameta.allure.Allure.addAttachment("Request Parameters", details); + createGetFileClient.getFileFromSpecificPillar(collectionID, + fileID, filePart, uploadUrl, pillarID, eventHandler, auditTrailInformation); + }); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientComponentTest.java index 1f2116b86..06b4841ba 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientComponentTest.java @@ -24,6 +24,8 @@ */ package org.bitrepository.access.getfileids; +import io.qameta.allure.junit5.AllureJunit5; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.access.AccessComponentFactory; import org.bitrepository.access.ContributorQuery; import org.bitrepository.access.getfileids.conversation.FileIDsCompletePillarEvent; @@ -35,20 +37,22 @@ import org.bitrepository.client.eventhandler.OperationEvent; import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.protocol.bus.MessageReceiver; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.bind.JAXBException; import java.math.BigInteger; import java.net.URL; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.*; + /** * Test class for the 'GetFileIDsClient'. */ +@ExtendWith(AllureJunit5.class) +@ExtendWith(SuiteInfoParameterResolver.class) public class GetFileIDsClientComponentTest extends DefaultClientTest { private TestGetFileIDsMessageFactory messageFactory; @@ -71,11 +75,12 @@ public void verifyGetFileIDsClientFromFactory() throws Exception { AccessComponentFactory.getInstance().createGetFileIDsClient(settingsForCUT, securityManager, settingsForTestClient.getComponentID()), "The default GetFileClient from the Access factory should be of the type '" + - ConversationBasedGetFileIDsClient.class.getName() + "'."); + ConversationBasedGetFileIDsClient.class.getName() + "'."); } @Test @Tag("regressiontest") + @DisplayName("Test that the GetFileIDsClient can be created from the AccessComponentFactory.") public void getFileIDsDeliveredAtUrl() throws Exception { addDescription("Tests the delivery of fileIDs from a pillar at a given URL."); addStep("Initialise the variables for this test.", @@ -357,7 +362,7 @@ public void getFileIDsFromOtherCollection() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getPillarIDs().getPillarID().add(PILLAR2_ID); String otherCollection = settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getID(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetFileIDsClient client = createGetFileIDsClient(); addStep("Request the putting of a file through the PutClient for collection2", @@ -398,8 +403,7 @@ public void getFileIDsFromOtherCollection() throws Exception { */ private GetFileIDsClient createGetFileIDsClient() { return new GetFileIDsClientTestWrapper(new ConversationBasedGetFileIDsClient( - messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID()), - testEventManager); + messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID())); } @Override diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientTestWrapper.java index 352e181ca..48027b01b 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getfileids/GetFileIDsClientTestWrapper.java @@ -24,9 +24,9 @@ */ package org.bitrepository.access.getfileids; +import io.qameta.allure.Allure; import org.bitrepository.access.ContributorQuery; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; import java.net.URL; import java.util.Arrays; @@ -37,26 +37,29 @@ public class GetFileIDsClientTestWrapper implements GetFileIDsClient { /** The actual GetFileIDsClient to perform the operations.*/ private final GetFileIDsClient client; - /** The EventManager to manage the events.*/ - private final TestEventManager eventManager; - + /** - * Constructor. + * Constructor. * @param client The actual GetFileIDsClient. - * @param eventManager The EventManager to notify about the operations performed by this wrapper. */ - public GetFileIDsClientTestWrapper(GetFileIDsClient client, TestEventManager eventManager) { + public GetFileIDsClientTestWrapper(GetFileIDsClient client) { this.client = client; - this.eventManager = eventManager; } @Override public void getFileIDs(String collectionID, ContributorQuery[] contributorQueries, String fileID, URL addressForResult, EventHandler eventHandler) { - eventManager.addStimuli("Calling getFileIDs(" + - (contributorQueries == null ? "null" : Arrays.asList(contributorQueries)) + - ", " + fileID + ", " + addressForResult + ", " - + eventHandler + ")"); - client.getFileIDs(collectionID, contributorQueries, fileID, addressForResult, eventHandler); + String stepName = "Calling getFileIDs for: " + (fileID != null ? fileID : "all files"); + + StringBuilder details = new StringBuilder(); + details.append("Collection: ").append(collectionID).append("\n") + .append("Contributor Queries: ").append(contributorQueries == null ? "null" : Arrays.asList(contributorQueries)).append("\n") + .append("Address for Result: ").append(addressForResult).append("\n") + .append("EventHandler: ").append(eventHandler); + + Allure.step(stepName, () -> { + Allure.addAttachment("GetFileIDs Request Parameters", details.toString()); + client.getFileIDs(collectionID, contributorQueries, fileID, addressForResult, eventHandler); + }); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientComponentTest.java index 90a0997d2..bd03164a4 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientComponentTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.access.getstatus; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.access.AccessComponentFactory; import org.bitrepository.access.getstatus.conversation.StatusCompleteContributorEvent; import org.bitrepository.bitrepositoryelements.ResultingStatus; @@ -40,11 +41,15 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.DatatypeFactory; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +@ExtendWith(SuiteInfoParameterResolver.class) public class GetStatusClientComponentTest extends DefaultFixtureClientTest { private TestGetStatusMessageFactory testMessageFactory; @@ -82,7 +87,7 @@ public void incompleteSetOfIdendifyResponses() throws Exception { DatatypeFactory datatypeFactory = DatatypeFactory.newInstance(); settingsForCUT.getRepositorySettings().getClientSettings() .setIdentificationTimeoutDuration(datatypeFactory.newDuration(1000)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetStatusClient client = createGetStatusClient(); client.getStatus(testEventHandler); @@ -116,7 +121,7 @@ public void getAllStatuses() throws InterruptedException { addDescription("Tests the simplest case of getting status for all contributors."); addStep("Create a GetStatusClient.", ""); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); GetStatusClient client = createGetStatusClient(); addStep("Retrieve from all contributors in the collection", @@ -188,7 +193,7 @@ public void getAllStatuses() throws InterruptedException { */ private GetStatusClient createGetStatusClient() { return new GetStatusClientTestWrapper(new ConversationBasedGetStatusClient( - messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID()), testEventManager); + messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID())); } private ResultingStatus createTestResultingStatus(String componentID) { diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientTestWrapper.java index a57405324..5ccc6d9db 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getstatus/GetStatusClientTestWrapper.java @@ -22,20 +22,23 @@ package org.bitrepository.access.getstatus; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; public class GetStatusClientTestWrapper implements GetStatusClient { - private final GetStatusClient getStatusClient; - private final TestEventManager testEventManager; + private GetStatusClient getStatusClient; - public GetStatusClientTestWrapper(GetStatusClient getStatusClient, - TestEventManager testEventManager) { + public GetStatusClientTestWrapper(GetStatusClient getStatusClient) { this.getStatusClient = getStatusClient; - this.testEventManager = testEventManager; + } + @Override public void getStatus(EventHandler eventHandler) { - testEventManager.addStimuli("Calling getAuditTrails()"); - getStatusClient.getStatus(eventHandler); + if (io.qameta.allure.Allure.getLifecycle().getCurrentTestCase().isPresent()) { + io.qameta.allure.Allure.step("Calling getStatus", () -> { + getStatusClient.getStatus(eventHandler); + }); + } else { + getStatusClient.getStatus(eventHandler); + } } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/DefaultClientTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/DefaultClientTest.java index c9f57afeb..2ab476a9d 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/DefaultClientTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/DefaultClientTest.java @@ -21,11 +21,12 @@ * #L% */ +import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositorymessages.MessageRequest; import org.bitrepository.bitrepositorymessages.MessageResponse; import org.bitrepository.client.eventhandler.OperationEvent; -import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.protocol.bus.MessageReceiver; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -33,14 +34,15 @@ import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; -import org.junit.jupiter.api.Assertions; +import static org.bitrepository.common.utils.AllureTestUtils.*; + /** * Tests the general client functionality. A number of abstract methods with needs to be implemented with concrete * functionality by the test for the specific operations. */ public abstract class DefaultClientTest extends DefaultFixtureClientTest { - protected final TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + protected final TestEventHandler testEventHandler = new TestEventHandler(); private DatatypeFactory datatypeFactory; @BeforeEach @@ -57,7 +59,8 @@ public void identificationNegativeTest() throws Exception { "A IDENTIFY_REQUEST_SENT should be generate and a identification request should be sent."); startOperation(testEventHandler); MessageRequest identifyRequest = waitForIdentifyRequest(); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a identification response from contributor1 with a IDENTIFICATION_NEGATIVE response code .", "A component failed event should be generated."); @@ -65,30 +68,36 @@ public void identificationNegativeTest() throws Exception { MessageResponse identifyResponse1 = createIdentifyResponse(identifyRequest, PILLAR1_ID, pillar1DestinationId); identifyResponse1.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_NEGATIVE); messageBus.sendMessage(identifyResponse1); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); addStep("Send a identification response from contributor2 with a IDENTIFICATION_POSITIVE response code .", "A component COMPONENT_IDENTIFIED event should be generated followed by a IDENTIFICATION_COMPLETE."); MessageResponse identifyResponse2 = createIdentifyResponse(identifyRequest, PILLAR2_ID, pillar2DestinationId); identifyResponse2.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_POSITIVE); messageBus.sendMessage(identifyResponse2); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); addStep("Verify that the client continues to the performing phase.", "A REQUEST_SENT event should be generated and a OperationRequest should be sent only to contributor2" + "."); checkNoRequestIsReceived(pillar1Receiver); MessageRequest request = waitForRequest(pillar2Receiver); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a final response message from contributor2", "A COMPONENT_COMPLETE event should be generated followed by at COMPLETE event."); MessageResponse completeMsg = createFinalResponse(request, PILLAR2_ID, pillar2DestinationId); completeMsg.getResponseInfo().setResponseCode(ResponseCode.OPERATION_COMPLETED); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -100,14 +109,16 @@ public void identificationFailureTest() throws Exception { "A IDENTIFY_REQUEST_SENT should be generate and a identification request should be sent."); startOperation(testEventHandler); MessageRequest identifyRequest = waitForIdentifyRequest(); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a identification response from contributor1 with a FAILURE response code.", "A component failed event should be generated."); MessageResponse identifyResponse1 = createIdentifyResponse(identifyRequest, PILLAR1_ID, pillar1DestinationId); identifyResponse1.getResponseInfo().setResponseCode(ResponseCode.FAILURE); messageBus.sendMessage(identifyResponse1); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); addStep("Send a identification response from contributor2 with a IDENTIFICATION_POSITIVE response code .", "A component COMPONENT_IDENTIFIED event should be generated followed by a IDENTIFICATION_COMPLETE."); @@ -115,22 +126,27 @@ public void identificationFailureTest() throws Exception { identifyRequest, PILLAR2_ID, pillar2DestinationId); identifyResponse2.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_POSITIVE); messageBus.sendMessage(identifyResponse2); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); addStep("Verify that the client continues to the performing phase.", "A REQUEST_SENT event should be generated and a Request should be sent only to contributor2."); checkNoRequestIsReceived(pillar1Receiver); MessageRequest request = waitForRequest(pillar2Receiver); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a final response message from contributor2", "A COMPONENT_COMPLETE event should be generated followed by at COMPLETE event."); MessageResponse completeMsg = createFinalResponse(request, PILLAR2_ID, pillar2DestinationId); completeMsg.getResponseInfo().setResponseCode(ResponseCode.OPERATION_COMPLETED); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -146,32 +162,41 @@ public void oneContributorNotRespondingTest() throws Exception { "A IDENTIFY_REQUEST_SENT should be generate and a identification request should be sent."); startOperation(testEventHandler); MessageRequest identifyRequest = waitForIdentifyRequest(); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); - addStep("Send a identification response from contributor1.", "A COMPONENT_IDENTIFIED event should be generated."); + addStep("Send a identification response from contributor1.", + "A COMPONENT_IDENTIFIED event should be generated."); MessageResponse identifyResponse1 = createIdentifyResponse(identifyRequest, PILLAR1_ID, pillar1DestinationId); identifyResponse1.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_POSITIVE); messageBus.sendMessage(identifyResponse1); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); addStep("Wait 1 second.", "A IDENTIFY_TIMEOUT event should be generated, followed by a IDENTIFICATION_COMPLETE."); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); addStep("Verify that the client continues to the performing phase.", "A REQUEST_SENT event should be generated and a Request should be sent to pillar1."); MessageRequest request = waitForRequest(pillar1Receiver); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Send a final response upload message", "A COMPONENT_COMPLETE event should be generated followed by at COMPLETE event."); MessageResponse completeMsg = createFinalResponse(request, PILLAR1_ID, pillar1DestinationId); completeMsg.getResponseInfo().setResponseCode(ResponseCode.OPERATION_COMPLETED); messageBus.sendMessage(completeMsg); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_COMPLETE, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @@ -187,13 +212,18 @@ public void noContributorsRespondingTest() throws Exception { addStep("Start the operation.", "A IDENTIFY_REQUEST_SENT event should be generated."); startOperation(testEventHandler); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Wait for 1 second", "An IdentifyPillarTimeout event should be received followed by a FAILED event"); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_TIMEOUT, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @@ -209,7 +239,8 @@ public void operationTimeoutTest() throws Exception { addStep("Start the operation", "A IDENTIFY_REQUEST_SENT event should be received."); startOperation(testEventHandler); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); MessageRequest identifyRequest = waitForIdentifyRequest(); addStep("Send positive responses from the pillar1 and a negative response from pillar2", @@ -218,17 +249,22 @@ public void operationTimeoutTest() throws Exception { "Finally a operation request should be sent to pillar1 and a REQUEST_SENT event be " + "generated"); messageBus.sendMessage(createIdentifyResponse(identifyRequest, PILLAR1_ID, pillar1DestinationId)); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_IDENTIFIED, + testEventHandler.waitForEvent().getEventType()); MessageResponse identifyResponse2 = createIdentifyResponse(identifyRequest, PILLAR2_ID, pillar2DestinationId); identifyResponse2.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_NEGATIVE); messageBus.sendMessage(identifyResponse2); - Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.COMPONENT_FAILED, + testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFICATION_COMPLETE, + testEventHandler.waitForEvent().getEventType()); waitForRequest(pillar1Receiver); - Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); addStep("Wait for 1 second", "An FAILED event should be received"); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } @Test @@ -297,9 +333,11 @@ public void conversationTimeoutTest() throws Exception { addStep("Start the operation", "A IDENTIFY_REQUEST_SENT event should be generated followed by a FAILED event after 100 ms."); startOperation(testEventHandler); - Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.IDENTIFY_REQUEST_SENT, + testEventHandler.waitForEvent().getEventType()); Assertions.assertNotNull(waitForIdentifyRequest()); - Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + Assertions.assertEquals(OperationEvent.OperationEventType.FAILED, + testEventHandler.waitForEvent().getEventType()); } diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/DefaultFixtureClientTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/DefaultFixtureClientTest.java index 79cb9a37b..3a4bfb709 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/DefaultFixtureClientTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/DefaultFixtureClientTest.java @@ -63,15 +63,15 @@ protected void shutdownCUT() { protected void registerMessageReceivers() { super.registerMessageReceivers(); - collectionReceiver = new MessageReceiver(settingsForCUT.getCollectionDestination(), testEventManager); + collectionReceiver = new MessageReceiver(settingsForCUT.getCollectionDestination()); addReceiver(collectionReceiver); pillar1DestinationId = "Pillar1_topic" + getTopicPostfix(); - pillar1Receiver = new MessageReceiver(pillar1DestinationId, testEventManager); + pillar1Receiver = new MessageReceiver(pillar1DestinationId); addReceiver(pillar1Receiver); pillar2DestinationId = "Pillar2_topic" + getTopicPostfix(); - pillar2Receiver = new MessageReceiver(pillar2DestinationId, testEventManager); + pillar2Receiver = new MessageReceiver(pillar2DestinationId); addReceiver(pillar2Receiver); } diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/TestEventHandler.java b/bitrepository-client/src/test/java/org/bitrepository/client/TestEventHandler.java index b1249d01e..33782355c 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/TestEventHandler.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/TestEventHandler.java @@ -26,48 +26,41 @@ import org.bitrepository.client.eventhandler.EventHandler; import org.bitrepository.client.eventhandler.OperationEvent; -import org.jaccept.TestEventManager; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.isTestRunning; import static org.junit.jupiter.api.Assertions.assertNull; - -/** - * Used to listen for operation event and store them for later retrieval by a test. - */ +/** Used to listen for operation event and store them for later retrieval by a test. */ public class TestEventHandler implements EventHandler { - /** - * The TestEventManager used to manage the event for the associated test. - */ - private final TestEventManager testEventManager; - /** - * The queue used to store the received operation events. - */ + /** The TestEventManager used to manage the event for the associated test. */ + + /** The queue used to store the received operation events. */ private final BlockingQueue eventQueue = new LinkedBlockingQueue<>(); - /** - * The default time to wait for events - */ + /** The default time to wait for events */ private static final long DEFAULT_WAIT_SECONDS = 3; - /** - * The constructor. - * - * @param testEventManager The TestEventManager used to manage the event for the associated test. + /** The constructor. */ - public TestEventHandler(TestEventManager testEventManager) { + public TestEventHandler() { super(); - this.testEventManager = testEventManager; + } @Override public void handleEvent(OperationEvent event) { - testEventManager.addResult("Received event: " + event); - eventQueue.add(event); + if (isTestRunning()) { + io.qameta.allure.Allure.step("Received event: " + event, () -> { + eventQueue.add(event); + }); + } else { + eventQueue.add(event); + } } /** diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/exception/NegativeResponseExceptionTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/exception/NegativeResponseExceptionTest.java index 87bef14a6..8ac26b5f0 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/exception/NegativeResponseExceptionTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/exception/NegativeResponseExceptionTest.java @@ -23,13 +23,15 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.client.exceptions.NegativeResponseException; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; -public class NegativeResponseExceptionTest extends ExtendedTestCase { + +public class NegativeResponseExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/exception/UnexpectedResponseExceptionTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/exception/UnexpectedResponseExceptionTest.java index 5cafa83eb..00fc9bcc7 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/exception/UnexpectedResponseExceptionTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/exception/UnexpectedResponseExceptionTest.java @@ -22,13 +22,14 @@ package org.bitrepository.client.exception; import org.bitrepository.client.exceptions.UnexpectedResponseException; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; -public class UnexpectedResponseExceptionTest extends ExtendedTestCase { +public class UnexpectedResponseExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/CommandLineTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/CommandLineTest.java index 78641b86c..015a701b9 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/CommandLineTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/CommandLineTest.java @@ -23,17 +23,18 @@ import org.apache.commons.cli.Option; import org.bitrepository.commandline.utils.CommandLineArgumentsHandler; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.Assertions.assertTrue; -public class CommandLineTest extends ExtendedTestCase { +public class CommandLineTest { private static final String SETTINGS_DIR = "SettingsDir"; private static final String KEY_FILE = "KeyFile"; private static final String DUMMY_DATA = "DummyData"; diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/DeleteFileCmdTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/DeleteFileCmdTest.java index e5e4ee130..e9ce5264c 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/DeleteFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/DeleteFileCmdTest.java @@ -5,31 +5,36 @@ * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ package org.bitrepository.commandline; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.client.DefaultFixtureClientTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertThrows; +@ExtendWith(SuiteInfoParameterResolver.class) public class DeleteFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; @@ -43,20 +48,20 @@ public void setupClient() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, "-p" + PILLAR1_ID, "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, + "-c" + DEFAULT_COLLECTION_ID, "-i" + DEFAULT_FILE_ID}; new DeleteFileCmd(args); } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void missingCollectionArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Tests the scenario, where the collection arguments is missing."); @@ -70,7 +75,7 @@ public void missingCollectionArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void missingPillarArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Tests the different scenarios, with the pillar argument."); @@ -84,7 +89,7 @@ public void missingPillarArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void unknownPillarArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addStep("Testing against a non-existing pillar id", "Should fail"); @@ -99,7 +104,7 @@ public void unknownPillarArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void missingFileIDArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Tests the scenario, where no arguments for file id argument is given."); @@ -113,28 +118,28 @@ public void missingFileIDArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { addDescription("Test MD5 checksum without salt -> no failure"); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, "-p" + PILLAR1_ID, "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, + "-c" + DEFAULT_COLLECTION_ID, "-i" + DEFAULT_FILE_ID, "-R" + "MD5"}; new DeleteFileCmd(args); } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void checksumArgumentSaltAlgorithmWithSaltTest() throws Exception { addDescription("Test HMAC_SHA256 checksum with salt -> No failure"); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, "-p" + PILLAR1_ID, "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, + "-c" + DEFAULT_COLLECTION_ID, "-i" + DEFAULT_FILE_ID, "-R" + "HMAC_SHA256", "-S" + "SALT"}; diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetChecksumsCmdTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetChecksumsCmdTest.java index 2b097a6af..5c27c4f60 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetChecksumsCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetChecksumsCmdTest.java @@ -21,15 +21,19 @@ */ package org.bitrepository.commandline; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.client.DefaultFixtureClientTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; import static org.junit.jupiter.api.Assertions.assertThrows; +@ExtendWith(SuiteInfoParameterResolver.class) public class GetChecksumsCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileCmdTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileCmdTest.java index 075430613..461b6e2f7 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileCmdTest.java @@ -5,31 +5,35 @@ * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ package org.bitrepository.commandline; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.client.DefaultFixtureClientTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; import static org.junit.jupiter.api.Assertions.assertThrows; +@ExtendWith(SuiteInfoParameterResolver.class) public class GetFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; @@ -42,18 +46,18 @@ public void setupClient() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, + "-c" + DEFAULT_COLLECTION_ID, "-i" + DEFAULT_FILE_ID}; new GetFileCmd(args); } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void missingCollectionArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Tests the scenario, where the collection arguments is missing."); @@ -65,19 +69,19 @@ public void missingCollectionArgumentTest() throws Exception { } @Test - @Tag( "regressiontest" ) + @Tag("regressiontest") public void specificPillarArgumentTest() throws Exception { addDescription("Test argument for a specific pillar"); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, + "-c" + DEFAULT_COLLECTION_ID, "-p" + PILLAR1_ID, "-i" + DEFAULT_FILE_ID}; new GetFileCmd(args); } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void unknownPillarArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Testing against a non-existing pillar id -> Should fail"); @@ -91,7 +95,7 @@ public void unknownPillarArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void missingFileIDArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Tests the scenario, where no arguments for file id argument is given."); diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileIDsCmdTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileIDsCmdTest.java index ef8d6b391..2414d5b37 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileIDsCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileIDsCmdTest.java @@ -5,31 +5,35 @@ * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ package org.bitrepository.commandline; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.client.DefaultFixtureClientTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; import static org.junit.jupiter.api.Assertions.assertThrows; +@ExtendWith(SuiteInfoParameterResolver.class) public class GetFileIDsCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; @@ -42,10 +46,10 @@ public void setupClient() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, "-c" + DEFAULT_COLLECTION_ID}; new GetFileIDsCmd(args); @@ -53,7 +57,7 @@ public void defaultSuccessScenarioTest() throws Exception { @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void missingCollectionArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Tests the scenario, where the collection arguments is missing."); @@ -65,10 +69,10 @@ public void missingCollectionArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void specificPillarArgumentTest() throws Exception { addDescription("Test argument for a specific pillar"); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, "-c" + DEFAULT_COLLECTION_ID, "-p" + PILLAR1_ID, @@ -77,7 +81,7 @@ public void specificPillarArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void unknownPillarArgumentTest() throws Exception { assertThrows(IllegalArgumentException.class, () -> { addDescription("Testing against a non-existing pillar id -> Should fail"); @@ -91,10 +95,10 @@ public void unknownPillarArgumentTest() throws Exception { } @Test - @Tag( "regressiontest") + @Tag("regressiontest") public void fileArgumentTest() throws Exception { addDescription("Tests the argument for a specific file."); - String[] args = new String[]{"-s" + SETTINGS_DIR, + String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, "-c" + DEFAULT_COLLECTION_ID, "-i" + DEFAULT_FILE_ID}; diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/PutFileCmdTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/PutFileCmdTest.java index b63c26372..61b096f02 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/PutFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/PutFileCmdTest.java @@ -21,13 +21,17 @@ */ package org.bitrepository.commandline; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.client.DefaultFixtureClientTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; import static org.junit.jupiter.api.Assertions.assertThrows; +@ExtendWith(SuiteInfoParameterResolver.class) public class PutFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/ReplaceFileCmdTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/ReplaceFileCmdTest.java index c116e6259..8ec0cf361 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/ReplaceFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/ReplaceFileCmdTest.java @@ -21,15 +21,20 @@ */ package org.bitrepository.commandline; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.client.DefaultFixtureClientTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertThrows; +@ExtendWith(SuiteInfoParameterResolver.class) public class ReplaceFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; diff --git a/bitrepository-client/src/test/java/org/bitrepository/commandline/utils/ChecksumExtractionUtilsTest.java b/bitrepository-client/src/test/java/org/bitrepository/commandline/utils/ChecksumExtractionUtilsTest.java index ab30006c8..76b8153c5 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/utils/ChecksumExtractionUtilsTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/utils/ChecksumExtractionUtilsTest.java @@ -22,6 +22,7 @@ package org.bitrepository.commandline.utils; import org.apache.commons.cli.Option; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.ChecksumType; import org.bitrepository.client.DefaultFixtureClientTest; import org.bitrepository.commandline.Constants; @@ -30,9 +31,12 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +@ExtendWith(SuiteInfoParameterResolver.class) public class ChecksumExtractionUtilsTest extends DefaultFixtureClientTest { CommandLineArgumentsHandler cmdHandler; OutputHandler output; diff --git a/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientComponentTest.java index c08e84a20..a8903205e 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientComponentTest.java @@ -24,6 +24,7 @@ */ package org.bitrepository.modify.deletefile; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.*; import org.bitrepository.bitrepositorymessages.*; import org.bitrepository.client.DefaultFixtureClientTest; @@ -37,10 +38,15 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.DatatypeFactory; import java.nio.charset.StandardCharsets; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class DeleteFileClientComponentTest extends DefaultFixtureClientTest { private TestDeleteFileMessageFactory messageFactory; private DatatypeFactory datatypeFactory; @@ -74,7 +80,11 @@ public void deleteClientTester() throws Exception { .clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID() .add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); + settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID() + .clear(); + settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID() + .add(PILLAR1_ID); DeleteFileClient deleteClient = createDeleteFileClient(); String checksum = "123checksum321"; @@ -164,7 +174,7 @@ public void deleteClientTester() throws Exception { public void fileAlreadyDeletedFromPillar() throws Exception { addDescription("Test that a delete on a pillar completes successfully when the file is missing " + "(has already been deleted). This is a test of the Idempotent behaviour of the delete client"); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); addStep("Request a file to be deleted on pillar1.", @@ -214,7 +224,7 @@ public void deleteClientIdentificationTimeout() throws Exception { .add(PILLAR1_ID); settingsForCUT.getRepositorySettings().getClientSettings() .setIdentificationTimeoutDuration(datatypeFactory.newDuration(1000)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); String checksum = "123checksum321"; @@ -257,7 +267,7 @@ public void deleteClientOperationTimeout() throws Exception { .add(PILLAR1_ID); settingsForCUT.getRepositorySettings().getClientSettings() .setOperationTimeoutDuration(datatypeFactory.newDuration(100)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); String checksum = "123checksum321"; @@ -317,7 +327,7 @@ public void deleteClientPillarFailedDuringPerform() throws Exception { .clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID() .add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); String checksum = "123checksum321"; @@ -379,7 +389,7 @@ public void deleteClientPillarFailedDuringPerform() throws Exception { @Tag("regressiontest") public void deleteClientSpecifiedPillarFailedDuringIdentification() throws Exception { addDescription("Tests the handling of a identification failure for a pillar for the DeleteClient. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); addStep("Request a file to be deleted on the pillar1.", @@ -409,7 +419,7 @@ public void deleteClientSpecifiedPillarFailedDuringIdentification() throws Excep @Tag("regressiontest") public void deleteClientOtherPillarFailedDuringIdentification() throws Exception { addDescription("Tests the handling of a identification failure for a pillar for the DeleteClient. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); addStep("Request a file to be deleted on the pillar1.", @@ -458,7 +468,7 @@ public void deleteClientOtherPillarFailedDuringIdentification() throws Exception @Tag("regressiontest") public void deleteOnChecksumPillar() throws Exception { addDescription("Verify that the DeleteClient works correctly when a checksum pillar is present. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); addStep("Request a file to be deleted on the pillar1.", @@ -506,7 +516,7 @@ public void deleteOnChecksumPillar() throws Exception { public void deleteOnChecksumPillarWithDefaultReturnChecksumType() throws Exception { addDescription("Verify that the DeleteClient works correctly when a return checksum of the default type" + "is requested. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); addStep("Request a file to be deleted on the pillar1. The call should include a request for a check sum of " + @@ -549,7 +559,7 @@ public void deleteOnChecksumPillarWithDefaultReturnChecksumType() throws Excepti public void deleteOnChecksumPillarWithSaltedReturnChecksumType() throws Exception { addDescription("Verify that the DeleteClient works correctly when a return checksum with a salt " + "is requested. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); DeleteFileClient deleteClient = createDeleteFileClient(); addStep("Request a file to be deleted on the pillar1. The call should include a request for a salted check " + @@ -596,7 +606,6 @@ public void deleteOnChecksumPillarWithSaltedReturnChecksumType() throws Exceptio */ private DeleteFileClient createDeleteFileClient() { return new DeleteFileClientTestWrapper(new ConversationBasedDeleteFileClient( - messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID()), - testEventManager); + messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID())); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientTestWrapper.java index c59a41fee..24b3e9a15 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/modify/deletefile/DeleteFileClientTestWrapper.java @@ -1,61 +1,68 @@ /* * #%L * Bitrepository Access Client - * + * * $Id$ * $HeadURL$ * %% * Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ package org.bitrepository.modify.deletefile; +import io.qameta.allure.Allure; import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; /** * Wrapper class for a DeleteFileClient adding testmanager logging. */ public class DeleteFileClientTestWrapper implements DeleteFileClient { - /** The PutClient to wrap. */ + /** + * The PutClient to wrap. + */ private final DeleteFileClient wrappedDeleteClient; /** The manager to monitor the operations.*/ - private final TestEventManager testEventManager; /** * Constructor. + * * @param deleteClientInstance The instance to wrap and monitor. - * @param eventManager The manager to monitor the operations. */ - public DeleteFileClientTestWrapper(DeleteFileClient deleteClientInstance, TestEventManager eventManager) { + public DeleteFileClientTestWrapper(DeleteFileClient deleteClientInstance) { this.wrappedDeleteClient = deleteClientInstance; - this.testEventManager = eventManager; } @Override public void deleteFile(String collectionID, String fileID, String pillarID, ChecksumDataForFileTYPE checksumForPillar, - ChecksumSpecTYPE checksumRequested, EventHandler eventHandler, String auditTrailInformation) { - testEventManager.addStimuli("Calling deleteFile(" + fileID + ", " + pillarID + ", " + checksumForPillar + ", " - + checksumRequested + ", eventHandler, " + auditTrailInformation + ")"); - wrappedDeleteClient.deleteFile(collectionID, fileID, pillarID, checksumForPillar, checksumRequested, - eventHandler, - auditTrailInformation); + ChecksumSpecTYPE checksumRequested, EventHandler eventHandler, String auditTrailInformation) { + String stepName = "Calling deleteFile for file: " + fileID; + String details = "Collection: " + collectionID + "\n" + + "Pillar: " + pillarID + "\n" + + "Checksum: " + checksumForPillar + "\n" + + "Audit Info: " + auditTrailInformation; + + Allure.step(stepName, () -> { + Allure.addAttachment("Delete Request Parameters", details); + wrappedDeleteClient.deleteFile(collectionID, fileID, pillarID, checksumForPillar, checksumRequested, + eventHandler, + auditTrailInformation); + }); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientComponentTest.java index 65b66a9d8..0aa561fc6 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientComponentTest.java @@ -24,32 +24,26 @@ */ package org.bitrepository.modify.putfile; -import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE; -import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; -import org.bitrepository.bitrepositoryelements.ChecksumType; -import org.bitrepository.bitrepositoryelements.ResponseCode; -import org.bitrepository.bitrepositoryelements.ResponseInfo; -import org.bitrepository.bitrepositorymessages.IdentifyPillarsForPutFileRequest; -import org.bitrepository.bitrepositorymessages.IdentifyPillarsForPutFileResponse; -import org.bitrepository.bitrepositorymessages.PutFileFinalResponse; -import org.bitrepository.bitrepositorymessages.PutFileProgressResponse; -import org.bitrepository.bitrepositorymessages.PutFileRequest; +import io.qameta.allure.*; +import org.bitrepository.SuiteInfoParameterResolver; +import org.bitrepository.bitrepositoryelements.*; +import org.bitrepository.bitrepositorymessages.*; import org.bitrepository.client.DefaultFixtureClientTest; import org.bitrepository.client.TestEventHandler; import org.bitrepository.client.eventhandler.OperationEvent.OperationEventType; import org.bitrepository.common.utils.Base16Utils; import org.bitrepository.common.utils.TestFileHelper; import org.bitrepository.modify.ModifyComponentFactory; -import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.*; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.DatatypeFactory; import java.math.BigInteger; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.*; +@ExtendWith(SuiteInfoParameterResolver.class) public class PutFileClientComponentTest extends DefaultFixtureClientTest { private TestPutFileMessageFactory messageFactory; private DatatypeFactory datatypeFactory; @@ -81,7 +75,7 @@ public void normalPutFile() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); @@ -151,7 +145,7 @@ public void noPillarsResponding() throws Exception { settingsForCUT.getRepositorySettings().getClientSettings() .setIdentificationTimeoutDuration(datatypeFactory.newDuration(100)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Request the putting of a file through the PutClient", @@ -171,54 +165,111 @@ public void noPillarsResponding() throws Exception { @Test @Tag("regressiontest") + @DisplayName("Partial put allowed when only one pillar responds") + @Description("Tests the handling of missing identification responses from one pillar, when partial puts are allowed.") + @Issue("BITMAG-598") + @Severity(SeverityLevel.CRITICAL) public void onePillarRespondingWithPartialPutAllowed() throws Exception { - addReference("" + - "BITMAG-598 It should be possible to putFiles, even though only a subset of the pillars are available"); - addDescription("Tests the handling of missing identification responses from one pillar, " + - "when partial put are allowed"); - addFixture("Sets the identification timeout to 100 ms and allow partial puts."); + Allure.step("Fixture: Set identification timeout to 100 ms and allow partial puts.", () -> { settingsForCUT.getRepositorySettings().getClientSettings() .setIdentificationTimeoutDuration(datatypeFactory.newDuration(100)); settingsForCUT.getReferenceSettings().getPutFileSettings().setPartialPutsAllow(true); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + }); + + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); - addStep("Request the putting of a file through the PutClient", - "A identification request should be dispatched."); + IdentifyPillarsForPutFileRequest receivedIdentifyRequestMessage = Allure.step( + "Request file put through PutClient (Expected: Identify request dispatched)", () -> { + putClient.putFile(collectionID, httpServerConfiguration.getURL(DEFAULT_FILE_ID), DEFAULT_FILE_ID, 0, null, null, testEventHandler, null); Assertions.assertEquals(OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); - IdentifyPillarsForPutFileRequest receivedIdentifyRequestMessage = - collectionReceiver.waitForMessage(IdentifyPillarsForPutFileRequest.class); - addStep("Only send an identification response from one pillar.", - "An COMPONENT_IDENTIFIED event should be generate."); + return collectionReceiver.waitForMessage(IdentifyPillarsForPutFileRequest.class); + }); + + Allure.step("Only send an identification response from one pillar (Expected: COMPONENT_IDENTIFIED event)", () -> { IdentifyPillarsForPutFileResponse identifyResponse = messageFactory.createIdentifyPillarsForPutFileResponse( receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(identifyResponse); Assertions.assertEquals(OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); + }); - addStep("Await the timeout.", "An IDENTIFY_TIMEOUT events, a COMPONENT_FAILED " + - "event for the non-responding pillar and an IDENTIFICATION_COMPLETE event should be generated."); + Allure.step("Await the timeout (Expected: IDENTIFY_TIMEOUT, COMPONENT_FAILED, and IDENTIFICATION_COMPLETE)", () -> { Assertions.assertEquals(OperationEventType.IDENTIFY_TIMEOUT, testEventHandler.waitForEvent().getEventType()); Assertions.assertEquals(OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); Assertions.assertEquals(OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); + }); + + PutFileRequest receivedPutFileRequest = Allure.step( + "Client proceeds to send putFileOperation request to responding pillar (Expected: REQUEST_SENT)", () -> { - addStep("The client should proceed to send a putFileOperation request to the responding pillar.", - "A REQUEST_SENT event should be generated and a PutFileRequest should be received on the pillar."); Assertions.assertEquals(OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); - PutFileRequest receivedPutFileRequest = pillar1Receiver.waitForMessage(PutFileRequest.class); - addStep("Send a pillar complete event", - "The client should generate a COMPONENT_COMPLETE followed by a COMPLETE event"); + return pillar1Receiver.waitForMessage(PutFileRequest.class); + }); + + Allure.step("Send a pillar complete event (Expected: COMPONENT_COMPLETE followed by FAILED)", () -> { PutFileFinalResponse putFileFinalResponse = messageFactory.createPutFileFinalResponse( receivedPutFileRequest, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(putFileFinalResponse); Assertions.assertEquals(OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); Assertions.assertEquals(OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); + }); } +// @Test +// @Tag("regressiontest") +// public void onePillarRespondingWithPartialPutAllowed() throws Exception { +// addReference("" + +// "BITMAG-598 It should be possible to putFiles, even though only a subset of the pillars are available"); +// addDescription("Tests the handling of missing identification responses from one pillar, " + +// "when partial put are allowed"); +// addFixture("Sets the identification timeout to 100 ms and allow partial puts."); +// +// settingsForCUT.getRepositorySettings().getClientSettings() +// .setIdentificationTimeoutDuration(datatypeFactory.newDuration(100)); +// settingsForCUT.getReferenceSettings().getPutFileSettings().setPartialPutsAllow(true); +// TestEventHandler testEventHandler = new TestEventHandler(); +// PutFileClient putClient = createPutFileClient(); +// +// addStep("Request the putting of a file through the PutClient", +// "A identification request should be dispatched."); +// putClient.putFile(collectionID, httpServerConfiguration.getURL(DEFAULT_FILE_ID), DEFAULT_FILE_ID, 0, null, +// null, testEventHandler, null); +// Assertions.assertEquals(OperationEventType.IDENTIFY_REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); +// IdentifyPillarsForPutFileRequest receivedIdentifyRequestMessage = +// collectionReceiver.waitForMessage(IdentifyPillarsForPutFileRequest.class); +// +// addStep("Only send an identification response from one pillar.", +// "An COMPONENT_IDENTIFIED event should be generate."); +// IdentifyPillarsForPutFileResponse identifyResponse = messageFactory.createIdentifyPillarsForPutFileResponse( +// receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); +// messageBus.sendMessage(identifyResponse); +// Assertions.assertEquals(OperationEventType.COMPONENT_IDENTIFIED, testEventHandler.waitForEvent().getEventType()); +// +// addStep("Await the timeout.", "An IDENTIFY_TIMEOUT events, a COMPONENT_FAILED " + +// "event for the non-responding pillar and an IDENTIFICATION_COMPLETE event should be generated."); +// Assertions.assertEquals(OperationEventType.IDENTIFY_TIMEOUT, testEventHandler.waitForEvent().getEventType()); +// Assertions.assertEquals(OperationEventType.COMPONENT_FAILED, testEventHandler.waitForEvent().getEventType()); +// Assertions.assertEquals(OperationEventType.IDENTIFICATION_COMPLETE, testEventHandler.waitForEvent().getEventType()); +// +// addStep("The client should proceed to send a putFileOperation request to the responding pillar.", +// "A REQUEST_SENT event should be generated and a PutFileRequest should be received on the pillar."); +// Assertions.assertEquals(OperationEventType.REQUEST_SENT, testEventHandler.waitForEvent().getEventType()); +// PutFileRequest receivedPutFileRequest = pillar1Receiver.waitForMessage(PutFileRequest.class); +// +// addStep("Send a pillar complete event", +// "The client should generate a COMPONENT_COMPLETE followed by a COMPLETE event"); +// PutFileFinalResponse putFileFinalResponse = messageFactory.createPutFileFinalResponse( +// receivedPutFileRequest, PILLAR1_ID, pillar1DestinationId); +// messageBus.sendMessage(putFileFinalResponse); +// Assertions.assertEquals(OperationEventType.COMPONENT_COMPLETE, testEventHandler.waitForEvent().getEventType()); +// Assertions.assertEquals(OperationEventType.FAILED, testEventHandler.waitForEvent().getEventType()); +// } + @Test @Tag("regressiontest") public void onePillarRespondingWithPartialPutDisallowed() throws Exception { @@ -229,7 +280,7 @@ public void onePillarRespondingWithPartialPutDisallowed() throws Exception { settingsForCUT.getRepositorySettings().getClientSettings() .setIdentificationTimeoutDuration(datatypeFactory.newDuration(100)); settingsForCUT.getReferenceSettings().getPutFileSettings().setPartialPutsAllow(false); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Request the putting of a file through the PutClient", @@ -266,7 +317,7 @@ public void putClientOperationTimeout() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); settingsForCUT.getRepositorySettings().getClientSettings() .setOperationTimeoutDuration(datatypeFactory.newDuration(100)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Request the putting of a file through the PutClient", @@ -306,7 +357,7 @@ public void putClientPillarOperationFailed() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Ensure that the test-file is placed on the HTTP server.", "Should be removed an reuploaded."); @@ -352,7 +403,7 @@ public void putClientPillarOperationFailed() throws Exception { public void fileExistsOnPillarNoChecksumFromPillar() throws Exception { addDescription("Tests that PutClient handles the presence of a file correctly, when the pillar doesn't return a " + "checksum in the identification response. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Call putFile.", @@ -386,7 +437,7 @@ public void fileExistsOnPillarNoChecksumFromPillar() throws Exception { public void fileExistsOnPillarDifferentChecksumFromPillar() throws Exception { addDescription("Tests that PutClient handles the presence of a file correctly, when the pillar " + "returns a checksum different from the file being put. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Call putFile.", @@ -425,7 +476,7 @@ public void fileExistsOnPillarDifferentChecksumFromPillar() throws Exception { public void sameFileExistsOnOnePillar() throws Exception { addDescription("Tests that PutClient handles the presence of a file correctly, when the pillar " + "returns a checksum equal the file being put (idempotent)."); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Call putFile.", @@ -481,7 +532,7 @@ public void sameFileExistsOnOnePillar() throws Exception { public void fileExistsOnPillarChecksumFromPillarNoClientChecksum() throws Exception { addDescription("Tests that PutClient handles the presence of a file correctly, when the pillar " + "returns a checksum but the putFile was called without a checksum. "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Call putFile.", @@ -522,7 +573,7 @@ public void saltedReturnChecksumsWithChecksumPillar() throws Exception { "put, replace and delete clients fails if return checksums are requested and a checksumpillar is " + "involved"); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Call putFile while requesting a salted checksum to be returned.", @@ -575,7 +626,7 @@ public void defaultReturnChecksumsWithChecksumPillar() throws Exception { addDescription("Tests that PutClient handles the presence of a ChecksumPillar correctly, when a return" + " checksum of default type is requested (which a checksum pillar can provide). "); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Call putFile while requesting a salted checksum to be returned.", @@ -627,7 +678,7 @@ public void noReturnChecksumsWithChecksumPillar() throws Exception { addDescription("Tests that PutClient handles the presence of a ChecksumPillar correctly, when no return" + " checksum is requested."); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Call putFile while requesting a salted checksum to be returned.", @@ -679,7 +730,7 @@ public void onePillarPutRetrySuccess() throws Exception { settingsForCUT.getReferenceSettings().getClientSettings().setOperationRetryCount(BigInteger.valueOf(2)); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Request the putting of a file through the PutClient", @@ -733,7 +784,7 @@ public void onePillarPutRetryFailure() throws Exception { settingsForCUT.getReferenceSettings().getClientSettings().setOperationRetryCount(BigInteger.valueOf(2)); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Request the putting of a file through the PutClient", @@ -801,7 +852,7 @@ public void putToOtherCollection() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getPillarIDs().getPillarID().add(PILLAR2_ID); String otherCollection = settingsForCUT.getRepositorySettings().getCollections().getCollection().get(1).getID(); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); PutFileClient putClient = createPutFileClient(); addStep("Request the putting of a file through the PutClient for collection2", @@ -845,6 +896,6 @@ public void putToOtherCollection() throws Exception { private PutFileClient createPutFileClient() { return new PutFileClientTestWrapper(new ConversationBasedPutFileClient( messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID()) - , testEventManager); + ); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientTestWrapper.java index 3dab15541..e7f3a19d8 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/modify/putfile/PutFileClientTestWrapper.java @@ -24,10 +24,10 @@ */ package org.bitrepository.modify.putfile; +import io.qameta.allure.Allure; import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; import java.net.URL; @@ -36,27 +36,31 @@ */ public class PutFileClientTestWrapper implements PutFileClient { private final PutFileClient wrappedPutClient; - private final TestEventManager testEventManager; /** * Constructor. * @param putClientInstance The instance to wrap and monitor. - * @param eventManager The manager to monitor the operations. */ - public PutFileClientTestWrapper(PutFileClient putClientInstance, TestEventManager eventManager) { + public PutFileClientTestWrapper(PutFileClient putClientInstance) { this.wrappedPutClient = putClientInstance; - this.testEventManager = eventManager; } @Override public void putFile(String collectionID, URL url, String fileID, long sizeOfFile, ChecksumDataForFileTYPE checksumForValidationAtPillar, - ChecksumSpecTYPE checksumRequestsForValidation, EventHandler eventHandler, String auditTrailInformation) { - testEventManager.addStimuli("Calling PutFileWithId(" + url + ", " + fileID + ", " + sizeOfFile + ", " - + checksumForValidationAtPillar + ", " + checksumRequestsForValidation + ", " + eventHandler + ", " - + auditTrailInformation + ")"); - wrappedPutClient.putFile(collectionID, url, fileID, sizeOfFile, checksumForValidationAtPillar, - checksumRequestsForValidation, - eventHandler, auditTrailInformation); + ChecksumSpecTYPE checksumRequestsForValidation, EventHandler eventHandler, String auditTrailInformation) { + String stepName = "Calling putFile for file: " + fileID; + StringBuilder details = new StringBuilder(); + details.append("Collection: ").append(collectionID).append("\n") + .append("URL: ").append(url).append("\n") + .append("Size: ").append(sizeOfFile).append("\n") + .append("Audit Info: ").append(auditTrailInformation); + + Allure.step(stepName, () -> { + Allure.addAttachment("Put Request Parameters", details.toString()); + wrappedPutClient.putFile(collectionID, url, fileID, sizeOfFile, checksumForValidationAtPillar, + checksumRequestsForValidation, + eventHandler, auditTrailInformation); + }); } } diff --git a/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientComponentTest.java b/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientComponentTest.java index c03227a1a..3c3cf32b3 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientComponentTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientComponentTest.java @@ -24,16 +24,9 @@ */ package org.bitrepository.modify.replacefile; -import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE; -import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; -import org.bitrepository.bitrepositoryelements.ChecksumType; -import org.bitrepository.bitrepositoryelements.ResponseCode; -import org.bitrepository.bitrepositoryelements.ResponseInfo; -import org.bitrepository.bitrepositorymessages.IdentifyPillarsForReplaceFileRequest; -import org.bitrepository.bitrepositorymessages.IdentifyPillarsForReplaceFileResponse; -import org.bitrepository.bitrepositorymessages.ReplaceFileFinalResponse; -import org.bitrepository.bitrepositorymessages.ReplaceFileProgressResponse; -import org.bitrepository.bitrepositorymessages.ReplaceFileRequest; +import org.bitrepository.SuiteInfoParameterResolver; +import org.bitrepository.bitrepositoryelements.*; +import org.bitrepository.bitrepositorymessages.*; import org.bitrepository.client.DefaultFixtureClientTest; import org.bitrepository.client.TestEventHandler; import org.bitrepository.client.eventhandler.OperationEvent; @@ -46,13 +39,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.net.URL; import java.nio.charset.StandardCharsets; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +@ExtendWith(SuiteInfoParameterResolver.class) public class ReplaceFileClientComponentTest extends DefaultFixtureClientTest { private ChecksumSpecTYPE DEFAULT_CHECKSUM_SPEC; private ChecksumDataForFileTYPE DEFAULT_OLD_CHECKSUM_DATA; @@ -90,7 +87,7 @@ public void replaceClientTester() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); ReplaceFileClient replaceClient = createReplaceFileClient(); ChecksumSpecTYPE checksumRequest = new ChecksumSpecTYPE(); checksumRequest.setChecksumType(ChecksumType.SHA1); @@ -168,7 +165,7 @@ public void replaceClientIdentificationTimeout() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); settingsForCUT.getRepositorySettings().getClientSettings() .setIdentificationTimeoutDuration(datatypeFactory.newDuration(100)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); ReplaceFileClient replaceClient = createReplaceFileClient(); ChecksumSpecTYPE checksumRequest = new ChecksumSpecTYPE(); checksumRequest.setChecksumType(ChecksumType.SHA1); @@ -204,7 +201,7 @@ public void replaceClientOperationTimeout() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); settingsForCUT.getRepositorySettings().getClientSettings() .setOperationTimeoutDuration(datatypeFactory.newDuration(100)); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); ReplaceFileClient replaceClient = createReplaceFileClient(); ChecksumSpecTYPE checksumRequest = new ChecksumSpecTYPE(); @@ -254,7 +251,7 @@ public void replaceClientPillarFailed() throws Exception { settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().add(PILLAR1_ID); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); ReplaceFileClient replaceClient = createReplaceFileClient(); ChecksumSpecTYPE checksumRequest = new ChecksumSpecTYPE(); @@ -309,7 +306,7 @@ public void saltedReturnChecksumsForNewFileWithChecksumPillar() throws Exception addDescription("Tests that the ReplaceClient handles the presence of a ChecksumPillar correctly, " + "when a salted return checksum (which a checksum pillar can't provide) is requested for the new file."); - TestEventHandler testEventHandler = new TestEventHandler(testEventManager); + TestEventHandler testEventHandler = new TestEventHandler(); ReplaceFileClient replaceClient = createReplaceFileClient(); addStep("Call replaceFile while requesting a salted checksum to be returned.", @@ -353,8 +350,7 @@ public void saltedReturnChecksumsForNewFileWithChecksumPillar() throws Exception */ private ReplaceFileClient createReplaceFileClient() { return new ReplaceFileClientTestWrapper(new ConversationBasedReplaceFileClient( - messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID()), - testEventManager); + messageBus, conversationMediator, settingsForCUT, settingsForTestClient.getComponentID())); } private ChecksumDataForFileTYPE createChecksumData(String checksum) { diff --git a/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientTestWrapper.java b/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientTestWrapper.java index a7a92a208..f8f9b0020 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientTestWrapper.java +++ b/bitrepository-client/src/test/java/org/bitrepository/modify/replacefile/ReplaceFileClientTestWrapper.java @@ -24,10 +24,10 @@ */ package org.bitrepository.modify.replacefile; +import io.qameta.allure.Allure; import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.client.eventhandler.EventHandler; -import org.jaccept.TestEventManager; import java.net.URL; @@ -37,31 +37,34 @@ public class ReplaceFileClientTestWrapper implements ReplaceFileClient { /** The PutClient to wrap. */ private final ReplaceFileClient wrappedReplaceClient; - /** The manager to monitor the operations.*/ - private final TestEventManager testEventManager; /** * @param putClientInstance The instance to wrap and monitor. - * @param eventManager The manager to monitor the operations. */ - public ReplaceFileClientTestWrapper(ReplaceFileClient putClientInstance, TestEventManager eventManager) { + public ReplaceFileClientTestWrapper(ReplaceFileClient putClientInstance) { this.wrappedReplaceClient = putClientInstance; - this.testEventManager = eventManager; } @Override public void replaceFile(String collectionID, String fileID, String pillarID, ChecksumDataForFileTYPE checksumForDeleteAtPillar, - ChecksumSpecTYPE checksumRequestedForDeletedFile, URL url, long sizeOfNewFile, - ChecksumDataForFileTYPE checksumForNewFileValidationAtPillar, ChecksumSpecTYPE checksumRequestsForNewFile, - EventHandler eventHandler, String auditTrailInformation) { - testEventManager.addStimuli("replaceFile(" + fileID + ", " + pillarID + ", " + checksumForDeleteAtPillar + ", " - + checksumRequestedForDeletedFile + ", " + url + ", " + sizeOfNewFile + ", " - + checksumForNewFileValidationAtPillar + ", " + checksumRequestsForNewFile + ", " + eventHandler + ", " - + auditTrailInformation); - wrappedReplaceClient.replaceFile(collectionID, fileID, pillarID, checksumForDeleteAtPillar, - checksumRequestedForDeletedFile, - url, sizeOfNewFile, checksumForNewFileValidationAtPillar, checksumRequestsForNewFile, eventHandler, - auditTrailInformation); + ChecksumSpecTYPE checksumRequestedForDeletedFile, URL url, long sizeOfNewFile, + ChecksumDataForFileTYPE checksumForNewFileValidationAtPillar, ChecksumSpecTYPE checksumRequestsForNewFile, + EventHandler eventHandler, String auditTrailInformation) { + String stepName = "Calling replaceFile for: " + fileID; + StringBuilder details = new StringBuilder(); + details.append("Collection: ").append(collectionID).append("\n") + .append("Pillar: ").append(pillarID).append("\n") + .append("URL: ").append(url).append("\n") + .append("New Size: ").append(sizeOfNewFile).append("\n") + .append("Audit Info: ").append(auditTrailInformation); + + Allure.step(stepName, () -> { + Allure.addAttachment("Replace Request Parameters", details.toString()); + wrappedReplaceClient.replaceFile(collectionID, fileID, pillarID, checksumForDeleteAtPillar, + checksumRequestedForDeletedFile, + url, sizeOfNewFile, checksumForNewFileValidationAtPillar, checksumRequestsForNewFile, eventHandler, + auditTrailInformation); + }); } } diff --git a/bitrepository-core/src/test/java/org/bitrepository/SuiteInfoParameterResolver.java b/bitrepository-core/src/test/java/org/bitrepository/SuiteInfoParameterResolver.java new file mode 100644 index 000000000..6aad249cf --- /dev/null +++ b/bitrepository-core/src/test/java/org/bitrepository/SuiteInfoParameterResolver.java @@ -0,0 +1,48 @@ +package org.bitrepository; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.ParameterContext; +import org.junit.jupiter.api.extension.ParameterResolutionException; +import org.junit.jupiter.api.extension.ParameterResolver; + +import java.lang.reflect.Method; +import java.util.Optional; +import java.util.Set; + +public class SuiteInfoParameterResolver implements ParameterResolver { + + @Override + public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return parameterContext.getParameter().getType() == SuiteInfo.class; + } + + @Override + public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext) throws ParameterResolutionException { + return new SuiteInfo() { + @Override + public Optional getPillarType() { + return Optional.empty(); + } + + @Override + public String getDisplayName() { + return extensionContext.getDisplayName(); + } + + @Override + public Set getTags() { + return extensionContext.getTags(); + } + + @Override + public Optional> getTestClass() { + return extensionContext.getTestClass(); + } + + @Override + public Optional getTestMethod() { + return extensionContext.getTestMethod(); + } + }; + } +} \ No newline at end of file diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/ArgumentValidatorTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/ArgumentValidatorTest.java index f5380743b..8390d50a7 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/ArgumentValidatorTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/ArgumentValidatorTest.java @@ -5,23 +5,22 @@ * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% */ package org.bitrepository.common; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -30,7 +29,10 @@ import java.util.HashSet; import java.util.List; -public class ArgumentValidatorTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class ArgumentValidatorTest { @Test @Tag("regressiontest") public void testArgumentValidatorObject() throws Exception { @@ -44,9 +46,9 @@ public void testArgumentValidatorObject() throws Exception { // expected } } - + @Test - @Tag("regressiontest" ) + @Tag("regressiontest") public void testArgumentValidatorString() throws Exception { addDescription("Test the argument validator for arguments for strings"); addStep("Test empty string", "Should only throw an exception when the string is null or empty"); @@ -66,7 +68,7 @@ public void testArgumentValidatorString() throws Exception { } @Test - @Tag("regressiontest" ) + @Tag("regressiontest") public void testArgumentValidatorInteger() throws Exception { addDescription("Test the argument validator for arguments for integers"); addStep("Test not negative", "Should only throw an exception if the integer is negative"); @@ -77,7 +79,7 @@ public void testArgumentValidatorInteger() throws Exception { } catch (IllegalArgumentException e) { // expected } - + addStep("Test positive", "Should only throw an exception if the integer is not positive"); ArgumentValidator.checkPositive(1, "No exception expected."); try { @@ -106,7 +108,7 @@ public void testArgumentValidatorLong() throws Exception { } catch (IllegalArgumentException e) { // expected } - + addStep("Test positive", "Should only throw an exception if the long is not positive"); ArgumentValidator.checkPositive(1L, "No exception expected."); try { @@ -122,9 +124,9 @@ public void testArgumentValidatorLong() throws Exception { // expected } } - + @Test - @Tag("regressiontest" ) + @Tag("regressiontest") public void testArgumentValidatorCollection() throws Exception { addDescription("Test the argument validator for arguments for collections"); addStep("Check against null or empty collection", "Should throw exception exception when non-empty collection"); @@ -142,9 +144,9 @@ public void testArgumentValidatorCollection() throws Exception { } ArgumentValidator.checkNotNullOrEmpty(List.of("NO FAILURE"), "No exception expected."); } - + @Test - @Tag("regressiontest" ) + @Tag("regressiontest") public void testArgumentValidatorArrays() throws Exception { addDescription("Test the argument validator for arguments for arrays"); addStep("Check against null or empty arrays", "Should throw exception exception when non-empty array"); diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/exception/UnableToFinishExceptionTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/exception/UnableToFinishExceptionTest.java index 6cade7fe5..e1b005990 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/exception/UnableToFinishExceptionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/exception/UnableToFinishExceptionTest.java @@ -22,12 +22,15 @@ package org.bitrepository.common.exception; import org.bitrepository.common.exceptions.UnableToFinishException; -import org.jaccept.structure.ExtendedTestCase; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class UnableToFinishExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class UnableToFinishExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsLoaderTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsLoaderTest.java index 162b58701..c4f5d2576 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsLoaderTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsLoaderTest.java @@ -24,16 +24,13 @@ */ package org.bitrepository.common.settings; -import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.List; -import static java.util.List.of; -import static org.junit.jupiter.api.Assertions.assertEquals; - -public class SettingsLoaderTest extends ExtendedTestCase { +public class SettingsLoaderTest { private static final String PATH_TO_SETTINGS = "settings/xml/bitrepository-devel"; private static final String PATH_TO_EXAMPLE_SETTINGS = "examples/settings"; @@ -44,8 +41,8 @@ public void testDevelopmentCollectionSettingsLoading() { new SettingsProvider(new XMLFileSettingsLoader(PATH_TO_SETTINGS), getClass().getSimpleName()); Settings settings = settingsLoader.getSettings(); - List expectedPillarIDs = of("Pillar1", "Pillar2"); - assertEquals(expectedPillarIDs, settings.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID()); + List expectedPillarIDs = List.of("Pillar1", "Pillar2"); + Assertions.assertEquals(expectedPillarIDs, settings.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID()); } @Test diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsTest.java index 47d087d85..5acf51dbf 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/settings/SettingsTest.java @@ -1,6 +1,5 @@ package org.bitrepository.common.settings; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -11,7 +10,11 @@ import java.math.BigInteger; import java.time.Duration; -public class SettingsTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.junit.jupiter.api.Assertions.assertThrows; + +public class SettingsTest { private DatatypeFactory factory; diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/settings/XMLFileSettingsLoaderTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/settings/XMLFileSettingsLoaderTest.java index 528799d11..1bd2e74f7 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/settings/XMLFileSettingsLoaderTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/settings/XMLFileSettingsLoaderTest.java @@ -25,12 +25,11 @@ package org.bitrepository.common.settings; import org.bitrepository.settings.repositorysettings.RepositorySettings; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class XMLFileSettingsLoaderTest extends ExtendedTestCase{ +public class XMLFileSettingsLoaderTest{ private static final String PATH_TO_SETTINGS = "settings/xml/bitrepository-devel"; @Test diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/AllureEventLogger.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/AllureEventLogger.java new file mode 100644 index 000000000..aa404c70b --- /dev/null +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/AllureEventLogger.java @@ -0,0 +1,200 @@ +package org.bitrepository.common.utils; + +import com.google.gson.Gson; +import io.qameta.allure.Allure; +import io.qameta.allure.model.Status; +import org.bitrepository.protocol.utils.BitrepositoryEvent; + +import java.time.Duration; +import java.time.Instant; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.stream.Collectors; + +import static org.bitrepository.common.utils.AllureTestUtils.isTestRunning; + +public class AllureEventLogger { + private final List events = new CopyOnWriteArrayList<>(); + private final String componentName; + private static final Gson gson = new Gson(); + + public AllureEventLogger(String componentName) { + this.componentName = componentName; + allureStep("Initialize event logger for: " + componentName); + } + + /** + * Safely execute Allure step only if test context is active + */ + private void allureStep(String stepName) { + if (isTestRunning()) { + Allure.step(stepName); + } + } + + /** + * Safely execute Allure step with status only if test context is active + */ + private void allureStep(String stepName, Status status) { + if (isTestRunning()) { + Allure.step(stepName, status); + } + } + + /** + * Safely add attachment only if test context is active + */ + private void allureAttachment(String name, String type, String content, String fileExtension) { + if (isTestRunning()) { + Allure.addAttachment(name, type, content, fileExtension); + } + } + + /** + * Safely add attachment only if test context is active + */ + private void allureAttachment(String name, String type, String content) { + if (isTestRunning()) { + Allure.addAttachment(name, type, content); + } + } + + /** + * Log an event (replaces TestEventHandler's event capturing) + */ + public void logEvent(BitrepositoryEvent event) { + allureStep("Event received: " + event.getType()); + events.add(event); + + allureAttachment( + String.format(Locale.ROOT, "[%s] Event: %s", componentName, event.getType()), + "application/json", + gson.toJson(Map.of( + "type", event.getType(), + "timestamp", event.getTimestamp(), + "data", event.getData() + )), + ".json" + ); + } + + /** + * Wait for a specific event (replaces TestEventHandler.waitForEvent) + */ + public BitrepositoryEvent waitForEvent(String eventType, Duration timeout) { + allureStep(String.format(Locale.ROOT, "Waiting for event: %s (timeout: %ds)", eventType, timeout.getSeconds())); + Instant deadline = Instant.now().plus(timeout); + + while (Instant.now().isBefore(deadline)) { + BitrepositoryEvent event = findEvent(eventType); + if (event != null) { + allureStep( + String.format(Locale.ROOT, "✓ Event '%s' received after %dms", + eventType, + Duration.between(event.getTimestamp(), Instant.now()).toMillis()), + Status.PASSED + ); + return event; + } + + try { + Thread.sleep(100); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException("Interrupted while waiting for event", e); + } + } + + // Event not received - fail with detailed info + String capturedEvents = events.isEmpty() + ? "No events captured" + : "Captured events: " + events.stream() + .map(BitrepositoryEvent::getType) + .reduce((a, b) -> a + ", " + b) + .orElse(""); + + allureStep( + String.format(Locale.ROOT, "✗ Timeout waiting for '%s'. %s", eventType, capturedEvents), + Status.FAILED + ); + + throw new AssertionError( + String.format(Locale.ROOT, "Event '%s' not received within %ds. %s", + eventType, timeout.getSeconds(), capturedEvents) + ); + } + + /** + * Check if event was received (replaces TestEventHandler.receivedEvent) + */ + public boolean receivedEvent(String eventType) { + allureStep("Verify event received: " + eventType); + boolean received = findEvent(eventType) != null; + + if (received) { + allureStep("✓ Event '" + eventType + "' was received", Status.PASSED); + } else { + allureStep("✗ Event '" + eventType + "' was NOT received", Status.FAILED); + } + + return received; + } + + /** + * Get all events of a specific type + */ + public List getEvents(String eventType) { + return events.stream() + .filter(e -> e.getType().equals(eventType)) + .collect(Collectors.toList()); + } + + /** + * Get all captured events + */ + public List getAllEvents() { + return List.copyOf(events); + } + + /** + * Clear all captured events + */ + public void clear() { + allureStep("Clear event log for " + componentName); + events.clear(); + } + + private BitrepositoryEvent findEvent(String eventType) { + return events.stream() + .filter(e -> e.getType().equals(eventType)) + .findFirst() + .orElse(null); + } + + /** + * Attach event summary to Allure report + */ + public void attachEventSummary() { + allureStep("Generate event summary"); + + if (events.isEmpty()) { + allureAttachment("Event Summary", "text/plain", "No events captured"); + return; + } + + StringBuilder summary = new StringBuilder(); + summary.append(String.format(Locale.ROOT, "Total events: %d\n\n", events.size())); + + for (int i = 0; i < events.size(); i++) { + BitrepositoryEvent event = events.get(i); + summary.append(String.format(Locale.ROOT, "%d. [%s] %s\n", + i + 1, + event.getTimestamp(), + event.getType())); + } + + allureAttachment("Event Summary", "text/plain", summary.toString()); + } +} diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/AllureTestUtils.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/AllureTestUtils.java new file mode 100644 index 000000000..e0a0c4497 --- /dev/null +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/AllureTestUtils.java @@ -0,0 +1,108 @@ +package org.bitrepository.common.utils; + +import io.qameta.allure.Allure; + +public class AllureTestUtils { + + /** + * Check if we're inside an active test context + */ + public static boolean isTestRunning() { + try { + Allure.getLifecycle().getCurrentTestCase(); + return true; + } catch (IllegalStateException e) { + return false; + } + } + + /** + * Add a description to the current test + */ + public static void addDescription(String description) { + if (isTestRunning()) { + Allure.description(description); + } + } + + /** + * Add a test step with expected result + */ + public static void addStep(String stepDescription, String expectedResult) { + if (!isTestRunning()) return; + Allure.step(stepDescription, () -> { + Allure.addAttachment("Expected Result", "text/plain", expectedResult); + }); + } + + /** + * Add a fixture/setup description + */ + public static void addFixture(String fixtureDescription) { + if (!isTestRunning()) return; + Allure.step("Fixture: " + fixtureDescription, () -> { + Allure.step("Setup: " + fixtureDescription); + }); + } + + /** + * Add a reference + */ + public static void addReference(String reference) { + if (!isTestRunning()) return; + if (reference.contains("BITMAG-")) { + int startIdx = reference.indexOf("BITMAG-"); + int endIdx = reference.indexOf(">", startIdx); + if (endIdx > startIdx) { + String jiraIssue = reference.substring(startIdx, endIdx); + Allure.link(jiraIssue, "https://sbforge.org/jira/browse/" + jiraIssue); + } + } + Allure.addAttachment("Reference", "text/html", reference); + } + + /** + * Add a step that executes code + */ + public static T addStep(String stepDescription, StepBody body) { + handleStepRunning(body); + return Allure.step(stepDescription, body::execute); + } + + private static void handleStepRunning(StepBody body) { + if (!isTestRunning()) { + try { + body.execute(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } + + /** + * Add a step that executes code with expected result documentation + */ + public static T addStep(String stepDescription, String expectedResult, StepBody body) { + handleStepRunning(body); + return Allure.step(stepDescription, () -> { + Allure.addAttachment("Expected Result", "text/plain", expectedResult); + return body.execute(); + }); + } + + /** + * Functional interface for steps that return a value + */ + @FunctionalInterface + public interface StepBody { + T execute() throws Exception; + } + + /** + * Functional interface for steps that don't return a value + */ + @FunctionalInterface + public interface VoidStepBody { + void execute() throws Exception; + } +} diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/Base16UtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/Base16UtilsTest.java index 70a9d1330..625cef032 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/Base16UtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/Base16UtilsTest.java @@ -22,15 +22,17 @@ package org.bitrepository.common.utils; import org.apache.commons.codec.DecoderException; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Utility class for handling encoding and decoding of base64 bytes. */ -public class Base16UtilsTest extends ExtendedTestCase { +public class Base16UtilsTest { private final String DECODED_CHECKSUM = "ff5aca7ae8c80c9a3aeaf9173e4dfd27"; private final byte[] ENCODED_CHECKSUM = diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/CalendarUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/CalendarUtilsTest.java index d24bfffda..a4537d41b 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/CalendarUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/CalendarUtilsTest.java @@ -21,10 +21,9 @@ */ package org.bitrepository.common.utils; -import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Assertions; import javax.xml.datatype.XMLGregorianCalendar; import java.text.ParseException; @@ -34,7 +33,10 @@ import java.util.Locale; import java.util.TimeZone; -public class CalendarUtilsTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class CalendarUtilsTest { long DATE_IN_MILLIS = 123456789L; @Test diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/ChecksumUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/ChecksumUtilsTest.java index 0e3d1a50b..61abca071 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/ChecksumUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/ChecksumUtilsTest.java @@ -28,7 +28,6 @@ import org.bitrepository.bitrepositoryelements.ChecksumType; import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -39,7 +38,10 @@ import java.nio.charset.StandardCharsets; import java.security.NoSuchAlgorithmException; -public class ChecksumUtilsTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class ChecksumUtilsTest { @Test @Tag("regressiontest") public void calculateHmacChecksums() throws Exception { diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDUtilsTest.java index 9974d3309..0b648b818 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDUtilsTest.java @@ -22,12 +22,14 @@ package org.bitrepository.common.utils; import org.bitrepository.bitrepositoryelements.FileIDs; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class FileIDUtilsTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class FileIDUtilsTest { String FILE_ID = "Test-File-Id"; @Test diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDValidatorTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDValidatorTest.java index bda9137da..b03dc87aa 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDValidatorTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileIDValidatorTest.java @@ -23,18 +23,18 @@ import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class FileIDValidatorTest extends ExtendedTestCase { - /** - * The settings for the tests. Should be instantiated in the setup. - */ +public class FileIDValidatorTest { + /** The settings for the tests. Should be instantiated in the setup.*/ Settings settings; @BeforeAll @@ -119,7 +119,6 @@ public void badRegexTest() throws Exception { validator = new TestFileIDValidator(settings); Assertions.assertNull(validator.getRegex()); } - private class TestFileIDValidator extends FileIDValidator { public TestFileIDValidator(Settings settings) { diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileUtilsTest.java index 5e27b58ab..70ff86654 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/FileUtilsTest.java @@ -22,13 +22,19 @@ package org.bitrepository.common.utils; import org.apache.activemq.util.ByteArrayInputStream; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.File; import java.nio.charset.StandardCharsets; -public class FileUtilsTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class FileUtilsTest { String DIR = "test-directory"; String directory = "test-directory"; String subDirectory = "sub-directory"; String testFileName = "test.file.name"; diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/ResponseInfoUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/ResponseInfoUtilsTest.java index 3f20050fe..edb4ac173 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/ResponseInfoUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/ResponseInfoUtilsTest.java @@ -21,15 +21,17 @@ */ package org.bitrepository.common.utils; -import org.bitrepository.bitrepositoryelements.ResponseInfo; import org.bitrepository.bitrepositoryelements.ResponseCode; -import org.jaccept.structure.ExtendedTestCase; +import org.bitrepository.bitrepositoryelements.ResponseInfo; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + -public class ResponseInfoUtilsTest extends ExtendedTestCase { +public class ResponseInfoUtilsTest { @Test @Tag("regressiontest") public void responseInfoTester() throws Exception { diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/StreamUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/StreamUtilsTest.java index d45750377..7fdd07c8f 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/StreamUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/StreamUtilsTest.java @@ -22,15 +22,18 @@ package org.bitrepository.common.utils; import org.apache.activemq.util.ByteArrayInputStream; -import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.Assertions; + import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; -public class StreamUtilsTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class StreamUtilsTest { String DATA = "The data for the streams."; @Test diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeMeasurementUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeMeasurementUtilsTest.java index 0fc14dcfe..8341d76f2 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeMeasurementUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeMeasurementUtilsTest.java @@ -25,18 +25,19 @@ package org.bitrepository.common.utils; import org.bitrepository.bitrepositoryelements.TimeMeasureTYPE; -import org.jaccept.structure.ExtendedTestCase; +import org.bitrepository.bitrepositoryelements.TimeMeasureUnit; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.bitrepository.bitrepositoryelements.TimeMeasureUnit; import java.math.BigInteger; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; + /** * Tests the TimeMeasureComparator class. */ -public class TimeMeasurementUtilsTest extends ExtendedTestCase { +public class TimeMeasurementUtilsTest { @Test @Tag("regressiontest") public void testCompareMilliSeconds() { diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeUtilsTest.java index a56e86cf2..461a355c0 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/TimeUtilsTest.java @@ -21,7 +21,6 @@ */ package org.bitrepository.common.utils; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -35,8 +34,12 @@ import java.util.Locale; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; -public class TimeUtilsTest extends ExtendedTestCase { +public class TimeUtilsTest { private static final ZonedDateTime BASE = Instant.EPOCH.atZone(ZoneOffset.UTC); @Test diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/utils/XmlUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/utils/XmlUtilsTest.java index 6f27771ad..fee5631d2 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/utils/XmlUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/utils/XmlUtilsTest.java @@ -2,7 +2,6 @@ import org.bitrepository.bitrepositoryelements.TimeMeasureTYPE; import org.bitrepository.bitrepositoryelements.TimeMeasureUnit; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -13,8 +12,11 @@ import java.math.BigInteger; import java.time.Duration; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.junit.jupiter.api.Assertions.assertThrows; -public class XmlUtilsTest extends ExtendedTestCase { +public class XmlUtilsTest { private DatatypeFactory factory; diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java index 2b2b6fe18..5d89964c9 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java @@ -26,8 +26,8 @@ import ch.qos.logback.classic.LoggerContext; import ch.qos.logback.core.util.StatusPrinter; -import org.bitrepository.ExtendedTestInfoParameterResolver; import org.bitrepository.SuiteInfo; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.common.utils.SettingsUtils; @@ -41,8 +41,7 @@ import org.bitrepository.protocol.messagebus.SimpleMessageBus; import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; -import org.jaccept.TestEventManager; -import org.jaccept.structure.ExtendedTestCase; +import org.bitrepository.protocol.utils.TestWatcherExtension; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.RegisterExtension; @@ -51,16 +50,11 @@ import javax.jms.JMSException; import java.net.MalformedURLException; import java.net.URL; -import org.bitrepository.protocol.utils.TestWatcherExtension; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.TestInfo; -import org.junit.jupiter.api.extension.ExtendWith; -import org.junit.jupiter.api.extension.TestWatcher; +import java.util.List; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@ExtendWith(ExtendedTestInfoParameterResolver.class) -public abstract class IntegrationTest extends ExtendedTestCase { - protected static TestEventManager testEventManager = TestEventManager.getInstance(); +@ExtendWith(SuiteInfoParameterResolver.class) +public abstract class IntegrationTest { public static LocalActiveMQBroker broker; public static EmbeddedHttpServer server; public static HttpServerConfiguration httpServerConfiguration; @@ -110,7 +104,7 @@ public void initializeSuite(SuiteInfo testInfo) { * super.registerReceivers() when overriding */ protected void registerMessageReceivers() { - alarmReceiver = new MessageReceiver(settingsForCUT.getAlarmDestination(), testEventManager); + alarmReceiver = new MessageReceiver(settingsForCUT.getAlarmDestination()); addReceiver(alarmReceiver); } @@ -195,7 +189,6 @@ protected void setupSettings() { makeUserSpecificSettings(settingsForTestClient); } - protected Settings loadSettings(String componentID) { return TestSettingsProvider.reloadSettings(componentID); } @@ -301,4 +294,4 @@ protected String createDate() { protected SecurityManager createSecurityManager() { return new DummySecurityManager(); } -} +} \ No newline at end of file diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/MessageCreationTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/MessageCreationTest.java index 1911bd7a6..b581ff259 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/MessageCreationTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/MessageCreationTest.java @@ -30,7 +30,6 @@ import org.bitrepository.bitrepositorymessages.GetChecksumsFinalResponse; import org.bitrepository.common.JaxbHelper; import org.bitrepository.protocol.message.ExampleMessageFactory; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.w3c.dom.Document; @@ -49,13 +48,15 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertThrows; /** * Test whether we are able to create message objects from xml. The input XML is the example code defined in the * message-xml, thereby also testing whether this is valid. * */ -public class MessageCreationTest extends ExtendedTestCase { +public class MessageCreationTest { @Test @Tag("regressiontest") public void messageCreationTest() throws Exception { diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/ActiveMQMessageBusTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/ActiveMQMessageBusTest.java index 8b117d8cd..fef8b1d64 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/ActiveMQMessageBusTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/ActiveMQMessageBusTest.java @@ -38,6 +38,10 @@ import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Runs the GeneralMessageBusTest using a LocalActiveMQBroker (if useEmbeddedMessageBus is true) and a suitable @@ -53,7 +57,8 @@ protected void setupMessageBus() { broker.start(); } messageBus = new MessageBusWrapper(ProtocolComponentFactory.getInstance().getMessageBus( - settingsForTestClient, securityManager), testEventManager); + settingsForTestClient, securityManager)); + } @Test diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/GeneralMessageBusTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/GeneralMessageBusTest.java index 60d4d2417..83ec580b2 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/GeneralMessageBusTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/GeneralMessageBusTest.java @@ -24,26 +24,31 @@ */ package org.bitrepository.protocol.bus; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositorymessages.AlarmMessage; import org.bitrepository.protocol.IntegrationTest; import org.bitrepository.protocol.message.ExampleMessageFactory; -import org.jaccept.TestEventManager; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Class for testing the interface with the message bus. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class GeneralMessageBusTest extends IntegrationTest { protected static MessageReceiver collectionReceiver; @Override protected void registerMessageReceivers() { super.registerMessageReceivers(); - collectionReceiver = new MessageReceiver(settingsForCUT.getCollectionDestination(), testEventManager); + collectionReceiver = new MessageReceiver(settingsForCUT.getCollectionDestination()); addReceiver(collectionReceiver); } @@ -75,14 +80,13 @@ public final void busActivityTest() throws Exception { @Tag("regressiontest") public final void twoListenersForTopicTest() throws Exception { addDescription("Verifies that two listeners on the same topic both receive the message"); - TestEventManager testEventManager = TestEventManager.getInstance(); addStep("Make a connection to the message bus and add two listeners", "No exceptions should be thrown"); - MessageReceiver receiver1 = new MessageReceiver(alarmDestinationID, testEventManager); + MessageReceiver receiver1 = new MessageReceiver(alarmDestinationID); addReceiver(receiver1); messageBus.addListener(receiver1.getDestination(), receiver1.getMessageListener()); - MessageReceiver receiver2 = new MessageReceiver(alarmDestinationID, testEventManager); + MessageReceiver receiver2 = new MessageReceiver(alarmDestinationID); addReceiver(receiver2); messageBus.addListener(receiver2.getDestination(), receiver2.getMessageListener()); diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageBusWrapper.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageBusWrapper.java index 0592da9e7..43f112df1 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageBusWrapper.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageBusWrapper.java @@ -27,25 +27,30 @@ import org.bitrepository.bitrepositorymessages.Message; import org.bitrepository.protocol.messagebus.MessageBus; import org.bitrepository.protocol.messagebus.MessageListener; -import org.jaccept.TestEventManager; + import javax.jms.JMSException; import java.util.List; public class MessageBusWrapper implements MessageBus { private final MessageBus messageBus; - private final TestEventManager testEventManager; + - public MessageBusWrapper(MessageBus messageBus, TestEventManager testEventManager) { + public MessageBusWrapper(MessageBus messageBus) { super(); this.messageBus = messageBus; - this.testEventManager = testEventManager; } @Override public void sendMessage(Message content) { - testEventManager.addStimuli("Sending message: " + content); - messageBus.sendMessage(content); + if (io.qameta.allure.Allure.getLifecycle().getCurrentTestCase().isPresent()) { + io.qameta.allure.Allure.step("Sending message: " + content.getClass().getSimpleName(), () -> { + io.qameta.allure.Allure.addAttachment("Message Content", content.toString()); + messageBus.sendMessage(content); + }); + } else { + messageBus.sendMessage(content); + } } @Override diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageReceiver.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageReceiver.java index 530e29914..2f44293fa 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageReceiver.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MessageReceiver.java @@ -27,7 +27,7 @@ import org.bitrepository.bitrepositorymessages.Message; import org.bitrepository.protocol.MessageContext; import org.bitrepository.protocol.messagebus.MessageListener; -import org.jaccept.TestEventManager; + import org.junit.jupiter.api.Assertions; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -65,15 +65,14 @@ public class MessageReceiver { private final MessageModel messageModel = new MessageModel(); private final String destination; private final MessageListener messageListener; - private final TestEventManager testEventManager; + /** * @param destination The destination to use for the receiver. Primarily used for logging purposes. - * @param testEventManager The test event manager to use for */ - public MessageReceiver(String destination, TestEventManager testEventManager) { + public MessageReceiver(String destination) { this.destination = destination; - this.testEventManager = testEventManager; + messageListener = new TestMessageHandler(); } @@ -153,7 +152,6 @@ public void checkNoMessagesRemain() { } if (outstandingMessages.length() > 0 ) { String info = "The following messages haven't been handled by the testcase: " + outstandingMessages; - testEventManager.addResult(info); log.warn(info); } } @@ -176,9 +174,6 @@ private class MessageModel { private void addMessage(T message) { if (pillarFilter != null && !pillarFilter.contains(((Message)message).getFrom())) return; - if(testEventManager != null) { - testEventManager.addResult("Received message on " + getDestination() + " : " + message); - } @SuppressWarnings("unchecked") BlockingQueue queue = (BlockingQueue)getMessageQueue(message.getClass()); queue.add(message); diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MultiThreadedMessageBusTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MultiThreadedMessageBusTest.java index 53c64626d..78ea30685 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MultiThreadedMessageBusTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/bus/MultiThreadedMessageBusTest.java @@ -29,20 +29,26 @@ import org.bitrepository.protocol.IntegrationTest; import org.bitrepository.protocol.MessageContext; import org.bitrepository.protocol.ProtocolComponentFactory; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.protocol.message.ExampleMessageFactory; import org.bitrepository.protocol.messagebus.MessageListener; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Class for testing the interface with the message bus. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class MultiThreadedMessageBusTest extends IntegrationTest { /** * The time to wait when sending a message before it definitely should @@ -61,7 +67,7 @@ protected void setupMessageBus() { broker.start(); } messageBus = new MessageBusWrapper(ProtocolComponentFactory.getInstance().getMessageBus( - settingsForTestClient, securityManager), testEventManager); + settingsForTestClient, securityManager)); } diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/HttpServerConnector.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/HttpServerConnector.java index 52ac4ae17..1c0b88136 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/HttpServerConnector.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/HttpServerConnector.java @@ -24,7 +24,7 @@ */ package org.bitrepository.protocol.fileexchange; -import org.jaccept.TestEventManager; + import java.io.File; import java.net.MalformedURLException; @@ -41,7 +41,7 @@ public class HttpServerConnector { /** The configuration for the file exchange.*/ private final HttpServerConfiguration config; - private final TestEventManager testEventManager; + public static final String TEMP_DOWNLOADED_FILES_ROOT = "target/temp-download-dir"; private final String tempDownloadedFilesDir; @@ -50,9 +50,9 @@ public class HttpServerConnector { * * @param config The configuration for file exchange. */ - public HttpServerConnector(HttpServerConfiguration config, TestEventManager testEventManager) { + public HttpServerConnector(HttpServerConfiguration config) { this.config = config; - this.testEventManager = testEventManager; + tempDownloadedFilesDir = TEMP_DOWNLOADED_FILES_ROOT + File.separator + config.getHttpServerName(); File tempDownloadedFilesDirHandle = new File(tempDownloadedFilesDir); tempDownloadedFilesDirHandle.delete(); diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/LocalFileExchangeTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/LocalFileExchangeTest.java index 5c229e9ef..85d78b9f4 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/LocalFileExchangeTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/fileexchange/LocalFileExchangeTest.java @@ -5,7 +5,6 @@ import org.bitrepository.protocol.LocalFileExchange; import org.bitrepository.settings.referencesettings.FileExchangeSettings; import org.fusesource.hawtbuf.ByteArrayInputStream; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Tag; @@ -27,7 +26,7 @@ import java.nio.file.Paths; @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class LocalFileExchangeTest extends ExtendedTestCase { +public class LocalFileExchangeTest { final static String BASE_FILE_EXCHANGE_DIR = "target/fileexchange/"; private FileExchange exchange; diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/http/HttpFileExchangeTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/http/HttpFileExchangeTest.java index f49ff09ae..acc776d05 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/http/HttpFileExchangeTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/http/HttpFileExchangeTest.java @@ -25,7 +25,6 @@ import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.settings.referencesettings.FileExchangeSettings; import org.bitrepository.settings.referencesettings.ProtocolType; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -34,7 +33,11 @@ import java.net.MalformedURLException; import java.net.URL; -public class HttpFileExchangeTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + + +public class HttpFileExchangeTest { @Test @Tag("regressiontest") public void checkUrlEncodingOfFilenamesTest() throws MalformedURLException { diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/messagebus/ReceivedMessageHandlerTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/messagebus/ReceivedMessageHandlerTest.java index 39a2a6cff..b4b2ea469 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/messagebus/ReceivedMessageHandlerTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/messagebus/ReceivedMessageHandlerTest.java @@ -28,19 +28,22 @@ import org.bitrepository.settings.referencesettings.MessageCategory; import org.bitrepository.settings.referencesettings.MessageThreadPool; import org.bitrepository.settings.referencesettings.MessageThreadPools; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.math.BigInteger; import java.util.Arrays; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addFixture; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; -public class ReceivedMessageHandlerTest extends ExtendedTestCase { + +public class ReceivedMessageHandlerTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusDelayTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusDelayTest.java index d5b83d6d6..8d9ed5b17 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusDelayTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusDelayTest.java @@ -30,9 +30,10 @@ import org.bitrepository.protocol.messagebus.MessageBusManager; import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; -import org.jaccept.TestEventManager; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.io.FileOutputStream; import java.nio.charset.StandardCharsets; @@ -42,11 +43,13 @@ import java.util.List; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class MessageBusDelayTest extends ExtendedTestCase { +public class MessageBusDelayTest { private Settings settings; private SecurityManager securityManager; - protected TestEventManager testEventManager = TestEventManager.getInstance(); private static final int PERFORMANCE_COUNT = 1000; private static final int NUMBER_OF_TESTS = 100; private static final boolean WRITE_RESULTS_TO_DISC = true; @@ -57,7 +60,6 @@ public void setup() { securityManager = new DummySecurityManager(); } - @Disabled("Temporarily disabled due to performance issues") @Test @Tag("StressTest") public void testManyTimes() { @@ -78,7 +80,7 @@ public void performStatisticalAnalysisOfMessageDelay() throws Exception { MessageBus messageBus = MessageBusManager.getMessageBus(settings, securityManager); MessageReceiver destinationReceiver; String destination = "DelayPerformanceTestDestination-" + new Date().getTime(); - destinationReceiver = new MessageReceiver("Performance test topic receiver", null); + destinationReceiver = new MessageReceiver("Performance test topic receiver"); messageBus.addListener(destination, destinationReceiver.getMessageListener()); List delayList = new ArrayList<>(PERFORMANCE_COUNT); diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfListenersStressTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfListenersStressTest.java index 216973632..5f65e903f 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfListenersStressTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfListenersStressTest.java @@ -38,7 +38,6 @@ import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -49,9 +48,11 @@ import java.io.IOException; import java.net.ServerSocket; import java.util.ArrayList; -import java.util.Date; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Stress testing of the messagebus. *

@@ -66,11 +67,7 @@ * This is controlled through the variables 'WRITE_RESULTS_TO_FILE', which deternimes whether to write to the file, and * 'OUTPUT_FILE_NAME' which is the name of the file to write the output results. */ -public class MessageBusNumberOfListenersStressTest extends ExtendedTestCase { - /** - * The queue name. - */ - private static String QUEUE = "TEST-LISTENERS"; +public class MessageBusNumberOfListenersStressTest { /** * The default time to wait for a simple communication. */ @@ -112,10 +109,12 @@ public class MessageBusNumberOfListenersStressTest extends ExtendedTestCase { */ private static boolean sendMoreMessages = true; private Settings settings; + private String testQueue; @BeforeEach public void initializeSettings() { settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); + testQueue = "TEST-LISTENERS-" + System.currentTimeMillis(); } /** @@ -130,7 +129,6 @@ public void testManyListenersOnLocalMessageBus() throws Exception { addDescription("Tests how many messages can be handled within a given timeframe when a given number of " + "listeners are receiving them."); addStep("Define constants", "This should not be possible to fail."); - QUEUE += "-" + (new Date()).getTime(); messageReceived = 0; idReached = -1; sendMoreMessages = true; @@ -138,7 +136,7 @@ public void testManyListenersOnLocalMessageBus() throws Exception { addStep("Define the message to send.", "Should retrieve the Alarm message from examples and set the To."); alarmMessage = ExampleMessageFactory.createMessage(AlarmMessage.class); - alarmMessage.setDestination(QUEUE); + alarmMessage.setDestination(testQueue); addStep("Make configuration for the messagebus.", "Both should be created."); settings.getRepositorySettings().getProtocolSettings().setMessageBusConfiguration( @@ -173,7 +171,6 @@ public void testManyListenersOnDistributedMessageBus() throws Exception { addDescription("Tests how many messages can be handled within a given timeframe when a given number of " + "listeners are receiving them."); addStep("Define constants", "This should not be possible to fail."); - QUEUE += "-" + (new Date()).getTime(); messageReceived = 0; idReached = -1; sendMoreMessages = true; @@ -181,7 +178,7 @@ public void testManyListenersOnDistributedMessageBus() throws Exception { addStep("Define the message to send.", "Should retrieve the Alarm message from examples and set the To."); alarmMessage = ExampleMessageFactory.createMessage(AlarmMessage.class); - alarmMessage.setDestination(QUEUE); + alarmMessage.setDestination(testQueue); addStep("Make configuration for the messagebus.", "Both should be created."); MessageBusConfiguration conf = new MessageBusConfiguration(); @@ -218,18 +215,16 @@ public void testListeners(MessageBusConfiguration conf, SecurityManager security addStep("Initialise the message listeners.", "Should be created and connected to the message bus."); for (int i = 0; i < NUMBER_OF_LISTENERS; i++) { - Settings listenerSettings = TestSettingsProvider.getSettings(getClass().getSimpleName()); + Settings listenerSettings = TestSettingsProvider.getSettings(getClass().getSimpleName() + i); listenerSettings.getRepositorySettings().getProtocolSettings().setMessageBusConfiguration(conf); - listeners.add(new NotificationMessageListener(listenerSettings, securityManager)); + listeners.add(new NotificationMessageListener(listenerSettings, securityManager, testQueue)); } addStep("Wait for setup", "We wait!"); - synchronized (this) { - try { - wait(DEFAULT_WAIT_TIME); - } catch (InterruptedException e) { - e.printStackTrace(); - } + try { + Thread.sleep(DEFAULT_WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); } @@ -238,23 +233,19 @@ public void testListeners(MessageBusConfiguration conf, SecurityManager security addStep("Wait for the timeframe on '" + TIME_FRAME + "' milliseconds.", "We wait!"); - synchronized (this) { - try { - wait(TIME_FRAME); - } catch (InterruptedException e) { - e.printStackTrace(); - } + try { + Thread.sleep(TIME_FRAME); + } catch (InterruptedException e) { + e.printStackTrace(); } addStep("Stop sending more messages and await all the messages to be received by all the listeners", "Should be Ok"); sendMoreMessages = false; - synchronized (this) { - try { - wait(DEFAULT_WAIT_TIME); - } catch (InterruptedException e) { - e.printStackTrace(); - } + try { + Thread.sleep(DEFAULT_WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); } addStep("Verifying the amount of message sent '" + idReached + "' has been received by all '" @@ -286,12 +277,10 @@ public void testListeners(MessageBusConfiguration conf, SecurityManager security } listeners.clear(); - synchronized (this) { - try { - wait(DEFAULT_WAIT_TIME); - } catch (InterruptedException e) { - e.printStackTrace(); - } + try { + Thread.sleep(DEFAULT_WAIT_TIME); + } catch (InterruptedException e) { + e.printStackTrace(); } } } @@ -349,24 +338,26 @@ private static class NotificationMessageListener implements MessageListener { * The amount of messages received. */ private int count; + private final String queueName; /** * Constructor. * * @param settings The configuration for defining the message bus. */ - public NotificationMessageListener(Settings settings, SecurityManager securityManager) { + public NotificationMessageListener(Settings settings, SecurityManager securityManager, String queueName) { this.bus = new ActiveMQMessageBus(settings, securityManager); this.count = 0; + this.queueName = queueName; - bus.addListener(QUEUE, this); + bus.addListener(queueName, this); } /** * Method for stopping interaction with the message listener. */ public void stop() { - bus.removeListener(QUEUE, this); + bus.removeListener(queueName, this); try { bus.close(); } catch (javax.jms.JMSException e) { diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfMessagesStressTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfMessagesStressTest.java index 52f4c3355..1a16cc500 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfMessagesStressTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusNumberOfMessagesStressTest.java @@ -38,18 +38,23 @@ import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.jms.JMSException; import java.io.IOException; import java.net.ServerSocket; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Stress testing of the messagebus. */ -public class MessageBusNumberOfMessagesStressTest extends ExtendedTestCase { +public class MessageBusNumberOfMessagesStressTest { /** * The name of the queue to send the messages. */ @@ -117,7 +122,6 @@ public void SendManyMessagesDistributed() throws Exception { * Tests the amount of messages send through a local messagebus. * It should be at least 20 per second. */ - @Disabled("Temporarily disabled due to performance issues in the message bus handling") @Test @Tag("StressTest") public void SendManyMessagesLocally() throws Exception { diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusSizeOfMessageStressTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusSizeOfMessageStressTest.java index b0e1f7475..7225db63d 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusSizeOfMessageStressTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusSizeOfMessageStressTest.java @@ -41,7 +41,6 @@ import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -51,13 +50,16 @@ import java.net.ServerSocket; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Stress testing of the messagebus. *

* The size is regulated by the 'BUFFER_TEXT' and the 'NUMBER_OF_REPEATS_OF_BUFFER_TEXT'. * Currently, the buffer text is 100 bytes, and it is repeated 100 times, thus generating a message of size 10 kB. */ -public class MessageBusSizeOfMessageStressTest extends ExtendedTestCase { +public class MessageBusSizeOfMessageStressTest { private static String QUEUE = "TEST-QUEUE"; private final long TIME_FRAME = 60000L; private Settings settings; diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusTimeToSendMessagesStressTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusTimeToSendMessagesStressTest.java index 8b9401cb2..6786c11a5 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusTimeToSendMessagesStressTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/performancetest/MessageBusTimeToSendMessagesStressTest.java @@ -38,7 +38,6 @@ import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -48,19 +47,16 @@ import java.net.ServerSocket; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Stress testing of the messagebus. */ -public class MessageBusTimeToSendMessagesStressTest extends ExtendedTestCase { - /** - * The time to wait when sending a message before it definitely should - * have been consumed by a listener. - */ +public class MessageBusTimeToSendMessagesStressTest { + /** The time to wait when sending a message before it definitely should + * have been consumed by a listener.*/ static final int TIME_FOR_MESSAGE_TRANSFER_WAIT = 500; - /** - * The name of the queue to send the messages. - */ - private static String QUEUE = "TEST-QUEUE"; /** * The number of messages to send. */ @@ -70,10 +66,12 @@ public class MessageBusTimeToSendMessagesStressTest extends ExtendedTestCase { */ private static Date startSending; private Settings settings; + private String testQueue; @BeforeEach public void initializeSettings() { settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); + testQueue = "TEST-QUEUE-" + System.currentTimeMillis(); } /** @@ -85,7 +83,6 @@ public void initializeSettings() { public void SendManyMessagesDistributed() { addDescription("Tests how fast a given number of messages can be handled."); addStep("Define constants", "This should not be possible to fail."); - QUEUE += "-" + (new Date()).getTime(); addStep("Make configuration for the messagebus.", "Both should be created."); MessageBusConfiguration conf = MessageBusConfigurationFactory.createDefaultConfiguration(); @@ -103,12 +100,10 @@ public void SendManyMessagesDistributed() { addStep("Sleep until the listeners have received all the messages.", "Should be sleeping."); while (!listener.isFinished()) { - synchronized (this) { - try { - wait(TIME_FOR_MESSAGE_TRANSFER_WAIT); - } catch (InterruptedException e) { - /* e.printStackTrace(); */ - } + try { + Thread.sleep(TIME_FOR_MESSAGE_TRANSFER_WAIT); + } catch (InterruptedException e) { + /* e.printStackTrace(); */ } } @@ -135,7 +130,6 @@ public void SendManyMessagesDistributed() { public void SendManyMessagesLocally() throws Exception { addDescription("Tests how many messages can be handled within a given timeframe."); addStep("Define constants", "This should not be possible to fail."); - QUEUE += "-" + (new Date()).getTime(); addStep("Make configuration for the messagebus and define the local broker.", "Both should be created."); @@ -161,15 +155,13 @@ public void SendManyMessagesLocally() throws Exception { sendAllTheMessages(conf, securityManager); addStep("Sleep until the listeners has received all the messages.", "Should be sleeping."); - long startTime = new Date().getTime(); + long startTime = System.currentTimeMillis(); long oneMinuteInMillis = 60000; - while (!listener.isFinished() && (new Date().getTime() - startTime) < oneMinuteInMillis) { - synchronized (this) { - try { - wait(TIME_FOR_MESSAGE_TRANSFER_WAIT); - } catch (InterruptedException e) { - e.printStackTrace(); - } + while (!listener.isFinished() && (System.currentTimeMillis() - startTime) < oneMinuteInMillis) { + try { + Thread.sleep(TIME_FOR_MESSAGE_TRANSFER_WAIT); + } catch (InterruptedException e) { + e.printStackTrace(); } } @@ -188,7 +180,6 @@ public void SendManyMessagesLocally() throws Exception { /** * Finds a free port on the localhost. - * * @return A free port number. * @throws IOException If an I/O error occurs. */ @@ -218,7 +209,7 @@ private class MessageSenderThread extends Thread { private final String id; public MessageSenderThread(MessageBusConfiguration conf, SecurityManager securityManager, int numberOfMessages, String id) { - Settings senderSettings = TestSettingsProvider.getSettings(MessageBusTimeToSendMessagesStressTest.class.getSimpleName()); + Settings senderSettings = TestSettingsProvider.getSettings(MessageBusTimeToSendMessagesStressTest.class.getSimpleName() + id); senderSettings.getRepositorySettings().getProtocolSettings().setMessageBusConfiguration(conf); this.bus = new ActiveMQMessageBus(senderSettings, securityManager); this.numberOfMessages = numberOfMessages; @@ -229,7 +220,7 @@ public MessageSenderThread(MessageBusConfiguration conf, SecurityManager securit public void run() { try { AlarmMessage message = ExampleMessageFactory.createMessage(AlarmMessage.class); - message.setDestination(QUEUE); + message.setDestination(testQueue); for (int i = 0; i < numberOfMessages; i++) { message.setCorrelationID(id + ":" + i); bus.sendMessage(message); @@ -264,14 +255,14 @@ public CountMessagesListener(SecurityManager securityManager) { this.bus = new ActiveMQMessageBus(settings, securityManager); this.count = 0; - bus.addListener(QUEUE, this); + bus.addListener(testQueue, this); } /** * Method for stopping interaction with the message-listener. */ public void stop() { - bus.removeListener(QUEUE, this); + bus.removeListener(testQueue, this); try { bus.close(); } catch (javax.jms.JMSException e) { diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/CertificateIDTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/CertificateIDTest.java index c38bca1ad..6976dd709 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/CertificateIDTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/CertificateIDTest.java @@ -26,7 +26,6 @@ import org.bouncycastle.cms.SignerInformation; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Base64; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -37,7 +36,10 @@ import java.security.Security; import java.security.cert.X509Certificate; -public class CertificateIDTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class CertificateIDTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/PermissionStoreTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/PermissionStoreTest.java index ee0e996b6..fc5fc5602 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/PermissionStoreTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/PermissionStoreTest.java @@ -26,7 +26,6 @@ import org.bouncycastle.cms.SignerId; import org.bouncycastle.cms.SignerInformation; import org.bouncycastle.util.encoders.Base64; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -35,8 +34,9 @@ import java.math.BigInteger; import java.security.cert.X509Certificate; +import static org.bitrepository.common.utils.AllureTestUtils.*; -public class PermissionStoreTest extends ExtendedTestCase { +public class PermissionStoreTest { private static final String componentID = "TEST"; private PermissionStore permissionStore; diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SecurityManagerTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SecurityManagerTest.java index 2ea72a400..a26a02c3e 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SecurityManagerTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SecurityManagerTest.java @@ -31,7 +31,6 @@ import org.bitrepository.protocol.security.exception.OperationAuthorizationException; import org.bitrepository.settings.repositorysettings.*; import org.bouncycastle.util.encoders.Base64; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -42,7 +41,10 @@ import java.nio.charset.StandardCharsets; import java.util.List; -public class SecurityManagerTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class SecurityManagerTest { private final Logger log = LoggerFactory.getLogger(getClass()); private org.bitrepository.protocol.security.SecurityManager securityManager; private PermissionStore permissionStore; diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/CertificateUseExceptionTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/CertificateUseExceptionTest.java index 433de9ccc..5e82c48df 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/CertificateUseExceptionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/CertificateUseExceptionTest.java @@ -21,12 +21,15 @@ */ package org.bitrepository.protocol.security.exception; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class CertificateUseExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + + +public class CertificateUseExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageAuthenticationExceptionTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageAuthenticationExceptionTest.java index 1e53f2802..433432f37 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageAuthenticationExceptionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageAuthenticationExceptionTest.java @@ -21,12 +21,15 @@ */ package org.bitrepository.protocol.security.exception; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class MessageAuthenticationExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + + +public class MessageAuthenticationExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageSignerExceptionTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageSignerExceptionTest.java index d7efe3677..1902463a3 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageSignerExceptionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/MessageSignerExceptionTest.java @@ -21,12 +21,14 @@ */ package org.bitrepository.protocol.security.exception; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class MessageSignerExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class MessageSignerExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/OperationAuthorizationExceptionTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/OperationAuthorizationExceptionTest.java index 8156f9cf2..ab17d7006 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/OperationAuthorizationExceptionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/OperationAuthorizationExceptionTest.java @@ -21,12 +21,14 @@ */ package org.bitrepository.protocol.security.exception; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class OperationAuthorizationExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class OperationAuthorizationExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/PermissionStoreExceptionTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/PermissionStoreExceptionTest.java index d5aeb5d53..b9240d9e8 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/PermissionStoreExceptionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/PermissionStoreExceptionTest.java @@ -21,12 +21,14 @@ */ package org.bitrepository.protocol.security.exception; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class PermissionStoreExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class PermissionStoreExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/SecurityExceptionTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/SecurityExceptionTest.java index 1c6e99306..30a031f84 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/SecurityExceptionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/SecurityExceptionTest.java @@ -21,12 +21,14 @@ */ package org.bitrepository.protocol.security.exception; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class SecurityExceptionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class SecurityExceptionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/UnregisteredPermissionTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/UnregisteredPermissionTest.java index 35d8cd267..729e531be 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/UnregisteredPermissionTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/exception/UnregisteredPermissionTest.java @@ -21,12 +21,14 @@ */ package org.bitrepository.protocol.security.exception; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class UnregisteredPermissionTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class UnregisteredPermissionTest { @Test @Tag("regressiontest") diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/BitrepositoryEvent.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/BitrepositoryEvent.java new file mode 100644 index 000000000..7b21d3103 --- /dev/null +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/BitrepositoryEvent.java @@ -0,0 +1,33 @@ +package org.bitrepository.protocol.utils; + +import java.time.Instant; +import java.util.Map; +import java.util.HashMap; + +public class BitrepositoryEvent { + private final String type; + private final Instant timestamp; + private final Map data; + + public BitrepositoryEvent(String type, Map data) { + this.type = type; + this.timestamp = Instant.now(); + this.data = new HashMap<>(data); + } + + public String getType() { + return type; + } + + public Instant getTimestamp() { + return timestamp; + } + + public Map getData() { + return new HashMap<>(data); + } + + public Object getData(String key) { + return data.get(key); + } +} diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/ConfigLoaderTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/ConfigLoaderTest.java index c980e8064..e3f7b69e6 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/ConfigLoaderTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/ConfigLoaderTest.java @@ -22,16 +22,19 @@ package org.bitrepository.protocol.utils; import org.bitrepository.common.utils.FileUtils; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; + import java.io.File; -class ConfigLoaderTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class ConfigLoaderTest { String goodFilePath = "logback-test.xml"; @BeforeEach diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageUtilsTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageUtilsTest.java index 8fd90ef42..88e419d08 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageUtilsTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageUtilsTest.java @@ -24,12 +24,15 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositoryelements.ResponseInfo; import org.bitrepository.bitrepositorymessages.MessageResponse; -import org.jaccept.structure.ExtendedTestCase; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class MessageUtilsTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class MessageUtilsTest { @Test @Tag("regressiontest") public void testPositiveIdentification() { diff --git a/bitrepository-core/src/test/resources/logback.xml b/bitrepository-core/src/test/resources/logback.xml new file mode 100644 index 000000000..f5ba13fd3 --- /dev/null +++ b/bitrepository-core/src/test/resources/logback.xml @@ -0,0 +1,11 @@ + + + + %d{yyyy-MM-dd HH:mm:ss} %-5level %logger{36} - %msg%n + + + + + + + \ No newline at end of file diff --git a/bitrepository-integration/pom.xml b/bitrepository-integration/pom.xml index 1356936f9..867a33e39 100644 --- a/bitrepository-integration/pom.xml +++ b/bitrepository-integration/pom.xml @@ -84,6 +84,15 @@ This is mainly the Quickstart bundle. + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.basedir}/allure-results + ${project.basedir}/allure-report + + maven-assembly-plugin diff --git a/bitrepository-integrity-service/pom.xml b/bitrepository-integrity-service/pom.xml index 343f25070..0b3936176 100644 --- a/bitrepository-integrity-service/pom.xml +++ b/bitrepository-integrity-service/pom.xml @@ -99,6 +99,15 @@ + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.basedir}/allure-results + ${project.basedir}/allure-report + + maven-assembly-plugin diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityAlerterTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityAlerterTest.java index dca38b3fc..526a23753 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityAlerterTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityAlerterTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.integrityservice; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.AlarmCode; import org.bitrepository.bitrepositorymessages.AlarmMessage; import org.bitrepository.integrityservice.alerter.IntegrityAlarmDispatcher; @@ -29,7 +30,12 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class IntegrityAlerterTest extends IntegrationTest { @Test @Tag("regressiontest") diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityDatabaseTestCase.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityDatabaseTestCase.java index 3c05cf6eb..3df0a3288 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityDatabaseTestCase.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityDatabaseTestCase.java @@ -33,7 +33,6 @@ import org.bitrepository.service.database.DBConnector; import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; @@ -41,7 +40,7 @@ import java.math.BigInteger; import java.util.List; -public abstract class IntegrityDatabaseTestCase extends ExtendedTestCase { +public abstract class IntegrityDatabaseTestCase { protected Settings settings; @BeforeEach diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityWorkflowSchedulerTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityWorkflowSchedulerTest.java index bb8a2f59e..e46b7b1d4 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityWorkflowSchedulerTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/IntegrityWorkflowSchedulerTest.java @@ -26,15 +26,14 @@ //import org.bitrepository.integrityservice.mocks.MockWorkflow; //import org.bitrepository.integrityservice.scheduler.TimerBasedScheduler; //import org.bitrepository.integrityservice.scheduler.workflow.Workflow; -//import org.jaccept.structure.ExtendedTestCase; -// +//// // // // ///** // * Test that scheduler calls triggers. // */ -//public class IntegrityWorkflowSchedulerTest extends ExtendedTestCase { +//public class IntegrityWorkflowSchedulerTest { // Settings settings; // private final Long INTERVAL = 500L; // private final Long INTERVAL_DELAY = 250L; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/FileInfoTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/FileInfoTest.java index e4f405cb2..6b27aa35b 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/FileInfoTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/FileInfoTest.java @@ -22,7 +22,6 @@ package org.bitrepository.integrityservice.cache; import org.bitrepository.common.utils.CalendarUtils; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -30,7 +29,10 @@ import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.XMLGregorianCalendar; -public class FileInfoTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class FileInfoTest { private static final String FILE_ID = "TEST-FILE"; private static final long LAST_FILE_CHECK_MILLIS = 1000000; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDAOTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDAOTest.java index c96d5f3fe..087f008d7 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDAOTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDAOTest.java @@ -46,6 +46,9 @@ import java.text.SimpleDateFormat; import java.util.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class IntegrityDAOTest extends IntegrityDatabaseTestCase { String TEST_PILLAR_1 = "MY-TEST-PILLAR-1"; String TEST_PILLAR_2 = "MY-TEST-PILLAR-2"; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDBToolsTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDBToolsTest.java index d4b0b4c78..6edb93dec 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDBToolsTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDBToolsTest.java @@ -43,7 +43,11 @@ import java.util.ArrayList; import java.util.List; -import static org.junit.jupiter.api.Assertions.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class IntegrityDBToolsTest extends IntegrityDatabaseTestCase { diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDatabaseTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDatabaseTest.java index 084681b9d..7bb6d6c96 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDatabaseTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/cache/IntegrityDatabaseTest.java @@ -42,11 +42,10 @@ import org.mockito.Mockito; import java.math.BigInteger; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Date; -import java.util.List; -import java.util.Map; +import java.util.*; + +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; public class IntegrityDatabaseTest extends IntegrityDatabaseTestCase { AuditTrailManager auditManager; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/checking/MaxChecksumAgeProviderTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/checking/MaxChecksumAgeProviderTest.java index e99017fcb..5fe36ad14 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/checking/MaxChecksumAgeProviderTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/checking/MaxChecksumAgeProviderTest.java @@ -22,7 +22,6 @@ package org.bitrepository.integrityservice.checking; import org.bitrepository.settings.referencesettings.ObsoleteChecksumSettings; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -32,7 +31,10 @@ import javax.xml.datatype.DatatypeFactory; import java.time.Duration; -public class MaxChecksumAgeProviderTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class MaxChecksumAgeProviderTest { DatatypeFactory factory; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/collector/IntegrityInformationCollectorTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/collector/IntegrityInformationCollectorTest.java index 28a19737c..e5a2b22bb 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/collector/IntegrityInformationCollectorTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/collector/IntegrityInformationCollectorTest.java @@ -32,20 +32,28 @@ import org.bitrepository.bitrepositoryelements.FilePart; import org.bitrepository.client.eventhandler.EventHandler; import org.bitrepository.modify.putfile.PutFileClient; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.net.URL; import java.util.List; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doThrow; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; /** * Test that collecting integrity information has the desired effect. */ -public class IntegrityInformationCollectorTest extends ExtendedTestCase { +public class IntegrityInformationCollectorTest { public final static String collectionID = "dummy-collection"; public final static String fileId = "FILE_ID"; @@ -70,7 +78,6 @@ public void testCollectorGetFileIDs() throws Exception { collector.getFileIDs(collectionID, List.of(pillarID), auditTrailInformation, contributorQueries, eventHandler); verify(getFileIDsClient).getFileIDs(eq(collectionID), any(), any(), any(), any(EventHandler.class)); - addStep("Call the getFileIDs on the collector four times more.", "The GetFileIDsClient should have been called 5 times."); collector.getFileIDs(collectionID, List.of(pillarID), auditTrailInformation, contributorQueries, null); diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/component/IntegrityServiceComponentTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/component/IntegrityServiceComponentTest.java index 34194955f..261075fdf 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/component/IntegrityServiceComponentTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/component/IntegrityServiceComponentTest.java @@ -48,15 +48,15 @@ public abstract class IntegrityServiceComponentTest extends IntegrationTest { protected void registerMessageReceivers() { super.registerMessageReceivers(); - collectionReceiver = new MessageReceiver(settingsForCUT.getCollectionDestination(), testEventManager); + collectionReceiver = new MessageReceiver(settingsForCUT.getCollectionDestination()); addReceiver(collectionReceiver); pillar1DestinationId = "Pillar1_topic" + getTopicPostfix(); - pillar1Receiver = new MessageReceiver(pillar1DestinationId, testEventManager); + pillar1Receiver = new MessageReceiver(pillar1DestinationId); addReceiver(pillar1Receiver); pillar2DestinationId = "Pillar2_topic" + getTopicPostfix(); - pillar2Receiver = new MessageReceiver(pillar2DestinationId, testEventManager); + pillar2Receiver = new MessageReceiver(pillar2DestinationId); addReceiver(pillar2Receiver); } } diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/integrationtest/MissingChecksumTests.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/integrationtest/MissingChecksumTests.java index 66367769a..6fd9560a0 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/integrationtest/MissingChecksumTests.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/integrationtest/MissingChecksumTests.java @@ -49,7 +49,6 @@ import org.bitrepository.integrityservice.workflow.step.UpdateChecksumsStep; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.service.exception.WorkflowAbortedException; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -63,8 +62,10 @@ import java.math.BigInteger; import java.util.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; -public class MissingChecksumTests extends ExtendedTestCase { +public class MissingChecksumTests { private static final String PILLAR_1 = "pillar1"; private static final String PILLAR_2 = "pillar2"; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/BasicIntegrityReporterTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/BasicIntegrityReporterTest.java index 55603a981..8aaac8070 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/BasicIntegrityReporterTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/BasicIntegrityReporterTest.java @@ -22,14 +22,20 @@ package org.bitrepository.integrityservice.reports; -import org.jaccept.structure.ExtendedTestCase; +import org.bitrepository.SuiteInfoParameterResolver; +import org.bitrepository.protocol.IntegrationTest; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.io.File; -public class BasicIntegrityReporterTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) +public class BasicIntegrityReporterTest extends IntegrationTest { private static final String REPORT_SUMMARY_START = "The following integrity issues were found:\n"; @Test diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/ExampleReportGenerationTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/ExampleReportGenerationTest.java index 6f56b30b3..c84d896c2 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/ExampleReportGenerationTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/reports/ExampleReportGenerationTest.java @@ -21,14 +21,13 @@ */ package org.bitrepository.integrityservice.reports; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Test; import java.io.*; import java.nio.charset.StandardCharsets; -public class ExampleReportGenerationTest extends ExtendedTestCase { +public class ExampleReportGenerationTest { private final String CHECKSUM_ISSUE1 = "checksum-issue-file1"; private final String CHECKSUM_ISSUE2 = "checksum-issue-file2"; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/stresstest/DatabaseStressTests.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/stresstest/DatabaseStressTests.java index e292f2e10..304f18be6 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/stresstest/DatabaseStressTests.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/stresstest/DatabaseStressTests.java @@ -36,8 +36,11 @@ import org.bitrepository.service.database.DatabaseManager; import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; @@ -45,7 +48,9 @@ import java.math.BigInteger; import java.util.Date; -public class DatabaseStressTests extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; + +public class DatabaseStressTests { private static final String PILLAR_1 = "pillar1"; private static final String PILLAR_2 = "pillar2"; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityWorkflowManagerTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityWorkflowManagerTest.java index edbca957a..f7d32735a 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityWorkflowManagerTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityWorkflowManagerTest.java @@ -27,8 +27,11 @@ import org.bitrepository.common.utils.SettingsUtils; import org.bitrepository.service.scheduler.TimerBasedScheduler; import org.bitrepository.service.workflow.WorkflowManager; -import org.bitrepository.settings.referencesettings.*; -import org.jaccept.structure.ExtendedTestCase; +import org.bitrepository.settings.referencesettings.Collections; +import org.bitrepository.settings.referencesettings.Schedule; +import org.bitrepository.settings.referencesettings.Schedules; +import org.bitrepository.settings.referencesettings.WorkflowConfiguration; +import org.bitrepository.settings.referencesettings.WorkflowSettings; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -36,13 +39,15 @@ import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.*; -public class IntegrityWorkflowManagerTest extends ExtendedTestCase { +public class IntegrityWorkflowManagerTest { private Settings settings; private WorkflowSettings workflowSettings; private TimerBasedScheduler scheduler; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/RepairMissingFilesWorkflowTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/RepairMissingFilesWorkflowTest.java index 424a33515..c623ced09 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/RepairMissingFilesWorkflowTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/RepairMissingFilesWorkflowTest.java @@ -36,7 +36,6 @@ import org.bitrepository.service.audit.AuditTrailManager; import org.bitrepository.service.workflow.Workflow; import org.bitrepository.settings.referencesettings.ProtocolType; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -52,10 +51,21 @@ import java.util.Iterator; import java.util.List; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -public class RepairMissingFilesWorkflowTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyInt; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class RepairMissingFilesWorkflowTest { private static final String PILLAR_1 = "pillar1"; private static final String PILLAR_2 = "pillar2"; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/SaltedChecksumWorkflowTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/SaltedChecksumWorkflowTest.java index 8eaee8095..8d52c0142 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/SaltedChecksumWorkflowTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/SaltedChecksumWorkflowTest.java @@ -38,7 +38,6 @@ import org.bitrepository.integrityservice.collector.IntegrityInformationCollector; import org.bitrepository.service.audit.AuditTrailManager; import org.bitrepository.service.workflow.Workflow; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -46,10 +45,20 @@ import java.util.Arrays; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.*; - -public class SaltedChecksumWorkflowTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doAnswer; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; +import static org.mockito.Mockito.when; + +public class SaltedChecksumWorkflowTest { private static final String PILLAR_1 = "pillar1"; private static final String PILLAR_2 = "pillar2"; @@ -197,7 +206,7 @@ public void testOneComponentFailureAndTwoOtherAgreeOnChecksum() { @Test @Tag("regressiontest") @Tag("integritytest") - public void testOneComponentFailureAndTwoOtherDisagreeOnChecksum() { + public void testOneComponentFailureAndTwoOtherDisagreeOnChecksum() throws Exception { addDescription("Test that the workflow works when both pillars deliver the same checksum."); addStep("Prepare for calls to mocks", ""); when(model.getNumberOfFilesInCollection(anyString())).thenReturn(Long.valueOf(1)); diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetChecksumForFileStepTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetChecksumForFileStepTest.java index c8e72a816..7915a7ab0 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetChecksumForFileStepTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetChecksumForFileStepTest.java @@ -42,6 +42,8 @@ import javax.xml.datatype.DatatypeConfigurationException; import java.util.Arrays; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.mockito.ArgumentMatchers.*; /** diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetFileStepTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetFileStepTest.java index 8e1b5d02b..843254f22 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetFileStepTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/GetFileStepTest.java @@ -32,6 +32,7 @@ import java.net.URL; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/HandleChecksumValidationStepTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/HandleChecksumValidationStepTest.java index 0b69d19d5..7cff2c86c 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/HandleChecksumValidationStepTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/HandleChecksumValidationStepTest.java @@ -49,6 +49,9 @@ import java.util.Date; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Performs the validation of the integrity for the checksums. */ diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/PutFileStepTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/PutFileStepTest.java index 1a8c6f53d..7accc6ca5 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/PutFileStepTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/PutFileStepTest.java @@ -33,6 +33,7 @@ import java.net.URL; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateChecksumsStepTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateChecksumsStepTest.java index 3c4bab11f..90b44e2a0 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateChecksumsStepTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateChecksumsStepTest.java @@ -42,6 +42,8 @@ import java.util.HashSet; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.mockito.ArgumentMatchers.*; import static org.mockito.Mockito.*; @@ -316,8 +318,7 @@ public Void answer(InvocationOnMock invocation) { step.performStep(); ContributorQuery[] expectedContributorQueries = - makeFullQueries(settings.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID() - ); + makeFullQueries(settings.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID()); verify(collector).getChecksums(eq(TEST_COLLECTION), any(), any(ChecksumSpecTYPE.class), any(), anyString(), eq(expectedContributorQueries), any(EventHandler.class)); diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateFileIDsStepTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateFileIDsStepTest.java index e5a3aed84..b090253da 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateFileIDsStepTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/UpdateFileIDsStepTest.java @@ -45,6 +45,8 @@ import java.util.HashSet; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/WorkflowstepTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/WorkflowstepTest.java index e19a10689..611140fee 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/WorkflowstepTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/step/WorkflowstepTest.java @@ -30,7 +30,6 @@ import org.bitrepository.integrityservice.collector.IntegrityInformationCollector; import org.bitrepository.integrityservice.workflow.IntegrityContributors; import org.bitrepository.service.audit.AuditTrailManager; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.BeforeEach; import javax.xml.datatype.DatatypeConfigurationException; @@ -38,7 +37,7 @@ import static org.mockito.Mockito.mock; -public class WorkflowstepTest extends ExtendedTestCase { +public class WorkflowstepTest { protected Settings settings; public static final String TEST_PILLAR_1 = "test-pillar-1"; diff --git a/bitrepository-monitoring-service/pom.xml b/bitrepository-monitoring-service/pom.xml index e814b7ef3..32794a491 100644 --- a/bitrepository-monitoring-service/pom.xml +++ b/bitrepository-monitoring-service/pom.xml @@ -88,6 +88,15 @@ + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.basedir}/allure-results + ${project.basedir}/allure-report + + maven-assembly-plugin diff --git a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/alarm/MonitorAlerterTest.java b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/alarm/MonitorAlerterTest.java index cfb26dbb5..8210501c5 100644 --- a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/alarm/MonitorAlerterTest.java +++ b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/alarm/MonitorAlerterTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.monitoringservice.alarm; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.ResultingStatus; import org.bitrepository.bitrepositoryelements.StatusCode; import org.bitrepository.bitrepositoryelements.StatusInfo; @@ -34,11 +35,16 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.math.BigInteger; import java.util.HashMap; import java.util.Map; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class MonitorAlerterTest extends IntegrationTest { @Test diff --git a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusCollectorTest.java b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusCollectorTest.java index 5b8acd76f..324a8d7cb 100644 --- a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusCollectorTest.java +++ b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusCollectorTest.java @@ -26,14 +26,20 @@ import org.bitrepository.monitoringservice.MockAlerter; import org.bitrepository.monitoringservice.MockGetStatusClient; import org.bitrepository.monitoringservice.MockStatusStore; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class StatusCollectorTest extends ExtendedTestCase { +public class StatusCollectorTest { Settings settings; private final int INTERVAL = 500; diff --git a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusEventHandlerTest.java b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusEventHandlerTest.java index 8d84a3340..de95185a5 100644 --- a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusEventHandlerTest.java +++ b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/collector/StatusEventHandlerTest.java @@ -25,12 +25,15 @@ import org.bitrepository.client.eventhandler.*; import org.bitrepository.monitoringservice.MockAlerter; import org.bitrepository.monitoringservice.MockStatusStore; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -public class StatusEventHandlerTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + + +public class StatusEventHandlerTest { public static final String TEST_COLLECTION = "collection1"; diff --git a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/status/ComponentStatusStoreTest.java b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/status/ComponentStatusStoreTest.java index bcd1938c1..a0d5e71cf 100644 --- a/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/status/ComponentStatusStoreTest.java +++ b/bitrepository-monitoring-service/src/test/java/org/bitrepository/monitoringservice/status/ComponentStatusStoreTest.java @@ -27,15 +27,21 @@ import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.common.utils.CalendarUtils; -import org.jaccept.structure.ExtendedTestCase; -import org.junit.jupiter.api.*; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.util.HashSet; import java.util.Map; import java.util.Set; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class ComponentStatusStoreTest extends ExtendedTestCase { +public class ComponentStatusStoreTest { Settings settings; @BeforeAll diff --git a/bitrepository-reference-pillar/pom.xml b/bitrepository-reference-pillar/pom.xml index a9cab9473..5dfd1009f 100644 --- a/bitrepository-reference-pillar/pom.xml +++ b/bitrepository-reference-pillar/pom.xml @@ -89,6 +89,15 @@ + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.basedir}/allure-results + ${project.basedir}/allure-report + + org.apache.maven.plugins maven-surefire-plugin diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultFixturePillarTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultFixturePillarTest.java index 5f2e659b0..8b49b9494 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultFixturePillarTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultFixturePillarTest.java @@ -54,7 +54,7 @@ protected void registerMessageReceivers() { super.registerMessageReceivers(); clientDestinationId = settingsForTestClient.getReceiverDestinationID(); - clientReceiver = new MessageReceiver(clientDestinationId, testEventManager); + clientReceiver = new MessageReceiver(clientDestinationId); addReceiver(clientReceiver); pillarDestinationId = settingsForCUT.getContributorDestinationID(); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultPillarTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultPillarTest.java index fd3e05ece..9b9044d8a 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultPillarTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/DefaultPillarTest.java @@ -47,6 +47,8 @@ import java.io.IOException; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addFixture; + public abstract class DefaultPillarTest extends DefaultFixturePillarTest { protected FileStore archives; protected StorageModel model; @@ -111,7 +113,7 @@ protected void createReferencePillar() { } public void shutdownMediator() { - if(mediator != null) { + if (mediator != null) { mediator.close(); mediator = null; } @@ -121,6 +123,7 @@ public void shutdownMediator() { protected String getComponentID() { return "ReferencePillar-" + testMethodName; } + private void initializeArchiveWithEmptyFile() throws IOException { addFixture("Initialize the Reference pillar cache with an empty file in default collection " + collectionID); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MediatorTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MediatorTest.java index beb5fae65..bba7411a4 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MediatorTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MediatorTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.pillar; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositorymessages.AlarmMessage; import org.bitrepository.bitrepositorymessages.IdentifyContributorsForGetStatusRequest; @@ -39,12 +40,17 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; import java.util.UUID; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class MediatorTest extends DefaultFixturePillarTest { MockAuditManager audits; MessageHandlerContext context; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MockedPillarTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MockedPillarTest.java index cfc6e0ccf..5fb0a0528 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MockedPillarTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/MockedPillarTest.java @@ -36,6 +36,7 @@ import org.bitrepository.service.audit.MockAuditManager; import org.bitrepository.service.contributor.ResponseDispatcher; +import static org.bitrepository.common.utils.AllureTestUtils.addFixture; import static org.mockito.Mockito.mock; public abstract class MockedPillarTest extends DefaultFixturePillarTest { diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/ClientProvider.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/ClientProvider.java index d3eedae43..b4d617c76 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/ClientProvider.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/ClientProvider.java @@ -5,16 +5,16 @@ * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% @@ -35,7 +35,6 @@ import org.bitrepository.modify.putfile.PutFileClientTestWrapper; import org.bitrepository.modify.replacefile.BlockingReplaceFileClient; import org.bitrepository.modify.replacefile.ReplaceFileClientTestWrapper; -import org.jaccept.TestEventManager; /** * Provides (blocking) reference client instances. @@ -43,7 +42,6 @@ public class ClientProvider { private final org.bitrepository.protocol.security.SecurityManager securityManager; private final Settings settings; - private final TestEventManager eventManager; private BlockingPutFileClient putFileClient; private BlockingReplaceFileClient replaceFileClient; @@ -54,27 +52,24 @@ public class ClientProvider { /** * @param securityManager The security manager to use for the clients. - * @param settings The settings to use for the clients. - * @param eventManager + * @param settings The settings to use for the clients. */ public ClientProvider( - org.bitrepository.protocol.security.SecurityManager securityManager, - Settings settings, - TestEventManager eventManager) { + org.bitrepository.protocol.security.SecurityManager securityManager, + Settings settings) { this.securityManager = securityManager; this.settings = settings; - this.eventManager = eventManager; } public synchronized BlockingPutFileClient getPutClient() { if (putFileClient == null) { putFileClient = new BlockingPutFileClient( - new PutFileClientTestWrapper( - ModifyComponentFactory.getInstance().retrievePutClient( - settings, securityManager, settings.getComponentID() - ), eventManager - ) + new PutFileClientTestWrapper( + ModifyComponentFactory.getInstance().retrievePutClient( + settings, securityManager, settings.getComponentID() + ) + ) ); } return putFileClient; @@ -86,7 +81,7 @@ public synchronized BlockingReplaceFileClient getReplaceFileClient() { new ReplaceFileClientTestWrapper( ModifyComponentFactory.getInstance().retrieveReplaceFileClient( settings, securityManager, settings.getComponentID() - ), eventManager + ) ) ); } @@ -96,11 +91,11 @@ public synchronized BlockingReplaceFileClient getReplaceFileClient() { public synchronized BlockingDeleteFileClient getDeleteFileClient() { if (getDeleteFileClient == null) { getDeleteFileClient = new BlockingDeleteFileClient( - new DeleteFileClientTestWrapper( - ModifyComponentFactory.getInstance().retrieveDeleteFileClient( - settings, securityManager, settings.getComponentID() - ), eventManager - ) + new DeleteFileClientTestWrapper( + ModifyComponentFactory.getInstance().retrieveDeleteFileClient( + settings, securityManager, settings.getComponentID() + ) + ) ); } return getDeleteFileClient; @@ -109,11 +104,11 @@ public synchronized BlockingDeleteFileClient getDeleteFileClient() { public synchronized BlockingGetChecksumsClient getGetChecksumsClient() { if (getChecksumsClient == null) { getChecksumsClient = new BlockingGetChecksumsClient( - new GetChecksumsClientTestWrapper( - AccessComponentFactory.getInstance().createGetChecksumsClient( - settings, securityManager, settings.getComponentID() - ), eventManager - ) + new GetChecksumsClientTestWrapper( + AccessComponentFactory.getInstance().createGetChecksumsClient( + settings, securityManager, settings.getComponentID() + ) + ) ); } return getChecksumsClient; @@ -122,11 +117,11 @@ public synchronized BlockingGetChecksumsClient getGetChecksumsClient() { public synchronized BlockingGetFileIDsClient getGetFileIDsClient() { if (getFileIDsClient == null) { getFileIDsClient = new BlockingGetFileIDsClient( - new GetFileIDsClientTestWrapper( - AccessComponentFactory.getInstance().createGetFileIDsClient( - settings, securityManager, settings.getComponentID() - ), eventManager - ) + new GetFileIDsClientTestWrapper( + AccessComponentFactory.getInstance().createGetFileIDsClient( + settings, securityManager, settings.getComponentID() + ) + ) ); } return getFileIDsClient; @@ -139,7 +134,7 @@ public synchronized BlockingAuditTrailClient getAuditTrailsClient() { new AuditTrailClientTestWrapper( AccessComponentFactory.getInstance().createAuditTrailClient( settings, securityManager, settings.getComponentID() - ), eventManager + ) ) ); } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/PillarIntegrationTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/PillarIntegrationTest.java index 0774350c7..cb4bb91c9 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/PillarIntegrationTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/PillarIntegrationTest.java @@ -21,8 +21,8 @@ */ package org.bitrepository.pillar.integration; -import org.bitrepository.ExtendedTestInfoParameterResolver; import org.bitrepository.SuiteInfo; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.client.conversation.mediator.CollectionBasedConversationMediator; import org.bitrepository.client.conversation.mediator.ConversationMediatorManager; import org.bitrepository.client.eventhandler.EventHandler; @@ -42,7 +42,6 @@ import org.bitrepository.protocol.messagebus.SimpleMessageBus; import org.bitrepository.protocol.security.*; import org.bitrepository.protocol.security.SecurityManager; -import org.jaccept.TestEventManager; import org.junit.jupiter.api.*; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.platform.suite.api.AfterSuite; @@ -51,6 +50,8 @@ import java.io.IOException; import java.io.InputStream; +import static org.bitrepository.common.utils.AllureTestUtils.isTestRunning; + /** * Super class for all tests which should test functionality on a single pillar. *

@@ -58,7 +59,7 @@ * to be invariant against the initial pillar state. */ @TestInstance(TestInstance.Lifecycle.PER_CLASS) -@ExtendWith(ExtendedTestInfoParameterResolver.class) +@ExtendWith(SuiteInfoParameterResolver.class) public abstract class PillarIntegrationTest extends IntegrationTest { /** * The path to the directory containing the integration test configuration files @@ -87,10 +88,10 @@ public abstract class PillarIntegrationTest extends IntegrationTest { protected void initializeCUT() { super.initializeCUT(); reloadMessageBus(); - clientProvider = new ClientProvider(securityManager, settingsForTestClient, testEventManager); + clientProvider = new ClientProvider(securityManager, settingsForTestClient); pillarFileManager = new PillarFileManager(collectionID, - getPillarID(), settingsForTestClient, clientProvider, testEventManager, httpServerConfiguration); - clientEventHandler = new ClientEventLogger(testEventManager); + getPillarID(), settingsForTestClient, clientProvider, httpServerConfiguration); + clientEventHandler = new ClientEventLogger(); } /** @@ -111,7 +112,8 @@ protected void initializeCUT() { @BeforeAll public void initializeSuite(SuiteInfo testInfo) { if (testConfiguration == null) { - testConfiguration = new PillarIntegrationTestConfiguration(PATH_TO_TESTPROPS_DIR + "/" + TEST_CONFIGURATION_FILE_NAME); + testConfiguration = + new PillarIntegrationTestConfiguration(PATH_TO_TESTPROPS_DIR + "/" + TEST_CONFIGURATION_FILE_NAME); } super.initializeSuite(testInfo); @@ -120,7 +122,7 @@ public void initializeSuite(SuiteInfo testInfo) { startEmbeddedPillar(testInfo); reloadMessageBus(); - clientProvider = new ClientProvider(securityManager, settingsForTestClient, testEventManager); + clientProvider = new ClientProvider(securityManager, settingsForTestClient); nonDefaultCollectionId = settingsForTestClient.getCollections().get(1).getID(); irrelevantCollectionId = settingsForTestClient.getCollections().get(2).getID(); putDefaultFile(); @@ -199,7 +201,7 @@ public void initMessagebus() { * checksumPillarTest a checksum pillar is started, else a normal 'full' reference pillar is started. *

* - * @param testInfo + * @param testInfo The suite info containing the pillar type. */ protected void startEmbeddedPillar(SuiteInfo testInfo) { if (testConfiguration.useEmbeddedPillar()) { @@ -293,8 +295,7 @@ protected void putDefaultFile() { try (InputStream fis = getClass().getClassLoader().getResourceAsStream("default-test-file.txt")) { fe.putFile(fis, defaultFileUrl); } catch (IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + throw new RuntimeException("Failed to upload default test file", e); } @@ -317,21 +318,22 @@ public class ClientEventLogger implements EventHandler { /** * The TestEventManager used to manage the event for the associated test. */ - private final TestEventManager testEventManager; /** * The constructor. - * - * @param testEventManager The TestEventManager used to manage the event for the associated test. */ - public ClientEventLogger(TestEventManager testEventManager) { + public ClientEventLogger() { super(); - this.testEventManager = testEventManager; } @Override public void handleEvent(OperationEvent event) { - testEventManager.addResult("Received event: " + event); + if (!isTestRunning()) { + return; + } + io.qameta.allure.Allure.step("Received event: " + event.getEventType(), () -> { + io.qameta.allure.Allure.addAttachment("Event Details", event.toString()); + }); } } } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarIdentificationTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarIdentificationTest.java index 9494c4057..e144e35e2 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarIdentificationTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarIdentificationTest.java @@ -30,6 +30,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public abstract class DefaultPillarIdentificationTest extends DefaultPillarMessagingTest { @Test diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarMessagingTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarMessagingTest.java index 11d82f9e1..e5f7a1068 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarMessagingTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarMessagingTest.java @@ -30,6 +30,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Contains the tests for exploringa pillars handling of general messaging. The concrete class needs to * implement the abstract methods and add any operation specific tests. The test will not work for Alarm and status diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/PillarFunctionTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/PillarFunctionTest.java index 3e251d73c..1cc90df5f 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/PillarFunctionTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/PillarFunctionTest.java @@ -50,7 +50,7 @@ public void generalMethodSetup(TestInfo testInfo) throws Exception { protected void registerMessageReceivers() { super.registerMessageReceivers(); - clientReceiver = new MessageReceiver(settingsForTestClient.getReceiverDestinationID(), testEventManager); + clientReceiver = new MessageReceiver(settingsForTestClient.getReceiverDestinationID()); addReceiver(clientReceiver); Collection pillarFilter = Collections.singletonList(testConfiguration.getPillarUnderTestID()); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/DeleteFileRequestIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/DeleteFileRequestIT.java index e282fd71f..42b907688 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/DeleteFileRequestIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/DeleteFileRequestIT.java @@ -38,12 +38,15 @@ import java.util.concurrent.TimeUnit; -class DeleteFileRequestIT extends DefaultPillarOperationTest { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class DeleteFileRequestIT extends DefaultPillarOperationTest { protected DeleteFileMessageFactory msgFactory; private String pillarDestination; @BeforeEach - void initialiseReferenceTest() throws Exception { + public void initialiseReferenceTest() throws Exception { pillarDestination = lookupDeleteFileDestination(); msgFactory = new DeleteFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), pillarDestination); clientProvider.getPutClient().putFile( @@ -57,7 +60,7 @@ void initialiseReferenceTest() throws Exception { @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) - void normalDeleteFileTest() { + public void normalDeleteFileTest() { addDescription("Tests a normal DeleteFile sequence"); addStep("Send a DeleteFile request to " + testConfiguration.getPillarUnderTestID(), "The pillar should generate a OPERATION_ACCEPTED_PROGRESS progress response followed by a " + diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/IdentifyPillarsForDeleteFileIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/IdentifyPillarsForDeleteFileIT.java index 052265109..96cab29ef 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/IdentifyPillarsForDeleteFileIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/deletefile/IdentifyPillarsForDeleteFileIT.java @@ -34,6 +34,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class IdentifyPillarsForDeleteFileIT extends DefaultPillarIdentificationTest { protected DeleteFileMessageFactory msgFactory; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getaudittrails/GetAuditTrailsTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getaudittrails/GetAuditTrailsTest.java index 5dca417f3..8a185817e 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getaudittrails/GetAuditTrailsTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getaudittrails/GetAuditTrailsTest.java @@ -32,6 +32,7 @@ import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.*; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumQueryTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumQueryTest.java index fd3c9d12e..21a79f8fb 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumQueryTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumQueryTest.java @@ -35,6 +35,8 @@ import java.util.GregorianCalendar; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.*; + public class GetChecksumQueryTest extends PillarFunctionTest { @Test @@ -62,8 +64,7 @@ public void checksumSortingTest() { @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void maxNumberOfResultTest() { - addDescription("Verifies the size of the result set can be limited by setting the maxNumberOfResult parameter" + - "."); + addDescription("Verifies the size of the result set can be limited by setting the maxNumberOfResult parameter."); addFixture("Ensure at least two files are present on the pillar"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumTest.java index 081860f95..6a31c2aa3 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/GetChecksumTest.java @@ -29,16 +29,11 @@ import org.bitrepository.common.utils.Base16Utils; import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.TestInstance; +import org.bitrepository.common.utils.AllureTestUtils; +import org.junit.jupiter.api.*; import java.util.List; -import static org.junit.jupiter.api.Assertions.assertNotNull; -import static org.junit.jupiter.api.Assertions.assertTrue; - @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class GetChecksumTest extends PillarFunctionTest { @@ -51,18 +46,18 @@ public void retrieveFirst2Files() { @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void md5ChecksumsForAllFilesTest() throws NegativeResponseException { - addDescription("Test the pillar support for MD5 type checksums"); + AllureTestUtils.addDescription("Test the pillar support for MD5 type checksums"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); - addStep("Request MD5 checksums for all files on the pillar", + AllureTestUtils.addStep("Request MD5 checksums for all files on the pillar", "A list (at least 2 long) of MD5 checksums should be returned."); ChecksumSpecTYPE checksumSpec = new ChecksumSpecTYPE(); checksumSpec.setChecksumType(ChecksumType.MD5); List checksums = pillarFileManager.getChecksums(checksumSpec, null, null); - assertTrue(checksums.size() >= 2, "The length of the returned checksums were less that 2"); + Assertions.assertTrue(checksums.size() >= 2, "The length of the returned checksums were less that 2"); - addStep("Retrieve the first two files and verify that the checksums are correct", + AllureTestUtils.addStep("Retrieve the first two files and verify that the checksums are correct", "Not implemented"); // ToDo implement this } @@ -70,25 +65,25 @@ public void md5ChecksumsForAllFilesTest() throws NegativeResponseException { @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void sha1ChecksumsForDefaultTest() throws NegativeResponseException { - addDescription("Test the pillar support for SHA1 type checksums"); + AllureTestUtils.addDescription("Test the pillar support for SHA1 type checksums"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); - addStep("Request SHA1 checksums for the DefaultFile on the pillar", + AllureTestUtils.addStep("Request SHA1 checksums for the DefaultFile on the pillar", "The SHA1 checksum for the default file should be returned should be returned (Not checked yet)."); ChecksumSpecTYPE checksumSpec = new ChecksumSpecTYPE(); checksumSpec.setChecksumType(ChecksumType.SHA1); List checksums = pillarFileManager.getChecksums( checksumSpec, null, defaultFileId); - assertNotNull(checksums.get(0)); + Assertions.assertNotNull(checksums.get(0)); } @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void md5SaltChecksumsForDefaultTest() throws NegativeResponseException { - addDescription("Test the pillar support for MD5 type checksums with a salt"); + AllureTestUtils.addDescription("Test the pillar support for MD5 type checksums with a salt"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); - addStep("Request salted MD5 checksums for the default on the pillar", + AllureTestUtils.addStep("Request salted MD5 checksums for the default on the pillar", "The correct of SHA1 checksum should be returned (Not checked yet)."); ChecksumSpecTYPE checksumSpec = new ChecksumSpecTYPE(); checksumSpec.setChecksumType(ChecksumType.HMAC_MD5); @@ -99,16 +94,16 @@ public void md5SaltChecksumsForDefaultTest() throws NegativeResponseException { } List checksums = pillarFileManager.getChecksums( checksumSpec, null, defaultFileId); - assertNotNull(checksums.get(0)); + Assertions.assertNotNull(checksums.get(0)); } @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void sha1SaltChecksumsForDefaultTest() throws NegativeResponseException { - addDescription("Test the pillar support for SHA1 type checksums with a salt"); + AllureTestUtils.addDescription("Test the pillar support for SHA1 type checksums with a salt"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); - addStep("Request salted SHA1 checksums for the default on the pillar", + AllureTestUtils.addStep("Request salted SHA1 checksums for the default on the pillar", "The correct of SHA1 checksum should be returned (Not checked yet)."); ChecksumSpecTYPE checksumSpec = new ChecksumSpecTYPE(); checksumSpec.setChecksumType(ChecksumType.HMAC_SHA1); @@ -119,6 +114,6 @@ public void sha1SaltChecksumsForDefaultTest() throws NegativeResponseException { } List checksums = pillarFileManager.getChecksums( checksumSpec, null, defaultFileId); - assertNotNull(checksums.get(0)); + Assertions.assertNotNull(checksums.get(0)); } } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/IdentifyPillarsForGetChecksumsIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/IdentifyPillarsForGetChecksumsIT.java index 315219b7c..546ca17a2 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/IdentifyPillarsForGetChecksumsIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getchecksums/IdentifyPillarsForGetChecksumsIT.java @@ -38,6 +38,8 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; public class IdentifyPillarsForGetChecksumsIT extends DefaultPillarIdentificationTest { protected GetChecksumsMessageFactory msgFactory; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/GetFileRequestIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/GetFileRequestIT.java index 71ce1f8b0..d4cdc48dd 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/GetFileRequestIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/GetFileRequestIT.java @@ -21,14 +21,17 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; -class GetFileRequestIT extends PillarFunctionTest { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class GetFileRequestIT extends PillarFunctionTest { private final Logger log = LoggerFactory.getLogger(this.getClass()); protected GetFileMessageFactory msgFactory; protected URL testFileURL = null; protected FileExchange fe = null; @BeforeEach - void initialiseReferenceTest() throws Exception { + public void initialiseReferenceTest() throws Exception { String pillarDestination = lookupGetFileDestination(); msgFactory = new GetFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), pillarDestination); testFileURL = new URL(defaultFileUrl.toExternalForm() + System.currentTimeMillis()); @@ -36,7 +39,7 @@ void initialiseReferenceTest() throws Exception { } @AfterEach - void cleanUp(TestInfo testInfo) { + public void cleanUp(TestInfo testInfo) { try { fe.deleteFile(testFileURL); } catch (Exception e) { diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/IdentifyPillarsForGetFileIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/IdentifyPillarsForGetFileIT.java index 10ee38c40..739e8fc34 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/IdentifyPillarsForGetFileIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfile/IdentifyPillarsForGetFileIT.java @@ -31,13 +31,15 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertEquals; class IdentifyPillarsForGetFileIT extends PillarFunctionTest { protected GetFileMessageFactory msgFactory; @BeforeEach - void initialiseReferenceTest() throws Exception { + public void initialiseReferenceTest() throws Exception { msgFactory = new GetFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsQueryTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsQueryTest.java index 45bd35370..922c438f6 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsQueryTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsQueryTest.java @@ -36,6 +36,7 @@ import java.util.GregorianCalendar; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.*; public class GetFileIDsQueryTest extends PillarFunctionTest { @@ -66,8 +67,7 @@ public void fileidsSortingTest() { @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void maxNumberOfResultTest() { - addDescription("Verifies the size of the result set can be limited by setting the maxNumberOfResult parameter" + - "."); + addDescription("Verifies the size of the result set can be limited by setting the maxNumberOfResult parameter."); addFixture("Ensure at least two files are present on the pillar"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsTest.java index e15bf22d5..5bc2dfdf1 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/GetFileIDsTest.java @@ -21,14 +21,10 @@ */ package org.bitrepository.pillar.integration.func.getfileids; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.FileIDs; import org.bitrepository.bitrepositoryelements.ResponseCode; -import org.bitrepository.bitrepositorymessages.GetFileIDsFinalResponse; -import org.bitrepository.bitrepositorymessages.GetFileIDsProgressResponse; -import org.bitrepository.bitrepositorymessages.GetFileIDsRequest; -import org.bitrepository.bitrepositorymessages.IdentifyPillarsForGetFileIDsResponse; -import org.bitrepository.bitrepositorymessages.MessageRequest; -import org.bitrepository.bitrepositorymessages.MessageResponse; +import org.bitrepository.bitrepositorymessages.*; import org.bitrepository.common.utils.FileIDsUtils; import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; @@ -37,9 +33,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class GetFileIDsTest extends DefaultPillarOperationTest { protected GetFileIDsMessageFactory msgFactory; private String pillarDestination; @@ -77,7 +78,8 @@ public void pillarGetFileIDsTestSuccessCase() throws Exception { Assertions.assertEquals(getPillarID(), progressResponse.getFrom()); Assertions.assertEquals(getPillarID(), progressResponse.getPillarID()); Assertions.assertEquals(pillarDestination, progressResponse.getReplyTo()); - Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, progressResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); addStep("Retrieve the FinalResponse for the GetFileIDs request", "The GetFileIDs response should be sent by the pillar."); @@ -90,8 +92,12 @@ public void pillarGetFileIDsTestSuccessCase() throws Exception { Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); Assertions.assertEquals(pillarDestination, finalResponse.getReplyTo()); Assertions.assertNull(finalResponse.getResultingFileIDs().getResultAddress()); - Assertions.assertTrue(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size() >= 2, - "Should be at least 2 files, but found: " + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); + Assertions.assertTrue( + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem() + .size() >= 2, + "Should be at least 2 files, but found: " + + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem() + .size()); } @Test @@ -127,8 +133,11 @@ public void pillarGetFileIDsSpecificFileIDRequest() throws Exception { addStep("Retrieve the FinalResponse for the GetFileIDs request.", "A OPERATION_COMPLETE final response only containing the requested file-id."); GetFileIDsFinalResponse finalResponse = (GetFileIDsFinalResponse) receiveResponse(); - Assertions.assertEquals(1, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); - Assertions.assertEquals(defaultFileId, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID()); + Assertions.assertEquals(1, + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); + Assertions.assertEquals(defaultFileId, + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0) + .getFileID()); Assertions.assertFalse(finalResponse.isSetPartialResult() && finalResponse.isPartialResult()); } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/IdentifyPillarsForGetFileIDsIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/IdentifyPillarsForGetFileIDsIT.java index 86ff7c392..033c63faa 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/IdentifyPillarsForGetFileIDsIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getfileids/IdentifyPillarsForGetFileIDsIT.java @@ -36,6 +36,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class IdentifyPillarsForGetFileIDsIT extends DefaultPillarIdentificationTest { protected GetFileIDsMessageFactory msgFactory; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/GetStatusRequestIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/GetStatusRequestIT.java index 016b2f614..3508e7e73 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/GetStatusRequestIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/GetStatusRequestIT.java @@ -33,6 +33,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class GetStatusRequestIT extends PillarFunctionTest { protected GetStatusMessageFactory msgFactory; private String pillarDestination; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/IdentifyContributorsForGetStatusIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/IdentifyContributorsForGetStatusIT.java index f81116ed4..df6e4322a 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/IdentifyContributorsForGetStatusIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/getstatus/IdentifyContributorsForGetStatusIT.java @@ -33,6 +33,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class IdentifyContributorsForGetStatusIT extends PillarFunctionTest { protected GetStatusMessageFactory msgFactory; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/multicollection/MultipleCollectionIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/multicollection/MultipleCollectionIT.java index 1836cca27..0efbce437 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/multicollection/MultipleCollectionIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/multicollection/MultipleCollectionIT.java @@ -34,6 +34,9 @@ import java.util.Collection; import java.util.Collections; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class MultipleCollectionIT extends PillarIntegrationTest { /** * Used for receiving responses from the pillar @@ -74,7 +77,7 @@ public void fileInOtherCollectionTest() throws Exception { protected void registerMessageReceivers() { super.registerMessageReceivers(); - clientReceiver = new MessageReceiver(settingsForTestClient.getReceiverDestinationID(), testEventManager); + clientReceiver = new MessageReceiver(settingsForTestClient.getReceiverDestinationID()); addReceiver(clientReceiver); Collection pillarFilter = Collections.singletonList(testConfiguration.getPillarUnderTestID()); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/IdentifyPillarsForPutFileIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/IdentifyPillarsForPutFileIT.java index e19b7ab71..9bd52e08c 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/IdentifyPillarsForPutFileIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/IdentifyPillarsForPutFileIT.java @@ -34,6 +34,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class IdentifyPillarsForPutFileIT extends DefaultPillarIdentificationTest { protected PutFileMessageFactory msgFactory; @@ -119,7 +122,6 @@ public void fileExistsTest() { "implement idempotent behaviour based on this response."); addStep("Sending a putFile identification for a file already in the pillar.", "The pillar under test should send a DUPLICATE_FILE_FAILURE response with the (default type) checksum" + - " " + "of the existing file."); IdentifyPillarsForPutFileRequest identifyRequest = msgFactory.createIdentifyPillarsForPutFileRequest( defaultFileId, 0L); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/PutFileRequestIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/PutFileRequestIT.java index 79f964b06..ef6446ac8 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/PutFileRequestIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/putfile/PutFileRequestIT.java @@ -35,6 +35,9 @@ import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class PutFileRequestIT extends DefaultPillarOperationTest { protected PutFileMessageFactory msgFactory; private String pillarDestination; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/IdentifyPillarsForReplaceFileIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/IdentifyPillarsForReplaceFileIT.java index d5d1d63c3..f928c5639 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/IdentifyPillarsForReplaceFileIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/IdentifyPillarsForReplaceFileIT.java @@ -34,6 +34,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class IdentifyPillarsForReplaceFileIT extends DefaultPillarIdentificationTest { protected ReplaceFileMessageFactory msgFactory; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/ReplaceFileRequestIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/ReplaceFileRequestIT.java index 123596b8e..72057700f 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/ReplaceFileRequestIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/replacefile/ReplaceFileRequestIT.java @@ -40,6 +40,9 @@ import java.util.concurrent.TimeUnit; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class ReplaceFileRequestIT extends DefaultPillarOperationTest { protected ReplaceFileMessageFactory msgFactory; private String pillarDestination; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/model/PillarFileManager.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/model/PillarFileManager.java index 318e7cab2..351c115f6 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/model/PillarFileManager.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/model/PillarFileManager.java @@ -5,16 +5,16 @@ * Copyright (C) 2010 - 2012 The State and University Library, The Royal Library and The State Archives, Denmark * %% * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as - * published by the Free Software Foundation, either version 2.1 of the + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 2.1 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Lesser Public License for more details. - * - * You should have received a copy of the GNU General Lesser Public + * + * You should have received a copy of the GNU General Lesser Public * License along with this program. If not, see * . * #L% @@ -36,7 +36,6 @@ import org.bitrepository.common.utils.TestFileHelper; import org.bitrepository.pillar.integration.ClientProvider; import org.bitrepository.protocol.fileexchange.HttpServerConfiguration; -import org.jaccept.TestEventManager; import java.util.List; @@ -46,7 +45,7 @@ public class PillarFileManager { private final Settings mySettings; private final ClientProvider clientProvider; @SuppressWarnings("unused") - private final TestEventManager testEventManager; + private final HttpServerConfiguration httpServerConfiguration; private int knownNumberOfFilesOnPillar = -1; @@ -55,14 +54,13 @@ public PillarFileManager( String pillarID, Settings mySettings, ClientProvider clientProvider, - TestEventManager testEventManager, HttpServerConfiguration httpServerConfiguration) { this.collectionID = collectionID; this.pillarID = pillarID; this.mySettings = mySettings; this.clientProvider = clientProvider; this.httpServerConfiguration = httpServerConfiguration; - this.testEventManager = testEventManager; + } /** @@ -70,14 +68,14 @@ public PillarFileManager( */ public void deleteAllFiles() { List filesWithChecksums = getChecksums(null, null, null); - for (ChecksumDataForChecksumSpecTYPE checksumData: filesWithChecksums) { + for (ChecksumDataForChecksumSpecTYPE checksumData : filesWithChecksums) { ChecksumDataForFileTYPE checksumDataForFile = new ChecksumDataForFileTYPE(); checksumDataForFile.setCalculationTimestamp(checksumData.getCalculationTimestamp()); checksumDataForFile.setChecksumSpec(ChecksumUtils.getDefault(mySettings)); checksumDataForFile.setChecksumValue(checksumData.getChecksumValue()); try { clientProvider.getDeleteFileClient().deleteFile(collectionID, - checksumData.getFileID(), pillarID, checksumDataForFile, null, null, ""); + checksumData.getFileID(), pillarID, checksumDataForFile, null, null, ""); } catch (OperationFailedException e) { throw new RuntimeException("Failed to delete from pillar " + pillarID, e); } @@ -88,6 +86,7 @@ public void deleteAllFiles() { * Will ensure that at least desiredNumberOfFiles are present on the pillar. Maintains a counter of * how many files where found last time, based on the assumation that the number of files between calls will * now decrease. If to few files are initially present, the remaining files are put to the pillar. + * * @param desiredNumberOfFiles */ public void ensureNumberOfFilesOnPillar(int desiredNumberOfFiles, String newFileIDPrefix) { @@ -109,7 +108,7 @@ public void addFilesToPillar(String collectionID, int numberOfFilesToAdd, String // ToDo: This would be more precise if the client allowed put to a single pillar. clientProvider.getPutClient().putFile(collectionID, httpServerConfiguration.getURL(TestFileHelper.DEFAULT_FILE_ID), newFileID, 10L, - TestFileHelper.getDefaultFileChecksum(), null, null, null); + TestFileHelper.getDefaultFileChecksum(), null, null, null); } catch (Exception e) { throw new RuntimeException("Failed to put file on pillar " + pillarID, e); } @@ -117,14 +116,14 @@ public void addFilesToPillar(String collectionID, int numberOfFilesToAdd, String } public List getFileIDs(ContributorQuery query) { - if(query == null) { + if (query == null) { query = new ContributorQuery(pillarID, null, null, null); } - + try { List result = clientProvider.getGetFileIDsClient(). - getGetFileIDs(collectionID, new ContributorQuery[]{query}, null, null, null); - FileIDsCompletePillarEvent pillarResult = (FileIDsCompletePillarEvent)result.get(0); + getGetFileIDs(collectionID, new ContributorQuery[]{query}, null, null, null); + FileIDsCompletePillarEvent pillarResult = (FileIDsCompletePillarEvent) result.get(0); return pillarResult.getFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem(); } catch (Exception e) { throw new RuntimeException("Failed to fileIDs from pillar " + pillarID, e); @@ -144,8 +143,8 @@ public List getChecksums(ChecksumSpecTYPE check try { List result = clientProvider.getGetChecksumsClient().getChecksums(collectionID, - new ContributorQuery[]{query}, fileID, checksumSpec, null, null, null); - ChecksumsCompletePillarEvent pillarResult = (ChecksumsCompletePillarEvent)result.get(0); + new ContributorQuery[]{query}, fileID, checksumSpec, null, null, null); + ChecksumsCompletePillarEvent pillarResult = (ChecksumsCompletePillarEvent) result.get(0); return pillarResult.getChecksums().getChecksumDataItems(); } catch (Exception e) { throw new RuntimeException("Failed to fileIDs from pillar " + pillarID, e); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetAuditTrailsFileStressIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetAuditTrailsFileStressIT.java index b6f262195..aa8bc451c 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetAuditTrailsFileStressIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetAuditTrailsFileStressIT.java @@ -36,6 +36,9 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class GetAuditTrailsFileStressIT extends PillarPerformanceTest { protected AuditTrailClient auditTrailClient; PutFileClient putClient; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetFileStressIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetFileStressIT.java index d9b1a02df..e2d86dc96 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetFileStressIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/GetFileStressIT.java @@ -32,11 +32,22 @@ import org.bitrepository.pillar.integration.perf.metrics.Metrics; import org.bitrepository.pillar.messagefactories.GetFileMessageFactory; import org.bitrepository.protocol.bus.MessageReceiver; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import java.io.IOException; +import java.nio.file.DirectoryStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class GetFileStressIT extends PillarPerformanceTest { + public static final String FOLDER_NAME = "src/test/resources"; protected GetFileClient getFileClient; @BeforeEach @@ -46,6 +57,23 @@ settingsForTestClient, createSecurityManager(), settingsForTestClient.getCompone ); } + @AfterAll + static void removeUnnecessaryFiles() throws IOException { + removeFiles("noIdentfy", FOLDER_NAME); + removeFiles("parallel", FOLDER_NAME); + removeFiles("single", FOLDER_NAME); + } + + private static void removeFiles(String fileStartsWith, String folderName) throws IOException { + Path directory = Paths.get(folderName); + String pathStr = directory.toAbsolutePath().toString(); + try (DirectoryStream stream = Files.newDirectoryStream(directory, fileStartsWith + "*")) { + for (Path entry : stream) { + Files.delete(entry); + } + } + } + @Test @Tag("pillar-stress-test") public void singleGetFilePerformanceTest() throws Exception { @@ -127,7 +155,7 @@ defaultFileId, null, getPillarID(), getPillarID(), } public String lookupGetFileDestination() { - MessageReceiver clientReceiver = new MessageReceiver(settingsForTestClient.getReceiverDestinationID(), testEventManager); + MessageReceiver clientReceiver = new MessageReceiver(settingsForTestClient.getReceiverDestinationID()); messageBus.addListener(clientReceiver.getDestination(), clientReceiver.getMessageListener()); GetFileMessageFactory pillarLookupmMsgFactory = new GetFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PutFileStressIT.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PutFileStressIT.java index 8cc2dd6f5..071c25373 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PutFileStressIT.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PutFileStressIT.java @@ -29,13 +29,15 @@ import org.bitrepository.modify.putfile.PutFileClient; import org.bitrepository.pillar.integration.perf.metrics.Metrics; import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + public class PutFileStressIT extends PillarPerformanceTest { protected PutFileClient putClient; @@ -46,7 +48,6 @@ settingsForTestClient, createSecurityManager(), settingsForTestClient.getCompone ); } - @Disabled("Temporarily disabled due to performance issues") @Test @Tag("pillar-stress-test") @Tag("stress-test-pillar-population") @@ -71,7 +72,6 @@ public void singleTreadedPut() throws Exception { //ToDo assert that the files are present } - @Disabled("Temporarily disabled due to performance issues") @Test @Tag("pillar-stress-test") public void parallelPut() throws Exception { diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/DeleteFileTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/DeleteFileTest.java index 3af9880e4..de01c8c5a 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/DeleteFileTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/DeleteFileTest.java @@ -25,24 +25,30 @@ */ package org.bitrepository.pillar.messagehandling; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.AlarmCode; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositorymessages.*; import org.bitrepository.pillar.MockedPillarTest; import org.bitrepository.pillar.messagefactories.DeleteFileMessageFactory; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.mockito.ArgumentMatchers; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.ArgumentMatchers.*; + /** * Tests the PutFile functionality on the ReferencePillar. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class DeleteFileTest extends MockedPillarTest { private DeleteFileMessageFactory msgFactory; @@ -58,8 +64,8 @@ public void initializeCUT() { @Tag("regressiontest") @Tag("pillartest") public void goodCaseIdentification() throws Exception { - addDescription("Tests the identification for a DeleteFile operation on the pillar for the successful scenario" + - "."); + addDescription( + "Tests the identification for a DeleteFile operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); final String FILE_ID = defaultFileId + testMethodName; @@ -69,7 +75,7 @@ public void goodCaseIdentification() throws Exception { public Boolean answer(InvocationOnMock invocation) { return true; } - }).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + }).when(model).hasFileID(eq(FILE_ID), anyString()); Mockito.doAnswer(new Answer() { public String answer(InvocationOnMock invocation) { return settingsForCUT.getComponentID(); @@ -86,12 +92,13 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); - Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); + assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + ResponseCode.IDENTIFICATION_POSITIVE); + assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); + assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - Assertions.assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -110,7 +117,7 @@ public void badCaseIdentification() throws Exception { public Boolean answer(InvocationOnMock invocation) { return false; } - }).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + }).when(model).hasFileID(eq(FILE_ID), anyString()); Mockito.doAnswer(new Answer() { public String answer(InvocationOnMock invocation) { return settingsForCUT.getComponentID(); @@ -127,12 +134,13 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); - Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); + assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); + assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - Assertions.assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -151,7 +159,7 @@ public void badCaseOperationNoFile() throws Exception { public Boolean answer(InvocationOnMock invocation) { return false; } - }).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + }).when(model).hasFileID(eq(FILE_ID), anyString()); Mockito.doAnswer(new Answer() { public String answer(InvocationOnMock invocation) { return settingsForCUT.getComponentID(); @@ -167,12 +175,12 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the DeleteFile request", "The final response should tell about the error, and not contain the file."); DeleteFileFinalResponse finalResponse = clientReceiver.waitForMessage(DeleteFileFinalResponse.class); - Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); - Assertions.assertEquals(FILE_ID, finalResponse.getFileID()); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); + assertEquals(getPillarID(), finalResponse.getPillarID()); + assertEquals(FILE_ID, finalResponse.getFileID()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - Assertions.assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -191,7 +199,7 @@ public void badCaseOperationMissingVerification() throws Exception { public Boolean answer(InvocationOnMock invocation) { return true; } - }).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + }).when(model).hasFileID(eq(FILE_ID), anyString()); Mockito.doAnswer(new Answer() { public String answer(InvocationOnMock invocation) { return settingsForCUT.getComponentID(); @@ -207,19 +215,19 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the DeleteFile request", "The final response should tell about the error, and not contain the file."); DeleteFileFinalResponse finalResponse = clientReceiver.waitForMessage(DeleteFileFinalResponse.class); - Assertions.assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); - Assertions.assertEquals(FILE_ID, finalResponse.getFileID()); + assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE); + assertEquals(finalResponse.getPillarID(), getPillarID()); + assertEquals(finalResponse.getFileID(), FILE_ID); addStep("Pillar should have sent an alarm", "Alarm contains information about the missing verification " + "checksum"); AlarmMessage alarm = alarmReceiver.waitForMessage(AlarmMessage.class); - Assertions.assertEquals(FILE_ID, alarm.getAlarm().getFileID()); - Assertions.assertEquals(getPillarID(), alarm.getAlarm().getAlarmRaiser()); - Assertions.assertEquals(AlarmCode.CHECKSUM_ALARM, alarm.getAlarm().getAlarmCode()); + assertEquals(FILE_ID, alarm.getAlarm().getFileID()); + assertEquals(getPillarID(), alarm.getAlarm().getAlarmRaiser()); + assertEquals(AlarmCode.CHECKSUM_ALARM, alarm.getAlarm().getAlarmCode()); - Assertions.assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -239,7 +247,7 @@ public void goodCaseOperation() throws Exception { public Boolean answer(InvocationOnMock invocation) { return true; } - }).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + }).when(model).hasFileID(eq(FILE_ID), anyString()); Mockito.doAnswer(new Answer() { public String answer(InvocationOnMock invocation) { return settingsForCUT.getComponentID(); @@ -249,7 +257,7 @@ public String answer(InvocationOnMock invocation) { public String answer(InvocationOnMock invocation) { return DEFAULT_MD5_CHECKSUM; } - }).when(model).getChecksumForFile(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString(), ArgumentMatchers.any(ChecksumSpecTYPE.class)); + }).when(model).getChecksumForFile(eq(FILE_ID), anyString(), any(ChecksumSpecTYPE.class)); addStep("Create and send the actual DeleteFile message to the pillar.", "Should be received and handled by the pillar."); @@ -259,18 +267,18 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the ProgressResponse for the DeleteFile request", "The DeleteFile progress response should be sent by the pillar."); DeleteFileProgressResponse progressResponse = clientReceiver.waitForMessage(DeleteFileProgressResponse.class); - Assertions.assertEquals(FILE_ID, progressResponse.getFileID()); - Assertions.assertEquals(getPillarID(), progressResponse.getPillarID()); + assertEquals(FILE_ID, progressResponse.getFileID()); + assertEquals(getPillarID(), progressResponse.getPillarID()); addStep("Retrieve the FinalResponse for the DeleteFile request", "The final response should tell about the error, and not contain the file."); DeleteFileFinalResponse finalResponse = clientReceiver.waitForMessage(DeleteFileFinalResponse.class); - Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); - Assertions.assertEquals(FILE_ID, finalResponse.getFileID()); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); + assertEquals(getPillarID(), finalResponse.getPillarID()); + assertEquals(FILE_ID, finalResponse.getFileID()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - Assertions.assertEquals(1, audits.getCallsForAuditEvent(), + assertEquals(1, audits.getCallsForAuditEvent(), "Should create one audit trail for the DeleteFile operation"); } } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GeneralMessageHandlingTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GeneralMessageHandlingTest.java index 9ec7078ce..e0eb7e05b 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GeneralMessageHandlingTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GeneralMessageHandlingTest.java @@ -3,7 +3,8 @@ * Bitrepository Reference Pillar * * $Id: PutFileOnReferencePillarTest.java 589 2011-12-01 15:34:42Z jolf $ - * $HeadURL: https://sbforge.org/svn/bitrepository/bitrepository-reference/trunk/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/PutFileOnReferencePillarTest.java $ + * $HeadURL: https://sbforge.org/svn/bitrepository/bitrepository-reference/trunk/bitrepository-reference-pillar/src + * /test/java/org/bitrepository/pillar/PutFileOnReferencePillarTest.java $ * %% * Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark * %% @@ -24,6 +25,7 @@ */ package org.bitrepository.pillar.messagehandling; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositorymessages.MessageRequest; import org.bitrepository.bitrepositorymessages.MessageResponse; import org.bitrepository.pillar.MockedPillarTest; @@ -36,9 +38,13 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; import static org.junit.jupiter.api.Assertions.assertThrows; +@ExtendWith(SuiteInfoParameterResolver.class) public class GeneralMessageHandlingTest extends MockedPillarTest { MockRequestHandler requestHandler; @@ -110,7 +116,7 @@ public void testPillarMessageHandlerValidateFileIDFormatRootPathFileId() throws public void testPillarMessageHandlerValidateFileIDFormatSubFolderToParentFolderFileId() throws Exception { assertThrows(RequestHandlerException.class, () -> { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id " + - "containing path to a parent directory, but starting with a sub-folder"); + "containing path to a parent directory, but starting with a sub-folder"); requestHandler.validateFileIDFormat("OTHER_COLLECTION/../../folderDir/test.txt"); }); } @@ -121,7 +127,7 @@ public void testPillarMessageHandlerValidateFileIDFormatSubFolderToParentFolderF public void testPillarMessageHandlerValidateFileIDFormatEnvHomePathFileId() throws Exception { assertThrows(RequestHandlerException.class, () -> { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id " + - "containing path relative paths from the environment variable home folder"); + "containing path relative paths from the environment variable home folder"); requestHandler.validateFileIDFormat("$HOME/bin/execute.sh"); }); } @@ -132,7 +138,7 @@ public void testPillarMessageHandlerValidateFileIDFormatEnvHomePathFileId() thro public void testPillarMessageHandlerValidateFileIDFormatTildeHomePathFileId() throws Exception { assertThrows(RequestHandlerException.class, () -> { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id " + - "containing path relative paths from the tilde home folder"); + "containing path relative paths from the tilde home folder"); requestHandler.validateFileIDFormat("~/bin/execute.sh"); }); } @@ -143,7 +149,7 @@ public void testPillarMessageHandlerValidateFileIDFormatTildeHomePathFileId() th public void testPillarMessageHandlerValidateFileIDFormatTooLong() throws Exception { assertThrows(RequestHandlerException.class, () -> { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id " + - "which has more characters than required"); + "which has more characters than required"); String fileId = ""; for (int i = 0; i < 300; i++) { fileId += Integer.toString(i); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetAuditTrailsTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetAuditTrailsTest.java index d64158373..13f99808d 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetAuditTrailsTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetAuditTrailsTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.pillar.messagehandling; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.AuditTrailEvent; import org.bitrepository.bitrepositoryelements.FileAction; import org.bitrepository.bitrepositoryelements.ResponseCode; @@ -31,12 +32,16 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigInteger; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +@ExtendWith(SuiteInfoParameterResolver.class) public class GetAuditTrailsTest extends MockedPillarTest { private GetAuditTrailsMessageFactory msgFactory; @@ -68,7 +73,8 @@ public void checksumPillarGetAuditTrailsSuccessful() { Assertions.assertEquals(identifyRequest.getCorrelationID(), receivedIdentifyResponse.getCorrelationID()); Assertions.assertEquals(settingsForCUT.getComponentID(), receivedIdentifyResponse.getFrom()); Assertions.assertEquals(identifyRequest.getReplyTo(), receivedIdentifyResponse.getDestination()); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); addStep("Make and send the request for the actual GetAuditTrails operation", "Should be caught and handled by the pillar."); @@ -78,12 +84,14 @@ public void checksumPillarGetAuditTrailsSuccessful() { messageBus.sendMessage(request); addStep("Receive and validate the progress response.", "Should be sent by the pillar."); - GetAuditTrailsProgressResponse progressResponse = clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); + GetAuditTrailsProgressResponse progressResponse = + clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); Assertions.assertEquals(collectionID, progressResponse.getCollectionID()); Assertions.assertEquals(identifyRequest.getCorrelationID(), progressResponse.getCorrelationID()); Assertions.assertEquals(settingsForCUT.getComponentID(), progressResponse.getFrom()); Assertions.assertEquals(identifyRequest.getReplyTo(), receivedIdentifyResponse.getDestination()); - Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, progressResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); addStep("Receive and validate the final response", "Should be sent by the pillar."); GetAuditTrailsFinalResponse finalResponse = clientReceiver.waitForMessage(GetAuditTrailsFinalResponse.class); @@ -92,7 +100,8 @@ public void checksumPillarGetAuditTrailsSuccessful() { Assertions.assertEquals(settingsForCUT.getComponentID(), receivedIdentifyResponse.getFrom()); Assertions.assertEquals(identifyRequest.getReplyTo(), receivedIdentifyResponse.getDestination()); Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(1, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); + Assertions.assertEquals(1, + finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); } @Test @@ -126,7 +135,8 @@ public void checksumPillarGetAuditTrailsSpecificRequests() { addStep("Retrieve and validate the response.", "Should be a positive response."); IdentifyContributorsForGetAuditTrailsResponse identifyResponse = clientReceiver.waitForMessage( IdentifyContributorsForGetAuditTrailsResponse.class); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, identifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + identifyResponse.getResponseInfo().getResponseCode()); addStep("Make and send the request for the actual GetAuditTrails operation", "Should be caught and handled by the pillar."); @@ -136,14 +146,18 @@ public void checksumPillarGetAuditTrailsSpecificRequests() { messageBus.sendMessage(request); addStep("Receive and validate the progress response.", "Should be sent by the pillar."); - GetAuditTrailsProgressResponse progressResponse = clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); - Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, progressResponse.getResponseInfo().getResponseCode()); + GetAuditTrailsProgressResponse progressResponse = + clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); addStep("Receive and validate the final response", "Should be sent by the pillar."); GetAuditTrailsFinalResponse finalResponse = clientReceiver.waitForMessage(GetAuditTrailsFinalResponse.class); Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(1, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); - AuditTrailEvent event = finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().get(0); + Assertions.assertEquals(1, + finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); + AuditTrailEvent event = + finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().get(0); Assertions.assertEquals(ACTOR, event.getActorOnFile()); Assertions.assertEquals(AUDITTRAIL, event.getAuditTrailInformation()); Assertions.assertEquals(FILE_ID, event.getFileID()); @@ -153,18 +167,20 @@ public void checksumPillarGetAuditTrailsSpecificRequests() { addStep("Make another request, where both ingested audit trails is requested", "Should be handled by the pillar."); request = msgFactory.createGetAuditTrailsRequest(auditTrail, getComponentID(), - identifyRequest.getCorrelationID(), null, getPillarID(), null, null, - null, null, null, clientDestinationId, null, pillarDestinationId); + identifyRequest.getCorrelationID(), null, getPillarID(), null, null, null, null, null, + clientDestinationId, null, pillarDestinationId); messageBus.sendMessage(request); addStep("Receive and validate the progress response.", "Should be sent by the pillar."); progressResponse = clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); - Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, progressResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); addStep("Receive and validate the final response", "Should be sent by the pillar."); finalResponse = clientReceiver.waitForMessage(GetAuditTrailsFinalResponse.class); Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(2, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); + Assertions.assertEquals(2, + finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); Assertions.assertFalse(finalResponse.isPartialResult()); } @@ -215,15 +231,18 @@ public void checksumPillarGetAuditTrailsMaximumNumberOfResults() { null, null, null, null, clientDestinationId, null, pillarDestinationId); messageBus.sendMessage(request); - GetAuditTrailsProgressResponse progressResponse = clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); + GetAuditTrailsProgressResponse progressResponse = + clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); Assertions.assertEquals(collectionID, progressResponse.getCollectionID()); - Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, progressResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); addStep("Validate the final response", "Contains OPERATION_COMPLETE, " + "with only the requested amount of audits, and acknowledges that it is only a partial result set."); GetAuditTrailsFinalResponse finalResponse = clientReceiver.waitForMessage(GetAuditTrailsFinalResponse.class); Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); - Assertions.assertEquals(maxNumberOfResults, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); + Assertions.assertEquals(maxNumberOfResults, + finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); Assertions.assertTrue(finalResponse.isSetPartialResult()); } } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetChecksumsTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetChecksumsTest.java index 4b1f1e4ce..9479a66ec 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetChecksumsTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetChecksumsTest.java @@ -25,6 +25,7 @@ */ package org.bitrepository.pillar.messagehandling; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.bitrepositoryelements.FileIDs; import org.bitrepository.bitrepositoryelements.ResponseCode; @@ -38,6 +39,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; @@ -46,9 +48,13 @@ import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Tests the PutFile functionality on the ReferencePillar. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class GetChecksumsTest extends MockedPillarTest { private GetChecksumsMessageFactory msgFactory; @@ -93,7 +99,8 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetChecksumsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetChecksumsResponse.class); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(fileids, receivedIdentifyResponse.getFileIDs()); @@ -135,7 +142,8 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetChecksumsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetChecksumsResponse.class); - Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(fileids, receivedIdentifyResponse.getFileIDs()); @@ -193,7 +201,8 @@ public ExtractedChecksumResultSet answer(InvocationOnMock invocation) { Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); Assertions.assertEquals(1, finalResponse.getResultingChecksums().getChecksumDataItems().size()); - Assertions.assertEquals(FILE_ID, finalResponse.getResultingChecksums().getChecksumDataItems().get(0).getFileID()); + Assertions.assertEquals(FILE_ID, + finalResponse.getResultingChecksums().getChecksumDataItems().get(0).getFileID()); } @SuppressWarnings("rawtypes") @@ -333,6 +342,7 @@ public ExtractedChecksumResultSet answer(InvocationOnMock invocation) { Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); Assertions.assertEquals(1, finalResponse.getResultingChecksums().getChecksumDataItems().size()); - Assertions.assertEquals(defaultFileId, finalResponse.getResultingChecksums().getChecksumDataItems().get(0).getFileID()); + Assertions.assertEquals(defaultFileId, + finalResponse.getResultingChecksums().getChecksumDataItems().get(0).getFileID()); } } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileIDsTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileIDsTest.java index 3d1bc2b6a..a783c3f52 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileIDsTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileIDsTest.java @@ -25,6 +25,7 @@ */ package org.bitrepository.pillar.messagehandling; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.FileIDs; import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositorymessages.*; @@ -36,6 +37,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; @@ -44,9 +46,13 @@ import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Tests the PutFile functionality on the ReferencePillar. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class GetFileIDsTest extends MockedPillarTest { private GetFileIDsMessageFactory msgFactory; @@ -62,8 +68,8 @@ public void initializeCUT() { @Tag("regressiontest") @Tag("pillartest") public void goodCaseIdentification() throws Exception { - addDescription("Tests the identification for a GetFileIDs operation on the pillar " + - "for the successful scenario."); + addDescription( + "Tests the identification for a GetFileIDs operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); String FILE_ID = defaultFileId + testMethodName; FileIDs fileids = FileIDsUtils.getSpecificFileIDs(FILE_ID); @@ -91,7 +97,8 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileIDsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileIDsResponse.class); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(fileids, receivedIdentifyResponse.getFileIDs()); @@ -133,7 +140,8 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileIDsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileIDsResponse.class); - Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(fileids, receivedIdentifyResponse.getFileIDs()); @@ -163,13 +171,15 @@ public String answer(InvocationOnMock invocation) { } }).when(model).getPillarID(); Mockito.doAnswer(new Answer() { - public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { - ExtractedFileIDsResultSet res = new ExtractedFileIDsResultSet(); - res.insertFileID(FILE_ID, new Date(0)); - return res; - } - }).when(model).getFileIDsResultSet(ArgumentMatchers.anyString(), ArgumentMatchers.any(XMLGregorianCalendar.class), - ArgumentMatchers.any(XMLGregorianCalendar.class), ArgumentMatchers.anyLong(), ArgumentMatchers.anyString()); + public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { + ExtractedFileIDsResultSet res = new ExtractedFileIDsResultSet(); + res.insertFileID(FILE_ID, new Date(0)); + return res; + } + }).when(model) + .getFileIDsResultSet(ArgumentMatchers.anyString(), ArgumentMatchers.any(XMLGregorianCalendar.class), + ArgumentMatchers.any(XMLGregorianCalendar.class), ArgumentMatchers.anyLong(), + ArgumentMatchers.anyString()); addStep("Create and send the actual GetFileIDs message to the pillar.", "Should be received and handled by the pillar."); @@ -192,7 +202,8 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { Assertions.assertEquals(1, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); Assertions.assertEquals(FILE_ID, - finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID()); + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0) + .getFileID()); } @SuppressWarnings("rawtypes") @@ -225,7 +236,8 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { return res; } }).when(model).getFileIDsResultSet(ArgumentMatchers.isNull(), ArgumentMatchers.any(XMLGregorianCalendar.class), - ArgumentMatchers.any(XMLGregorianCalendar.class), ArgumentMatchers.anyLong(), ArgumentMatchers.anyString()); + ArgumentMatchers.any(XMLGregorianCalendar.class), ArgumentMatchers.anyLong(), + ArgumentMatchers.anyString()); addStep("Create and send the actual GetFileIDs message to the pillar.", "Should be received and handled by the pillar."); @@ -348,6 +360,7 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { Assertions.assertEquals(1, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); Assertions.assertEquals(FILE_ID, - finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID()); + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0) + .getFileID()); } } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileTest.java index c484e4407..38caf1f69 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/GetFileTest.java @@ -25,6 +25,7 @@ */ package org.bitrepository.pillar.messagehandling; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositorymessages.*; import org.bitrepository.common.filestore.FileInfo; @@ -37,6 +38,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; @@ -44,10 +46,14 @@ import java.io.ByteArrayInputStream; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Tests the PutFile functionality on the ReferencePillar. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class GetFileTest extends MockedPillarTest { private GetFileMessageFactory msgFactory; @@ -83,7 +89,8 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileResponse.class); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); @@ -123,7 +130,8 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileResponse.class); - Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/PutFileTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/PutFileTest.java index 479da4390..fbaf178b7 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/PutFileTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/PutFileTest.java @@ -25,6 +25,7 @@ */ package org.bitrepository.pillar.messagehandling; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.AlarmCode; import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; @@ -37,14 +38,19 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Tests the PutFile functionality on the ReferencePillar. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class PutFileTest extends MockedPillarTest { PutFileMessageFactory msgFactory; Long FILE_SIZE = 1L; @@ -90,7 +96,8 @@ public Object answer(InvocationOnMock invocation) throws Throwable { "The pillar should make a response."); IdentifyPillarsForPutFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForPutFileResponse.class); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); @@ -131,7 +138,8 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForPutFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForPutFileResponse.class); - Assertions.assertEquals(ResponseCode.DUPLICATE_FILE_FAILURE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.DUPLICATE_FILE_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); @@ -214,7 +222,8 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the PutFile request", "The final response should say 'operation_complete', and give the requested data."); PutFileFinalResponse finalResponse = clientReceiver.waitForMessage(PutFileFinalResponse.class); - Assertions.assertEquals(ResponseCode.NEW_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.NEW_FILE_CHECKSUM_FAILURE, + finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); Assertions.assertEquals(FILE_ID, finalResponse.getFileID()); @@ -295,7 +304,8 @@ public void goodCaseOperationWithChecksumReturn() throws Exception { res.setCalculationTimestamp(CalendarUtils.getNow()); res.setChecksumValue(Base16Utils.encodeBase16(DEFAULT_MD5_CHECKSUM)); return res; - }).when(model).getChecksumDataForFile(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString(), ArgumentMatchers.any(ChecksumSpecTYPE.class)); + }).when(model).getChecksumDataForFile(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString(), + ArgumentMatchers.any(ChecksumSpecTYPE.class)); addStep("Create and send the identify request message.", "Should be received and handled by the pillar."); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/ReplaceFileTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/ReplaceFileTest.java index e5016b9fc..afd7bdbdd 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/ReplaceFileTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/messagehandling/ReplaceFileTest.java @@ -26,6 +26,7 @@ package org.bitrepository.pillar.messagehandling; import org.apache.commons.codec.DecoderException; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.AlarmCode; import org.bitrepository.bitrepositoryelements.ChecksumDataForFileTYPE; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; @@ -38,14 +39,22 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentMatchers; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.doAnswer; + /** * Tests the ReplaceFile functionality on the ReferencePillar. */ +@ExtendWith(SuiteInfoParameterResolver.class) public class ReplaceFileTest extends MockedPillarTest { ReplaceFileMessageFactory msgFactory; Long FILE_SIZE = 1L; @@ -69,7 +78,8 @@ public void goodCaseIdentification() { addStep("Setup for having the file and delivering pillar id", "Should return true, when requesting file-id existence."); - Mockito.doAnswer(invocation -> true).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + Mockito.doAnswer(invocation -> true).when(model) + .hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> settingsForCUT.getComponentID()).when(model).getPillarID(); addStep("Create and send the identify request message.", @@ -82,7 +92,8 @@ public void goodCaseIdentification() { "The pillar should make a response."); IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); @@ -102,7 +113,8 @@ public void badCaseIdentification() { addStep("Setup for not having the file and delivering pillar id", "Should return false, when requesting file-id existence."); - Mockito.doAnswer(invocation -> false).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + Mockito.doAnswer(invocation -> false).when(model) + .hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> settingsForCUT.getComponentID()).when(model).getPillarID(); addStep("Create and send the identify request message.", @@ -115,7 +127,8 @@ public void badCaseIdentification() { "The pillar should make a response."); IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, receivedIdentifyResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), receivedIdentifyResponse.getPillarID()); Assertions.assertEquals(FILE_ID, receivedIdentifyResponse.getFileID()); @@ -135,7 +148,8 @@ public void badCaseOperationMissingFile() { addStep("Setup for not having the file and delivering pillar id", "Should return false, when requesting file-id existence."); - Mockito.doAnswer(invocation -> false).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + Mockito.doAnswer(invocation -> false).when(model) + .hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(new Answer() { public String answer(InvocationOnMock invocation) { return settingsForCUT.getComponentID(); @@ -172,7 +186,8 @@ public void badCaseOperationNoDestructiveChecksum() { addStep("Setup for having the file and delivering pillar id", "Should return true, when requesting file-id existence."); - Mockito.doAnswer(invocation -> true).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + Mockito.doAnswer(invocation -> true).when(model) + .hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> settingsForCUT.getComponentID()).when(model).getPillarID(); addStep("Create and send the identify request message.", @@ -184,7 +199,8 @@ public void badCaseOperationNoDestructiveChecksum() { addStep("Retrieve the FinalResponse for the ReplaceFile request", "The final response should give existing checksum failure."); ReplaceFileFinalResponse finalResponse = clientReceiver.waitForMessage(ReplaceFileFinalResponse.class); - Assertions.assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, + finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); Assertions.assertEquals(FILE_ID, finalResponse.getFileID()); @@ -209,7 +225,8 @@ public void badCaseOperationNoValidationChecksum() { addStep("Setup for having the file and delivering pillar id", "Should return true, when requesting file-id existence."); - Mockito.doAnswer(invocation -> true).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + Mockito.doAnswer(invocation -> true).when(model) + .hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> settingsForCUT.getComponentID()).when(model).getPillarID(); addStep("Create and send the identify request message.", @@ -221,7 +238,8 @@ public void badCaseOperationNoValidationChecksum() { addStep("Retrieve the FinalResponse for the ReplaceFile request", "The final response should give new file checksum failure."); ReplaceFileFinalResponse finalResponse = clientReceiver.waitForMessage(ReplaceFileFinalResponse.class); - Assertions.assertEquals(ResponseCode.NEW_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.NEW_FILE_CHECKSUM_FAILURE, + finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); Assertions.assertEquals(FILE_ID, finalResponse.getFileID()); @@ -248,8 +266,9 @@ public void badCaseOperationWrongDestructiveChecksum() throws Exception { Mockito.doAnswer(invocation -> true).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> settingsForCUT.getComponentID()).when(model).getPillarID(); - Mockito.doAnswer(invocation -> NON_DEFAULT_MD5_CHECKSUM).when(model).getChecksumForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), - ArgumentMatchers.any(ChecksumSpecTYPE.class)); + Mockito.doAnswer(invocation -> NON_DEFAULT_MD5_CHECKSUM).when(model) + .getChecksumForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), + ArgumentMatchers.any(ChecksumSpecTYPE.class)); addStep("Create and send the identify request message.", "Should be received and handled by the pillar."); @@ -260,7 +279,8 @@ public void badCaseOperationWrongDestructiveChecksum() throws Exception { addStep("Retrieve the FinalResponse for the ReplaceFile request", "The final response should give existing file checksum failure."); ReplaceFileFinalResponse finalResponse = clientReceiver.waitForMessage(ReplaceFileFinalResponse.class); - Assertions.assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); + Assertions.assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, + finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(getPillarID(), finalResponse.getPillarID()); Assertions.assertEquals(FILE_ID, finalResponse.getFileID()); @@ -283,10 +303,12 @@ public void goodCaseOperation() throws Exception { addStep("Setup for already having the file and delivering pillar id", "Should return true, when requesting file-id existence."); - Mockito.doAnswer(invocation -> true).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + Mockito.doAnswer(invocation -> true).when(model) + .hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> settingsForCUT.getComponentID()).when(model).getPillarID(); - Mockito.doAnswer(invocation -> DEFAULT_MD5_CHECKSUM).when(model).getChecksumForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), - ArgumentMatchers.any(ChecksumSpecTYPE.class)); + Mockito.doAnswer(invocation -> DEFAULT_MD5_CHECKSUM).when(model) + .getChecksumForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), + ArgumentMatchers.any(ChecksumSpecTYPE.class)); addStep("Create and send the identify request message.", "Should be received and handled by the pillar."); @@ -328,10 +350,12 @@ public void goodCaseOperationWithChecksumsReturn() throws Exception { addStep("Setup for already having the file and delivering pillar id", "Should return true, when requesting file-id existence."); - Mockito.doAnswer(invocation -> true).when(model).hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); + Mockito.doAnswer(invocation -> true).when(model) + .hasFileID(ArgumentMatchers.eq(FILE_ID), ArgumentMatchers.anyString()); Mockito.doAnswer(invocation -> settingsForCUT.getComponentID()).when(model).getPillarID(); - Mockito.doAnswer(invocation -> DEFAULT_MD5_CHECKSUM).when(model).getChecksumForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), - ArgumentMatchers.any(ChecksumSpecTYPE.class)); + Mockito.doAnswer(invocation -> DEFAULT_MD5_CHECKSUM).when(model) + .getChecksumForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), + ArgumentMatchers.any(ChecksumSpecTYPE.class)); Mockito.doAnswer(invocation -> { ChecksumDataForFileTYPE res = new ChecksumDataForFileTYPE(); res.setChecksumSpec(otherCsSpec); @@ -342,14 +366,14 @@ public void goodCaseOperationWithChecksumsReturn() throws Exception { e.printStackTrace(); } return res; - }).when(model).getChecksumDataForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.eq(otherCsSpec)); - Mockito.doAnswer(invocation -> { + }).when(model).getChecksumDataForFile(anyString(), anyString(), eq(otherCsSpec)); + doAnswer(invocation -> { ChecksumDataForFileTYPE res = new ChecksumDataForFileTYPE(); res.setChecksumSpec(csSpec); res.setCalculationTimestamp(CalendarUtils.getNow()); res.setChecksumValue(Base16Utils.encodeBase16(DEFAULT_MD5_CHECKSUM)); return res; - }).when(model).getChecksumDataForFile(ArgumentMatchers.anyString(), ArgumentMatchers.anyString(), ArgumentMatchers.eq(csSpec)); + }).when(model).getChecksumDataForFile(anyString(), anyString(), eq(csSpec)); addStep("Create and send the identify request message.", "Should be received and handled by the pillar."); @@ -372,7 +396,8 @@ public void goodCaseOperationWithChecksumsReturn() throws Exception { Assertions.assertNotNull(finalResponse.getChecksumDataForNewFile()); Assertions.assertEquals(newRequestChecksumSpec, finalResponse.getChecksumDataForNewFile().getChecksumSpec()); Assertions.assertNotNull(finalResponse.getChecksumDataForExistingFile()); - Assertions.assertEquals(existingRequestChecksumSpec, finalResponse.getChecksumDataForExistingFile().getChecksumSpec()); + Assertions.assertEquals(existingRequestChecksumSpec, + finalResponse.getChecksumDataForExistingFile().getChecksumSpec()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); Assertions.assertEquals(1, audits.getCallsForAuditEvent(), "Should make 1 put-file audit trail"); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/schedulablejobs/RecalculateChecksumWorkflowTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/schedulablejobs/RecalculateChecksumWorkflowTest.java index 0748027c4..efd0b6a7c 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/schedulablejobs/RecalculateChecksumWorkflowTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/schedulablejobs/RecalculateChecksumWorkflowTest.java @@ -21,17 +21,23 @@ * #L% */ +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.pillar.DefaultPillarTest; import org.bitrepository.service.workflow.SchedulableJob; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class RecalculateChecksumWorkflowTest extends DefaultPillarTest { DatatypeFactory factory; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/ChecksumPillarModelTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/ChecksumPillarModelTest.java index 4c08ab42b..e424976e8 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/ChecksumPillarModelTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/ChecksumPillarModelTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.pillar.store; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.bitrepositoryelements.ChecksumType; import org.bitrepository.common.utils.ChecksumUtils; @@ -32,10 +33,15 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.util.Date; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class ChecksumPillarModelTest extends DefaultFixturePillarTest { ChecksumStorageModel pillarModel; ChecksumStore cache; @@ -82,12 +88,14 @@ public void testPillarModelBasicFunctionality() { "It should say as it is in settings, or return default"); settingsForCUT.getReferenceSettings().getPillarSettings().setChecksumPillarFileDownload( ChecksumPillarFileDownload.ALWAYS_DOWNLOAD); - Assertions.assertEquals(ChecksumPillarFileDownload.ALWAYS_DOWNLOAD, pillarModel.getChecksumPillarFileDownload()); + Assertions.assertEquals(ChecksumPillarFileDownload.ALWAYS_DOWNLOAD, + pillarModel.getChecksumPillarFileDownload()); settingsForCUT.getReferenceSettings().getPillarSettings().setChecksumPillarFileDownload( ChecksumPillarFileDownload.NEVER_DOWNLOAD); Assertions.assertEquals(ChecksumPillarFileDownload.NEVER_DOWNLOAD, pillarModel.getChecksumPillarFileDownload()); settingsForCUT.getReferenceSettings().getPillarSettings().setChecksumPillarFileDownload(null); - Assertions.assertEquals(ChecksumPillarFileDownload.DOWNLOAD_WHEN_MISSING_FROM_MESSAGE, pillarModel.getChecksumPillarFileDownload()); + Assertions.assertEquals(ChecksumPillarFileDownload.DOWNLOAD_WHEN_MISSING_FROM_MESSAGE, + pillarModel.getChecksumPillarFileDownload()); } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/FullPillarModelTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/FullPillarModelTest.java index 16dcf2006..d5d888ca2 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/FullPillarModelTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/FullPillarModelTest.java @@ -21,6 +21,7 @@ */ package org.bitrepository.pillar.store; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.bitrepositoryelements.ChecksumSpecTYPE; import org.bitrepository.bitrepositoryelements.ChecksumType; import org.bitrepository.common.filestore.FileInfo; @@ -35,10 +36,15 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.io.ByteArrayInputStream; import java.io.IOException; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class FullPillarModelTest extends DefaultFixturePillarTest { FileStorageModel pillarModel; ChecksumStore cache; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ArchiveDirectoryTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ArchiveDirectoryTest.java index af3b999f1..95b75ae6a 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ArchiveDirectoryTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ArchiveDirectoryTest.java @@ -24,7 +24,6 @@ import org.bitrepository.common.utils.FileUtils; import org.bitrepository.common.utils.TestFileHelper; import org.bitrepository.pillar.store.filearchive.ArchiveDirectory; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; @@ -38,8 +37,10 @@ import java.util.List; import java.util.Objects; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; -class ArchiveDirectoryTest extends ExtendedTestCase { +class ArchiveDirectoryTest { private static final String DIR_NAME = "archive-directory"; private static final String FILE_DIR_NAME = DIR_NAME + "/fileDir"; private static final String FOLDER_DIR_NAME = DIR_NAME + "/" + ArchiveDirectory.FOLDER_DIR; @@ -48,7 +49,7 @@ class ArchiveDirectoryTest extends ExtendedTestCase { private static final String FOLDER_FILE_ID = "folder1/folder2/file1"; @AfterEach - void shutdownTests() throws Exception { + public void shutdownTests() throws Exception { File dir = new File(DIR_NAME); if (dir.exists()) { FileUtils.delete(new File(DIR_NAME)); @@ -58,7 +59,7 @@ void shutdownTests() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryExistingFile() throws Exception { + public void testArchiveDirectoryExistingFile() throws Exception { addDescription("Test the ArchiveDirectory when the file exists"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -79,7 +80,7 @@ void testArchiveDirectoryExistingFile() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryMissingFile() throws Exception { + public void testArchiveDirectoryMissingFile() throws Exception { addDescription("Test the ArchiveDirectory when the file is missing."); addStep("Setup", "No file added to the directory."); @@ -102,7 +103,7 @@ void testArchiveDirectoryMissingFile() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryNewFile() throws Exception { + public void testArchiveDirectoryNewFile() throws Exception { addDescription("Testing the ArchiveDirectory handling of a new file."); addStep("Setup", "No file added to the directory."); ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); @@ -141,7 +142,7 @@ void testArchiveDirectoryNewFile() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryMoveFileToArchive() throws Exception { + public void testArchiveDirectoryMoveFileToArchive() throws Exception { addDescription("Testing the error scenarios when moving a file from tmp to archive for the ArchiveDirectory."); addStep("Setup", "No file added to the directory."); ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); @@ -184,7 +185,7 @@ void testArchiveDirectoryMoveFileToArchive() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryRemoveFile() throws Exception { + public void testArchiveDirectoryRemoveFile() throws Exception { addDescription("Testing the error scenarios when removing files from the archive."); addStep("Setup", "No file added to the directory."); ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); @@ -223,7 +224,7 @@ void testArchiveDirectoryRemoveFile() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryExistingFolderFile() throws Exception { + public void testArchiveDirectoryExistingFolderFile() throws Exception { addDescription("Test the ArchiveDirectory when the file exists"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -244,7 +245,7 @@ void testArchiveDirectoryExistingFolderFile() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryMissingFolderFile() throws Exception { + public void testArchiveDirectoryMissingFolderFile() throws Exception { addDescription("Test the ArchiveDirectory when the file is missing."); addStep("Setup", "No file added to the directory."); @@ -267,7 +268,7 @@ void testArchiveDirectoryMissingFolderFile() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryNewFolderFile() throws Exception { + public void testArchiveDirectoryNewFolderFile() throws Exception { addDescription("Testing the ArchiveDirectory handling of a new file."); addStep("Setup", "No file added to the directory."); ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); @@ -307,7 +308,7 @@ void testArchiveDirectoryNewFolderFile() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryMoveFolderFileToArchive() throws Exception { + public void testArchiveDirectoryMoveFolderFileToArchive() throws Exception { addDescription("Testing the error scenarios when moving a file from tmp to archive for the ArchiveDirectory."); addStep("Setup", "No file added to the directory."); ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); @@ -351,7 +352,7 @@ void testArchiveDirectoryMoveFolderFileToArchive() throws Exception { @Test @Tag("regressiontest") @Tag("pillartest") - void testArchiveDirectoryRemoveFolderFile() throws Exception { + public void testArchiveDirectoryRemoveFolderFile() throws Exception { addDescription("Testing the error scenarios when removing files from the archive."); addStep("Setup", "No file added to the directory."); ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ReferenceArchiveTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ReferenceArchiveTest.java index 6a4ac1326..869d45de8 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ReferenceArchiveTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/archive/ReferenceArchiveTest.java @@ -3,7 +3,8 @@ * Bitrepository Reference Pillar * * $Id: PutFileOnReferencePillarTest.java 589 2011-12-01 15:34:42Z jolf $ - * $HeadURL: https://sbforge.org/svn/bitrepository/bitrepository-reference/trunk/bitrepository-reference-pillar/src/test/java/org + * $HeadURL: https://sbforge.org/svn/bitrepository/bitrepository-reference/trunk/bitrepository-reference-pillar/src + * /test/java/org * /bitrepository/pillar/PutFileOnReferencePillarTest.java $ * %% * Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark @@ -25,6 +26,7 @@ */ package org.bitrepository.pillar.store.archive; +import org.bitrepository.SuiteInfoParameterResolver; import org.bitrepository.common.utils.FileUtils; import org.bitrepository.pillar.DefaultPillarTest; import org.bitrepository.pillar.common.MessageHandlerContext; @@ -34,6 +36,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import java.io.File; import java.io.FileInputStream; @@ -42,6 +45,10 @@ import java.nio.charset.StandardCharsets; import java.util.List; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +@ExtendWith(SuiteInfoParameterResolver.class) public class ReferenceArchiveTest extends DefaultPillarTest { protected ReferenceArchive archive; protected PillarMediator mediator; @@ -145,8 +152,9 @@ public void testReferenceArchive() throws Exception { } private void createExistingFile() throws Exception { - OutputStreamWriter osw = new OutputStreamWriter(new FileOutputStream(new File(FILE_DIR_NAME, EXISTING_FILE), false), - StandardCharsets.UTF_8); + OutputStreamWriter osw = + new OutputStreamWriter(new FileOutputStream(new File(FILE_DIR_NAME, EXISTING_FILE), false), + StandardCharsets.UTF_8); osw.write("test-data\n"); osw.flush(); osw.close(); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseMigrationTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseMigrationTest.java index ab279e293..0f1a30c22 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseMigrationTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseMigrationTest.java @@ -30,7 +30,6 @@ import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; @@ -43,7 +42,11 @@ import java.util.Locale; import java.util.TimeZone; -public class ChecksumDatabaseMigrationTest extends ExtendedTestCase { +import static org.bitrepository.pillar.store.checksumdatabase.DatabaseConstants.CHECKSUM_TABLE; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class ChecksumDatabaseMigrationTest { protected Settings settings; static final String PATH_TO_DATABASE_UNPACKED = "target/test/referencepillar/checksumdb-for-migration"; @@ -91,7 +94,7 @@ public void testMigratingChecksumDatabaseFromV1ToV2() throws Exception { addStep("Validate setup", "Checksums table has version 1"); String extractVersionSql = "SELECT version FROM tableversions WHERE tablename = ?"; - int versionBefore = DatabaseUtils.selectIntValue(connector, extractVersionSql, DatabaseConstants.CHECKSUM_TABLE); + int versionBefore = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); Assertions.assertEquals(1, versionBefore, "Table version before migration"); addStep("Ingest a entry to the database without the collection id", "works only in version 1."); @@ -102,7 +105,7 @@ public void testMigratingChecksumDatabaseFromV1ToV2() throws Exception { addStep("Perform migration", "Checksums table has version 3"); ChecksumDBMigrator migrator = new ChecksumDBMigrator(connector, settings); migrator.migrate(); - int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, DatabaseConstants.CHECKSUM_TABLE); + int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); Assertions.assertEquals(4, versionAfter, "Table version after migration"); addStep("Validate the entry", "The collection id has been set to the default collection id"); @@ -131,7 +134,7 @@ public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { addStep("Validate setup", "Checksums table has version 3"); String extractVersionSql = "SELECT version FROM tableversions WHERE tablename = ?"; - int versionBefore = DatabaseUtils.selectIntValue(connector, extractVersionSql, DatabaseConstants.CHECKSUM_TABLE); + int versionBefore = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); Assertions.assertEquals(3, versionBefore, "Table version before migration"); addStep("Ingest a entry to the database with a date for the calculationdate", "works in version 3."); @@ -142,7 +145,7 @@ public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { addStep("Perform migration", "Checksums table has version 4"); ChecksumDBMigrator migrator = new ChecksumDBMigrator(connector, settings); migrator.migrate(); - int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, DatabaseConstants.CHECKSUM_TABLE); + int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); Assertions.assertEquals(4, versionAfter, "Table version after migration"); addStep("Validate the migration", "The timestamp is now the millis from epoch"); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseTest.java index c941fdf3d..02f81a4aa 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumDatabaseTest.java @@ -31,7 +31,6 @@ import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; import org.bitrepository.settings.repositorysettings.PillarIDs; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -41,7 +40,10 @@ import java.util.Date; import java.util.List; -public class ChecksumDatabaseTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class ChecksumDatabaseTest { private String collectionID; protected Settings settings; diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumEntryTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumEntryTest.java index ed83a621d..c4dc911b0 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumEntryTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/checksumcache/ChecksumEntryTest.java @@ -22,14 +22,16 @@ */ import org.bitrepository.pillar.store.checksumdatabase.ChecksumEntry; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import java.util.Date; -public class ChecksumEntryTest extends ExtendedTestCase { +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +public class ChecksumEntryTest { private static final String CE_FILE = "file"; private static final String CE_CHECKSUM = "checksum"; private static final Date CE_DATE = new Date(1234567890); diff --git a/bitrepository-reference-pillar/src/test/resources/logback-test.xml b/bitrepository-reference-pillar/src/test/resources/logback-test.xml new file mode 100644 index 000000000..4bc0d7be7 --- /dev/null +++ b/bitrepository-reference-pillar/src/test/resources/logback-test.xml @@ -0,0 +1,14 @@ + + + + %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n + + + + + + + + + + diff --git a/bitrepository-reference-pillar/src/test/resources/testprops/jaccept.properties b/bitrepository-reference-pillar/src/test/resources/testprops/jaccept.properties deleted file mode 100644 index 7eaa9b343..000000000 --- a/bitrepository-reference-pillar/src/test/resources/testprops/jaccept.properties +++ /dev/null @@ -1,26 +0,0 @@ -### -# #%L -# Bitrepository Protocol -# -# $Id: jaccept.properties 94 2011-02-24 09:56:09Z jolf $ -# $HeadURL: https://sbforge.org/svn/bitrepository/bitrepository-reference/trunk/bitrepository-access-putClient/src/test/resources/jaccept.properties $ -# %% -# Copyright (C) 2010 - 2011 The State and University Library, The Royal Library and The State Archives, Denmark -# %% -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Lesser General Public License as -# published by the Free Software Foundation, either version 2.1 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Lesser Public License for more details. -# -# You should have received a copy of the GNU General Lesser Public -# License along with this program. If not, see -# . -# #L% -### -jaccept.project.name=Bitrepository Acceptance test -jaccept.clientloader.clients=org.jaccept.StdOutLogger,org.jaccept.testreport.ReportGenerator \ No newline at end of file diff --git a/bitrepository-service/src/test/java/org/bitrepository/service/ContributorTest.java b/bitrepository-service/src/test/java/org/bitrepository/service/ContributorTest.java index c03ed49cd..95cd95f1e 100644 --- a/bitrepository-service/src/test/java/org/bitrepository/service/ContributorTest.java +++ b/bitrepository-service/src/test/java/org/bitrepository/service/ContributorTest.java @@ -42,12 +42,12 @@ protected void registerMessageReceivers() { super.registerMessageReceivers(); clientDestinationId = settingsForTestClient.getReceiverDestinationID(); - clientReceiver = new MessageReceiver(clientDestinationId, testEventManager); + clientReceiver = new MessageReceiver(clientDestinationId); addReceiver(clientReceiver); contributorDestinationId = settingsForCUT.getCollectionDestination() + "-" + getContributorID() + "-" + getTopicPostfix(); - contributorReceiver = new MessageReceiver(contributorDestinationId + " topic receiver", testEventManager); + contributorReceiver = new MessageReceiver(contributorDestinationId + " topic receiver"); addReceiver(contributorReceiver); } diff --git a/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseMigrationTest.java b/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseMigrationTest.java index 9a5c7351a..a5004619f 100644 --- a/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseMigrationTest.java +++ b/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseMigrationTest.java @@ -28,16 +28,18 @@ import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.*; import java.io.File; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + /** * Test database migration. Generates jaccept reports. * */ -public class AuditTrailContributorDatabaseMigrationTest extends ExtendedTestCase { +public class AuditTrailContributorDatabaseMigrationTest { protected Settings settings; static final String PATH_TO_DATABASE_UNPACKED = "target/test/audits/auditcontributerdb-v1"; diff --git a/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseTest.java b/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseTest.java index 7627c6753..96ce3179e 100644 --- a/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseTest.java +++ b/bitrepository-service/src/test/java/org/bitrepository/service/audit/AuditTrailContributorDatabaseTest.java @@ -29,7 +29,6 @@ import org.bitrepository.service.database.DatabaseManager; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Tag; @@ -40,11 +39,12 @@ import java.util.Date; import java.util.Locale; -/** - * Run audit trail contributor database test using Derby. Generates jaccept reports. - */ +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + +/** Run audit trail contributor database test using Derby. Generates jaccept reports. */ -public class AuditTrailContributorDatabaseTest extends ExtendedTestCase { +public class AuditTrailContributorDatabaseTest { private Settings settings; private DatabaseSpecifics databaseSpecifics; private String firstCollectionID; @@ -191,7 +191,6 @@ public void testAuditTrailDatabaseExtractionOrder() throws Exception { dm.getConnector().destroy(); } - public void contributorDatabaseCorrectTimestampTest() throws ParseException { addDescription("Testing the correct ingest and extraction of audittrail dates"); DatabaseManager dm = new AuditDatabaseManager(databaseSpecifics); diff --git a/bitrepository-service/src/test/java/org/bitrepository/service/exception/IdentifyContributorExceptionTest.java b/bitrepository-service/src/test/java/org/bitrepository/service/exception/IdentifyContributorExceptionTest.java index afa245379..9f908c16d 100644 --- a/bitrepository-service/src/test/java/org/bitrepository/service/exception/IdentifyContributorExceptionTest.java +++ b/bitrepository-service/src/test/java/org/bitrepository/service/exception/IdentifyContributorExceptionTest.java @@ -22,15 +22,18 @@ package org.bitrepository.service.exception; import org.bitrepository.bitrepositoryelements.ResponseCode; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + + /** * jaccept steps to validate that the exception thrown is the exception thrown. */ -public class IdentifyContributorExceptionTest extends ExtendedTestCase { +public class IdentifyContributorExceptionTest { private final String TEST_COLLECTION_ID = "test-collection-id"; @Test diff --git a/bitrepository-service/src/test/java/org/bitrepository/service/exception/IllegalOperationExceptionTest.java b/bitrepository-service/src/test/java/org/bitrepository/service/exception/IllegalOperationExceptionTest.java index ee45e9330..db38ae949 100644 --- a/bitrepository-service/src/test/java/org/bitrepository/service/exception/IllegalOperationExceptionTest.java +++ b/bitrepository-service/src/test/java/org/bitrepository/service/exception/IllegalOperationExceptionTest.java @@ -22,18 +22,22 @@ package org.bitrepository.service.exception; import org.bitrepository.bitrepositoryelements.ResponseCode; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; /** * Test that IllegalOperationException behaves as expected. */ -public class IllegalOperationExceptionTest extends ExtendedTestCase { +public class IllegalOperationExceptionTest { private final String TEST_COLLECTION_ID = "test-collection-id"; @Test diff --git a/bitrepository-service/src/test/java/org/bitrepository/service/exception/InvalidMessageExceptionTest.java b/bitrepository-service/src/test/java/org/bitrepository/service/exception/InvalidMessageExceptionTest.java index 4cad88d93..9c7b4dc0d 100644 --- a/bitrepository-service/src/test/java/org/bitrepository/service/exception/InvalidMessageExceptionTest.java +++ b/bitrepository-service/src/test/java/org/bitrepository/service/exception/InvalidMessageExceptionTest.java @@ -23,15 +23,18 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositoryelements.ResponseInfo; -import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.bitrepository.common.utils.AllureTestUtils.addDescription; +import static org.bitrepository.common.utils.AllureTestUtils.addStep; + + /** * Test that InvalidMessageException works as expected. */ -public class InvalidMessageExceptionTest extends ExtendedTestCase { +public class InvalidMessageExceptionTest { private final String TEST_COLLECTION_ID = "test-collection-id"; @Test diff --git a/bitrepository-webclient/pom.xml b/bitrepository-webclient/pom.xml index e1ad24af7..940f4bcc1 100644 --- a/bitrepository-webclient/pom.xml +++ b/bitrepository-webclient/pom.xml @@ -57,6 +57,15 @@ + + io.qameta.allure + allure-maven + 2.12.0 + + ${project.basedir}/allure-results + ${project.basedir}/allure-report + + maven-war-plugin diff --git a/pom.xml b/pom.xml index 02caa2d20..0853406d9 100644 --- a/pom.xml +++ b/pom.xml @@ -134,17 +134,40 @@ HEAD + - - org.slf4j - slf4j-api - ${slf4j.version} + + io.qameta.allure + allure-bom + 2.32.0 + pom + import + + + org.slf4j + slf4j-api + 2.0.17 + + + + + + org.slf4j + slf4j-api + 2.0.17 ch.qos.logback logback-classic - 1.2.3 + 1.5.22 + + + + ch.qos.logback + logback-core + 1.5.22 + - org.jaccept - jaccept-core - 0.4 + io.qameta.allure + allure-junit5 + 2.32.0 test + + com.google.code.gson + gson + 2.10.1 + test + + + org.aspectj + aspectjweaver + 1.9.22 + + + io.qameta.allure + allure-maven + ${allure.version} + + 2.20.1 + ${project.basedir}/target/site/allure-maven-plugin + ${project.basedir}/target/allure-results + + + org.apache.maven.plugins maven-enforcer-plugin 3.0.0-M3 @@ -361,6 +407,13 @@ maven-surefire-plugin 3.5.4 + + + ${project.basedir}/../target/allure-results + + + @{argLine} -javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/${aspectj.version}/aspectjweaver-${aspectj.version}.jar" + maven-failsafe-plugin @@ -487,13 +540,6 @@ skip-unit-tests - - maven-surefire-plugin - - - true - - @@ -515,9 +561,10 @@ 2.1.6 8.0.1 4.0.1 - 1.7.30 - dav:https://sbforge.org/maven/bitrepository/sites/reference/${project.version} - + 1.7.36 + dav:https://sbforge.org/maven/bitrepository/sites/reference/${project.version} UTF-8 + 1.9.7 + 2.17.0