From 56a77f90deee51bf5f19c33f5cf51b58c520ccba Mon Sep 17 00:00:00 2001 From: kaah Date: Thu, 11 Dec 2025 14:01:08 +0100 Subject: [PATCH 01/14] Initial migration from TestNG to JUnit 5 - Added JUnit 5 annotations to BitrepositoryTestSuite - Added GlobalSuiteExtension to implement JUnit 5 extension points for suite-level setup and teardown. - Ensured consistency and correctness of test suite configuration and setup methods. This commit updates the test suite configuration to use JUnit 5 annotations, allowing for more flexible and powerful test suite management. --- .../protocol/BitrepositoryTestSuite.java | 63 ++++++ .../protocol/GlobalSuiteExtension.java | 208 ++++++++++++++++++ .../protocol/IntegrationTest.java | 5 + .../protocol/bus/ActiveMQMessageBusTest.java | 31 ++- ...MessageBusNumberOfListenersStressTest.java | 16 +- pom.xml | 63 ++++-- 6 files changed, 351 insertions(+), 35 deletions(-) create mode 100644 bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java create mode 100644 bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java new file mode 100644 index 000000000..e31f8f4a0 --- /dev/null +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java @@ -0,0 +1,63 @@ +package org.bitrepository.protocol; + +import org.junit.platform.suite.api.ExcludeTags; +import org.junit.platform.suite.api.IncludeTags; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; +import org.junit.jupiter.api.extension.ExtendWith; +import org.bitrepository.protocol.GlobalSuiteExtension; + +/** + * BitrepositoryTestSuite is a JUnit 5 suite class that groups and configures multiple test classes + * for the BitRepository project. This suite uses JUnit 5 annotations to select test classes, packages, + * and tags, and extend the suite with custom extensions. + * + *

JUnit 5 Annotations Used:

+ * + * + *

Options in a JUnit 5 Suite:

+ * + * + *

Example Usage:

+ *
+ * {@code
+ * @Suite
+ * @SelectClasses({IntegrationTest.class})  // List your test classes here
+ * @SelectPackages("org.bitrepository.protocol")  // List your test packages here
+ * @IncludeTags("integration")  // List your include tags here
+ * @ExcludeTags("slow")  // List your exclude tags here
+ * @ExtendWith(GlobalSuiteExtension.class)
+ * public class BitrepositoryTestSuite {
+ *     // No need for methods here; this just groups and extends
+ * }
+ * }
+ * 
+ */ +@Suite +@SelectClasses({IntegrationTest.class}) // List your test classes here +@ExtendWith(GlobalSuiteExtension.class) +public class BitrepositoryTestSuite { + // No need for methods here; this just groups and extends +} + diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java new file mode 100644 index 000000000..8b8754b74 --- /dev/null +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java @@ -0,0 +1,208 @@ +package org.bitrepository.protocol; + +import org.bitrepository.common.settings.Settings; +import org.bitrepository.common.settings.TestSettingsProvider; +import org.bitrepository.common.utils.SettingsUtils; +import org.bitrepository.common.utils.TestFileHelper; +import org.bitrepository.protocol.bus.LocalActiveMQBroker; +import org.bitrepository.protocol.bus.MessageReceiver; +import org.bitrepository.protocol.fileexchange.HttpServerConfiguration; +import org.bitrepository.protocol.http.EmbeddedHttpServer; +import org.bitrepository.protocol.messagebus.MessageBus; +import org.bitrepository.protocol.messagebus.MessageBusManager; +import org.bitrepository.protocol.messagebus.SimpleMessageBus; +import org.bitrepository.protocol.security.DummySecurityManager; +import org.bitrepository.protocol.security.SecurityManager; +import org.jaccept.TestEventManager; +import org.junit.jupiter.api.extension.*; + +import javax.jms.JMSException; +import java.net.MalformedURLException; +import java.net.URL; + +public class GlobalSuiteExtension implements BeforeAllCallback, AfterAllCallback { + + private static boolean initialized = false; + protected static TestEventManager testEventManager = TestEventManager.getInstance(); + public static LocalActiveMQBroker broker; + public static EmbeddedHttpServer server; + public static HttpServerConfiguration httpServerConfiguration; + public static MessageBus messageBus; + private MessageReceiverManager receiverManager; + protected static String alarmDestinationID; + protected static MessageReceiver alarmReceiver; + protected static SecurityManager securityManager; + protected static Settings settingsForCUT; + protected static Settings settingsForTestClient; + protected static String collectionID; + protected String NON_DEFAULT_FILE_ID; + protected static String DEFAULT_FILE_ID; + protected static URL DEFAULT_FILE_URL; + protected static String DEFAULT_DOWNLOAD_FILE_ADDRESS; + protected static String DEFAULT_UPLOAD_FILE_ADDRESS; + protected String DEFAULT_AUDIT_INFORMATION; + protected String testMethodName; + + @Override + public void beforeAll(ExtensionContext context) { + if (!initialized) { + initialized = true; + settingsForCUT = loadSettings(getComponentID()); + settingsForTestClient = loadSettings("TestSuiteInitialiser"); + makeUserSpecificSettings(settingsForCUT); + makeUserSpecificSettings(settingsForTestClient); + httpServerConfiguration = new HttpServerConfiguration(settingsForTestClient.getReferenceSettings().getFileExchangeSettings()); + collectionID = settingsForTestClient.getCollections().get(0).getID(); + + securityManager = createSecurityManager(); + DEFAULT_FILE_ID = "DefaultFile"; + try { + DEFAULT_FILE_URL = httpServerConfiguration.getURL(TestFileHelper.DEFAULT_FILE_ID); + DEFAULT_DOWNLOAD_FILE_ADDRESS = DEFAULT_FILE_URL.toExternalForm(); + DEFAULT_UPLOAD_FILE_ADDRESS = DEFAULT_FILE_URL.toExternalForm() + "-" + DEFAULT_FILE_ID; + } catch (MalformedURLException e) { + throw new RuntimeException("Never happens"); + } + } + } + + @Override + public void afterAll(ExtensionContext context) { + if (initialized) { + teardownMessageBus(); + teardownHttpServer(); + } + } + + /** + * May be extended by subclasses needing to have their receivers managed. Remember to still call + * super.registerReceivers() when overriding + */ + protected void registerMessageReceivers() { + alarmReceiver = new MessageReceiver(settingsForCUT.getAlarmDestination(), testEventManager); + addReceiver(alarmReceiver); + } + + protected void addReceiver(MessageReceiver receiver) { + receiverManager.addReceiver(receiver); + } + protected void initializeCUT() {} + + /** + * Purges all messages from the receivers. + */ + protected void clearReceivers() { + receiverManager.clearMessagesInReceivers(); + } + + /** + * May be overridden by specific tests wishing to do stuff. Remember to call super if this is overridden. + */ + protected void shutdownCUT() {} + + /** + * Initializes the settings. Will postfix the alarm and collection topics with '-${user.name} + */ + protected void setupSettings() { + settingsForCUT = loadSettings(getComponentID()); + makeUserSpecificSettings(settingsForCUT); + SettingsUtils.initialize(settingsForCUT); + + alarmDestinationID = settingsForCUT.getRepositorySettings().getProtocolSettings().getAlarmDestination(); + + settingsForTestClient = loadSettings(testMethodName); + makeUserSpecificSettings(settingsForTestClient); + } + + + protected Settings loadSettings(String componentID) { + return TestSettingsProvider.reloadSettings(componentID); + } + + private void makeUserSpecificSettings(Settings settings) { + settings.getRepositorySettings().getProtocolSettings() + .setCollectionDestination(settings.getCollectionDestination() + getTopicPostfix()); + settings.getRepositorySettings().getProtocolSettings().setAlarmDestination(settings.getAlarmDestination() + getTopicPostfix()); + } + + /** + * Indicated whether an embedded active MQ should be started and used + */ + public boolean useEmbeddedMessageBus() { + return System.getProperty("useEmbeddedMessageBus", "true").equals("true"); + } + + /** + * Indicated whether an embedded http server should be started and used + */ + public boolean useEmbeddedHttpServer() { + return System.getProperty("useEmbeddedHttpServer", "false").equals("true"); + } + + /** + * Hooks up the message bus. + */ + protected void setupMessageBus() { + if (useEmbeddedMessageBus()) { + if (messageBus == null) { + messageBus = new SimpleMessageBus(); + } + } + } + + /** + * Shutdown the message bus. + */ + private void teardownMessageBus() { + MessageBusManager.clear(); + if (messageBus != null) { + try { + messageBus.close(); + messageBus = null; + } catch (JMSException e) { + throw new RuntimeException(e); + } + } + + if (broker != null) { + try { + broker.stop(); + broker = null; + } catch (Exception e) { + // No reason to pollute the test output with this + } + } + } + + /** + * Shutdown the embedded http server if any. + */ + protected void teardownHttpServer() { + if (useEmbeddedHttpServer()) { + server.stop(); + } + } + + /** + * Returns the postfix string to use when accessing user specific topics, which is the mechanism we use in the + * bit repository tests. + * + * @return The string to postfix all topix names with. + */ + protected String getTopicPostfix() { + return "-" + System.getProperty("user.name"); + } + + protected String getComponentID() { + return getClass().getSimpleName(); + } + + protected String createDate() { + return Long.toString(System.currentTimeMillis()); + } + + protected SecurityManager createSecurityManager() { + return new DummySecurityManager(); + } + +} \ No newline at end of file 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 ece1da863..2d9c82ff4 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java @@ -81,6 +81,10 @@ public abstract class IntegrationTest extends ExtendedTestCase { @BeforeSuite(alwaysRun = true) public void initializeSuite(ITestContext testContext) { + // + } + + private void initializationMethod() { settingsForCUT = loadSettings(getComponentID()); settingsForTestClient = loadSettings("TestSuiteInitialiser"); makeUserSpecificSettings(settingsForCUT); @@ -114,6 +118,7 @@ protected void addReceiver(MessageReceiver receiver) { @BeforeClass(alwaysRun = true) public void initMessagebus() { + initializationMethod(); setupMessageBus(); } 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 d5b9bf884..6b284a415 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 @@ -8,12 +8,12 @@ * 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 * . @@ -27,7 +27,9 @@ import org.bitrepository.protocol.ProtocolComponentFactory; import org.bitrepository.protocol.activemq.ActiveMQMessageBus; import org.bitrepository.protocol.message.ExampleMessageFactory; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.Assertions; import javax.jms.Message; import javax.jms.MessageListener; @@ -36,14 +38,7 @@ import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertEquals; - -/** - * Runs the GeneralMessageBusTest using a LocalActiveMQBroker (if useEmbeddedMessageBus is true) and a suitable - * MessageBus based on settingsForTestClient. Regression tests utilized that uses JAccept to generate reports. - */ - -public class ActiveMQMessageBusTest extends GeneralMessageBusTest { +public class ActiveMQMessageBusTest extends GeneralMessageBusTest { // Assuming it extends a base class @Override protected void setupMessageBus() { @@ -53,10 +48,10 @@ protected void setupMessageBus() { } messageBus = new MessageBusWrapper(ProtocolComponentFactory.getInstance().getMessageBus( settingsForTestClient, securityManager), testEventManager); - } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public final void collectionFilterTest() throws Exception { addDescription("Test that message bus filters identify requests to other collection, eg. ignores these."); addStep("Send an identify request with a undefined 'Collection' header property, " + @@ -90,7 +85,8 @@ public final void collectionFilterTest() throws Exception { collectionReceiver.checkNoMessageIsReceived(IdentifyPillarsForDeleteFileRequest.class); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public final void sendMessageToSpecificComponentTest() throws Exception { addDescription("Test that message bus correct uses the 'to' header property to indicated that the message " + "is meant for a specific component"); @@ -113,10 +109,11 @@ public void onMessage(Message message) { messageToSend.setTo(receiverID); messageBus.sendMessage(messageToSend); Message receivedMessage = messageList.poll(3, TimeUnit.SECONDS); - assertEquals(receivedMessage.getStringProperty(ActiveMQMessageBus.MESSAGE_TO_KEY), receiverID); + Assertions.assertEquals(receivedMessage.getStringProperty(ActiveMQMessageBus.MESSAGE_TO_KEY), receiverID); // Assertion update } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public final void toFilterTest() throws Exception { addDescription("Test that message bus filters identify requests to other components, eg. ignores these."); addStep("Send an identify request with a undefined 'To' header property, " + @@ -174,4 +171,4 @@ public final void toFilterTest() throws Exception { rawMessagebus.sendMessage(settingsForTestClient.getCollectionDestination(), rq); collectionReceiver.waitForMessage(DeleteFileRequest.class); } -} +} \ No newline at end of file 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 066c4eb50..696098426 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 @@ -39,9 +39,13 @@ import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +//import org.testng.Assert; +//import org.testng.annotations.BeforeMethod; +//import org.testng.annotations.Test; import java.io.File; import java.io.FileOutputStream; @@ -110,7 +114,7 @@ public class MessageBusNumberOfListenersStressTest extends ExtendedTestCase { private static boolean sendMoreMessages = true; private Settings settings; - @BeforeMethod + @BeforeEach public void initializeSettings() { settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); } @@ -121,7 +125,8 @@ public void initializeSettings() { * * @throws Exception Can possibly throw an exception. */ - @Test(groups = {"StressTest"}) + @Test + @Tag("StressTest") 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."); @@ -155,7 +160,8 @@ public void testManyListenersOnLocalMessageBus() throws Exception { } } - @Test(groups = {"StressTest"}) + @Test + @Tag("StressTest") 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."); diff --git a/pom.xml b/pom.xml index d74adb031..de63482f3 100644 --- a/pom.xml +++ b/pom.xml @@ -173,13 +173,50 @@ runtime + + org.glassfish.jaxb + jaxb-runtime + 2.3.6 + runtime + + + + + + + + + + org.mockito + mockito-junit-jupiter + 5.12.0 + test + + + org.junit.jupiter + junit-jupiter + 5.10.3 + test + + + + org.slf4j + jul-to-slf4j + ${slf4j.version} + + org.testng testng 7.1.0 test - + + org.junit.platform + junit-platform-suite-engine + 1.10.3 + test + org.mockito mockito-core 3.3.3 @@ -415,33 +452,33 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.1.0 + 3.4.5 org.apache.maven.plugins maven-checkstyle-plugin - 3.1.1 + 3.6.0 sonarCheckstyle.xml - - com.github.spotbugs - spotbugs-maven-plugin - 4.0.0 - - false - - + + + + + + + + org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.12 org.apache.maven.plugins maven-pmd-plugin - 3.13.0 + 3.26.0 From d41038e4ef4258447d9f96bbdcab8fd06b64c07d Mon Sep 17 00:00:00 2001 From: kaah Date: Mon, 15 Dec 2025 09:14:29 +0100 Subject: [PATCH 02/14] Initial --- pom.xml | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d74adb031..caa942967 100644 --- a/pom.xml +++ b/pom.xml @@ -173,13 +173,50 @@ runtime + + org.glassfish.jaxb + jaxb-runtime + 2.3.6 + runtime + + + + + + + + + + org.mockito + mockito-junit-jupiter + 5.12.0 + test + + + org.junit.jupiter + junit-jupiter + 5.10.3 + test + + + + org.slf4j + jul-to-slf4j + ${slf4j.version} + + org.testng testng 7.1.0 test - + + org.junit.platform + junit-platform-suite-engine + 1.10.3 + test + org.mockito mockito-core 3.3.3 From 7ec116cc80e60d2c2e5f3f52920e5d6dc73f31bc Mon Sep 17 00:00:00 2001 From: kaah Date: Tue, 16 Dec 2025 11:41:09 +0100 Subject: [PATCH 03/14] Changes due to PR --- .../protocol/GlobalSuiteExtension.java | 2 +- pom.xml | 61 +++++++------------ 2 files changed, 22 insertions(+), 41 deletions(-) diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java index 8b8754b74..886419ac8 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java @@ -61,7 +61,7 @@ public void beforeAll(ExtensionContext context) { DEFAULT_DOWNLOAD_FILE_ADDRESS = DEFAULT_FILE_URL.toExternalForm(); DEFAULT_UPLOAD_FILE_ADDRESS = DEFAULT_FILE_URL.toExternalForm() + "-" + DEFAULT_FILE_ID; } catch (MalformedURLException e) { - throw new RuntimeException("Never happens"); + throw new RuntimeException("Never happens", e); } } } diff --git a/pom.xml b/pom.xml index de63482f3..16992397f 100644 --- a/pom.xml +++ b/pom.xml @@ -173,37 +173,18 @@ runtime - - org.glassfish.jaxb - jaxb-runtime - 2.3.6 - runtime - - - - - - - - - - org.mockito - mockito-junit-jupiter - 5.12.0 - test - - - org.junit.jupiter - junit-jupiter - 5.10.3 - test - - - - org.slf4j - jul-to-slf4j - ${slf4j.version} - + + org.mockito + mockito-junit-jupiter + 5.12.0 + test + + + org.junit.jupiter + junit-jupiter + 5.10.3 + test + org.testng @@ -462,14 +443,14 @@ sonarCheckstyle.xml - - - - - - - - + + com.github.spotbugs + spotbugs-maven-plugin + 4.0.0 + + false + + org.jacoco jacoco-maven-plugin @@ -478,7 +459,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.26.0 + 3.28.0 From 305d6fa0db350f876bd8c97bbebe5c5d6e088b2c Mon Sep 17 00:00:00 2001 From: kaah Date: Wed, 17 Dec 2025 09:57:37 +0100 Subject: [PATCH 04/14] Working but with errors in a few tests. --- .../common/ArgumentValidatorTest.java | 48 +++--- .../common/DefaultThreadFactoryTest.java | 6 +- .../UnableToFinishExceptionTest.java | 24 +-- .../common/settings/SettingsLoaderTest.java | 13 +- .../common/settings/SettingsTest.java | 30 ++-- .../settings/XMLFileSettingsLoaderTest.java | 10 +- .../common/utils/Base16UtilsTest.java | 28 ++-- .../common/utils/CalendarUtilsTest.java | 71 +++++---- .../common/utils/ChecksumUtilsTest.java | 130 +++++++++-------- .../common/utils/FileIDUtilsTest.java | 19 +-- .../common/utils/FileIDValidatorTest.java | 43 +++--- .../common/utils/FileUtilsTest.java | 138 +++++++++--------- .../common/utils/ResponseInfoUtilsTest.java | 13 +- .../common/utils/StreamUtilsTest.java | 17 ++- .../utils/TimeMeasurementUtilsTest.java | 32 ++-- .../common/utils/TimeUtilsTest.java | 62 ++++---- .../common/utils/XmlUtilsTest.java | 110 ++++++++------ .../protocol/IntegrationTest.java | 94 ++++++------ .../protocol/MessageCreationTest.java | 31 ++-- .../protocol/bus/ActiveMQMessageBusTest.java | 13 +- .../protocol/bus/GeneralMessageBusTest.java | 17 ++- .../protocol/bus/MessageReceiver.java | 6 +- .../bus/MultiThreadedMessageBusTest.java | 20 +-- .../fileexchange/LocalFileExchangeTest.java | 42 +++--- .../protocol/http/HttpFileExchangeTest.java | 9 +- .../ReceivedMessageHandlerTest.java | 28 ++-- .../performancetest/MessageBusDelayTest.java | 13 +- ...MessageBusNumberOfListenersStressTest.java | 19 ++- .../MessageBusNumberOfMessagesStressTest.java | 20 +-- .../MessageBusSizeOfMessageStressTest.java | 19 ++- ...essageBusTimeToSendMessagesStressTest.java | 16 +- .../protocol/security/CertificateIDTest.java | 45 +++--- .../security/PermissionStoreTest.java | 17 ++- .../security/SecurityManagerTest.java | 52 ++++--- .../security/SignatureGeneratorTest.java | 2 +- .../CertificateUseExceptionTest.java | 25 ++-- .../MessageAuthenticationExceptionTest.java | 24 +-- .../exception/MessageSignerExceptionTest.java | 24 +-- .../OperationAuthorizationExceptionTest.java | 24 +-- .../PermissionStoreExceptionTest.java | 24 +-- .../exception/SecurityExceptionTest.java | 23 +-- .../exception/UnregisteredPermissionTest.java | 24 +-- .../protocol/utils/ConfigLoaderTest.java | 24 +-- .../utils/FileExchangeResolverTest.java | 13 +- .../utils/MessageDataTypeValidatorTest.java | 57 +++++--- .../protocol/utils/MessageUtilsTest.java | 41 +++--- .../settings/SettingsProviderTest.java | 20 +-- pom.xml | 51 ++----- 48 files changed, 887 insertions(+), 744 deletions(-) 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 07a936fbb..f792c7058 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/ArgumentValidatorTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/ArgumentValidatorTest.java @@ -22,54 +22,56 @@ package org.bitrepository.common; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.util.Arrays; import java.util.Collection; import java.util.HashSet; public class ArgumentValidatorTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void testArgumentValidatorObject() throws Exception { addDescription("Test the argument validator for arguments not null"); addStep("Test not null", "Should only throw an exception when a null is given."); ArgumentValidator.checkNotNull(new Object(), "No exception expected."); try { ArgumentValidator.checkNotNull(null, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } } - @Test(groups = { "regressiontest" }) + @Test @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"); ArgumentValidator.checkNotNullOrEmpty("NO EXCEPTION", "No exception expected."); try { ArgumentValidator.checkNotNullOrEmpty((String) null, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } try { ArgumentValidator.checkNotNullOrEmpty("", "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } } - @Test(groups = { "regressiontest" }) + @Test @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"); ArgumentValidator.checkNotNegative(1, "No exception expected."); try { ArgumentValidator.checkNotNegative(-1, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } @@ -78,26 +80,26 @@ public void testArgumentValidatorInteger() throws Exception { ArgumentValidator.checkPositive(1, "No exception expected."); try { ArgumentValidator.checkPositive(-1, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } try { ArgumentValidator.checkPositive(0, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } } - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void testArgumentValidatorLong() throws Exception { addDescription("Test the argument validator for arguments for longs"); addStep("Test not negative", "Should only throw an exception if the long is negative"); ArgumentValidator.checkNotNegative(1L, "No exception expected."); try { ArgumentValidator.checkNotNegative(-1L, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } @@ -106,64 +108,64 @@ public void testArgumentValidatorLong() throws Exception { ArgumentValidator.checkPositive(1L, "No exception expected."); try { ArgumentValidator.checkPositive(-1L, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } try { ArgumentValidator.checkPositive(0L, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } } - @Test(groups = { "regressiontest" }) + @Test @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"); try { ArgumentValidator.checkNotNullOrEmpty((Collection) null, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } try { ArgumentValidator.checkNotNullOrEmpty(new HashSet<>(), "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } ArgumentValidator.checkNotNullOrEmpty(Arrays.asList("NO FAILURE"), "No exception expected."); } - @Test(groups = { "regressiontest" }) + @Test @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"); try { ArgumentValidator.checkNotNullOrEmpty((Object[]) null, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } try { ArgumentValidator.checkNotNullOrEmpty(new Object[0], "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } ArgumentValidator.checkNotNullOrEmpty(new Object[]{"NO FAILURE"}, "No exception expected."); } - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void testArgumentValidatorBoolean() throws Exception { addDescription("Test the argument validator for arguments for booleans"); addStep("validate checkTrue", "Should fail when false."); ArgumentValidator.checkTrue(true, "No exception expected"); try { ArgumentValidator.checkTrue(false, "Exception expected."); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalArgumentException e) { // expected } diff --git a/bitrepository-core/src/test/java/org/bitrepository/common/DefaultThreadFactoryTest.java b/bitrepository-core/src/test/java/org/bitrepository/common/DefaultThreadFactoryTest.java index 78b31927d..826cd8e09 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/common/DefaultThreadFactoryTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/common/DefaultThreadFactoryTest.java @@ -3,9 +3,10 @@ import ch.qos.logback.classic.Level; import ch.qos.logback.classic.spi.ILoggingEvent; import ch.qos.logback.core.Appender; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.slf4j.LoggerFactory; -import org.testng.annotations.Test; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.core.Is.is; @@ -21,7 +22,8 @@ public class DefaultThreadFactoryTest { private final String message = "Hey this is the message I want to see"; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testUncaughtExceptionHandler() throws Exception { // Technique from https://dzone.com/articles/unit-testing-asserting-line 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 86fe82fb5..f92e9285c 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 @@ -23,12 +23,14 @@ import org.bitrepository.common.exceptions.UnableToFinishException; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class UnableToFinishExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void testUnableToFinish() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -39,20 +41,20 @@ public void testUnableToFinish() throws Exception { try { throw new UnableToFinishException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof UnableToFinishException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof UnableToFinishException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new UnableToFinishException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof UnableToFinishException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof UnableToFinishException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } } 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 2ca793f24..609225f11 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 @@ -25,8 +25,9 @@ package org.bitrepository.common.settings; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.List; @@ -34,19 +35,21 @@ public class SettingsLoaderTest extends ExtendedTestCase { private static final String PATH_TO_SETTINGS = "settings/xml/bitrepository-devel"; private static final String PATH_TO_EXAMPLE_SETTINGS = "examples/settings"; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testDevelopmentCollectionSettingsLoading() { SettingsProvider settingsLoader = new SettingsProvider(new XMLFileSettingsLoader(PATH_TO_SETTINGS), getClass().getSimpleName()); Settings settings = settingsLoader.getSettings(); List expectedPillarIDs = List.of("Pillar1", "Pillar2"); - Assert.assertEquals( + Assertions.assertEquals( settings.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID(), expectedPillarIDs); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testExampleSettingsLoading() { SettingsProvider settingsLoader = new SettingsProvider(new XMLFileSettingsLoader(PATH_TO_EXAMPLE_SETTINGS), getClass().getSimpleName()); 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 719c5cf3e..78d89e9d3 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,48 +1,54 @@ package org.bitrepository.common.settings; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.math.BigInteger; import java.time.Duration; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class SettingsTest extends ExtendedTestCase { private DatatypeFactory factory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUpFactory() throws DatatypeConfigurationException { factory = DatatypeFactory.newInstance(); } - @Test(groups = {"regressiontest"}, expectedExceptions = NullPointerException.class) + @Test @Tag("regressiontest") public void getDurationFromXmlDurationOrMillisRequiresOneNonNullArg() { - addDescription("Tests that getDurationFromXmlDurationOrMillis() fails when given two nulls"); - addStep("null and null", "NPE"); + assertThrows(NullPointerException.class, () -> { + addDescription("Tests that getDurationFromXmlDurationOrMillis() fails when given two nulls"); + addStep("null and null", "NPE"); - Settings.getDurationFromXmlDurationOrMillis(null, null); + Settings.getDurationFromXmlDurationOrMillis(null, null); + }); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testGetDurationFromXmlDurationOrMillis() { addDescription("Tests conversions and selection by getDurationFromXmlDurationOrMillis()"); addStep("null and some milliseconds", "Duration of millis"); - Assert.assertEquals(Settings.getDurationFromXmlDurationOrMillis(null, BigInteger.valueOf(54321)), + Assertions.assertEquals(Settings.getDurationFromXmlDurationOrMillis(null, BigInteger.valueOf(54321)), Duration.ofMillis(54321)); addStep("XML duration and null", "XML duration converted"); - Assert.assertEquals( + Assertions.assertEquals( Settings.getDurationFromXmlDurationOrMillis( factory.newDuration("PT7M"), null), Duration.ofMinutes(7)); addStep("Conflicting XML duration and millis", "XML duration should be preferred"); - Assert.assertEquals( + Assertions.assertEquals( Settings.getDurationFromXmlDurationOrMillis( factory.newDuration("PT2M"), BigInteger.valueOf(13)), Duration.ofMinutes(2)); 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 9bd0c4ede..528799d11 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 @@ -26,17 +26,19 @@ import org.bitrepository.settings.repositorysettings.RepositorySettings; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class XMLFileSettingsLoaderTest extends ExtendedTestCase{ private static final String PATH_TO_SETTINGS = "settings/xml/bitrepository-devel"; - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void testCollectionSettingsLoading() throws Exception { SettingsLoader settingsLoader = new XMLFileSettingsLoader(PATH_TO_SETTINGS); RepositorySettings repositorySettings = settingsLoader.loadSettings(RepositorySettings.class); - Assert.assertNotNull(repositorySettings, "RepositorySettings"); + Assertions.assertNotNull(repositorySettings, "RepositorySettings"); } } 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 915a1cd30..5b9606ac1 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 @@ -23,8 +23,9 @@ import org.apache.commons.codec.DecoderException; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; /** * Utility class for handling encoding and decoding of base64 bytes. @@ -34,26 +35,28 @@ public class Base16UtilsTest extends ExtendedTestCase { private final String DECODED_CHECKSUM = "ff5aca7ae8c80c9a3aeaf9173e4dfd27"; private final byte[] ENCODED_CHECKSUM = new byte[]{-1,90,-54,122,-24,-56,12,-102,58,-22,-7,23,62,77,-3,39}; - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void encodeChecksum() throws Exception { addDescription("Validating the encoding of the checksums."); addStep("Encode the checksum and validate", "It should match the precalculated constant."); byte[] encodedChecksum = Base16Utils.encodeBase16(DECODED_CHECKSUM); - Assert.assertEquals(encodedChecksum.length, ENCODED_CHECKSUM.length, + Assertions.assertEquals(encodedChecksum.length, ENCODED_CHECKSUM.length, "The size of the encoded checksum differs from the expected."); for(int i = 0; i < encodedChecksum.length; i++){ - Assert.assertEquals(encodedChecksum[i], ENCODED_CHECKSUM[i]); + Assertions.assertEquals(encodedChecksum[i], ENCODED_CHECKSUM[i]); } } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void decodeChecksum() { addDescription("Validating the decoding of the checksums."); addStep("Decode the checksum and validate.", "It should match the precalculated constant."); String decodedChecksum = Base16Utils.decodeBase16(ENCODED_CHECKSUM); - Assert.assertEquals(decodedChecksum, DECODED_CHECKSUM); + Assertions.assertEquals(decodedChecksum, DECODED_CHECKSUM); } @Test @@ -61,18 +64,19 @@ public void decodesNull() { addDescription("Test decoding null"); byte[] data = null; String decoded = Base16Utils.decodeBase16(data); - Assert.assertNull(decoded); + Assertions.assertNull(decoded); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void badArgumentTest() { addDescription("Test bad arguments"); - Assert.assertThrows(IllegalArgumentException.class, () -> Base16Utils.encodeBase16(null)); + Assertions.assertThrows(IllegalArgumentException.class, () -> Base16Utils.encodeBase16(null)); addStep("Test with an odd number of characters.", "Should throw a decoder exception"); - Assert.assertThrows(DecoderException.class, () -> Base16Utils.encodeBase16("123")); + Assertions.assertThrows(DecoderException.class, () -> Base16Utils.encodeBase16("123")); addStep("Test with a non hex digit.", "Should throw a decoder exception"); - Assert.assertThrows(DecoderException.class, () -> Base16Utils.encodeBase16("1g")); + Assertions.assertThrows(DecoderException.class, () -> Base16Utils.encodeBase16("1g")); } } 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 0771e2768..01507f406 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 @@ -22,8 +22,9 @@ package org.bitrepository.common.utils; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.xml.datatype.XMLGregorianCalendar; import java.text.ParseException; @@ -36,38 +37,39 @@ public class CalendarUtilsTest extends ExtendedTestCase { long DATE_IN_MILLIS = 123456789L; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void calendarTester() throws Exception { addDescription("Test the calendar utility class"); addStep("Test the convertion of a date", "Should be the same date."); Date date = new Date(DATE_IN_MILLIS); XMLGregorianCalendar calendar = CalendarUtils.getXmlGregorianCalendar(date); - Assert.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), DATE_IN_MILLIS); + Assertions.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), DATE_IN_MILLIS); addStep("Test that a 'null' date is equivalent to epoch", "Should be date '0'"); calendar = CalendarUtils.getXmlGregorianCalendar((Date)null); - Assert.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), 0); + Assertions.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), 0); addStep("Test epoch", "Should be date '0'"); calendar = CalendarUtils.getEpoch(); - Assert.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), 0); + Assertions.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), 0); addStep("Test that a given time in millis is extractable in millis", "Should be same value"); calendar = CalendarUtils.getFromMillis(DATE_IN_MILLIS); - Assert.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), DATE_IN_MILLIS); + Assertions.assertEquals(calendar.toGregorianCalendar().getTimeInMillis(), DATE_IN_MILLIS); addStep("Test the 'getNow' function", "Should give a value very close to System.currentTimeInMillis"); long beforeNow = System.currentTimeMillis(); calendar = CalendarUtils.getNow(); long afterNow = System.currentTimeMillis(); - Assert.assertTrue(calendar.toGregorianCalendar().getTimeInMillis() <= afterNow); - Assert.assertTrue(calendar.toGregorianCalendar().getTimeInMillis() >= beforeNow); + Assertions.assertTrue(calendar.toGregorianCalendar().getTimeInMillis() <= afterNow); + Assertions.assertTrue(calendar.toGregorianCalendar().getTimeInMillis() >= beforeNow); addStep("Test the reverse conversion, from XMLCalendar to Date", "Should give the same value"); date = CalendarUtils.convertFromXMLGregorianCalendar(calendar); - Assert.assertTrue(date.getTime() <= afterNow); - Assert.assertTrue(date.getTime() >= beforeNow); - Assert.assertEquals(date.getTime(), calendar.toGregorianCalendar().getTimeInMillis()); + Assertions.assertTrue(date.getTime() <= afterNow); + Assertions.assertTrue(date.getTime() >= beforeNow); + Assertions.assertEquals(date.getTime(), calendar.toGregorianCalendar().getTimeInMillis()); } @Test @@ -75,10 +77,11 @@ public void displaysNiceTimeZoneId() { addDescription("Test that the time zone ID logged is human readable (for example Europe/Copenhagen)"); ZoneId zoneId = ZoneId.of("Europe/Copenhagen"); String displayName = CalendarUtils.getTimeZoneDisplayName(TimeZone.getTimeZone(zoneId)); - Assert.assertEquals(displayName, "Europe/Copenhagen"); + Assertions.assertEquals(displayName, "Europe/Copenhagen"); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void startDateTest() throws ParseException { addDescription("Test that the start date is considered as localtime and converted into UTC."); CalendarUtils cu = CalendarUtils.getInstance(TimeZone.getTimeZone("Europe/Copenhagen")); @@ -86,10 +89,11 @@ public void startDateTest() throws ParseException { Date expectedStartOfDay = sdf.parse("2015-02-25T23:00:00.000Z"); Date parsedStartOfDay = cu.makeStartDateObject("2015/02/26"); - Assert.assertEquals(parsedStartOfDay, expectedStartOfDay); + Assertions.assertEquals(parsedStartOfDay, expectedStartOfDay); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void endDateTest() throws ParseException { addDescription("Test that the end date is considered as localtime and converted into UTC."); CalendarUtils cu = CalendarUtils.getInstance(TimeZone.getTimeZone("Europe/Copenhagen")); @@ -97,10 +101,11 @@ public void endDateTest() throws ParseException { Date expectedStartOfDay = sdf.parse("2015-02-26T22:59:59.999Z"); Date parsedStartOfDay = cu.makeEndDateObject("2015/02/26"); - Assert.assertEquals(parsedStartOfDay, expectedStartOfDay); + Assertions.assertEquals(parsedStartOfDay, expectedStartOfDay); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void endDateRolloverTest() throws ParseException { addDescription("Test that the end date is correctly rolls over a year and month change."); CalendarUtils cu = CalendarUtils.getInstance(TimeZone.getTimeZone("Europe/Copenhagen")); @@ -108,10 +113,11 @@ public void endDateRolloverTest() throws ParseException { Date expectedStartOfDay = sdf.parse("2016-01-01T22:59:59.999Z"); Date parsedStartOfDay = cu.makeEndDateObject("2015/12/32"); - Assert.assertEquals(parsedStartOfDay, expectedStartOfDay); + Assertions.assertEquals(parsedStartOfDay, expectedStartOfDay); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testBeginningOfDay() throws ParseException { addDescription("Tests that the time is converted to the beginning of the day localtime, not UTC"); CalendarUtils cu = CalendarUtils.getInstance(TimeZone.getTimeZone("Europe/Copenhagen")); @@ -119,45 +125,48 @@ public void testBeginningOfDay() throws ParseException { Date expectedStartOfDayInUTC = sdf.parse("2016-01-31T23:00:00.000Z"); System.out.println("expectedStartOfDayInUTC parsed: " + expectedStartOfDayInUTC.getTime()); Date parsedStartOfDay = cu.makeStartDateObject("2016/02/01"); - Assert.assertEquals(parsedStartOfDay, expectedStartOfDayInUTC); + Assertions.assertEquals(parsedStartOfDay, expectedStartOfDayInUTC); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testEndOfDay() throws ParseException { addDescription("Tests that the time is converted to the beginning of the day localtime, not UTC"); CalendarUtils cu = CalendarUtils.getInstance(TimeZone.getTimeZone("Europe/Copenhagen")); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT); Date expectedEndOfDayInUTC = sdf.parse("2016-02-01T22:59:59.999Z"); Date parsedEndOfDay = cu.makeEndDateObject("2016/02/01"); - Assert.assertEquals(parsedEndOfDay, expectedEndOfDayInUTC); + Assertions.assertEquals(parsedEndOfDay, expectedEndOfDayInUTC); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testSummerWinterTimeChange() { addDescription("Test that the interval between start and end date on a summertime to " + "wintertime change is 25 hours (-1 millisecond)."); CalendarUtils cu = CalendarUtils.getInstance(TimeZone.getTimeZone("Europe/Copenhagen")); Date startDate = cu.makeStartDateObject("2015/10/25"); - Assert.assertNotNull(startDate); + Assertions.assertNotNull(startDate); Date endDate = cu.makeEndDateObject("2015/10/25"); - Assert.assertNotNull(endDate); + Assertions.assertNotNull(endDate); long MS_PER_HOUR = 1000 * 60 * 60; long expectedIntervalLength = (MS_PER_HOUR * 25) - 1; - Assert.assertEquals(endDate.getTime() - startDate.getTime(), expectedIntervalLength); + Assertions.assertEquals(endDate.getTime() - startDate.getTime(), expectedIntervalLength); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testWinterSummerTimeChange() { addDescription("Test that the interval between start and end date on a wintertime to " + "summertime change is 23 hours (-1 millisecond)."); CalendarUtils cu = CalendarUtils.getInstance(TimeZone.getTimeZone("Europe/Copenhagen")); Date startDate = cu.makeStartDateObject("2016/03/27"); - Assert.assertNotNull(startDate); + Assertions.assertNotNull(startDate); Date endDate = cu.makeEndDateObject("2016/03/27"); - Assert.assertNotNull(endDate); + Assertions.assertNotNull(endDate); long MS_PER_HOUR = 1000 * 60 * 60; long expectedIntervalLength = (MS_PER_HOUR * 23) - 1; - Assert.assertEquals(endDate.getTime() - startDate.getTime(), expectedIntervalLength); + Assertions.assertEquals(endDate.getTime() - startDate.getTime(), expectedIntervalLength); } } 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 f99f68fba..bd46db775 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 @@ -29,8 +29,9 @@ import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.File; @@ -39,7 +40,8 @@ import java.security.NoSuchAlgorithmException; public class ChecksumUtilsTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void calculateHmacChecksums() throws Exception { addDescription("Tests whether the utility class for calculating checksums with HMAC is able to " + "correctly calculate predefined examples from : " @@ -54,47 +56,48 @@ public void calculateHmacChecksums() throws Exception { ChecksumSpecTYPE csHmacSHA256 = new ChecksumSpecTYPE(); csHmacSHA256.setChecksumType(ChecksumType.HMAC_SHA256); csHmacSHA256.setChecksumSalt(new byte[]{0}); - - addStep("Test with no text and no key for HMAC_MD5, HMAC_SHA1, and HMAC_SHA256", + + addStep("Test with no text and no key for HMAC_MD5, HMAC_SHA1, and HMAC_SHA256", "Should give expected results."); InputStream data1 = new ByteArrayInputStream(new byte[0]); - Assert.assertEquals(ChecksumUtils.generateChecksum(data1, csHmacMD5), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data1, csHmacMD5), "74e6f7298a9c2d168935f58c001bad88"); - Assert.assertEquals(ChecksumUtils.generateChecksum(data1, csHmacSHA1), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data1, csHmacSHA1), "fbdb1d1b18aa6c08324b7d64b71fb76370690e1d"); - Assert.assertEquals(ChecksumUtils.generateChecksum(data1, csHmacSHA256), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data1, csHmacSHA256), "b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad"); - + String message = "The quick brown fox jumps over the lazy dog"; InputStream data2 = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); String key = "key"; csHmacMD5.setChecksumSalt(key.getBytes(StandardCharsets.UTF_8)); csHmacSHA1.setChecksumSalt(key.getBytes(StandardCharsets.UTF_8)); csHmacSHA256.setChecksumSalt(key.getBytes(StandardCharsets.UTF_8)); - - addStep("Test with the text '" + message + "' and key '" + key + "' for MD5, SHA1, and SHA256", + + addStep("Test with the text '" + message + "' and key '" + key + "' for MD5, SHA1, and SHA256", "Should give expected results."); - Assert.assertEquals(ChecksumUtils.generateChecksum(data2, csHmacMD5), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data2, csHmacMD5), "80070713463e7749b90c2dc24911e275"); data2.reset(); - Assert.assertEquals(ChecksumUtils.generateChecksum(data2, csHmacSHA1), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data2, csHmacSHA1), "de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9"); data2.reset(); - Assert.assertEquals(ChecksumUtils.generateChecksum(data2, csHmacSHA256), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data2, csHmacSHA256), "f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8"); data2.reset(); - + addStep("Try calculating HMAC with a null salt", "Should throw NoSuchAlgorithmException"); csHmacMD5.setChecksumSalt(null); try { ChecksumUtils.generateChecksum(data2, csHmacMD5); - Assert.fail("Should throw an IllegalArgumentException here!"); + Assertions.fail("Should throw an IllegalArgumentException here!"); } catch (IllegalArgumentException e) { // expected } } - - @Test(groups = { "regressiontest" }) + + @Test + @Tag("regressiontest") public void calculateDigestChecksums() throws Exception { addDescription("Tests whether the utility class for calculating checksums with MessageDigest is able to " + "correctly calculate the checksums."); @@ -105,27 +108,27 @@ public void calculateDigestChecksums() throws Exception { csSHA1.setChecksumType(ChecksumType.SHA1); ChecksumSpecTYPE csSHA256 = new ChecksumSpecTYPE(); csSHA256.setChecksumType(ChecksumType.SHA256); - - addStep("Test with no text and no key for MD5, SHA1, and SHA256", + + addStep("Test with no text and no key for MD5, SHA1, and SHA256", "Should give expected results."); InputStream data1 = new ByteArrayInputStream(new byte[0]); - Assert.assertEquals(ChecksumUtils.generateChecksum(data1, csMD5), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data1, csMD5), "d41d8cd98f00b204e9800998ecf8427e"); - Assert.assertEquals(ChecksumUtils.generateChecksum(data1, csSHA1), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data1, csSHA1), "da39a3ee5e6b4b0d3255bfef95601890afd80709"); - Assert.assertEquals(ChecksumUtils.generateChecksum(data1, csSHA256), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data1, csSHA256), "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"); - + addStep("Test with text ", "Should giver different checksums"); String message = "The quick brown fox jumps over the lazy dog"; InputStream data2 = new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8)); - Assert.assertEquals(ChecksumUtils.generateChecksum(data2, csMD5), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data2, csMD5), "9e107d9d372bb6826bd81d3542a419d6"); data2.reset(); - Assert.assertEquals(ChecksumUtils.generateChecksum(data2, csSHA1), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data2, csSHA1), "2fd4e1c67a2d28fced849ee1bb76e7391b93eb12"); data2.reset(); - Assert.assertEquals(ChecksumUtils.generateChecksum(data2, csSHA256), + Assertions.assertEquals(ChecksumUtils.generateChecksum(data2, csSHA256), "d7a8fbb307d7809469ca9abcb0082e4f8d5651e46d3cdb762d02d0bf37c9e592"); data2.reset(); @@ -133,13 +136,14 @@ public void calculateDigestChecksums() throws Exception { csMD5.setChecksumSalt("key".getBytes(StandardCharsets.UTF_8)); try { ChecksumUtils.generateChecksum(data1, csMD5); - Assert.fail("Should throw an IllegalArgumentException here!"); + Assertions.fail("Should throw an IllegalArgumentException here!"); } catch (IllegalArgumentException e) { // expected - } + } } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void testChecksumOnFile() throws Exception { addDescription("Test the checksum calculation on a file"); addStep("Setup", ""); @@ -147,21 +151,22 @@ public void testChecksumOnFile() throws Exception { csMD5.setChecksumType(ChecksumType.MD5); File testFile = new File("src/test/resources/test-files/default-test-file.txt"); - Assert.assertTrue(testFile.isFile()); - - addStep("Calculate the checksum of the file with the different ways of defining the MD5 without salt", + Assertions.assertTrue(testFile.isFile()); + + addStep("Calculate the checksum of the file with the different ways of defining the MD5 without salt", "Same result from each"); String cs1 = ChecksumUtils.generateChecksum(testFile, csMD5); String cs2 = ChecksumUtils.generateChecksum(testFile, ChecksumType.MD5); String cs3 = ChecksumUtils.generateChecksum(testFile, ChecksumType.MD5, null); - - Assert.assertEquals(cs1, cs2); - Assert.assertEquals(cs1, cs3); - Assert.assertEquals(cs2, cs3); + + Assertions.assertEquals(cs1, cs2); + Assertions.assertEquals(cs1, cs3); + Assertions.assertEquals(cs2, cs3); } - - @Test(groups = { "regressiontest" }) + + @Test + @Tag("regressiontest") public void testChecksumAlgorithmValidation() throws Exception { addDescription("Test the algorithm validation for every single possible checksum algorithm."); for (ChecksumType csType : ChecksumType.values()) { @@ -174,7 +179,7 @@ public void testChecksumAlgorithmValidation() throws Exception { } } } - + private void validateOtherChecksumType(ChecksumType algorithm) { addStep("Test '" + algorithm + "'", "Should be invalid no matter the salt!"); ChecksumSpecTYPE csType = new ChecksumSpecTYPE(); @@ -182,14 +187,14 @@ private void validateOtherChecksumType(ChecksumType algorithm) { try { ChecksumUtils.verifyAlgorithm(csType); - Assert.fail("The 'OTHER' algorithms should be invalid no matter the salt: '" + csType); + Assertions.fail("The 'OTHER' algorithms should be invalid no matter the salt: '" + csType); } catch (NoSuchAlgorithmException e) { // expected } - + try { ChecksumUtils.requiresSalt(algorithm); - Assert.fail("The 'OTHER' algorithms should be invalid no matter the salt: '" + csType); + Assertions.fail("The 'OTHER' algorithms should be invalid no matter the salt: '" + csType); } catch (NoSuchAlgorithmException e) { // expected } @@ -197,7 +202,7 @@ private void validateOtherChecksumType(ChecksumType algorithm) { csType.setChecksumSalt(new byte[]{0}); try { ChecksumUtils.verifyAlgorithm(csType); - Assert.fail("The 'OTHER' algorithms should be invalid with an empty salt: '" + csType); + Assertions.fail("The 'OTHER' algorithms should be invalid with an empty salt: '" + csType); } catch (NoSuchAlgorithmException e) { // expected } @@ -205,57 +210,58 @@ private void validateOtherChecksumType(ChecksumType algorithm) { csType.setChecksumSalt(new byte[]{1}); try { ChecksumUtils.verifyAlgorithm(csType); - Assert.fail("The 'OTHER' algorithms should be invalid with the salt: '" + csType); + Assertions.fail("The 'OTHER' algorithms should be invalid with the salt: '" + csType); } catch (NoSuchAlgorithmException e) { // expected } } - + private void validateHmac(ChecksumType hmacType) throws NoSuchAlgorithmException { addStep("Test '" + hmacType + "'", "Should be invalid without salt, and valid with no matter whether " + "the salt is empty."); ChecksumSpecTYPE csType = new ChecksumSpecTYPE(); csType.setChecksumType(hmacType); - + try { ChecksumUtils.verifyAlgorithm(csType); - Assert.fail("The HMAC algorithms should be invalid without the salt: '" + csType); + Assertions.fail("The HMAC algorithms should be invalid without the salt: '" + csType); } catch (NoSuchAlgorithmException e) { // expected } - Assert.assertTrue(ChecksumUtils.requiresSalt(hmacType), "HMAC algorithms must require salt."); - + Assertions.assertTrue(ChecksumUtils.requiresSalt(hmacType), "HMAC algorithms must require salt."); + csType.setChecksumSalt(new byte[]{0}); - ChecksumUtils.verifyAlgorithm(csType); + ChecksumUtils.verifyAlgorithm(csType); csType.setChecksumSalt(new byte[]{1}); - ChecksumUtils.verifyAlgorithm(csType); + ChecksumUtils.verifyAlgorithm(csType); } - + private void validateMessageDigest(ChecksumType algorithmType) throws NoSuchAlgorithmException { addStep("Test '" + algorithmType + "'", "Should be valid without salt, valid with an empty salt, " + "and invalid with a proper salt."); ChecksumSpecTYPE csType = new ChecksumSpecTYPE(); csType.setChecksumType(algorithmType); - - ChecksumUtils.verifyAlgorithm(csType); - Assert.assertFalse(ChecksumUtils.requiresSalt(algorithmType), "Non-HMAC algorithms must not require salt."); + ChecksumUtils.verifyAlgorithm(csType); + + Assertions.assertFalse(ChecksumUtils.requiresSalt(algorithmType), "Non-HMAC algorithms must not require salt."); csType.setChecksumSalt(new byte[0]); ChecksumUtils.verifyAlgorithm(csType); - + csType.setChecksumSalt(new byte[]{1}); try { ChecksumUtils.verifyAlgorithm(csType); - Assert.fail("The MessaegDigest algorithms should be invalid with the salt: '" + csType); + Assertions.fail("The MessaegDigest algorithms should be invalid with the salt: '" + csType); } catch (NoSuchAlgorithmException e) { // expected } } - - @Test(groups = { "regressiontest" }) + + @Test + @Tag("regressiontest") public void testDefaultChecksum() throws Exception { addDescription("Test the extraction of the default checksum from settings."); addStep("Setup the settings", "Loading the test settings"); @@ -263,8 +269,8 @@ public void testDefaultChecksum() throws Exception { addStep("Use utils to extract default checksum spec", "Should be the one defined in Settings."); ChecksumSpecTYPE csType = ChecksumUtils.getDefault(settings); - Assert.assertEquals(csType.getChecksumType().name(), + Assertions.assertEquals(csType.getChecksumType().name(), settings.getRepositorySettings().getProtocolSettings().getDefaultChecksumType()); - Assert.assertNull(csType.getChecksumSalt(), "Should not contain any salt."); + Assertions.assertNull(csType.getChecksumSalt(), "Should not contain any salt."); } } 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 4baef6c1d..46616d437 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 @@ -23,25 +23,26 @@ import org.bitrepository.bitrepositoryelements.FileIDs; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class FileIDUtilsTest extends ExtendedTestCase { String FILE_ID = "Test-File-Id"; - @Test( groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void fileIDsTest() throws Exception { addDescription("Test the utility class for generating FileIDs"); addStep("Test 'all file ids'", "is only AllFileIDs"); FileIDs allFileIDs = FileIDsUtils.getAllFileIDs(); - Assert.assertTrue(allFileIDs.isSetAllFileIDs()); - Assert.assertFalse(allFileIDs.isSetFileID()); - Assert.assertNull(allFileIDs.getFileID()); + Assertions.assertTrue(allFileIDs.isSetAllFileIDs()); + Assertions.assertFalse(allFileIDs.isSetFileID()); + Assertions.assertNull(allFileIDs.getFileID()); addStep("Test a specific file id", "Should not be AllFileIDs"); FileIDs specificFileIDs = FileIDsUtils.getSpecificFileIDs(FILE_ID); - Assert.assertFalse(specificFileIDs.isSetAllFileIDs()); - Assert.assertTrue(specificFileIDs.isSetFileID()); - Assert.assertEquals(specificFileIDs.getFileID(), FILE_ID); + Assertions.assertFalse(specificFileIDs.isSetAllFileIDs()); + Assertions.assertTrue(specificFileIDs.isSetFileID()); + Assertions.assertEquals(specificFileIDs.getFileID(), FILE_ID); } } 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 8bb8dbd88..d00fc91ce 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 @@ -24,20 +24,23 @@ import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +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; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class FileIDValidatorTest extends ExtendedTestCase { /** The settings for the tests. Should be instantiated in the setup.*/ Settings settings; - @BeforeClass (alwaysRun = true) + @BeforeAll public void setup() { settings = TestSettingsProvider.reloadSettings(getClass().getSimpleName()); } - @Test( groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void validatorTest() throws Exception { addDescription("Tests the FileIDValidator class for the input handling based on a given regex."); addStep("Setup the validator", "Should be ok."); @@ -50,23 +53,24 @@ public void validatorTest() throws Exception { String tooShort = ""; addStep("Test a null as argument", "The null should be ignored."); - Assert.assertNull(validator.validateFileID(null)); + Assertions.assertNull(validator.validateFileID(null)); addStep("Test a valid fileID", "Should be valid"); - Assert.assertNull(validator.validateFileID(validFileID)); + Assertions.assertNull(validator.validateFileID(validFileID)); addStep("Test invalid characters", "Should be invalid"); - Assert.assertNotNull(validator.validateFileID(invalidCharacters), "Should fail with bad characters here!"); + Assertions.assertNotNull(validator.validateFileID(invalidCharacters), "Should fail with bad characters here!"); addStep("Test invalid length", "Should be invalid"); - Assert.assertNotNull(validator.validateFileID(tooLong), "Should fail with invalid length here!"); + Assertions.assertNotNull(validator.validateFileID(tooLong), "Should fail with invalid length here!"); addStep("Test too short", "Should be invalid"); - Assert.assertNotNull(validator.validateFileID(tooShort), + Assertions.assertNotNull(validator.validateFileID(tooShort), "Should fail with invalid length here!"); } - @Test( groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void validatorDefaultTest() throws Exception { addDescription("Tests the FileIDValidator class default restrictions. Only the length should fail."); addStep("Setup the validator, where all file ids are allowed at default.", "Should be ok."); @@ -79,35 +83,36 @@ public void validatorDefaultTest() throws Exception { String tooShort = ""; addStep("Test a null as argument", "The null should be ignored."); - Assert.assertNull(validator.validateFileID(null)); + Assertions.assertNull(validator.validateFileID(null)); addStep("Test a valid fileID", "Should be valid"); - Assert.assertNull(validator.validateFileID(validFileID)); + Assertions.assertNull(validator.validateFileID(validFileID)); addStep("Test odd characters", "Should be valid"); - Assert.assertNull(validator.validateFileID(invalidCharacters)); + Assertions.assertNull(validator.validateFileID(invalidCharacters)); addStep("Test invalid length", "Should be invalid"); - Assert.assertNotNull(validator.validateFileID(tooLong), + Assertions.assertNotNull(validator.validateFileID(tooLong), "Should fail with invalid length here -> too long"); addStep("Test too short", "Should be invalid"); - Assert.assertNotNull(validator.validateFileID(tooShort), + Assertions.assertNotNull(validator.validateFileID(tooShort), "Should fail with invalid length here -> too short"); } - @Test( groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void badRegexTest() throws Exception { addDescription("Tests the FileIDValidator handling of bad file id pattern."); addStep("Give the validator a 'null' as allowed file id pattern", "Should be a null stored as regex." ); settings.getRepositorySettings().getProtocolSettings().setAllowedFileIDPattern(null); TestFileIDValidator validator = new TestFileIDValidator(settings); - Assert.assertNull(validator.getRegex()); + Assertions.assertNull(validator.getRegex()); addStep("Give the validator an empty string as allowed file id pattern", "Should be a null stored as regex." ); settings.getRepositorySettings().getProtocolSettings().setAllowedFileIDPattern(""); validator = new TestFileIDValidator(settings); - Assert.assertNull(validator.getRegex()); + Assertions.assertNull(validator.getRegex()); } private class TestFileIDValidator extends FileIDValidator { 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 4bf711ce2..c72fe8efa 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 @@ -23,10 +23,11 @@ import org.apache.activemq.util.ByteArrayInputStream; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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; @@ -38,14 +39,14 @@ public class FileUtilsTest extends ExtendedTestCase { String MOVED_FILE_NAME = "moved.file.name"; String DATA = "The data for the stream."; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setupTest() throws Exception { File dir = new File(DIR); if(dir.exists()) { FileUtils.delete(dir); } } - @AfterMethod(alwaysRun = true) + @AfterEach public void teardownTest() throws Exception { File dir = new File(DIR); if(dir.exists()) { @@ -53,50 +54,52 @@ public void teardownTest() throws Exception { } } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void createDirectoryTester() throws Exception { addDescription("Test the ability to create directories."); addStep("Test the ability to create a directory", "Should be created by utility."); File dir = new File(DIR); - Assert.assertFalse(dir.exists()); + Assertions.assertFalse(dir.exists()); File madeDir = FileUtils.retrieveDirectory(DIR); - Assert.assertTrue(madeDir.exists()); - Assert.assertTrue(madeDir.isDirectory()); - Assert.assertTrue(dir.isDirectory()); - Assert.assertEquals(dir.getAbsolutePath(), madeDir.getAbsolutePath()); + Assertions.assertTrue(madeDir.exists()); + Assertions.assertTrue(madeDir.isDirectory()); + Assertions.assertTrue(dir.isDirectory()); + Assertions.assertEquals(dir.getAbsolutePath(), madeDir.getAbsolutePath()); addStep("Test error scenarios, when the directory path is a file", "Should throw exception"); File testFile = new File(dir, TEST_FILE_NAME); - Assert.assertTrue(testFile.createNewFile()); + Assertions.assertTrue(testFile.createNewFile()); try { FileUtils.retrieveDirectory(testFile.getPath()); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalArgumentException e) { // expected } } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void createSubDirectoryTester() throws Exception { addDescription("Test the ability to create sub directories."); addStep("Test the ability to create sub-directories", "Should be created by utility"); File dir = FileUtils.retrieveDirectory(DIR); File subdir = new File(dir, SUB_DIR); - Assert.assertFalse(subdir.exists()); + Assertions.assertFalse(subdir.exists()); File madeSubdir = FileUtils.retrieveSubDirectory(dir, SUB_DIR); - Assert.assertTrue(madeSubdir.exists()); - Assert.assertTrue(madeSubdir.isDirectory()); - Assert.assertTrue(subdir.isDirectory()); - Assert.assertEquals(subdir.getAbsolutePath(), madeSubdir.getAbsolutePath()); + Assertions.assertTrue(madeSubdir.exists()); + Assertions.assertTrue(madeSubdir.isDirectory()); + Assertions.assertTrue(subdir.isDirectory()); + Assertions.assertEquals(subdir.getAbsolutePath(), madeSubdir.getAbsolutePath()); addStep("Test that it fails if the 'directory' is actually a file", "Throws exception"); File testFile = new File(dir, TEST_FILE_NAME); - Assert.assertTrue(testFile.createNewFile()); + Assertions.assertTrue(testFile.createNewFile()); try { FileUtils.retrieveSubDirectory(testFile, SUB_DIR); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalArgumentException e) { // expected } @@ -106,7 +109,7 @@ public void createSubDirectoryTester() throws Exception { try { dir.setWritable(false); FileUtils.retrieveSubDirectory(dir, SUB_DIR); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalStateException e) { // expected } finally { @@ -114,89 +117,94 @@ public void createSubDirectoryTester() throws Exception { } } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void createDeleteDirectoryTester() throws Exception { addDescription("Test the ability to delete directories."); addStep("Test deleting a directory with file and subdirectory", "Removes directory, sub-directory and file"); File dir = FileUtils.retrieveDirectory(DIR); File subdir = FileUtils.retrieveSubDirectory(dir, SUB_DIR); - Assert.assertTrue(dir.exists()); - Assert.assertTrue(subdir.exists()); + Assertions.assertTrue(dir.exists()); + Assertions.assertTrue(subdir.exists()); File testFile = new File(dir, TEST_FILE_NAME); - Assert.assertTrue(testFile.createNewFile()); - Assert.assertTrue(testFile.exists()); + Assertions.assertTrue(testFile.createNewFile()); + Assertions.assertTrue(testFile.exists()); FileUtils.delete(dir); - Assert.assertFalse(dir.exists()); - Assert.assertFalse(subdir.exists()); - Assert.assertFalse(testFile.exists()); + Assertions.assertFalse(dir.exists()); + Assertions.assertFalse(subdir.exists()); + Assertions.assertFalse(testFile.exists()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void deprecateFileTester() throws Exception { addDescription("Test the deprecation of a file."); addStep("Setup", ""); File dir = FileUtils.retrieveDirectory(DIR); File testFile = new File(dir, TEST_FILE_NAME); - Assert.assertFalse(testFile.exists()); - Assert.assertTrue(testFile.createNewFile()); - Assert.assertTrue(testFile.exists()); + Assertions.assertFalse(testFile.exists()); + Assertions.assertTrue(testFile.createNewFile()); + Assertions.assertTrue(testFile.exists()); addStep("Deprecate the file", "Should be move to '*.old'"); FileUtils.deprecateFile(testFile); - Assert.assertFalse(testFile.exists()); + Assertions.assertFalse(testFile.exists()); File deprecatedFile = new File(dir, TEST_FILE_NAME + ".old"); - Assert.assertTrue(deprecatedFile.exists()); + Assertions.assertTrue(deprecatedFile.exists()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void moveFileTester() throws Exception { addDescription("Test the moving of a file."); addStep("Setup", ""); File dir = FileUtils.retrieveDirectory(DIR); File testFile = new File(dir, TEST_FILE_NAME); File movedFile = new File(dir, MOVED_FILE_NAME); - Assert.assertFalse(testFile.exists()); - Assert.assertFalse(movedFile.exists()); - Assert.assertTrue(testFile.createNewFile()); - Assert.assertTrue(testFile.exists()); + Assertions.assertFalse(testFile.exists()); + Assertions.assertFalse(movedFile.exists()); + Assertions.assertTrue(testFile.createNewFile()); + Assertions.assertTrue(testFile.exists()); addStep("Move the file", "The 'moved' should exist, whereas the other should not."); FileUtils.moveFile(testFile, movedFile); - Assert.assertFalse(testFile.exists()); - Assert.assertTrue(movedFile.exists()); + Assertions.assertFalse(testFile.exists()); + Assertions.assertTrue(movedFile.exists()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void writeInputstreamTester() throws Exception { addDescription("Test writing an inputstream to a file."); addStep("Setup", ""); File dir = FileUtils.retrieveDirectory(DIR); File testFile = new File(dir, TEST_FILE_NAME); - Assert.assertFalse(testFile.exists()); + Assertions.assertFalse(testFile.exists()); ByteArrayInputStream in = new ByteArrayInputStream(DATA.getBytes(StandardCharsets.UTF_8)); addStep("Write the input stream to the file", "The file should exist and have same size as the data."); FileUtils.writeStreamToFile(in, testFile); - Assert.assertTrue(testFile.exists()); - Assert.assertEquals(testFile.length(), DATA.length()); + Assertions.assertTrue(testFile.exists()); + Assertions.assertEquals(testFile.length(), DATA.length()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void unzipFileTester() throws Exception { addDescription("Test unzipping a file."); addStep("Setup", ""); File dir = FileUtils.retrieveDirectory(DIR); File zipFile = new File("src/test/resources/test-files/test.jar"); - Assert.assertTrue(zipFile.isFile(), zipFile.getAbsolutePath()); - Assert.assertEquals(dir.listFiles().length, 0); + Assertions.assertTrue(zipFile.isFile(), zipFile.getAbsolutePath()); + Assertions.assertEquals(dir.listFiles().length, 0); addStep("Unzip the zipfile to the directory", "Should place a file and a directory inside the dir"); FileUtils.unzip(zipFile, dir); - Assert.assertEquals(dir.listFiles().length, 2); + Assertions.assertEquals(dir.listFiles().length, 2); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void cleanupEmptyDirectoriesTester() throws Exception { addDescription("Test the cleanup of empty directories."); File dir = FileUtils.retrieveDirectory(DIR); @@ -204,29 +212,29 @@ public void cleanupEmptyDirectoriesTester() throws Exception { File subSubDir = FileUtils.retrieveSubDirectory(subDir, SUB_DIR); addStep("Cleanup non-empty folder", "Should not do anything"); - Assert.assertTrue(subSubDir.isDirectory()); + Assertions.assertTrue(subSubDir.isDirectory()); FileUtils.cleanupEmptyDirectories(subDir, dir); - Assert.assertTrue(subSubDir.isDirectory()); - Assert.assertTrue(subDir.isDirectory()); - Assert.assertTrue(dir.isDirectory()); + Assertions.assertTrue(subSubDir.isDirectory()); + Assertions.assertTrue(subDir.isDirectory()); + Assertions.assertTrue(dir.isDirectory()); addStep("Cleanup when dir and root are the same", "Should do nothing"); - Assert.assertTrue(subSubDir.isDirectory()); + Assertions.assertTrue(subSubDir.isDirectory()); FileUtils.cleanupEmptyDirectories(subSubDir, subSubDir); - Assert.assertTrue(subSubDir.isDirectory()); + Assertions.assertTrue(subSubDir.isDirectory()); addStep("Test succes case, when the directory is empty", "Removes sub-dir"); - Assert.assertTrue(subSubDir.isDirectory()); + Assertions.assertTrue(subSubDir.isDirectory()); FileUtils.cleanupEmptyDirectories(subSubDir, dir); - Assert.assertFalse(subSubDir.isDirectory()); - Assert.assertFalse(subDir.isDirectory()); - Assert.assertTrue(dir.isDirectory()); + Assertions.assertFalse(subSubDir.isDirectory()); + Assertions.assertFalse(subDir.isDirectory()); + Assertions.assertTrue(dir.isDirectory()); addStep("Test with a file.", "Should do nothing."); File file = new File(dir, TEST_FILE_NAME); - Assert.assertTrue(file.createNewFile()); + Assertions.assertTrue(file.createNewFile()); FileUtils.cleanupEmptyDirectories(file, dir); - Assert.assertTrue(file.exists()); + Assertions.assertTrue(file.exists()); } } 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 c4b1d12b6..cf7f13719 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 @@ -24,20 +24,23 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositoryelements.ResponseInfo; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class ResponseInfoUtilsTest extends ExtendedTestCase { - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void responseInfoTester() throws Exception { addDescription("Test the response info."); addStep("Validate the positive identification response", "Should be 'IDENTIFICATION_POSITIVE'"); ResponseInfo ri = ResponseInfoUtils.getPositiveIdentification(); - Assert.assertEquals(ri.getResponseCode(), ResponseCode.IDENTIFICATION_POSITIVE); + Assertions.assertEquals(ri.getResponseCode(), ResponseCode.IDENTIFICATION_POSITIVE); addStep("Validate the Progress response", "Should be 'OPERATION_ACCEPTED_PROGRESS'"); ri = ResponseInfoUtils.getInitialProgressResponse(); - Assert.assertEquals(ri.getResponseCode(), ResponseCode.OPERATION_ACCEPTED_PROGRESS); + Assertions.assertEquals(ri.getResponseCode(), ResponseCode.OPERATION_ACCEPTED_PROGRESS); } } 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 cd50c471d..dba52b70e 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 @@ -23,8 +23,9 @@ import org.apache.activemq.util.ByteArrayInputStream; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; import java.nio.charset.StandardCharsets; @@ -32,7 +33,7 @@ public class StreamUtilsTest extends ExtendedTestCase { String DATA = "The data for the streams."; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void streamTester() throws Exception { addDescription("Tests the SteamUtils class."); addStep("Setup variables", ""); @@ -42,22 +43,22 @@ public void streamTester() throws Exception { addStep("Test with null arguments", "Should throw exceptions"); try { StreamUtils.copyInputStreamToOutputStream(null, out); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (Exception e) { - Assert.assertTrue(e instanceof IllegalArgumentException); + Assertions.assertTrue(e instanceof IllegalArgumentException); } try { StreamUtils.copyInputStreamToOutputStream(in, null); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (Exception e) { - Assert.assertTrue(e instanceof IllegalArgumentException); + Assertions.assertTrue(e instanceof IllegalArgumentException); } addStep("Test copying the input stream to the output stream.", "Should contain the same data."); StreamUtils.copyInputStreamToOutputStream(in, out); - Assert.assertEquals(out.toString(StandardCharsets.UTF_8), DATA); + Assertions.assertEquals(out.toString(StandardCharsets.UTF_8), DATA); } } 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 809041fed..c94773cd8 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 @@ -27,8 +27,10 @@ import org.bitrepository.bitrepositoryelements.TimeMeasureTYPE; import org.bitrepository.bitrepositoryelements.TimeMeasureUnit; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.math.BigInteger; @@ -36,7 +38,7 @@ * Tests the TimeMeasureComparator class. */ public class TimeMeasurementUtilsTest extends ExtendedTestCase { - @Test (groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void testCompareMilliSeconds() { addDescription("Test the comparison between TimeMeasure units."); TimeMeasureTYPE referenceTime = new TimeMeasureTYPE(); @@ -47,19 +49,19 @@ public void testCompareMilliSeconds() { compareTime.setTimeMeasureValue(new BigInteger("3")); compareTime.setTimeMeasureUnit(TimeMeasureUnit.MILLISECONDS); - Assert.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) < 0, referenceTime + + Assertions.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) < 0, referenceTime + " should be smaller than " + compareTime); compareTime.setTimeMeasureValue(new BigInteger("1")); - Assert.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) > 0, referenceTime + + Assertions.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) > 0, referenceTime + " should be larger than " + compareTime); compareTime.setTimeMeasureValue(new BigInteger("2")); - Assert.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) == 0, referenceTime + + Assertions.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) == 0, referenceTime + " should be same as " + compareTime); } - @Test (groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void testCompareMilliSecondsToHours() { addDescription("Test the comparison between milliseconds and hours."); long millis = 7200000L; @@ -71,31 +73,31 @@ public void testCompareMilliSecondsToHours() { compareTime.setTimeMeasureValue(new BigInteger("3")); compareTime.setTimeMeasureUnit(TimeMeasureUnit.HOURS); - Assert.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) < 0, referenceTime + + Assertions.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) < 0, referenceTime + " should be smaller than " + compareTime); compareTime.setTimeMeasureValue(new BigInteger("1")); - Assert.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) > 0, referenceTime + + Assertions.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) > 0, referenceTime + " should be larger than " + compareTime); compareTime.setTimeMeasureValue(new BigInteger("2")); - Assert.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) == 0, referenceTime + + Assertions.assertTrue(TimeMeasurementUtils.compare(referenceTime, compareTime) == 0, referenceTime + " should be same as " + compareTime); - Assert.assertEquals(TimeMeasurementUtils.getTimeMeasureInLong(referenceTime), millis); + Assertions.assertEquals(TimeMeasurementUtils.getTimeMeasureInLong(referenceTime), millis); } - @Test (groups = { "regressiontest" }) + @Test @Tag("regressiontest" ) public void testMaxValue() { addDescription("Test the Maximum value"); TimeMeasureTYPE time = TimeMeasurementUtils.getMaximumTime(); - Assert.assertEquals(time.getTimeMeasureValue().longValue(), Long.MAX_VALUE); - Assert.assertEquals(time.getTimeMeasureUnit(), TimeMeasureUnit.HOURS); + Assertions.assertEquals(time.getTimeMeasureValue().longValue(), Long.MAX_VALUE); + Assertions.assertEquals(time.getTimeMeasureUnit(), TimeMeasureUnit.HOURS); TimeMeasureTYPE time2 = TimeMeasurementUtils.getTimeMeasurementFromMilliseconds( BigInteger.valueOf(Long.MAX_VALUE)); time2.setTimeMeasureUnit(TimeMeasureUnit.HOURS); - Assert.assertEquals(TimeMeasurementUtils.compare(time, time2), 0); + Assertions.assertEquals(TimeMeasurementUtils.compare(time, time2), 0); } } 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 13ecbf7b5..086a09685 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 @@ -22,8 +22,10 @@ package org.bitrepository.common.utils; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.text.DateFormat; import java.text.SimpleDateFormat; @@ -39,13 +41,13 @@ import java.util.Locale; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class TimeUtilsTest extends ExtendedTestCase { private static final ZonedDateTime BASE = Instant.EPOCH.atZone(ZoneOffset.UTC); - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void timeTester() throws Exception { addDescription("Tests the TimeUtils. Pi days = 271433605 milliseconds"); addStep("Test that milliseconds can be converted into human readable seconds", @@ -81,7 +83,8 @@ public void timeTester() throws Exception { assertTrue(human.contains(expectedDays), human); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void printsHumanDuration() { assertEquals(TimeUtils.durationToHumanUsingEstimates(ChronoUnit.YEARS.getDuration()), "1y"); assertEquals(TimeUtils.durationToHumanUsingEstimates(ChronoUnit.MONTHS.getDuration()), "1m"); @@ -97,7 +100,8 @@ public void printsHumanDuration() { assertEquals(TimeUtils.durationToHumanUsingEstimates(Duration.ofHours(4_382_910)), "500y"); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void zeroIntervalTest() throws Exception { addDescription("Verifies that a 0 ms interval is represented correctly"); addStep("Call millisecondsToHuman with 0 ms", "The output should be '0 ms'"); @@ -105,7 +109,8 @@ public void zeroIntervalTest() throws Exception { assertEquals(zeroTimeString, " 0 ms"); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void durationsPrintHumanly() { addDescription("Tests durationToHuman()"); @@ -127,7 +132,9 @@ public void durationsPrintHumanly() { Duration allUnits = Duration.parse("P3DT5H7M11.013000017S"); assertEquals(TimeUtils.durationToHuman(allUnits), "3d 5h 7m 11s 13000017 ns"); } - @Test(groups = {"regressiontest"}) + + @Test + @Tag("regressiontest") public void differencesPrintHumanly() { addDescription("TimeUtils.humanDifference() should return" + " similar human readable strings to those from millisecondsToHuman()"); @@ -171,7 +178,8 @@ public void differencesPrintHumanly() { assertEquals(oneDaySomethingString, "1d 23h 59m"); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void differencesPrintsWithAppropriatePrecision() { // Include hours if months are 6 or less. testHumanDifference("11m", Period.ofMonths(11), Duration.ofHours(23)); @@ -216,46 +224,48 @@ private void testHumanDifference(String expected, TemporalAmount... amounts) { * formatted to depends on the default/system timezone. At some time the use of the old java Date * api should be discontinued and the new Java Time api used instead. */ - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void shortDateTest() { DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm", Locale.ROOT); Date date = new Date(1360069129256L); String shortDateString = TimeUtils.shortDate(date); - Assert.assertEquals(shortDateString, formatter.format(date)); + Assertions.assertEquals(shortDateString, formatter.format(date)); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void rejectsNegativeDuration() { - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> TimeUtils.durationToCountAndTimeUnit(Duration.ofSeconds(Long.MIN_VALUE))); - Assert.assertThrows(IllegalArgumentException.class, + Assertions.assertThrows(IllegalArgumentException.class, () -> TimeUtils.durationToCountAndTimeUnit(Duration.ofNanos(-1))); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void convertsDurationToCountAndTimeUnit() { CountAndTimeUnit expectedZero = TimeUtils.durationToCountAndTimeUnit(Duration.ZERO); - Assert.assertEquals(expectedZero.getCount(), 0); - Assert.assertNotNull(expectedZero.getUnit()); + Assertions.assertEquals(expectedZero.getCount(), 0); + Assertions.assertNotNull(expectedZero.getUnit()); - Assert.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofNanos(1)), + Assertions.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofNanos(1)), new CountAndTimeUnit(1, TimeUnit.NANOSECONDS)); - Assert.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofNanos(Long.MAX_VALUE)), + Assertions.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofNanos(Long.MAX_VALUE)), new CountAndTimeUnit(Long.MAX_VALUE, TimeUnit.NANOSECONDS)); - Assert.assertEquals( + Assertions.assertEquals( TimeUtils.durationToCountAndTimeUnit(Duration.of(Long.MAX_VALUE / 1000 + 1, ChronoUnit.MICROS)), new CountAndTimeUnit(Long.MAX_VALUE / 1000 + 1, TimeUnit.MICROSECONDS)); - Assert.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.of(Long.MAX_VALUE, ChronoUnit.MICROS)), + Assertions.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.of(Long.MAX_VALUE, ChronoUnit.MICROS)), new CountAndTimeUnit(Long.MAX_VALUE, TimeUnit.MICROSECONDS)); - Assert.assertEquals( + Assertions.assertEquals( TimeUtils.durationToCountAndTimeUnit(Duration.ofMillis(Long.MAX_VALUE / 1000 + 1)), new CountAndTimeUnit(Long.MAX_VALUE / 1000 + 1, TimeUnit.MILLISECONDS)); - Assert.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofMillis(Long.MAX_VALUE)), + Assertions.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofMillis(Long.MAX_VALUE)), new CountAndTimeUnit(Long.MAX_VALUE, TimeUnit.MILLISECONDS)); - Assert.assertEquals( + Assertions.assertEquals( TimeUtils.durationToCountAndTimeUnit(Duration.ofSeconds(Long.MAX_VALUE / 1000 + 1)), new CountAndTimeUnit(Long.MAX_VALUE / 1000 + 1, TimeUnit.SECONDS)); - Assert.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofSeconds(Long.MAX_VALUE)), + Assertions.assertEquals(TimeUtils.durationToCountAndTimeUnit(Duration.ofSeconds(Long.MAX_VALUE)), new CountAndTimeUnit(Long.MAX_VALUE, TimeUnit.SECONDS)); } 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 2bf1b2bab..651f9187c 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 @@ -3,68 +3,76 @@ import org.bitrepository.bitrepositoryelements.TimeMeasureTYPE; import org.bitrepository.bitrepositoryelements.TimeMeasureUnit; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.math.BigInteger; import java.time.Duration; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class XmlUtilsTest extends ExtendedTestCase { private DatatypeFactory factory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUpFactory() throws DatatypeConfigurationException { factory = DatatypeFactory.newInstance(); } - @Test(groups = {"regressiontest"}, expectedExceptions = IllegalArgumentException.class) + @Test + @Tag("regressiontest") public void negativeDurationIsRejected() { - XmlUtils.validateNonNegative(factory.newDuration("-PT0.00001S")); + assertThrows(IllegalArgumentException.class, () -> { + XmlUtils.validateNonNegative(factory.newDuration("-PT0.00001S")); + }); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testXmlDurationToDuration() { addDescription("Tests xmlDurationToDuration in sunshine scenario cases"); addStep("Durations of 0 of some time unit", "Duration.ZERO"); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P0Y")), Duration.ZERO); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P0M")), Duration.ZERO); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P0D")), Duration.ZERO); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0H")), Duration.ZERO); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0M")), Duration.ZERO); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0S")), Duration.ZERO); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0.0000S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P0Y")), Duration.ZERO); + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P0M")), Duration.ZERO); + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P0D")), Duration.ZERO); + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0H")), Duration.ZERO); + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0M")), Duration.ZERO); + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0S")), Duration.ZERO); + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT0.0000S")), Duration.ZERO); addStep("Test correct and precise conversion", "Hours, minutes and seconds are converted with full precision"); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3S")), Duration.ofSeconds(3)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3.3S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3.3S")), Duration.ofSeconds(3, 300_000_000)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3.000000003S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3.000000003S")), Duration.ofSeconds(3, 3)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3.123456789S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT3.123456789S")), Duration.ofSeconds(3, 123_456_789)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT4M")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT4M")), Duration.ofMinutes(4)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT5H")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT5H")), Duration.ofHours(5)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT6H7M8.9S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("PT6H7M8.9S")), Duration.ofHours(6).plusMinutes(7).plusSeconds(8).plusMillis(900)); addStep("Test approximate conversion", "Days, months and years are converted using estimated factors"); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P2D")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P2D")), Duration.ofDays(2)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P3DT4M")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("P3DT4M")), Duration.ofDays(3).plusMinutes(4)); // We require a month to be between 28 and 31 days exclusive @@ -80,18 +88,19 @@ public void testXmlDurationToDuration() { assertBetweenExclusive(convertedTwoYears, minTwoYearsLengthExclusive, maxTwoYearsLengthExclusive); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testNegativeXmlDurationToDuration() { // WorkflowInterval may be negative (meaning don’t run automatically) addDescription("Tests that xmlDurationToDuration() accepts a negative duration and converts it correctly"); addStep("Negative XML durations", "Corresponding negative java.time durations"); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-PT3S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-PT3S")), Duration.ofSeconds(-3)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-PT0.000001S")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-PT0.000001S")), Duration.ofNanos(-1000)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-PT24H")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-PT24H")), Duration.ofHours(-24)); - Assert.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-P1D")), + Assertions.assertEquals(XmlUtils.xmlDurationToDuration(factory.newDuration("-P1D")), Duration.ofDays(-1)); // We require minus 1 month to be between -31 and -28 days exclusive @@ -108,50 +117,55 @@ public void testNegativeXmlDurationToDuration() { } private static > void assertBetweenExclusive(T actual, T minExclusive, T maxExclusive) { - Assert.assertTrue(actual.compareTo(minExclusive) > 0); - Assert.assertTrue(actual.compareTo(maxExclusive) < 0); + Assertions.assertTrue(actual.compareTo(minExclusive) > 0); + Assertions.assertTrue(actual.compareTo(maxExclusive) < 0); } - @Test(groups = {"regressiontest"}, expectedExceptions = ArithmeticException.class) + @Test @Tag("regressiontest") public void tooManyDecimalsAreRejected() { - addDescription("Tests that xmlDurationToDuration() rejects more than 9 decimals on seconds"); - addStep("Duration with 10 decimals, PT2.0123456789S", "ArithmeticException"); - XmlUtils.xmlDurationToDuration(factory.newDuration("PT2.0123456789S")); + assertThrows(ArithmeticException.class, () -> { + addDescription("Tests that xmlDurationToDuration() rejects more than 9 decimals on seconds"); + addStep("Duration with 10 decimals, PT2.0123456789S", "ArithmeticException"); + XmlUtils.xmlDurationToDuration(factory.newDuration("PT2.0123456789S")); + }); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testXmlDurationToMilliseconds() { addDescription("Tests xmlDurationToMilliseconds in sunshine scenario cases"); addStep("Test correct and precise conversion", "Hours, minutes and seconds are converted with full precision"); - Assert.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration(1)), 1); - Assert.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration(1000)), 1000); + Assertions.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration(1)), 1); + Assertions.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration(1000)), 1000); - Assert.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("PT0.001S")), 1); - Assert.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("PT0.001999S")), 1); - Assert.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("PT2S")), 2000); + Assertions.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("PT0.001S")), 1); + Assertions.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("PT0.001999S")), 1); + Assertions.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("PT2S")), 2000); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testNegativeXmlDurationToMilliseconds() { - Assert.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("-PT1S")), -1000); + Assertions.assertEquals(XmlUtils.xmlDurationToMilliseconds(factory.newDuration("-PT1S")), -1000); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void convertsToTimeMeasure() { TimeMeasureTYPE shortTimeMeasure = XmlUtils.xmlDurationToTimeMeasure(factory.newDuration(1)); - Assert.assertEquals(shortTimeMeasure.getTimeMeasureUnit(), TimeMeasureUnit.MILLISECONDS); - Assert.assertEquals(shortTimeMeasure.getTimeMeasureValue(), BigInteger.ONE); + Assertions.assertEquals(shortTimeMeasure.getTimeMeasureUnit(), TimeMeasureUnit.MILLISECONDS); + Assertions.assertEquals(shortTimeMeasure.getTimeMeasureValue(), BigInteger.ONE); long hours = 2_562_047_788_015L; TimeMeasureTYPE longTimeMeasure = XmlUtils.xmlDurationToTimeMeasure(factory.newDurationDayTime( true, BigInteger.ZERO, BigInteger.valueOf(hours), BigInteger.ZERO, BigInteger.ZERO)); if (longTimeMeasure.getTimeMeasureUnit() == TimeMeasureUnit.HOURS) { - Assert.assertEquals(longTimeMeasure.getTimeMeasureValue(), BigInteger.valueOf(hours)); + Assertions.assertEquals(longTimeMeasure.getTimeMeasureValue(), BigInteger.valueOf(hours)); } else { - Assert.assertEquals(longTimeMeasure.getTimeMeasureUnit(), TimeMeasureUnit.MILLISECONDS); - Assert.assertEquals(longTimeMeasure.getTimeMeasureValue(), + Assertions.assertEquals(longTimeMeasure.getTimeMeasureUnit(), TimeMeasureUnit.MILLISECONDS); + Assertions.assertEquals(longTimeMeasure.getTimeMeasureValue(), BigInteger.valueOf(Duration.ofHours(hours).toMillis())); } } 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 ece1da863..3f13ce671 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java @@ -41,15 +41,12 @@ import org.bitrepository.protocol.security.SecurityManager; import org.jaccept.TestEventManager; import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInstance; import org.slf4j.LoggerFactory; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.BeforeSuite; -import org.testng.annotations.BeforeTest; import javax.jms.JMSException; import java.lang.reflect.Method; @@ -57,6 +54,7 @@ import java.net.URL; import java.util.List; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class IntegrationTest extends ExtendedTestCase { protected static TestEventManager testEventManager = TestEventManager.getInstance(); public static LocalActiveMQBroker broker; @@ -79,8 +77,7 @@ public abstract class IntegrationTest extends ExtendedTestCase { protected String testMethodName; - @BeforeSuite(alwaysRun = true) - public void initializeSuite(ITestContext testContext) { + private void initializationMethod() { settingsForCUT = loadSettings(getComponentID()); settingsForTestClient = loadSettings("TestSuiteInitialiser"); makeUserSpecificSettings(settingsForCUT); @@ -112,48 +109,49 @@ protected void addReceiver(MessageReceiver receiver) { receiverManager.addReceiver(receiver); } - @BeforeClass(alwaysRun = true) + @BeforeAll public void initMessagebus() { + initializationMethod(); setupMessageBus(); } - @AfterSuite(alwaysRun = true) - public void shutdownSuite() { - teardownMessageBus(); - teardownHttpServer(); - } - - /** - * Defines the standard BitRepositoryCollection configuration - */ - @BeforeMethod(alwaysRun = true) - public final void beforeMethod(Method method) { - testMethodName = method.getName(); - setupSettings(); - NON_DEFAULT_FILE_ID = TestFileHelper.createUniquePrefix(testMethodName); - DEFAULT_AUDIT_INFORMATION = testMethodName; - receiverManager = new MessageReceiverManager(messageBus); - registerMessageReceivers(); - messageBus.setCollectionFilter(List.of()); - messageBus.setComponentFilter(List.of()); - receiverManager.startListeners(); - initializeCUT(); - } +// @AfterAll +// public void shutdownSuite() { +// teardownMessageBus(); +// teardownHttpServer(); +// } + +// /** +// * Defines the standard BitRepositoryCollection configuration +// */ +// @BeforeEach +// public final void beforeMethod(Method method) { +// testMethodName = method.getName(); +// setupSettings(); +// NON_DEFAULT_FILE_ID = TestFileHelper.createUniquePrefix(testMethodName); +// DEFAULT_AUDIT_INFORMATION = testMethodName; +// receiverManager = new MessageReceiverManager(messageBus); +// registerMessageReceivers(); +// messageBus.setCollectionFilter(List.of()); +// messageBus.setComponentFilter(List.of()); +// receiverManager.startListeners(); +// initializeCUT(); +// } protected void initializeCUT() {} - @AfterMethod(alwaysRun = true) - public final void afterMethod(ITestResult testResult) { - if (receiverManager != null) { - receiverManager.stopListeners(); - } - if (testResult.isSuccess()) { - afterMethodVerification(); - } - shutdownCUT(); - } - +// @AfterEach +// public final void afterMethod(ITestResult testResult) { +// if (receiverManager != null) { +// receiverManager.stopListeners(); +// } +// if (testResult.isSuccess()) { +// afterMethodVerification(); +// } +// shutdownCUT(); +// } +// /** * May be used by specific tests for general verification when the test method has finished. Will only be run * if the test has passed (so far). @@ -199,14 +197,6 @@ private void makeUserSpecificSettings(Settings settings) { settings.getRepositorySettings().getProtocolSettings().setAlarmDestination(settings.getAlarmDestination() + getTopicPostfix()); } - @BeforeTest(alwaysRun = true) - public void writeLogStatus() { - if (System.getProperty("enableLogStatus", "false").equals("true")) { - LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); - StatusPrinter.print(lc); - } - } - /** * Indicated whether an embedded active MQ should be started and used */ 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 99b2f2b2b..ddef0ee6f 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/MessageCreationTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/MessageCreationTest.java @@ -31,7 +31,8 @@ import org.bitrepository.common.JaxbHelper; import org.bitrepository.protocol.message.ExampleMessageFactory; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.w3c.dom.Document; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; @@ -48,12 +49,14 @@ import java.nio.charset.StandardCharsets; import java.util.Iterator; +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 { - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void messageCreationTest() throws Exception { addDescription("Tests if 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."); @@ -66,17 +69,21 @@ public void messageCreationTest() throws Exception { } } - @Test(groups = {"regressiontest"}, expectedExceptions = SAXException.class) + @Test + @Tag("regressiontest") public void badDateMessageTest() throws IOException, SAXException, JAXBException { - addDescription("Test to ensure that messages carrying dates must provide offset."); - String messagePath = ExampleMessageFactory.PATH_TO_EXAMPLES + "BadMessages/" + - "BadDateAlarmMessage" + ExampleMessageFactory.EXAMPLE_FILE_POSTFIX; - InputStream messageIS = Thread.currentThread().getContextClassLoader().getResourceAsStream(messagePath); - assert messageIS != null; - String message = IOUtils.toString(messageIS, StandardCharsets.UTF_8); - JaxbHelper jaxbHelper = new JaxbHelper(ExampleMessageFactory.PATH_TO_SCHEMA, ExampleMessageFactory.SCHEMA_NAME); - jaxbHelper.validate(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))); - AlarmMessage am = jaxbHelper.loadXml(AlarmMessage.class, new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))); + assertThrows(SAXException.class, () -> { + + addDescription("Test to ensure that messages carrying dates must provide offset."); + String messagePath = ExampleMessageFactory.PATH_TO_EXAMPLES + "BadMessages/" + + "BadDateAlarmMessage" + ExampleMessageFactory.EXAMPLE_FILE_POSTFIX; + InputStream messageIS = Thread.currentThread().getContextClassLoader().getResourceAsStream(messagePath); + assert messageIS != null; + String message = IOUtils.toString(messageIS, StandardCharsets.UTF_8); + JaxbHelper jaxbHelper = new JaxbHelper(ExampleMessageFactory.PATH_TO_SCHEMA, ExampleMessageFactory.SCHEMA_NAME); + jaxbHelper.validate(new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))); + AlarmMessage am = jaxbHelper.loadXml(AlarmMessage.class, new ByteArrayInputStream(message.getBytes(StandardCharsets.UTF_8))); + }); } /** 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 d5b9bf884..419e6f620 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 @@ -27,7 +27,8 @@ import org.bitrepository.protocol.ProtocolComponentFactory; import org.bitrepository.protocol.activemq.ActiveMQMessageBus; import org.bitrepository.protocol.message.ExampleMessageFactory; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.jms.Message; import javax.jms.MessageListener; @@ -36,7 +37,8 @@ import java.util.concurrent.LinkedBlockingDeque; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Runs the GeneralMessageBusTest using a LocalActiveMQBroker (if useEmbeddedMessageBus is true) and a suitable @@ -56,7 +58,8 @@ protected void setupMessageBus() { } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public final void collectionFilterTest() throws Exception { addDescription("Test that message bus filters identify requests to other collection, eg. ignores these."); addStep("Send an identify request with a undefined 'Collection' header property, " + @@ -90,7 +93,7 @@ public final void collectionFilterTest() throws Exception { collectionReceiver.checkNoMessageIsReceived(IdentifyPillarsForDeleteFileRequest.class); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public final void sendMessageToSpecificComponentTest() throws Exception { addDescription("Test that message bus correct uses the 'to' header property to indicated that the message " + "is meant for a specific component"); @@ -116,7 +119,7 @@ public void onMessage(Message message) { assertEquals(receivedMessage.getStringProperty(ActiveMQMessageBus.MESSAGE_TO_KEY), receiverID); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public final void toFilterTest() throws Exception { addDescription("Test that message bus filters identify requests to other components, eg. ignores these."); addStep("Send an identify request with a undefined 'To' header property, " + 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 168c014bf..b7ba4d935 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 @@ -29,8 +29,9 @@ import org.bitrepository.protocol.message.ExampleMessageFactory; import org.bitrepository.protocol.messagebus.MessageBusManager; import org.jaccept.TestEventManager; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -47,13 +48,14 @@ protected void registerMessageReceivers() { addReceiver(collectionReceiver); } - @AfterMethod(alwaysRun = true) + @AfterEach public void tearDown() { messageBus.setComponentFilter(Arrays.asList(new String[]{})); messageBus.setCollectionFilter(Arrays.asList(new String[]{})); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest" ) public final void busActivityTest() throws Exception { addDescription("Tests whether it is possible to create a message listener, " + "and then set it to listen to the topic. Then puts a message" + @@ -70,7 +72,8 @@ public final void busActivityTest() throws Exception { alarmReceiver.waitForMessage(message.getClass()); } - @Test(groups = {"regressiontest"}) + @Test + @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(); @@ -94,7 +97,7 @@ public final void twoListenersForTopicTest() throws Exception { receiver2.waitForMessage(AlarmMessage.class); } - @Test(groups = { "specificationonly" }) + @Test @Tag("specificationonly" ) public final void messageBusFailoverTest() { addDescription("Verifies that we can switch to at second message bus " + "in the middle of a conversation, if the connection is lost. " + @@ -102,7 +105,7 @@ public final void messageBusFailoverTest() { "message bus"); } - @Test(groups = { "specificationonly" }) + @Test @Tag("specificationonly" ) public final void messageBusReconnectTest() { addDescription("Test whether we are able to reconnect to the message " + "bus if the connection is lost"); 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 b2690167e..278c48654 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 @@ -28,9 +28,9 @@ 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; -import org.testng.Assert; import javax.jms.ExceptionListener; import javax.jms.JMSException; @@ -119,7 +119,7 @@ public T waitForMessage(Class messageType, long timeout, TimeUnit unit) { log.debug("Read message after ({} ms): {}", waitTime, message); } else { log.info("Wait for {} message timed out ({} ms).", messageType.getSimpleName(), waitTime); - Assert.fail("Wait for " + messageType.getSimpleName() + " message timed out (" + waitTime + " ms)."); + Assertions.fail("Wait for " + messageType.getSimpleName() + " message timed out (" + waitTime + " ms)."); } return message; } @@ -136,7 +136,7 @@ public void checkNoMessageIsReceived(Class messageType) { throw new RuntimeException(e); // Should never happen } if (message != null) { - Assert.fail("Received unexpected message " + message); + Assertions.fail("Received unexpected message " + 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 e731ab923..b785f2cc3 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 @@ -31,9 +31,10 @@ import org.bitrepository.protocol.ProtocolComponentFactory; import org.bitrepository.protocol.message.ExampleMessageFactory; import org.bitrepository.protocol.messagebus.MessageListener; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; +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 java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -63,7 +64,8 @@ protected void setupMessageBus() { } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest" ) public final void manyTheadsBeforeFinish() throws Exception { addDescription("Tests whether it is possible to start the handling of many threads simultaneously."); IdentifyPillarsForGetFileRequest content = @@ -76,11 +78,11 @@ public final void manyTheadsBeforeFinish() throws Exception { for(int i = 0; i < threadCount; i++) { messageBus.sendMessage(content); } - Assert.assertEquals(finishQueue.poll(TIME_FOR_WAIT, TimeUnit.MILLISECONDS), FINISH); - Assert.assertEquals(count, threadCount); + Assertions.assertEquals(finishQueue.poll(TIME_FOR_WAIT, TimeUnit.MILLISECONDS), FINISH); + Assertions.assertEquals(count, threadCount); } - @AfterMethod(alwaysRun = true) + @AfterEach public void removeListener() { messageBus.removeListener("BusActivityTest", listener); } @@ -92,9 +94,9 @@ protected class MultiMessageListener implements MessageListener { public final void onMessage(Message message, MessageContext messageContext) { try { testIfFinished(); - Assert.assertNotNull(queue.poll(TIME_FOR_WAIT, TimeUnit.MILLISECONDS)); + Assertions.assertNotNull(queue.poll(TIME_FOR_WAIT, TimeUnit.MILLISECONDS)); } catch (InterruptedException e) { - Assert.fail("Should not throw an exception: ", e); + Assertions.fail("Should not throw an exception: ", e); } } 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 2e3b1ae1d..bafa2fe0c 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 @@ -6,9 +6,11 @@ import org.bitrepository.settings.referencesettings.FileExchangeSettings; import org.fusesource.hawtbuf.ByteArrayInputStream; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +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.io.ByteArrayOutputStream; import java.io.File; @@ -24,11 +26,12 @@ import java.nio.file.Files; import java.nio.file.Paths; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class LocalFileExchangeTest extends ExtendedTestCase { final static String BASE_FILE_EXCHANGE_DIR = "target/fileexchange/"; private FileExchange exchange; - @BeforeClass(alwaysRun = true) + @BeforeAll public void setup() throws IOException { createFileExchangeDir(); FileExchangeSettings settings = new FileExchangeSettings(); @@ -44,7 +47,8 @@ private void createFileExchangeDir() throws IOException { } } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void getUrlTest() throws MalformedURLException { String testFile = "getUrlTestfile"; @@ -52,9 +56,9 @@ public void getUrlTest() throws MalformedURLException { URL expectedUrl = new URL("file:" + basedir.getAbsolutePath() + "/" + testFile); URL actualUrl = exchange.getURL(testFile); - Assert.assertEquals(actualUrl, expectedUrl); + Assertions.assertEquals(actualUrl, expectedUrl); File actualFile = new File(actualUrl.getFile()); - Assert.assertFalse(actualFile.exists()); + Assertions.assertFalse(actualFile.exists()); } /** @@ -74,11 +78,11 @@ public void putFileByFileContainingHashTest() throws Exception { StandardCharsets.UTF_8)); URL fileExchangeUrl = exchange.putFile(testFile); - Assert.assertEquals(fileExchangeUrl, expectedUrl); + Assertions.assertEquals(fileExchangeUrl, expectedUrl); File actualFile = new File(fileExchangeUrl.toURI()); - Assert.assertTrue(actualFile.exists()); + Assertions.assertTrue(actualFile.exists()); String fileExchangeContent = readTestFileContent(actualFile); - Assert.assertEquals(fileExchangeContent, testFileContent); + Assertions.assertEquals(fileExchangeContent, testFileContent); actualFile.delete(); } @@ -93,12 +97,12 @@ public void putFileByFileTest() throws IOException { URL expectedUrl = new URL("file:" + basedir.getAbsolutePath() + "/" + testFileName); URL fileExchangeUrl = exchange.putFile(testFile); - Assert.assertEquals(fileExchangeUrl, expectedUrl); + Assertions.assertEquals(fileExchangeUrl, expectedUrl); File actualFile = new File(fileExchangeUrl.getFile()); - Assert.assertTrue(actualFile.exists()); + Assertions.assertTrue(actualFile.exists()); String fileExchangeContent = readTestFileContent(actualFile); - Assert.assertEquals(fileExchangeContent, testFileContent); + Assertions.assertEquals(fileExchangeContent, testFileContent); actualFile.delete(); } @@ -113,7 +117,7 @@ public void putFileByStreamTest() throws IOException { File fileExchangeFile = new File(fileExchangeUrl.getFile()); String fileExchangeContent = readTestFileContent(fileExchangeFile); - Assert.assertEquals(fileExchangeContent, testFileContent); + Assertions.assertEquals(fileExchangeContent, testFileContent); fileExchangeFile.delete(); } @@ -128,7 +132,7 @@ public void getFileByInputStreamTest() throws IOException { InputStream is = exchange.getFile(testFileUrl); String fileContent = IOUtils.toString(is, StandardCharsets.UTF_8); - Assert.assertEquals(fileContent, testFileContent); + Assertions.assertEquals(fileContent, testFileContent); } @Test @@ -143,7 +147,7 @@ public void getFileByOutputStreamTest() throws IOException { OutputStream os = new ByteArrayOutputStream(); exchange.getFile(os, testFileUrl); - Assert.assertEquals(os.toString(), testFileContent); + Assertions.assertEquals(os.toString(), testFileContent); } @Test @@ -160,7 +164,7 @@ public void getFileByAddressTest() throws IOException { exchange.getFile(destination, testFileUrl.toString()); String destinationContent = readTestFileContent(destination); - Assert.assertEquals(destinationContent, testFileContent); + Assertions.assertEquals(destinationContent, testFileContent); } @Test @@ -173,9 +177,9 @@ public void deleteFileTest() throws IOException, URISyntaxException { exchange.putFile(is, fileExchangeUrl); File fileExchangeFile = new File(fileExchangeUrl.getFile()); - Assert.assertTrue(fileExchangeFile.exists()); + Assertions.assertTrue(fileExchangeFile.exists()); exchange.deleteFile(fileExchangeUrl); - Assert.assertFalse(fileExchangeFile.exists()); + Assertions.assertFalse(fileExchangeFile.exists()); } private File createTestFile(String filename, String content) throws IOException { 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 736e463ff..ecc0bc3e2 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 @@ -26,16 +26,19 @@ import org.bitrepository.settings.referencesettings.FileExchangeSettings; import org.bitrepository.settings.referencesettings.ProtocolType; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.math.BigInteger; import java.net.MalformedURLException; import java.net.URL; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class HttpFileExchangeTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest" ) public void checkUrlEncodingOfFilenamesTest() throws MalformedURLException { addDescription("Tests that the filename is url-encoded correctly for a configured webdav server"); Settings mySettings = TestSettingsProvider.reloadSettings("uploadTest"); 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 9aa28b5a0..f2d37b578 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 @@ -29,7 +29,8 @@ import org.bitrepository.settings.referencesettings.MessageThreadPool; import org.bitrepository.settings.referencesettings.MessageThreadPools; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.math.BigInteger; import java.util.Arrays; @@ -41,7 +42,8 @@ public class ReceivedMessageHandlerTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest" ) public void singleMessageDispatch() { addDescription("Tests that a single message is dispatched correctly"); ReceivedMessageHandler handler = new ReceivedMessageHandler(null); @@ -52,7 +54,8 @@ public void singleMessageDispatch() { verify(defaultListener, timeout(100)).onMessage(testMessage, testMessageContext); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void parallelMessageDispatch() { addDescription("Tests that two messages can be handled in parallel in the default pool configuration."); addFixture("Create a ReceivedMessageHandler with a null configuration. This should create a " + @@ -76,7 +79,8 @@ public void parallelMessageDispatch() { verifyNoMoreInteractions(secondListener); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest" ) public void manyMessageDispatch() { addDescription("Tests that many (50) messages can be handled in parallel in the default pool configuration."); addFixture("Create a ReceivedMessageHandler with a null configuration. This should create a " + @@ -104,7 +108,8 @@ public void manyMessageDispatch() { verifyNoMoreInteractions(lastListener); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void singleThreadMessageDispatch() { addDescription("Tests that two messages will be handled in sequence if a singleThreaded pool is configured."); addFixture("Create a ReceivedMessageHandler with a single pool of size 1."); @@ -125,7 +130,8 @@ public void singleThreadMessageDispatch() { verify(secondListener, timeout(100)).onMessage(testMessage, null); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void specificMessagePools() { addDescription("Tests that different message types can be handled by different executors."); addFixture("Create a ReceivedMessageHandler with a two pools, one for status requests and one for put requests. " + @@ -159,7 +165,7 @@ public void specificMessagePools() { verifyNoMoreInteractions(thirdStatusListener); } - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void specificMessageNamePoolAndDefaultPool() { addDescription("Tests it is possible to specify a pool for a specific message type, with a " + "default pool for the remainder."); @@ -192,7 +198,8 @@ public void specificMessageNamePoolAndDefaultPool() { verifyNoMoreInteractions(thirdStatusListener); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest" ) public void specificMessageCategoryPoolAndDefaultPool() { addDescription("Tests it is possible to specify a pool for a specific message category, with a " + "default pool for the remainder."); @@ -224,7 +231,7 @@ public void specificMessageCategoryPoolAndDefaultPool() { verifyNoMoreInteractions(thirdStatusListener); } - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void specificCollectionPoolAndDefaultPool() { addDescription("Tests it is possible to specify a pool for a specific collection, with a " + "default pool for the remainder."); @@ -264,7 +271,8 @@ public void specificCollectionPoolAndDefaultPool() { verify(secondCollection1Listener, timeout(100)).onMessage(collection1Message, null); } - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void specificCollectionPoolWithSpecificMessageTypePool() { addDescription("Tests it is possible to specify a pool for a specific collection for only a specific" + "message type."); 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 710914fbd..4af621b3e 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 @@ -32,8 +32,10 @@ import org.bitrepository.protocol.security.SecurityManager; import org.jaccept.TestEventManager; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +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; @@ -43,6 +45,7 @@ import java.util.List; import java.util.concurrent.TimeUnit; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class MessageBusDelayTest extends ExtendedTestCase { private Settings settings; private SecurityManager securityManager; @@ -51,17 +54,19 @@ public class MessageBusDelayTest extends ExtendedTestCase { private static final int NUMBER_OF_TESTS = 100; private static final boolean WRITE_RESULTS_TO_DISC = true; - @BeforeClass(alwaysRun = true) + @BeforeAll public void setup() { settings = TestSettingsProvider.reloadSettings(getClass().getSimpleName()); securityManager = new DummySecurityManager(); } - @Test(groups = {"StressTest"}) + @Test + @Tag("StressTest") public void testManyTimes() { for (int i = 0; i < NUMBER_OF_TESTS; i++) { try { performStatisticalAnalysisOfMessageDelay(); + System.out.println("Test " + i + " done."); } catch (Exception e) { System.err.println("Unknown exception caught: " + e); } 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 066c4eb50..cff4e8c89 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 @@ -39,9 +39,10 @@ import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.io.FileOutputStream; @@ -110,7 +111,7 @@ public class MessageBusNumberOfListenersStressTest extends ExtendedTestCase { private static boolean sendMoreMessages = true; private Settings settings; - @BeforeMethod + @BeforeEach public void initializeSettings() { settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); } @@ -121,7 +122,8 @@ public void initializeSettings() { * * @throws Exception Can possibly throw an exception. */ - @Test(groups = {"StressTest"}) + @Test + @Tag("StressTest") 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."); @@ -155,7 +157,8 @@ public void testManyListenersOnLocalMessageBus() throws Exception { } } - @Test(groups = {"StressTest"}) + @Test + @Tag("StressTest") 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."); @@ -228,12 +231,12 @@ public void testListeners(MessageBusConfiguration conf, SecurityManager security addStep("Verifying the amount of message sent '" + idReached + "' has been received by all '" + NUMBER_OF_LISTENERS + "' listeners", "Should be the same amount for each listener, and the same " + "amount as the correlation ID of the message"); - Assert.assertEquals(messageReceived, idReached * NUMBER_OF_LISTENERS, + Assertions.assertEquals(messageReceived, idReached * NUMBER_OF_LISTENERS, "Reached message Id " + idReached + " thus each message of the " + NUMBER_OF_LISTENERS + " listener " + "should have received " + idReached + " message, though they have received " + messageReceived + " message all together."); for (NotificationMessageListener listener : listeners) { - Assert.assertTrue((listener.getCount() == idReached), + Assertions.assertTrue((listener.getCount() == idReached), "Should have received " + idReached + " messages, but has received " + listener.getCount()); } 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 3c6742ec0..0269e17aa 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,9 +38,11 @@ import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.util.Date; @@ -52,7 +54,7 @@ public class MessageBusNumberOfMessagesStressTest extends ExtendedTestCase { private static String QUEUE = "TEST-QUEUE"; private Settings settings; - @BeforeMethod + @BeforeEach public void initializeSettings() { settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); } @@ -61,7 +63,7 @@ public void initializeSettings() { * Tests the amount of messages sent over a message bus, which is not placed locally. * Require sending at least five messages per second. */ - @Test( groups = {"StressTest"} ) + @Test @Tag("StressTest") public void SendManyMessagesDistributed() throws Exception { addDescription("Tests how many messages can be handled within a given timeframe."); addStep("Define constants", "This should not be possible to fail."); @@ -89,7 +91,7 @@ public void SendManyMessagesDistributed() throws Exception { addStep("Stopped sending at '" + new Date() + "'", "Should have send more than '" + messagePerSec + "' messages per sec."); int count = listener.getCount(); - Assert.assertTrue(count > (messagePerSec * timeFrame/1000), "There where send '" + count + Assertions.assertTrue(count > (messagePerSec * timeFrame/1000), "There where send '" + count + "' messages in '" + timeFrame/1000 + "' seconds, but it is required to handle at least '" + messagePerSec + "' per second!"); System.out.println("Sent '" + count + "' messages in '" + timeFrame/1000 + "' seconds."); @@ -105,7 +107,7 @@ public void SendManyMessagesDistributed() throws Exception { * Tests the amount of messages send through a local messagebus. * It should be at least 20 per second. */ - @Test( groups = {"StressTest"} ) + @Test @Tag("StressTest") 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."); @@ -118,7 +120,7 @@ public void SendManyMessagesLocally() throws Exception { MessageBusConfigurationFactory.createEmbeddedMessageBusConfiguration() ); LocalActiveMQBroker broker = new LocalActiveMQBroker(settings.getMessageBusConfiguration()); - Assert.assertNotNull(broker); + Assertions.assertNotNull(broker); ResendMessageListener listener = null; @@ -142,7 +144,7 @@ public void SendManyMessagesLocally() throws Exception { addStep("Stopped sending at '" + new Date() + "'", "Should have send more than '" + messagePerSec + "' messages per sec."); int count = listener.getCount(); - Assert.assertTrue(count > (messagePerSec * timeFrame/1000), "There where send '" + count + Assertions.assertTrue(count > (messagePerSec * timeFrame/1000), "There where send '" + count + "' messages in '" + timeFrame/1000 + "' seconds, but it is required to handle at least '" + messagePerSec + "' per second!"); System.out.println("Sent '" + count + "' messages in '" + timeFrame/1000 + "' seconds."); 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 68be6421c..b08fcebf0 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 @@ -42,9 +42,11 @@ import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.util.Date; @@ -59,7 +61,7 @@ public class MessageBusSizeOfMessageStressTest extends ExtendedTestCase { private final long TIME_FRAME = 60000L; private Settings settings; - @BeforeMethod + @BeforeEach public void initializeSettings() { settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); } @@ -96,7 +98,7 @@ public void SendLargeMessagesDistributed() throws Exception { addStep("Validating messages have been sent.", "Should be OK"); int count = listener.getCount(); - Assert.assertTrue(count > 0, "Some message should have been sent."); + Assertions.assertTrue(count > 0, "Some message should have been sent."); System.out.println("Sent '" + count + "' messages in '" + TIME_FRAME / 1000 + "' seconds."); } finally { if (listener != null) { @@ -109,7 +111,8 @@ public void SendLargeMessagesDistributed() throws Exception { * Tests the amount of messages sent through a local messagebus. * It should be at least 20 per second. */ - @Test(groups = {"StressTest"}) + @Test + @Tag("StressTest") public void SendLargeMessagesLocally() throws Exception { addDescription("Tests how many messages can be handled within a given timeframe."); addStep("Define constants", "This should not be possible to fail."); @@ -117,9 +120,9 @@ public void SendLargeMessagesLocally() throws Exception { addStep("Make configuration for the messagebus and define the local broker.", "Both should be created."); MessageBusConfiguration conf = MessageBusConfigurationFactory.createEmbeddedMessageBusConfiguration(); - Assert.assertNotNull(conf); + Assertions.assertNotNull(conf); LocalActiveMQBroker broker = new LocalActiveMQBroker(conf); - Assert.assertNotNull(broker); + Assertions.assertNotNull(broker); ResendMessageListener listener = null; 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 f5827a9c4..ddbb37155 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 @@ -39,9 +39,11 @@ import org.bitrepository.protocol.security.SecurityManager; import org.bitrepository.settings.repositorysettings.MessageBusConfiguration; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.util.Date; @@ -60,7 +62,7 @@ public class MessageBusTimeToSendMessagesStressTest extends ExtendedTestCase { private static Date startSending; private Settings settings; - @BeforeMethod + @BeforeEach public void initializeSettings() { settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); } @@ -116,7 +118,7 @@ public void SendManyMessagesDistributed() { * Tests the amount of messages sent through a local messagebus. * It should be at least 20 per second. */ - @Test( groups = {"StressTest"} ) + @Test @Tag("StressTest") 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."); @@ -124,9 +126,9 @@ public void SendManyMessagesLocally() throws Exception { addStep("Make configuration for the messagebus and define the local broker.", "Both should be created."); MessageBusConfiguration conf = MessageBusConfigurationFactory.createEmbeddedMessageBusConfiguration(); - Assert.assertNotNull(conf); + Assertions.assertNotNull(conf); LocalActiveMQBroker broker = new LocalActiveMQBroker(conf); - Assert.assertNotNull(broker); + Assertions.assertNotNull(broker); CountMessagesListener listener = null; SecurityManager securityManager = new DummySecurityManager(); 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 9cdb8b02d..d1f66f9c2 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 @@ -27,8 +27,10 @@ import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.bouncycastle.util.encoders.Base64; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import javax.security.auth.x500.X500Principal; import java.io.ByteArrayInputStream; @@ -40,7 +42,8 @@ public class CertificateIDTest extends ExtendedTestCase { - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void positiveCertificateIdentificationTest() throws Exception { addDescription("Tests that a certificate can be identified based on the correct signature."); addStep("Create CertificateID object based on the certificate used to sign the data", "CertificateID object not null"); @@ -58,10 +61,11 @@ public void positiveCertificateIdentificationTest() throws Exception { CertificateID certificateIDFromSignature = new CertificateID(signer.getSID().getIssuer(), signer.getSID().getSerialNumber()); addStep("Assert that the two CertificateID objects are equal", "Assert succeeds"); - Assert.assertEquals(certificateIDfromCertificate, certificateIDFromSignature); + Assertions.assertEquals(certificateIDfromCertificate, certificateIDFromSignature); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void negativeCertificateIdentificationTest() throws Exception { addDescription("Tests that a certificate is not identified based on a incorrect signature."); addStep("Create CertificateID object based on a certificate not used for signing the data", "CertificateID object not null"); @@ -79,10 +83,11 @@ public void negativeCertificateIdentificationTest() throws Exception { CertificateID certificateIDFromSignature = new CertificateID(signer.getSID().getIssuer(), signer.getSID().getSerialNumber()); addStep("Assert that the two CertificateID objects are not equal", "Assert succeeds"); - Assert.assertNotSame(certificateIDFromCertificate, certificateIDFromSignature); + Assertions.assertNotSame(certificateIDFromCertificate, certificateIDFromSignature); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void equalTest() throws Exception { addDescription("Tests the equality of CertificateIDs"); addStep("Setup", ""); @@ -94,43 +99,43 @@ public void equalTest() throws Exception { CertificateID certificateID1 = new CertificateID(issuer, serial); addStep("Validate the content of the certificateID", "Should be same as x509Certificate"); - Assert.assertEquals(certificateID1.getIssuer(), issuer); - Assert.assertEquals(certificateID1.getSerial(), serial); + Assertions.assertEquals(certificateID1.getIssuer(), issuer); + Assertions.assertEquals(certificateID1.getSerial(), serial); addStep("Test whether it equals it self", "should give positive result"); - Assert.assertEquals(certificateID1, certificateID1); + Assertions.assertEquals(certificateID1, certificateID1); addStep("Test with a null as argument", "Should give negative result"); - Assert.assertNotEquals(certificateID1, null); + Assertions.assertNotEquals(certificateID1, null); addStep("Test with another class", "Should give negative result"); - Assert.assertNotEquals(new Object(), certificateID1); + Assertions.assertNotEquals(new Object(), certificateID1); addStep("Test with same issuer but no serial", "Should give negative result"); - Assert.assertNotEquals(new CertificateID(issuer, null), certificateID1); + Assertions.assertNotEquals(new CertificateID(issuer, null), certificateID1); addStep("Test with same serial but no issuer", "Should give negative result"); - Assert.assertNotEquals(new CertificateID((X500Principal) null, serial), certificateID1); + Assertions.assertNotEquals(new CertificateID((X500Principal) null, serial), certificateID1); addStep("Test the positive case, with both the issuer and serial ", "Should give positive result"); - Assert.assertEquals(new CertificateID(issuer, serial), certificateID1); + Assertions.assertEquals(new CertificateID(issuer, serial), certificateID1); addStep("Setup an empty certificate", ""); CertificateID certificateID2 = new CertificateID((X500Principal) null, null); addStep("Test empty certificate against issuer but no serial", "Should give negative result"); - Assert.assertNotEquals(new CertificateID(issuer, null), certificateID2); + Assertions.assertNotEquals(new CertificateID(issuer, null), certificateID2); addStep("Test empty certificate against serial but no issuer", "Should give negative result"); - Assert.assertNotEquals(new CertificateID((X500Principal) null, serial), certificateID2); + Assertions.assertNotEquals(new CertificateID((X500Principal) null, serial), certificateID2); addStep("Test empty certificate against serial and issuer", "Should give negative result"); - Assert.assertNotEquals(new CertificateID(issuer, serial), certificateID2); + Assertions.assertNotEquals(new CertificateID(issuer, serial), certificateID2); addStep("Test the positive case, with neither issuer nor serial", "Should give positive result"); - Assert.assertEquals(new CertificateID((X500Principal) null, null), certificateID2); + Assertions.assertEquals(new CertificateID((X500Principal) null, null), certificateID2); addStep("Check the hash codes for the two certificate", "Should not be the same"); - Assert.assertTrue(certificateID1.hashCode() != certificateID2.hashCode()); + Assertions.assertTrue(certificateID1.hashCode() != certificateID2.hashCode()); } } 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 dc0c48324..3fce32456 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 @@ -27,25 +27,27 @@ import org.bouncycastle.cms.SignerInformation; import org.bouncycastle.util.encoders.Base64; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.math.BigInteger; import java.security.cert.X509Certificate; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class PermissionStoreTest extends ExtendedTestCase { private static final String componentID = "TEST"; private PermissionStore permissionStore; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUp() throws Exception { permissionStore = new PermissionStore(); permissionStore.loadPermissions(SecurityTestConstants.getDefaultPermissions(), componentID); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void positiveCertificateRetrievalTest() throws Exception { addDescription("Tests that a certificate can be retrieved based on the correct signerId."); addStep("Create signer to lookup certificate", "No exceptions"); @@ -60,7 +62,8 @@ public void positiveCertificateRetrievalTest() throws Exception { assertEquals(positiveCertificate, certificateFromStore); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void negativeCertificateRetrievalTest() throws Exception { addDescription("Tests that a certificate cannot be retrieved based on the wrong signerId."); addStep("Create signer and modify its ID so lookup will fail", "No exceptions"); @@ -89,7 +92,7 @@ public void unknownCertificatePermissionCheckTest() { addDescription("Tests that a unknown certificate results in expected refusal."); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void certificateFingerprintTest() throws Exception { addDescription("Tests that a certificate fingerprint can correctly be retrieved for a signer."); addFixture("Create signer to lookup fingerprint"); 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 da047e206..1bf4a7b2a 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 @@ -38,11 +38,14 @@ import org.bitrepository.settings.repositorysettings.PermissionSet; 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; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -54,7 +57,7 @@ public class SecurityManagerTest extends ExtendedTestCase { private PermissionStore permissionStore; private Settings settings; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUp() throws Exception { settings = TestSettingsProvider.reloadSettings(getClass().getSimpleName()); settings.getRepositorySettings().getProtocolSettings().setRequireMessageAuthentication(true); @@ -77,12 +80,12 @@ private void setupSecurityManager(Settings settings) { SecurityTestConstants.getComponentID()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void operationAuthorizationBehaviourTest() throws Exception { addDescription("Tests that a signature only allows the correct requests."); List collections = settings.getRepositorySettings().getCollections().getCollection(); - Assert.assertEquals(collections.size(), 2, + Assertions.assertEquals(collections.size(), 2, "There should be two collections present to test the collection limited authorization"); settings.getRepositorySettings().setPermissionSet(getCollectionLimitedPermissionSet()); setupSecurityManager(settings); @@ -95,13 +98,13 @@ public void operationAuthorizationBehaviourTest() throws Exception { securityManager.authorizeOperation(PutFileRequest.class.getSimpleName(), SecurityTestConstants.getTestData(), TestCertProvider.getPositiveCertSignature(), collectionID1); } catch (OperationAuthorizationException e) { - Assert.fail(e.getMessage()); + Assertions.fail(e.getMessage()); } try { securityManager.authorizeOperation(PutFileRequest.class.getSimpleName(), SecurityTestConstants.getTestData(), TestCertProvider.getPositiveCertSignature(), collectionID2); } catch (OperationAuthorizationException e) { - Assert.fail(e.getMessage()); + Assertions.fail(e.getMessage()); } addStep("Check that GET_FILE is only allowed for the first collection.", @@ -112,18 +115,19 @@ public void operationAuthorizationBehaviourTest() throws Exception { securityManager.authorizeOperation(GetFileRequest.class.getSimpleName(), SecurityTestConstants.getTestData(), TestCertProvider.getPositiveCertSignature(), collectionID1); } catch (OperationAuthorizationException e) { - Assert.fail(e.getMessage()); + Assertions.fail(e.getMessage()); } try { securityManager.authorizeOperation(GetFileRequest.class.getSimpleName(), SecurityTestConstants.getTestData(), TestCertProvider.getPositiveCertSignature(), collectionID2); - Assert.fail("SecurityManager did not throw the expected OperationAuthorizationException"); + Assertions.fail("SecurityManager did not throw the expected OperationAuthorizationException"); } catch (OperationAuthorizationException ignored) { } } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void certificateAuthorizationBehaviourTest() throws Exception { addDescription("Tests that a certificate is only allowed by registered users (component)."); addStep("Check that the registered component is allowed.", "The registered component is allowed."); @@ -134,20 +138,21 @@ public void certificateAuthorizationBehaviourTest() throws Exception { securityManager.authorizeCertificateUse(SecurityTestConstants.getAllowedCertificateUser(), SecurityTestConstants.getTestData(), TestCertProvider.getPositiveCertSignature()); } catch (CertificateUseException e) { - Assert.fail(e.getMessage()); + Assertions.fail(e.getMessage()); } - Assert.assertNotNull(getSigningCertPermission().getPermission().get(0).getCertificate().getAllowedCertificateUsers()); + Assertions.assertNotNull(getSigningCertPermission().getPermission().get(0).getCertificate().getAllowedCertificateUsers()); addStep("Check that an unregistered component is not allowed.", "The unregistered component is not allowed."); try { securityManager.authorizeCertificateUse(SecurityTestConstants.getDisallowedCertificateUser(), SecurityTestConstants.getTestData(), TestCertProvider.getPositiveCertSignature()); - Assert.fail("SecurityManager did not throw the expected CertificateUseException"); + Assertions.fail("SecurityManager did not throw the expected CertificateUseException"); } catch (CertificateUseException ignored) { } } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void positiveSigningAuthenticationRoundtripTest() throws Exception { addDescription("Tests that a roundtrip of signing a request and afterwards authenticating is succeeds."); addStep("Sign a chunk of data.", "Data is signed successfully"); @@ -155,7 +160,7 @@ public void positiveSigningAuthenticationRoundtripTest() throws Exception { try { signature = securityManager.signMessage(SecurityTestConstants.getTestData()); } catch (MessageSigningException e) { - Assert.fail("Failed signing test data!", e); + Assertions.fail("Failed signing test data!", e); } permissionStore.loadPermissions(getSigningCertPermission(), SecurityTestConstants.getComponentID()); @@ -167,11 +172,11 @@ public void positiveSigningAuthenticationRoundtripTest() throws Exception { try { securityManager.authenticateMessage(SecurityTestConstants.getTestData(), signature); } catch (MessageAuthenticationException e) { - Assert.fail("Failed authenticating test data!", e); + Assertions.fail("Failed authenticating test data!", e); } } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void negativeSigningAuthenticationRoundtripUnkonwnCertificateTest() throws Exception { addDescription("Tests that a roundtrip of signing a request and afterwards authenticating it fails due to " + "a unknown certificate."); @@ -180,7 +185,7 @@ public void negativeSigningAuthenticationRoundtripUnkonwnCertificateTest() throw try { signature = securityManager.signMessage(SecurityTestConstants.getTestData()); } catch (MessageSigningException e) { - Assert.fail("Failed signing test data!", e); + Assertions.fail("Failed signing test data!", e); } String signatureString = new String(Base64.encode(signature.getBytes(SecurityModuleConstants.defaultEncodingType)), StandardCharsets.UTF_8); @@ -189,13 +194,14 @@ public void negativeSigningAuthenticationRoundtripUnkonwnCertificateTest() throw addStep("Check signature matches the data", "Signature cant be matched as certificate is unknown."); try { securityManager.authenticateMessage(SecurityTestConstants.getTestData(), signature);//signatureString); - Assert.fail("Authentication did not fail as expected"); + Assertions.fail("Authentication did not fail as expected"); } catch (MessageAuthenticationException e) { log.info(e.getMessage()); } } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void negativeSigningAuthenticationRoundtripBadDataTest() throws Exception { addDescription("Tests that a roundtrip of signing a request and afterwards authenticating it fails " + "due to bad data"); @@ -205,7 +211,7 @@ public void negativeSigningAuthenticationRoundtripBadDataTest() throws Exception try { signature = securityManager.signMessage(SecurityTestConstants.getTestData()); } catch (MessageSigningException e) { - Assert.fail("Failed signing test data!", e); + Assertions.fail("Failed signing test data!", e); } permissionStore.loadPermissions(getSigningCertPermission(), SecurityTestConstants.getComponentID()); @@ -217,7 +223,7 @@ public void negativeSigningAuthenticationRoundtripBadDataTest() throws Exception String corruptData = SecurityTestConstants.getTestData() + "foobar"; try { securityManager.authenticateMessage(corruptData, signature); - Assert.fail("Authentication did not fail as expected!"); + Assertions.fail("Authentication did not fail as expected!"); } catch (MessageAuthenticationException e) { log.info(e.getMessage()); } diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SignatureGeneratorTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SignatureGeneratorTest.java index 486ba4c04..724b07d98 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SignatureGeneratorTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/security/SignatureGeneratorTest.java @@ -3,7 +3,7 @@ import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.protocol.security.exception.MessageSigningException; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; public class SignatureGeneratorTest { /* 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 c0c4a63c7..46addbde1 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 @@ -22,12 +22,15 @@ package org.bitrepository.protocol.security.exception; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class CertificateUseExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest" ) public void testCertificateUseException() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -38,20 +41,20 @@ public void testCertificateUseException() throws Exception { try { throw new CertificateUseException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof CertificateUseException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof CertificateUseException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new CertificateUseException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof CertificateUseException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof CertificateUseException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } 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 be1cb3bfd..94bda84d8 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 @@ -22,12 +22,14 @@ package org.bitrepository.protocol.security.exception; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class MessageAuthenticationExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest" ) public void testMessageAuthenticationException() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -38,20 +40,20 @@ public void testMessageAuthenticationException() throws Exception { try { throw new MessageAuthenticationException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof MessageAuthenticationException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof MessageAuthenticationException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new MessageAuthenticationException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof MessageAuthenticationException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof MessageAuthenticationException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } 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 9887b6e21..123b675b7 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 @@ -22,12 +22,14 @@ package org.bitrepository.protocol.security.exception; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class MessageSignerExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test + @Tag("regressiontest") public void testMessageSigningException() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -38,20 +40,20 @@ public void testMessageSigningException() throws Exception { try { throw new MessageSigningException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof MessageSigningException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof MessageSigningException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new MessageSigningException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof MessageSigningException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof MessageSigningException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } 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 7bb62de02..4ba44cb01 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 @@ -22,12 +22,14 @@ package org.bitrepository.protocol.security.exception; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class OperationAuthorizationExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest" ) public void testOperationAuthorizationException() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -38,20 +40,20 @@ public void testOperationAuthorizationException() throws Exception { try { throw new OperationAuthorizationException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof OperationAuthorizationException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof OperationAuthorizationException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new OperationAuthorizationException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof OperationAuthorizationException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof OperationAuthorizationException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } 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 ee3143a4a..b1f5c00ef 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 @@ -22,12 +22,14 @@ package org.bitrepository.protocol.security.exception; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class PermissionStoreExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void testPermissionStoreException() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -38,20 +40,20 @@ public void testPermissionStoreException() throws Exception { try { throw new PermissionStoreException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof PermissionStoreException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof PermissionStoreException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new PermissionStoreException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof PermissionStoreException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof PermissionStoreException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } 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 89150025d..55f18cbb0 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 @@ -22,12 +22,13 @@ package org.bitrepository.protocol.security.exception; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class SecurityExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest" ) public void testSecurityException() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -38,20 +39,20 @@ public void testSecurityException() throws Exception { try { throw new SecurityException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof SecurityException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof SecurityException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new SecurityException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof SecurityException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof SecurityException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } 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 4bbe97ae6..c2e261603 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 @@ -22,12 +22,14 @@ package org.bitrepository.protocol.security.exception; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class UnregisteredPermissionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void testUnregisteredPermissionException() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -38,20 +40,20 @@ public void testUnregisteredPermissionException() throws Exception { try { throw new UnregisteredPermissionException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof UnregisteredPermissionException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof UnregisteredPermissionException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new UnregisteredPermissionException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof UnregisteredPermissionException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof UnregisteredPermissionException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } 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 63f61a3c9..95abba7e7 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 @@ -23,38 +23,40 @@ import org.bitrepository.common.utils.FileUtils; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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; public class ConfigLoaderTest extends ExtendedTestCase { String GOOD_FILE_PATH = "logback-test.xml"; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setup() { FileUtils.copyFile(new File("src/test/resources/logback-test.xml"), new File(GOOD_FILE_PATH)); } - @AfterMethod(alwaysRun = true) + @AfterEach public void teardown() { FileUtils.delete(new File(GOOD_FILE_PATH)); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testLoadingConfig() throws Exception { addDescription("Test the loading of a configuration file for the config loader."); addStep("Setup variables", ""); String badFilePath = "iDoNotExist.xml"; - Assert.assertFalse(new File(badFilePath).exists()); - Assert.assertTrue(new File(GOOD_FILE_PATH).exists()); + Assertions.assertFalse(new File(badFilePath).exists()); + Assertions.assertTrue(new File(GOOD_FILE_PATH).exists()); addStep("Test with a invalid file path", "Should throw an exception"); try { new LogbackConfigLoader(badFilePath); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalArgumentException e) { // expected } @@ -66,7 +68,7 @@ public void testLoadingConfig() throws Exception { try { new LogbackConfigLoader(GOOD_FILE_PATH); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalArgumentException e) { // expected } diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/FileExchangeResolverTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/FileExchangeResolverTest.java index 558bdab3b..c23af6453 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/FileExchangeResolverTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/FileExchangeResolverTest.java @@ -6,12 +6,13 @@ import org.bitrepository.protocol.http.HttpsFileExchange; import org.bitrepository.settings.referencesettings.FileExchangeSettings; import org.bitrepository.settings.referencesettings.ProtocolType; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.net.MalformedURLException; import java.net.URL; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class FileExchangeResolverTest { @Test @@ -59,9 +60,11 @@ public void resolveHttpsProtocolURL() throws MalformedURLException { assertEquals(exchange.getClass(), HttpsFileExchange.class); } - @Test(expectedExceptions = {IllegalArgumentException.class}) + @Test public void resolveBadProtocolURL() throws MalformedURLException { - URL badURL = new URL("ftp://some/path"); - FileExchangeResolver.getBasicFileExchangeFromURL(badURL); + assertThrows(IllegalArgumentException.class, () -> { + URL badURL = new URL("ftp://some/path"); + FileExchangeResolver.getBasicFileExchangeFromURL(badURL); + }); } } diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageDataTypeValidatorTest.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageDataTypeValidatorTest.java index 0cb10618d..4c015d152 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageDataTypeValidatorTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/MessageDataTypeValidatorTest.java @@ -6,45 +6,54 @@ import org.bitrepository.bitrepositoryelements.ChecksumType; import org.bitrepository.common.utils.Base16Utils; import org.bitrepository.common.utils.CalendarUtils; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertThrows; public class MessageDataTypeValidatorTest { - @Test(expectedExceptions = {IllegalArgumentException.class}) + @Test public void validateChecksumSpecTest() { - ChecksumSpecTYPE noChecksumTypeSpec = new ChecksumSpecTYPE(); - MessageDataTypeValidator.validate(noChecksumTypeSpec, "noChecksumTypeSpec"); + assertThrows(IllegalArgumentException.class, () -> { + ChecksumSpecTYPE noChecksumTypeSpec = new ChecksumSpecTYPE(); + MessageDataTypeValidator.validate(noChecksumTypeSpec, "noChecksumTypeSpec"); + }); } - @Test(expectedExceptions = {IllegalArgumentException.class}) + @Test public void validateChecksumDataForFileNoChecksumTest() { - ChecksumDataForFileTYPE noChecksumSpec = new ChecksumDataForFileTYPE(); - ChecksumSpecTYPE checksumTypeSpec = new ChecksumSpecTYPE(); - checksumTypeSpec.setChecksumType(ChecksumType.MD5); - noChecksumSpec.setChecksumSpec(checksumTypeSpec); - noChecksumSpec.setCalculationTimestamp(CalendarUtils.getNow()); - - MessageDataTypeValidator.validate(noChecksumSpec, "noChecksumSpec"); + assertThrows(IllegalArgumentException.class, () -> { + ChecksumDataForFileTYPE noChecksumSpec = new ChecksumDataForFileTYPE(); + ChecksumSpecTYPE checksumTypeSpec = new ChecksumSpecTYPE(); + checksumTypeSpec.setChecksumType(ChecksumType.MD5); + noChecksumSpec.setChecksumSpec(checksumTypeSpec); + noChecksumSpec.setCalculationTimestamp(CalendarUtils.getNow()); + MessageDataTypeValidator.validate(noChecksumSpec, "noChecksumSpec"); + }); } - @Test(expectedExceptions = {IllegalArgumentException.class}) + @Test public void validateChecksumDataForFileNoTimestampTest() throws DecoderException { - ChecksumDataForFileTYPE noChecksumSpec = new ChecksumDataForFileTYPE(); - ChecksumSpecTYPE checksumTypeSpec = new ChecksumSpecTYPE(); - checksumTypeSpec.setChecksumType(ChecksumType.MD5); - noChecksumSpec.setChecksumSpec(checksumTypeSpec); - noChecksumSpec.setChecksumValue(Base16Utils.encodeBase16("abab")); + assertThrows(IllegalArgumentException.class, () -> { + ChecksumDataForFileTYPE noChecksumSpec = new ChecksumDataForFileTYPE(); + ChecksumSpecTYPE checksumTypeSpec = new ChecksumSpecTYPE(); + checksumTypeSpec.setChecksumType(ChecksumType.MD5); + noChecksumSpec.setChecksumSpec(checksumTypeSpec); + noChecksumSpec.setChecksumValue(Base16Utils.encodeBase16("abab")); - MessageDataTypeValidator.validate(noChecksumSpec, "noChecksumSpec"); + MessageDataTypeValidator.validate(noChecksumSpec, "noChecksumSpec"); + }); } - @Test(expectedExceptions = {IllegalArgumentException.class}) + @Test public void validateChecksumDataForFileNoChecksumSpecTest() throws DecoderException { - ChecksumDataForFileTYPE noChecksumSpec = new ChecksumDataForFileTYPE(); - noChecksumSpec.setChecksumValue(Base16Utils.encodeBase16("abab")); - noChecksumSpec.setCalculationTimestamp(CalendarUtils.getNow()); + assertThrows(IllegalArgumentException.class, () -> { + ChecksumDataForFileTYPE noChecksumSpec = new ChecksumDataForFileTYPE(); + noChecksumSpec.setChecksumValue(Base16Utils.encodeBase16("abab")); + noChecksumSpec.setCalculationTimestamp(CalendarUtils.getNow()); - MessageDataTypeValidator.validate(noChecksumSpec, "noChecksumSpec"); + MessageDataTypeValidator.validate(noChecksumSpec, "noChecksumSpec"); + }); } //@Test(expectedExceptions = {IllegalArgumentException.class}) 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 368cbe233..53907d9a5 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 @@ -25,11 +25,13 @@ import org.bitrepository.bitrepositoryelements.ResponseInfo; import org.bitrepository.bitrepositorymessages.MessageResponse; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class MessageUtilsTest extends ExtendedTestCase { - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testPositiveIdentification() { addDescription("Tests isPositiveIdentifyResponse method in the message utility class."); MessageResponse response = new MessageResponse(); @@ -38,18 +40,19 @@ public void testPositiveIdentification() { addStep("validate that it can see a positive identify response", "Should return true for positive identify."); response.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_POSITIVE); - Assert.assertTrue(MessageUtils.isPositiveIdentifyResponse(response)); + Assertions.assertTrue(MessageUtils.isPositiveIdentifyResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_NEGATIVE); - Assert.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); + Assertions.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.OPERATION_COMPLETED); - Assert.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); + Assertions.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.OPERATION_PROGRESS); - Assert.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); + Assertions.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.OPERATION_ACCEPTED_PROGRESS); - Assert.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); + Assertions.assertFalse(MessageUtils.isPositiveIdentifyResponse(response)); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testIdentificationResponse() { addDescription("Tests isIdentifyResponse method in the message utility class."); MessageResponse response = new MessageResponse(); @@ -58,15 +61,15 @@ public void testIdentificationResponse() { addStep("validate that it can see a identify response", "Should only return true for identify responses."); response.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_NEGATIVE); - Assert.assertTrue(MessageUtils.isIdentifyResponse(response)); + Assertions.assertTrue(MessageUtils.isIdentifyResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_POSITIVE); - Assert.assertTrue(MessageUtils.isIdentifyResponse(response)); + Assertions.assertTrue(MessageUtils.isIdentifyResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.FAILURE); - Assert.assertFalse(MessageUtils.isIdentifyResponse(response)); + Assertions.assertFalse(MessageUtils.isIdentifyResponse(response)); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testProgressResponse() { addDescription("Tests isPositiveProgressResponse method in the message utility class."); MessageResponse response = new MessageResponse(); @@ -76,17 +79,17 @@ public void testProgressResponse() { addStep("validate progress response", "Should only return true for 'operation_progress', " + "'operation_accepted_progress' and 'identification_positive'."); response.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_NEGATIVE); - Assert.assertFalse(MessageUtils.isPositiveProgressResponse(response)); + Assertions.assertFalse(MessageUtils.isPositiveProgressResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_POSITIVE); - Assert.assertTrue(MessageUtils.isPositiveProgressResponse(response)); + Assertions.assertTrue(MessageUtils.isPositiveProgressResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.OPERATION_COMPLETED); - Assert.assertFalse(MessageUtils.isPositiveProgressResponse(response)); + Assertions.assertFalse(MessageUtils.isPositiveProgressResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.OPERATION_PROGRESS); - Assert.assertTrue(MessageUtils.isPositiveProgressResponse(response)); + Assertions.assertTrue(MessageUtils.isPositiveProgressResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.OPERATION_ACCEPTED_PROGRESS); - Assert.assertTrue(MessageUtils.isPositiveProgressResponse(response)); + Assertions.assertTrue(MessageUtils.isPositiveProgressResponse(response)); response.getResponseInfo().setResponseCode(ResponseCode.FAILURE); - Assert.assertFalse(MessageUtils.isIdentifyResponse(response)); + Assertions.assertFalse(MessageUtils.isIdentifyResponse(response)); } } diff --git a/bitrepository-core/src/test/java/org/bitrepository/settings/SettingsProviderTest.java b/bitrepository-core/src/test/java/org/bitrepository/settings/SettingsProviderTest.java index f202465da..c9d24ccb7 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/settings/SettingsProviderTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/settings/SettingsProviderTest.java @@ -24,23 +24,25 @@ import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.SettingsProvider; import org.bitrepository.common.settings.XMLFileSettingsLoader; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class SettingsProviderTest { private static final String PATH_TO_TEST_SETTINGS = "settings/xml/bitrepository-devel"; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void componentIDTest() { String myComponentID = "TestComponentID"; SettingsProvider settingsLoader = new SettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), myComponentID); Settings settings = settingsLoader.getSettings(); - Assert.assertEquals(settings.getComponentID(), myComponentID); + Assertions.assertEquals(settings.getComponentID(), myComponentID); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void reloadTest() { String myComponentID = "TestComponentID"; SettingsProvider settingsLoader = @@ -51,13 +53,13 @@ public void reloadTest() { String newCollectionID = "newCollectionID"; settings.getRepositorySettings().getCollections().getCollection().get(0).setID(newCollectionID); - Assert.assertEquals(settings.getRepositorySettings().getCollections().getCollection().get(0).getID(), + Assertions.assertEquals(settings.getRepositorySettings().getCollections().getCollection().get(0).getID(), newCollectionID); - Assert.assertEquals(settings.getCollections().get(0).getID(), newCollectionID); + Assertions.assertEquals(settings.getCollections().get(0).getID(), newCollectionID); settingsLoader.reloadSettings(); settings = settingsLoader.getSettings(); - Assert.assertEquals(settings.getRepositorySettings().getCollections().getCollection().get(0).getID(), originalCollectionID); - Assert.assertEquals(settings.getCollections().get(0).getID(), originalCollectionID); + Assertions.assertEquals(settings.getRepositorySettings().getCollections().getCollection().get(0).getID(), originalCollectionID); + Assertions.assertEquals(settings.getCollections().get(0).getID(), originalCollectionID); } } diff --git a/pom.xml b/pom.xml index caa942967..16992397f 100644 --- a/pom.xml +++ b/pom.xml @@ -173,37 +173,18 @@ runtime - - org.glassfish.jaxb - jaxb-runtime - 2.3.6 - runtime - - - - - - - - - - org.mockito - mockito-junit-jupiter - 5.12.0 - test - - - org.junit.jupiter - junit-jupiter - 5.10.3 - test - - - - org.slf4j - jul-to-slf4j - ${slf4j.version} - + + org.mockito + mockito-junit-jupiter + 5.12.0 + test + + + org.junit.jupiter + junit-jupiter + 5.10.3 + test + org.testng @@ -452,12 +433,12 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.1.0 + 3.4.5 org.apache.maven.plugins maven-checkstyle-plugin - 3.1.1 + 3.6.0 sonarCheckstyle.xml @@ -473,12 +454,12 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.12 org.apache.maven.plugins maven-pmd-plugin - 3.13.0 + 3.28.0 From 155ad250b403e8d3a01c80d9638909c9b0facf79 Mon Sep 17 00:00:00 2001 From: kaah Date: Wed, 17 Dec 2025 14:50:03 +0100 Subject: [PATCH 05/14] Put a @Disabled at testManyTimes() and commented it out, so people can choose to include the test or not --- .../protocol/performancetest/MessageBusDelayTest.java | 2 ++ .../performancetest/MessageBusNumberOfMessagesStressTest.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) 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 4af621b3e..046434aa3 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 @@ -33,6 +33,7 @@ import org.jaccept.TestEventManager; import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.TestInstance; @@ -62,6 +63,7 @@ public void setup() { @Test @Tag("StressTest") +// @Disabled public void testManyTimes() { for (int i = 0; i < NUMBER_OF_TESTS; i++) { try { 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 0269e17aa..af1efc56c 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 @@ -107,7 +107,8 @@ public void SendManyMessagesDistributed() throws Exception { * Tests the amount of messages send through a local messagebus. * It should be at least 20 per second. */ - @Test @Tag("StressTest") + @Test + @Tag("StressTest") 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."); From 8d421a4f11fbb8828e564c3fe96a09b23ab8e1ff Mon Sep 17 00:00:00 2001 From: kaah Date: Thu, 18 Dec 2025 14:23:06 +0100 Subject: [PATCH 06/14] The branch has now the same test methods that are wrong, but mvn clean install can't run because it gives errors in the module bitrepository-client, which hasn't been converted to junit 5 yet. --- .../protocol/BitrepositoryTestSuite.java | 3 +- .../protocol/IntegrationTest.java | 75 ++++++++++--------- .../MessageBusNumberOfMessagesStressTest.java | 2 + .../protocol/utils/TestWatcherExtension.java | 33 ++++++++ 4 files changed, 75 insertions(+), 38 deletions(-) create mode 100644 bitrepository-core/src/test/java/org/bitrepository/protocol/utils/TestWatcherExtension.java diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java index e31f8f4a0..4c9cdab62 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/BitrepositoryTestSuite.java @@ -1,5 +1,6 @@ package org.bitrepository.protocol; +import org.bitrepository.protocol.bus.ActiveMQMessageBusTest; import org.junit.platform.suite.api.ExcludeTags; import org.junit.platform.suite.api.IncludeTags; import org.junit.platform.suite.api.SelectClasses; @@ -55,7 +56,7 @@ * */ @Suite -@SelectClasses({IntegrationTest.class}) // List your test classes here +@SelectClasses({IntegrationTest.class, ActiveMQMessageBusTest.class}) // List your test classes here @ExtendWith(GlobalSuiteExtension.class) public class BitrepositoryTestSuite { // No need for methods here; this just groups and extends 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 3f13ce671..00b63c846 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java @@ -24,8 +24,6 @@ */ package org.bitrepository.protocol; -import ch.qos.logback.classic.LoggerContext; -import ch.qos.logback.core.util.StatusPrinter; import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.common.utils.SettingsUtils; @@ -39,22 +37,25 @@ import org.bitrepository.protocol.messagebus.SimpleMessageBus; import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; +import org.bitrepository.protocol.utils.TestWatcherExtension; import org.jaccept.TestEventManager; import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; import org.junit.jupiter.api.TestInstance; -import org.slf4j.LoggerFactory; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.api.extension.TestWatcher; import javax.jms.JMSException; -import java.lang.reflect.Method; import java.net.MalformedURLException; import java.net.URL; import java.util.List; @TestInstance(TestInstance.Lifecycle.PER_CLASS) +@ExtendWith(TestWatcherExtension.class) public abstract class IntegrationTest extends ExtendedTestCase { protected static TestEventManager testEventManager = TestEventManager.getInstance(); public static LocalActiveMQBroker broker; @@ -115,43 +116,43 @@ public void initMessagebus() { setupMessageBus(); } -// @AfterAll -// public void shutdownSuite() { -// teardownMessageBus(); -// teardownHttpServer(); -// } - -// /** -// * Defines the standard BitRepositoryCollection configuration -// */ -// @BeforeEach -// public final void beforeMethod(Method method) { -// testMethodName = method.getName(); -// setupSettings(); -// NON_DEFAULT_FILE_ID = TestFileHelper.createUniquePrefix(testMethodName); -// DEFAULT_AUDIT_INFORMATION = testMethodName; -// receiverManager = new MessageReceiverManager(messageBus); -// registerMessageReceivers(); -// messageBus.setCollectionFilter(List.of()); -// messageBus.setComponentFilter(List.of()); -// receiverManager.startListeners(); -// initializeCUT(); -// } + @AfterAll + public void shutdownSuite() { + teardownMessageBus(); + teardownHttpServer(); + } + /** + * Defines the standard BitRepositoryCollection configuration + */ + @BeforeEach + public final void beforeMethod(TestInfo testInfo) { + testMethodName = testInfo.getTestMethod().get().getName(); + setupSettings(); + NON_DEFAULT_FILE_ID = TestFileHelper.createUniquePrefix(testMethodName); + DEFAULT_AUDIT_INFORMATION = testMethodName; + receiverManager = new MessageReceiverManager(messageBus); + registerMessageReceivers(); + messageBus.setCollectionFilter(List.of()); + messageBus.setComponentFilter(List.of()); + receiverManager.startListeners(); + initializeCUT(); + } protected void initializeCUT() {} -// @AfterEach -// public final void afterMethod(ITestResult testResult) { -// if (receiverManager != null) { -// receiverManager.stopListeners(); -// } -// if (testResult.isSuccess()) { -// afterMethodVerification(); -// } -// shutdownCUT(); -// } -// + @AfterEach + public final void afterMethod() { + if (receiverManager != null) { + receiverManager.stopListeners(); + } + if (TestWatcherExtension.isTestSuccessful()) { + afterMethodVerification(); + } + shutdownCUT(); + } + + /** * May be used by specific tests for general verification when the test method has finished. Will only be run * if the test has passed (so far). 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 af1efc56c..8a417cdc8 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 @@ -40,6 +40,7 @@ import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -109,6 +110,7 @@ public void SendManyMessagesDistributed() throws Exception { */ @Test @Tag("StressTest") +// @Disabled 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."); diff --git a/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/TestWatcherExtension.java b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/TestWatcherExtension.java new file mode 100644 index 000000000..2f095aed9 --- /dev/null +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/utils/TestWatcherExtension.java @@ -0,0 +1,33 @@ +package org.bitrepository.protocol.utils; + +import org.junit.jupiter.api.extension.ExtensionContext; +import org.junit.jupiter.api.extension.TestWatcher; + +import java.util.Optional; + +public class TestWatcherExtension implements TestWatcher { + private static boolean testSuccessful = true; + + @Override + public void testAborted(ExtensionContext context, Throwable cause) { + testSuccessful = false; + } + + @Override + public void testDisabled(ExtensionContext context, Optional reason) { + } + + @Override + public void testFailed(ExtensionContext context, Throwable cause) { + testSuccessful = false; + } + + @Override + public void testSuccessful(ExtensionContext context) { + testSuccessful = true; + } + + public static boolean isTestSuccessful() { + return testSuccessful; + } +} \ No newline at end of file From 6d94dcfada58d861022f6a2e71bc62bd87c8243a Mon Sep 17 00:00:00 2001 From: kaah Date: Thu, 18 Dec 2025 20:21:25 +0100 Subject: [PATCH 07/14] Able to test in junit --- .../alarm/AlarmExceptionTest.java | 18 +-- .../alarm/handler/AlarmHandlerTest.java | 21 +-- .../AlarmDatabaseExtractionModelTest.java | 5 +- .../alarm/store/AlarmDatabaseTest.java | 127 +++++++++--------- 4 files changed, 91 insertions(+), 80 deletions(-) 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 28655f84c..f1246358c 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 @@ -22,29 +22,31 @@ package org.bitrepository.alarm; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class AlarmExceptionTest extends ExtendedTestCase { - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void alarmExceptionTest() throws Exception { addDescription("Tests that AlarmExceptions can be thrown."); String alarmError = "The message of the alarm exception"; try { throw new AlarmException(alarmError); } catch (AlarmException e) { - Assert.assertEquals(e.getMessage(), alarmError); - Assert.assertNull(e.getCause()); + Assertions.assertEquals(e.getMessage(), alarmError); + Assertions.assertNull(e.getCause()); } String otherError = "This is the message of the included exception"; try { throw new AlarmException(alarmError, new Exception(otherError)); } catch (AlarmException e) { - Assert.assertEquals(e.getMessage(), alarmError); - Assert.assertNotNull(e.getCause()); - Assert.assertEquals(e.getCause().getMessage(), otherError); + Assertions.assertEquals(e.getMessage(), alarmError); + Assertions.assertNotNull(e.getCause()); + Assertions.assertEquals(e.getCause().getMessage(), otherError); } } 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 1728fda3a..d63418bfd 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 @@ -26,38 +26,39 @@ import org.bitrepository.bitrepositorymessages.AlarmMessage; import org.bitrepository.bitrepositorymessages.Message; import org.bitrepository.protocol.IntegrationTest; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import static org.testng.AssertJUnit.assertEquals; public class AlarmHandlerTest extends IntegrationTest { - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void alarmMediatorTest() throws Exception { addDescription("Test the mediator handling of alarm messages."); addStep("Setup mediator and create alarm handler.", "Should be ok."); AlarmMediator mediator = new AlarmMediator(messageBus, alarmDestinationID); MockAlarmHandler alarmHandler = new MockAlarmHandler(); mediator.addHandler(alarmHandler); - Assert.assertEquals(alarmHandler.getCallsForClose(), 0); - Assert.assertEquals(alarmHandler.getCallsForHandleAlarm(), 0); + Assertions.assertEquals(alarmHandler.getCallsForClose(), 0); + Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 0); addStep("Try giving it a non-alarm message", "Should not call the alarm handler."); Message msg = new Message(); mediator.onMessage(msg, null); assertEquals(alarmHandler.getCallsForClose(), 0); - Assert.assertEquals(alarmHandler.getCallsForHandleAlarm(), 0); + Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 0); addStep("Giv the mediator an AlarmMessage", "Should be sent to the alarm handler"); AlarmMessage alarmMsg = new AlarmMessage(); mediator.onMessage(alarmMsg, null); - Assert.assertEquals(alarmHandler.getCallsForClose(), 0); - Assert.assertEquals(alarmHandler.getCallsForHandleAlarm(), 1); + Assertions.assertEquals(alarmHandler.getCallsForClose(), 0); + Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 1); addStep("Close the mediator.", "Should also close the alarm handler."); mediator.close(); - Assert.assertEquals(alarmHandler.getCallsForClose(), 1); - Assert.assertEquals(alarmHandler.getCallsForHandleAlarm(), 1); + Assertions.assertEquals(alarmHandler.getCallsForClose(), 1); + Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 1); } protected class MockAlarmHandler implements AlarmHandler { 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 ad746832d..bc4cc20ca 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 @@ -23,8 +23,9 @@ import org.bitrepository.bitrepositoryelements.AlarmCode; import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.testng.Assert; -import org.testng.annotations.Test; import java.util.Date; @@ -33,7 +34,7 @@ */ public class AlarmDatabaseExtractionModelTest extends ExtendedTestCase { - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void alarmExceptionTest() throws Exception { addDescription("Test the AlarmDatabaseExtractionModel class"); addStep("Define constants etc.", "Should be OK"); 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 bdcbc0417..e8fb50967 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 @@ -31,11 +31,12 @@ import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; +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 java.io.File; import java.text.ParseException; @@ -64,7 +65,7 @@ public class AlarmDatabaseTest extends ExtendedTestCase { String DATABASE_URL = "jdbc:derby:" + DATABASE_DIRECTORY + "/" + DATABASE_NAME; File dbDir = null; - @BeforeClass (alwaysRun = true) + @BeforeAll public void setup() { settings = TestSettingsProvider.reloadSettings("AlarmDatabaseUnderTest"); @@ -75,7 +76,7 @@ public void setup() { integrityDatabaseCreator.createAlarmDatabase(settings, null); } - @AfterMethod (alwaysRun = true) + @AfterEach public void cleanupDatabase() { // TODO DBConnector connector = new DBConnector(settings.getReferenceSettings().getAlarmServiceSettings().getAlarmServiceDatabase()); @@ -83,7 +84,7 @@ public void cleanupDatabase() { DatabaseUtils.executeStatement(connector, "DELETE FROM " + COMPONENT_TABLE); } - @AfterClass (alwaysRun = true) + @AfterAll public void shutdown() { addStep("Cleanup after test.", "Should remove directory with test material."); if(dbDir != null) { @@ -91,7 +92,9 @@ public void shutdown() { } } - @Test(groups = {"regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void AlarmDatabaseExtractionTest() { addDescription("Testing the connection to the alarm service database especially with regards to " + "extracting the data from it."); @@ -110,80 +113,82 @@ public void AlarmDatabaseExtractionTest() { addStep("Try to extract all the data from the database.", "Should deliver both alarms."); List extractedAlarms = database.extractAlarms(null, null, null, null, null, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 2); + Assertions.assertEquals(extractedAlarms.size(), 2); addStep("Try to extract the alarms for component 1.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(component1, null, null, null, null, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); - Assert.assertNull(extractedAlarms.get(0).getFileID()); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); + Assertions.assertNull(extractedAlarms.get(0).getFileID()); addStep("Try to extract the alarms for component 2.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(component2, null, null, null, null, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); - Assert.assertEquals(extractedAlarms.get(0).getFileID(), fileID); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + Assertions.assertEquals(extractedAlarms.get(0).getFileID(), fileID); addStep("Try to extract the alarms for the alarm code 'COMPONENT_FAILURE'.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, AlarmCode.COMPONENT_FAILURE, null, null, null, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); - Assert.assertNull(extractedAlarms.get(0).getFileID()); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); + Assertions.assertNull(extractedAlarms.get(0).getFileID()); addStep("Try to extract the alarms for the alarm code 'CHECKSUM_ALARM'.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, AlarmCode.CHECKSUM_ALARM, null, null, null, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); - Assert.assertEquals(extractedAlarms.get(0).getFileID(), fileID); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + Assertions.assertEquals(extractedAlarms.get(0).getFileID(), fileID); addStep("Try to extract the new alarm.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, null, restrictionDate, null, null, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); - Assert.assertEquals(extractedAlarms.get(0).getFileID(), fileID); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + Assertions.assertEquals(extractedAlarms.get(0).getFileID(), fileID); addStep("Try to extract the old alarm.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, null, null, restrictionDate, null, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); - Assert.assertNull(extractedAlarms.get(0).getFileID()); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); + Assertions.assertNull(extractedAlarms.get(0).getFileID()); addStep("Try to extract the alarms for the file id.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, null, null, null, fileID, null, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); - Assert.assertEquals(extractedAlarms.get(0).getFileID(), fileID); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + Assertions.assertEquals(extractedAlarms.get(0).getFileID(), fileID); addStep("Try to extract the alarms for the collection id.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, null, null, null, null, collection1, null, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); - Assert.assertEquals(extractedAlarms.get(0).getCollectionID(), collection1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); + Assertions.assertEquals(extractedAlarms.get(0).getCollectionID(), collection1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); addStep("Try to extract the oldest alarm from the database.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, null, null, null, null, null, 1, true); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); - Assert.assertNull(extractedAlarms.get(0).getFileID()); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.COMPONENT_FAILURE); + Assertions.assertNull(extractedAlarms.get(0).getFileID()); addStep("Try to extract the newest alarm from the database.", "Should deliver one alarm."); extractedAlarms = database.extractAlarms(null, null, null, null, null, null, 1, false); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); - Assert.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); - Assert.assertEquals(extractedAlarms.get(0).getFileID(), fileID); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmRaiser(), component2); + Assertions.assertEquals(extractedAlarms.get(0).getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + Assertions.assertEquals(extractedAlarms.get(0).getFileID(), fileID); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void AlarmDatabaseLargeIngestionTest() { addDescription("Testing the ingestion of a large texts into the database"); addStep("Setup and create alarm", ""); @@ -210,11 +215,13 @@ public void AlarmDatabaseLargeIngestionTest() { database.addAlarm(alarm); List extractedAlarms = database.extractAlarms(null, null, null, null, null, null, null, true); - Assert.assertEquals(extractedAlarms.size(), 1); - Assert.assertEquals(extractedAlarms.get(0), alarm); + Assertions.assertEquals(extractedAlarms.size(), 1); + Assertions.assertEquals(extractedAlarms.get(0), alarm); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void alarmDatabaseCorrectTimestampTest() throws ParseException { addDescription("Testing the correct ingest and extraction of alarm dates"); AlarmDAOFactory alarmDAOFactory = new AlarmDAOFactory(); @@ -225,11 +232,11 @@ public void alarmDatabaseCorrectTimestampTest() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT); Date summertimeTS = sdf.parse("2015-10-25T02:59:54.000+02:00"); Date summertimeUnix = new Date(1445734794000L); - Assert.assertEquals(summertimeTS, summertimeUnix); + Assertions.assertEquals(summertimeTS, summertimeUnix); Date wintertimeTS = sdf.parse("2015-10-25T02:59:54.000+01:00"); Date wintertimeUnix = new Date(1445738394000L); - Assert.assertEquals(wintertimeTS, wintertimeUnix); + Assertions.assertEquals(wintertimeTS, wintertimeUnix); Alarm summertimeAlarm = new Alarm(); summertimeAlarm.setAlarmCode(AlarmCode.CHECKSUM_ALARM); @@ -250,13 +257,13 @@ public void alarmDatabaseCorrectTimestampTest() throws ParseException { addStep("Extract and check alarms", ""); List summertimeAlarms = database.extractAlarms(null, null, null, null, "summertime", null, null, true); - Assert.assertEquals(summertimeAlarms.size(), 1); - Assert.assertEquals( + Assertions.assertEquals(summertimeAlarms.size(), 1); + Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(summertimeAlarms.get(0).getOrigDateTime()), summertimeUnix); List wintertimeAlarms = database.extractAlarms(null, null, null, null, "wintertime", null, null, true); - Assert.assertEquals(wintertimeAlarms.size(), 1); - Assert.assertEquals( + Assertions.assertEquals(wintertimeAlarms.size(), 1); + Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(wintertimeAlarms.get(0).getOrigDateTime()), wintertimeUnix); } From 56f5133451ba85aca876e2d7407cf73b6f033dbf Mon Sep 17 00:00:00 2001 From: kaah Date: Fri, 19 Dec 2025 23:00:13 +0100 Subject: [PATCH 08/14] Many tests migrated to junit but a log missing --- .../alarm/handler/AlarmHandlerTest.java | 2 - .../AlarmDatabaseExtractionModelTest.java | 34 +-- .../alarm/store/AlarmDatabaseTest.java | 2 + .../audittrails/AuditTrailServiceTest.java | 6 +- .../collector/AuditCollectorTest.java | 15 +- .../collector/IncrementalCollectorTest.java | 24 +- .../preserver/AuditPackerTest.java | 6 +- .../AuditPreservationEventHandlerTest.java | 4 +- .../preserver/LocalAuditPreservationTest.java | 24 +- .../audittrails/store/AuditDatabaseTest.java | 114 +++---- .../AuditServiceDatabaseMigrationTest.java | 10 +- .../AuditTrailClientComponentTest.java | 30 +- .../getaudittrails/AuditTrailQueryTest.java | 28 +- .../GetChecksumsClientComponentTest.java | 28 +- .../getfile/AbstractGetFileClientTest.java | 5 +- .../getfile/GetFileClientComponentTest.java | 44 +-- .../GetFileIDsClientComponentTest.java | 42 +-- .../GetStatusClientComponentTest.java | 22 +- .../client/DefaultClientTest.java | 28 +- .../client/TestEventHandler.java | 3 +- ...llectionBasedConversationMediatorTest.java | 5 +- .../mediator/ConversationMediatorTest.java | 9 +- .../NegativeResponseExceptionTest.java | 17 +- .../UnexpectedResponseExceptionTest.java | 25 +- .../commandline/CommandLineTest.java | 54 ++-- .../commandline/DeleteFileCmdTest.java | 91 +++--- .../commandline/GetChecksumsCmdTest.java | 42 +-- .../commandline/GetFileCmdTest.java | 61 ++-- .../commandline/GetFileIDsCmdTest.java | 49 +-- .../commandline/PutFileCmdTest.java | 95 +++--- .../commandline/ReplaceFileCmdTest.java | 227 +++++++------- .../utils/ChecksumExtractionUtilsTest.java | 26 +- .../DeleteFileClientComponentTest.java | 161 +++++----- .../putfile/PutFileClientComponentTest.java | 68 +++-- .../ReplaceFileClientComponentTest.java | 109 +++---- .../common/utils/StreamUtilsTest.java | 3 +- .../common/utils/XmlUtilsTest.java | 3 +- .../MessageBusNumberOfMessagesStressTest.java | 3 +- .../MessageBusSizeOfMessageStressTest.java | 2 +- ...essageBusTimeToSendMessagesStressTest.java | 2 +- .../security/PermissionStoreTest.java | 4 +- .../IntegrityAlerterTest.java | 18 +- .../IntegrityDatabaseTestCase.java | 9 +- .../IntegrityWorkflowSchedulerTest.java | 42 +-- .../integrityservice/cache/FileInfoTest.java | 34 ++- .../cache/IntegrityDAOTest.java | 280 +++++++++--------- .../cache/IntegrityDBToolsTest.java | 23 +- .../cache/IntegrityDatabaseTest.java | 73 ++--- .../checking/MaxChecksumAgeProviderTest.java | 20 +- .../IntegrityInformationCollectorTest.java | 21 +- .../integrationtest/MissingChecksumTests.java | 18 +- .../reports/BasicIntegrityReporterTest.java | 34 ++- .../reports/ExampleReportGenerationTest.java | 3 +- .../stresstest/DatabaseStressTests.java | 19 +- .../web/PillarDetailsDtoTest.java | 4 +- .../workflow/IntegrityContributorsTest.java | 71 ++--- .../IntegrityWorkflowManagerTest.java | 25 +- .../RepairMissingFilesWorkflowTest.java | 18 +- .../workflow/SaltedChecksumWorkflowTest.java | 31 +- .../step/GetChecksumForFileStepTest.java | 41 +-- .../workflow/step/GetFileStepTest.java | 38 ++- .../HandleChecksumValidationStepTest.java | 95 +++--- .../workflow/step/PutFileStepTest.java | 39 ++- .../step/UpdateChecksumsStepTest.java | 28 +- .../workflow/step/UpdateFileIDsStepTest.java | 22 +- .../workflow/step/WorkflowstepTest.java | 5 +- .../alarm/MonitorAlerterTest.java | 16 +- .../collector/StatusCollectorTest.java | 48 +-- .../collector/StatusEventHandlerTest.java | 46 +-- .../status/ComponentStatusStoreTest.java | 56 ++-- .../bitrepository/pillar/MediatorTest.java | 12 +- .../pillar/common/SettingsHelperTest.java | 16 +- .../integration/PillarIntegrationTest.java | 7 - .../func/DefaultPillarIdentificationTest.java | 6 +- .../func/DefaultPillarMessagingTest.java | 13 +- .../func/DefaultPillarOperationTest.java | 2 +- .../integration/func/PillarFunctionTest.java | 2 +- .../func/deletefile/DeleteFileRequestIT.java | 54 ++-- .../IdentifyPillarsForDeleteFileIT.java | 42 +-- .../getaudittrails/GetAuditTrailsTest.java | 14 +- .../getchecksums/GetChecksumQueryTest.java | 48 +-- .../func/getchecksums/GetChecksumTest.java | 16 +- .../IdentifyPillarsForGetChecksumsIT.java | 14 +- .../func/getfile/GetFileRequestIT.java | 26 +- .../getfile/IdentifyPillarsForGetFileIT.java | 10 +- .../func/getfileids/GetFileIDsQueryTest.java | 18 +- .../func/getfileids/GetFileIDsTest.java | 24 +- .../IdentifyPillarsForGetFileIDsIT.java | 14 +- .../func/getstatus/GetStatusRequestIT.java | 20 +- .../IdentifyContributorsForGetStatusIT.java | 8 +- .../multicollection/MultipleCollectionIT.java | 8 +- .../putfile/IdentifyPillarsForPutFileIT.java | 14 +- .../func/putfile/PutFileRequestIT.java | 16 +- .../IdentifyPillarsForReplaceFileIT.java | 42 +-- .../replacefile/ReplaceFileRequestIT.java | 32 +- .../perf/GetAuditTrailsFileStressIT.java | 8 +- .../integration/perf/GetFileStressIT.java | 10 +- .../perf/PillarPerformanceTest.java | 3 - .../integration/perf/PutFileStressIT.java | 8 +- .../messagehandling/DeleteFileTest.java | 14 +- .../GeneralMessageHandlingTest.java | 26 +- .../messagehandling/GetAuditTrailsTest.java | 14 +- .../messagehandling/GetChecksumsTest.java | 18 +- .../messagehandling/GetFileIDsTest.java | 18 +- .../pillar/messagehandling/GetFileTest.java | 12 +- .../pillar/messagehandling/PutFileTest.java | 20 +- .../messagehandling/ReplaceFileTest.java | 24 +- .../RecalculateChecksumWorkflowTest.java | 22 +- .../pillar/store/ChecksumPillarModelTest.java | 18 +- .../pillar/store/FullPillarModelTest.java | 18 +- .../store/PillarSettingsProviderTest.java | 10 +- .../store/archive/ArchiveDirectoryTest.java | 152 +++++----- .../store/archive/ReferenceArchiveTest.java | 28 +- .../ChecksumDatabaseMigrationTest.java | 26 +- .../checksumcache/ChecksumDatabaseTest.java | 160 +++++----- .../checksumcache/ChecksumEntryTest.java | 12 +- .../service/ServiceSettingsProviderTest.java | 17 +- ...TrailContributorDatabaseMigrationTest.java | 17 +- .../AuditTrailContributorDatabaseTest.java | 77 ++--- .../IdentifyContributorExceptionTest.java | 33 ++- .../IllegalOperationExceptionTest.java | 15 +- .../InvalidMessageExceptionTest.java | 47 +-- pom.xml | 12 +- 123 files changed, 2140 insertions(+), 1881 deletions(-) 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 d63418bfd..4361dc080 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 @@ -30,8 +30,6 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import static org.testng.AssertJUnit.assertEquals; - public class AlarmHandlerTest extends IntegrationTest { @Test @Tag("regressiontest") public void alarmMediatorTest() throws Exception { 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 bc4cc20ca..b5d7bfa83 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 @@ -25,7 +25,7 @@ import org.jaccept.structure.ExtendedTestCase; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; -import org.testng.Assert; + import java.util.Date; @@ -43,53 +43,53 @@ public void alarmExceptionTest() throws Exception { addStep("Create an empty model", "Should be populated with nulls."); AlarmDatabaseExtractionModel model = new AlarmDatabaseExtractionModel(null, null, null, null, null, null, null, ascending); - Assert.assertNull(model.getAlarmCode()); - Assert.assertNull(model.getComponentId()); - Assert.assertNull(model.getEndDate()); - Assert.assertNull(model.getFileID()); - Assert.assertNull(model.getStartDate()); - Assert.assertNull(model.getCollectionID()); - Assert.assertEquals(model.getAscending(), ascending); - Assert.assertEquals(model.getMaxCount().intValue(), Integer.MAX_VALUE); + Assertions.assertNull(model.getAlarmCode()); + Assertions.assertNull(model.getComponentId()); + Assertions.assertNull(model.getEndDate()); + Assertions.assertNull(model.getFileID()); + Assertions.assertNull(model.getStartDate()); + Assertions.assertNull(model.getCollectionID()); + Assertions.assertEquals(model.getAscending(), ascending); + Assertions.assertEquals(model.getMaxCount().intValue(), Integer.MAX_VALUE); addStep("Test the AlarmCode", "Should be able to put a new one in and extract it again."); AlarmCode defaultAlarmCode = AlarmCode.COMPONENT_FAILURE; model.setAlarmCode(defaultAlarmCode); - Assert.assertEquals(model.getAlarmCode(), defaultAlarmCode); + Assertions.assertEquals(model.getAlarmCode(), defaultAlarmCode); addStep("Test the ascending", "Should be able to put a new one in and extract it again."); boolean defaultAscending = false; model.setAscending(defaultAscending); - Assert.assertEquals(model.getAscending(), defaultAscending); + Assertions.assertEquals(model.getAscending(), defaultAscending); addStep("Test the ComponentID", "Should be able to put a new one in and extract it again."); String defaultComponentID = "DefaultComponentID"; model.setComponentId(defaultComponentID); - Assert.assertEquals(model.getComponentId(), defaultComponentID); + Assertions.assertEquals(model.getComponentId(), defaultComponentID); addStep("Test the EndDate", "Should be able to put a new one in and extract it again."); Date defaultEndDate = new Date(987654321); model.setEndDate(defaultEndDate); - Assert.assertEquals(model.getEndDate(), defaultEndDate); + Assertions.assertEquals(model.getEndDate(), defaultEndDate); addStep("Test the FileID", "Should be able to put a new one in and extract it again."); String defaultFileID = "DefaultFileID"; model.setFileID(defaultFileID); - Assert.assertEquals(model.getFileID(), defaultFileID); + Assertions.assertEquals(model.getFileID(), defaultFileID); addStep("Test the MaxCount", "Should be able to put a new one in and extract it again."); Integer defaultMaxCount = 192837456; model.setMaxCount(defaultMaxCount); - Assert.assertEquals(model.getMaxCount(), defaultMaxCount); + Assertions.assertEquals(model.getMaxCount(), defaultMaxCount); addStep("Test the StartDate", "Should be able to put a new one in and extract it again."); Date defaultStartDate = new Date(123456789); model.setStartDate(defaultStartDate); - Assert.assertEquals(model.getStartDate(), defaultStartDate); + Assertions.assertEquals(model.getStartDate(), defaultStartDate); addStep("Test the CollectionID", "Should be able to put a new one in and extract it again."); String collectionID = "collection1"; model.setCollectionID(collectionID); - Assert.assertEquals(model.getCollectionID(), collectionID); + Assertions.assertEquals(model.getCollectionID(), collectionID); } } 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 e8fb50967..d05ccc9ed 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 @@ -37,6 +37,7 @@ 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.File; import java.text.ParseException; @@ -52,6 +53,7 @@ /** * Sees if alarms are correctly stored in the database. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class AlarmDatabaseTest extends ExtendedTestCase { /** The settings for the tests. Should be instantiated in the setup.*/ Settings settings; 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 f4798bbf7..015dabcd7 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 @@ -39,8 +39,8 @@ import org.bitrepository.settings.repositorysettings.Collection; import org.jaccept.structure.ExtendedTestCase; import org.mockito.ArgumentCaptor; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + + import javax.xml.datatype.DatatypeFactory; import java.util.concurrent.ThreadFactory; @@ -72,7 +72,7 @@ public void setup() { threadFactory = new DefaultThreadFactory(this.getClass().getSimpleName(), Thread.NORM_PRIORITY); } - @Test(groups = {"unstable"}) + @Test @Tag("unstable"}) public void auditTrailServiceTest() throws Exception { addDescription("Test the Audit Trail Service"); DatatypeFactory factory = DatatypeFactory.newInstance(); 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 9032fd6b7..9687eac88 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 @@ -34,11 +34,11 @@ import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.settings.repositorysettings.Collection; import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.mockito.ArgumentCaptor; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; - import javax.xml.datatype.DatatypeFactory; import static org.mockito.ArgumentMatchers.any; @@ -48,6 +48,7 @@ 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.*/ Settings settings; @@ -55,7 +56,7 @@ public class AuditCollectorTest extends ExtendedTestCase { public static final String TEST_COLLECTION = "dummy-collection"; public static final String DEFAULT_CONTRIBUTOR = "Contributor1"; - @BeforeClass (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("AuditCollectorUnderTest"); Collection c = settings.getRepositorySettings().getCollections().getCollection().get(0); @@ -64,7 +65,7 @@ public void setup() throws Exception { settings.getRepositorySettings().getCollections().getCollection().add(c); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void auditCollectorIntervalTest() throws Exception { addDescription("Test that the collector calls the AuditClient at the correct intervals."); DatatypeFactory factory = DatatypeFactory.newInstance(); @@ -85,7 +86,7 @@ public void auditCollectorIntervalTest() throws Exception { isNull(), isNull(), eventHandlerCaptor.capture(), any(String.class)); EventHandler eventHandler = eventHandlerCaptor.getValue(); - Assert.assertNotNull(eventHandler, "Should have an event handler"); + Assertions.assertNotNull(eventHandler, "Should have an event handler"); eventHandler.handleEvent(new AuditTrailResult(DEFAULT_CONTRIBUTOR, TEST_COLLECTION, new ResultingAuditTrails(), false)); eventHandler.handleEvent(new CompleteEvent(TEST_COLLECTION, null)); 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 93a755ba8..eeecbb54d 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 @@ -40,9 +40,9 @@ import org.bitrepository.service.AlarmDispatcher; import org.jaccept.structure.ExtendedTestCase; import org.mockito.ArgumentCaptor; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + + + import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigInteger; @@ -72,7 +72,7 @@ public void setup() throws Exception { threadFactory = new DefaultThreadFactory(this.getClass().getSimpleName(), Thread.NORM_PRIORITY, false); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void singleIncrementTest() throws InterruptedException { addDescription("Verifies the behaviour in the simplest case with just one result set "); AuditTrailClient client = mock(AuditTrailClient.class); @@ -116,14 +116,14 @@ public void singleIncrementTest() throws InterruptedException { verify(store, timeout(3000).times(1)) .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); - Assert.assertTrue(collectionRunner.finished, "The collector should have finished after the complete event, as " + + Assertions.assertTrue(collectionRunner.finished, "The collector should have finished after the complete event, as " + "no partialResults where received"); verifyNoMoreInteractions(store); verifyNoMoreInteractions(client); verifyNoInteractions(alarmDispatcher); } - @Test(groups = {"regressiontest"}) + @Test @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."); @@ -166,7 +166,7 @@ public void multipleIncrementTest() throws Exception { verify(store, timeout(3000).times(1)) .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); - Assert.assertFalse(collectionRunner.finished, "The collector should not have finished after the complete " + + 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", @@ -190,7 +190,7 @@ public void multipleIncrementTest() throws Exception { .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); Thread.sleep(100); - Assert.assertTrue(collectionRunner.finished, "The collector should have finished after the complete event, as " + + Assertions.assertTrue(collectionRunner.finished, "The collector should have finished after the complete event, as " + "no partialResults where received in the second increment."); verifyNoMoreInteractions(store); @@ -198,7 +198,7 @@ public void multipleIncrementTest() throws Exception { verifyNoInteractions(alarmDispatcher); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void contributorFailureTest() throws Exception { addDescription("Tests that the collector is able to collect from the remaining contributors if a " + "contributor fails."); @@ -242,7 +242,7 @@ public void contributorFailureTest() throws Exception { .addAuditTrails(any(AuditTrailEvents.class), eq(TEST_COLLECTION), eq(TEST_CONTRIBUTOR2)); eventHandler.handleEvent(new OperationFailedEvent(TEST_COLLECTION, "", null)); - Assert.assertFalse(collectionRunner.finished, "The collector should not have finished after the complete " + + 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 contributor 2 with PartialResults set to false", @@ -263,12 +263,12 @@ public void contributorFailureTest() throws Exception { verify(alarmDispatcher, timeout(3000)).error(any(Alarm.class)); Thread.sleep(100); - Assert.assertTrue(collectionRunner.finished); + Assertions.assertTrue(collectionRunner.finished); verifyNoMoreInteractions(store); verifyNoMoreInteractions(client); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void collectionIDFailureTest() throws Exception { addDescription("Tests what happens when a wrong collection id is received."); String FALSE_COLLECTION = "FalseCollection" + new Date().getTime(); 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 f2ec094e3..0f4585964 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 @@ -6,8 +6,8 @@ import org.bitrepository.common.utils.SettingsUtils; import org.bitrepository.settings.referencesettings.AuditTrailPreservation; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + + import java.io.IOException; import java.util.List; @@ -18,7 +18,7 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; + public class AuditPackerTest extends ExtendedTestCase { private String collectionID; 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 611e83e11..b27d48667 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 @@ -24,7 +24,7 @@ import org.bitrepository.audittrails.store.AuditTrailStore; import org.bitrepository.client.eventhandler.CompleteEvent; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; + import java.util.HashMap; import java.util.Map; @@ -40,7 +40,7 @@ public class AuditPreservationEventHandlerTest extends ExtendedTestCase { String PILLARID = "pillarID"; public static final String TEST_COLLECTION = "dummy-collection"; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void auditPreservationEventHandlerTest() throws Exception { addDescription("Test the handling of the audit trail event handler."); addStep("Setup", ""); 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 a0e726b7a..f88a6e8f9 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 @@ -38,8 +38,8 @@ import org.jaccept.structure.ExtendedTestCase; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + + import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; @@ -55,7 +55,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; + public class LocalAuditPreservationTest extends ExtendedTestCase { /** The settings for the tests. Should be instantiated in the setup. */ @@ -105,12 +105,12 @@ public void auditPreservationSchedulingTest() throws Exception { LocalAuditTrailPreserver preserver = new LocalAuditTrailPreserver(settings, store, client, fileExchangeMock); - /*Assert.assertEquals(store.getCallsToAddAuditTrails(), 0); - Assert.assertEquals(store.getCallsToGetAuditTrails(), 0); - Assert.assertEquals(store.getCallsToGetPreservationSequenceNumber(), 1); - Assert.assertEquals(store.getCallsToLargestSequenceNumber(), 0); - Assert.assertEquals(store.getCallsToSetPreservationSequenceNumber(), 0); - Assert.assertEquals(client.getCallsToPutFile(), 0);*/ + /*Assertions.assertEquals(store.getCallsToAddAuditTrails(), 0); + Assertions.assertEquals(store.getCallsToGetAuditTrails(), 0); + Assertions.assertEquals(store.getCallsToGetPreservationSequenceNumber(), 1); + Assertions.assertEquals(store.getCallsToLargestSequenceNumber(), 0); + Assertions.assertEquals(store.getCallsToSetPreservationSequenceNumber(), 0); + Assertions.assertEquals(client.getCallsToPutFile(), 0);*/ verify(store).getPreservationSequenceNumber(PILLAR_ID, collectionID); verifyNoMoreInteractions(store); @@ -138,13 +138,13 @@ public AuditEventIterator answer(InvocationOnMock invocation) { null, null, PILLAR_ID, 0L, null, null, null, null, null, null, null); verify(iterator).getNextAuditTrailEvent(); - //Assert.assertEquals(store.getCallsToGetAuditTrails(), settings.getRepositorySettings().getGetAuditTrailSettings().getNonPillarContributorIDs().size()); + //Assertions.assertEquals(store.getCallsToGetAuditTrails(), settings.getRepositorySettings().getGetAuditTrailSettings().getNonPillarContributorIDs().size()); - //Assert.assertEquals(store.getCallsToGetPreservationSequenceNumber(), 2); + //Assertions.assertEquals(store.getCallsToGetPreservationSequenceNumber(), 2); assertEquals(client.getCallsToPutFile(), 1); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) @SuppressWarnings("rawtypes") public void auditPreservationIngestTest() throws Exception { addDescription("Tests the ingest of the audit trail preservation."); 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 c2f0b220e..e58106536 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 @@ -30,9 +30,9 @@ import org.bitrepository.service.database.DatabaseManager; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigInteger; @@ -70,7 +70,7 @@ public void setup() throws Exception { collectionID = settings.getCollections().get(0).getID(); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest", "databasetest"}) public void AuditDatabaseExtractionTest() throws Exception { addDescription("Testing the connection to the audit trail service database especially with regards to " + "extracting the data from it."); @@ -83,108 +83,108 @@ public void AuditDatabaseExtractionTest() throws Exception { AuditTrailServiceDAO database = new AuditTrailServiceDAO(dm); addStep("Validate that the database is empty and then populate it.", "Should be possible."); - Assert.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 0); + Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 0); database.addAuditTrails(createEvents(), collectionID, pillarID); - Assert.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 10); + Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 10); addStep("Extract the audit trails", ""); List res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 2, res.toString()); + Assertions.assertEquals(res.size(), 2, res.toString()); addStep("Test the extraction of FileID", "Should be able to extract the audit of each file individually."); res = getEventsFromIterator(database.getAuditTrailsByIterator(fileID, null, null, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID); res = getEventsFromIterator(database.getAuditTrailsByIterator(fileID2, null, null, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID2); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID2); addStep("Test the extraction of CollectionID", "Only results when the defined collection is used"); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, collectionID, null, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 2, res.toString()); + Assertions.assertEquals(res.size(), 2, res.toString()); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, "NOT-THE-CORRECT-COLLECTION-ID" + System.currentTimeMillis(), null, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 0, res.toString()); + Assertions.assertEquals(res.size(), 0, res.toString()); addStep("Perform extraction based on the component id.", ""); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, pillarID, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 2, res.toString()); + Assertions.assertEquals(res.size(), 2, res.toString()); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, "NO COMPONENT", null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 0, res.toString()); + Assertions.assertEquals(res.size(), 0, res.toString()); addStep("Perform extraction based on the sequence number restriction", "Should be possible to have both lower and upper sequence number restrictions."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, 5L, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID2); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID2); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, 5L, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID); addStep("Perform extraction based on actor id restriction.", "Should be possible to restrict on the id of the actor."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, actor1, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getActorOnFile(), actor1); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getActorOnFile(), actor1); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, actor2, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getActorOnFile(), actor2); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getActorOnFile(), actor2); addStep("Perform extraction based on operation restriction.", "Should be possible to restrict on the FileAction operation."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, FileAction.INCONSISTENCY, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getActionOnFile(), FileAction.INCONSISTENCY); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getActionOnFile(), FileAction.INCONSISTENCY); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, FileAction.FAILURE, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getActionOnFile(), FileAction.FAILURE); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getActionOnFile(), FileAction.FAILURE); addStep("Perform extraction based on date restriction.", "Should be possible to restrict on the date of the audit."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, restrictionDate, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID2); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID2); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, restrictionDate, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID); addStep("Perform extraction based on fingerprint restriction.", "Should be possible to restrict on the fingerprint of the audit."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, null, fingerprint1, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID); - Assert.assertEquals(res.get(0).getCertificateID(), fingerprint1); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID); + Assertions.assertEquals(res.get(0).getCertificateID(), fingerprint1); addStep("Perform extraction based on operationID restriction.", "Should be possible to restrict on the operationID of the audit."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, null, null, operationID2)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals(res.get(0).getFileID(), fileID2); - Assert.assertEquals(res.get(0).getOperationID(), operationID2); + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(res.get(0).getFileID(), fileID2); + Assertions.assertEquals(res.get(0).getOperationID(), operationID2); database.close(); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest", "databasetest"}) public void AuditDatabasePreservationTest() throws Exception { addDescription("Tests the functions related to the preservation of the database."); addStep("Adds the variables to the settings and instantaites the database cache", "Should be connected."); @@ -192,25 +192,25 @@ public void AuditDatabasePreservationTest() throws Exception { settings.getReferenceSettings().getAuditTrailServiceSettings().getAuditTrailServiceDatabase()); AuditTrailServiceDAO database = new AuditTrailServiceDAO(dm); - Assert.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 0); + Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 0); database.addAuditTrails(createEvents(), collectionID, pillarID); - Assert.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 10); + Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 10); addStep("Validate the preservation sequence number", "Should be zero, since it has not been updated yet."); long pindex = database.getPreservationSequenceNumber(pillarID, collectionID); - Assert.assertEquals(pindex, 0); + Assertions.assertEquals(pindex, 0); addStep("Validate the insertion of the preservation sequence number", "Should be the same value extracted afterwards."); long givenPreservationIndex = 123456789; database.setPreservationSequenceNumber(pillarID, collectionID, givenPreservationIndex); - Assert.assertEquals(database.getPreservationSequenceNumber(pillarID, collectionID), givenPreservationIndex); + Assertions.assertEquals(database.getPreservationSequenceNumber(pillarID, collectionID), givenPreservationIndex); database.close(); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest", "databasetest"}) public void auditDatabaseCorrectTimestampTest() throws ParseException { addDescription("Testing the correct ingest and extraction of audittrail dates"); DatabaseManager dm = new AuditTrailDatabaseManager( @@ -220,11 +220,11 @@ public void auditDatabaseCorrectTimestampTest() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT); Date summertimeTS = sdf.parse("2015-10-25T02:59:54.000+02:00"); Date summertimeUnix = new Date(1445734794000L); - Assert.assertEquals(summertimeTS, summertimeUnix); + Assertions.assertEquals(summertimeTS, summertimeUnix); Date wintertimeTS = sdf.parse("2015-10-25T02:59:54.000+01:00"); Date wintertimeUnix = new Date(1445738394000L); - Assert.assertEquals(wintertimeTS, wintertimeUnix); + Assertions.assertEquals(wintertimeTS, wintertimeUnix); AuditTrailEvents events = new AuditTrailEvents(); events.getAuditTrailEvent().add(createSingleEvent(CalendarUtils.getXmlGregorianCalendar(summertimeTS), @@ -237,19 +237,19 @@ public void auditDatabaseCorrectTimestampTest() throws ParseException { List res = getEventsFromIterator(database.getAuditTrailsByIterator("summertime", null, null, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals( + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(res.get(0).getActionDateTime()), summertimeUnix); res = getEventsFromIterator(database.getAuditTrailsByIterator("wintertime", null, null, null, null, null, null, null, null, null, null)); - Assert.assertEquals(res.size(), 1, res.toString()); - Assert.assertEquals( + Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(res.get(0).getActionDateTime()), wintertimeUnix); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest", "databasetest"}) public void AuditDatabaseIngestTest() throws Exception { addDescription("Testing ingest of audittrails into the database"); addStep("Adds the variables to the settings and instantaites the database cache", "Should be connected."); @@ -275,7 +275,7 @@ public void AuditDatabaseIngestTest() throws Exception { "actor", "auditInfo", "fileID", "info", pillarID, new BigInteger("2"), operationID1, fingerprint1)); try { database.addAuditTrails(events, collectionID, pillarID); - Assert.fail("Should throw an exception."); + Assertions.fail("Should throw an exception."); } catch (IllegalArgumentException e) { // expected } @@ -286,7 +286,7 @@ public void AuditDatabaseIngestTest() throws Exception { "actor", "auditInfo", "fileID", "info", pillarID, new BigInteger("3"), operationID1, fingerprint1)); try { database.addAuditTrails(events, collectionID, pillarID); - Assert.fail("Should throw an exception."); + Assertions.fail("Should throw an exception."); } catch (IllegalStateException e) { //expected } @@ -297,7 +297,7 @@ public void AuditDatabaseIngestTest() throws Exception { null, "auditInfo", "fileID", "info", pillarID, new BigInteger("4"), operationID1, fingerprint1)); try { database.addAuditTrails(events, collectionID, pillarID); - Assert.fail("Should throw an exception."); + Assertions.fail("Should throw an exception."); } catch (IllegalStateException e) { // expected } @@ -314,7 +314,7 @@ public void AuditDatabaseIngestTest() throws Exception { "actor", "auditInfo", null, "info", pillarID, new BigInteger("6"), operationID1, fingerprint1)); try { database.addAuditTrails(events, collectionID, pillarID); - Assert.fail("Should throw an exception."); + Assertions.fail("Should throw an exception."); } catch (IllegalStateException e) { // expected } @@ -331,7 +331,7 @@ public void AuditDatabaseIngestTest() throws Exception { "actor", "auditInfo", "fileID", "info", null, new BigInteger("8"), operationID1, fingerprint1)); try { database.addAuditTrails(events, collectionID, pillarID); - Assert.fail("Should throw an exception."); + Assertions.fail("Should throw an exception."); } catch (IllegalStateException e) { // expected } @@ -344,7 +344,7 @@ public void AuditDatabaseIngestTest() throws Exception { "actor", "auditInfo", "fileID", "info", pillarID, null, operationID1, fingerprint1)); try { database.addAuditTrails(events, collectionID, pillarID); - Assert.fail("Should throw an exception."); + Assertions.fail("Should throw an exception."); } catch (IllegalStateException e) { // expected } @@ -363,7 +363,7 @@ public void AuditDatabaseIngestTest() throws Exception { } - @Test(groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest", "databasetest"}) public void AuditDatabaseGoodIngestTest() throws Exception { addDescription("Testing good case ingest of audittrails into the database"); addStep("Adds the variables to the settings and instantaites the database cache", "Should be connected."); 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 a7b76f976..fe60d0479 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 @@ -29,15 +29,15 @@ import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import java.io.File; import static org.bitrepository.audittrails.store.AuditDatabaseConstants.AUDIT_TRAIL_TABLE; import static org.bitrepository.audittrails.store.AuditDatabaseConstants.DATABASE_VERSION_ENTRY; -import static org.testng.Assert.assertEquals; + // 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. @@ -68,7 +68,7 @@ public void cleanup() throws Exception { FileUtils.deleteDirIfExists(new File(PATH_TO_DATABASE_UNPACKED)); } - @Test( groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest", "databasetest"}) public void testMigratingAuditServiceDatabase() { addDescription("Tests that the database can be migrated to latest version with the provided scripts."); DBConnector connector = new DBConnector( 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 e16eeda11..30a61b29a 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 @@ -42,16 +42,17 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.protocol.bus.MessageReceiver; import org.bitrepository.settings.repositorysettings.Collection; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.math.BigInteger; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; /** * Test the default AuditTrailClient. @@ -60,7 +61,7 @@ public class AuditTrailClientComponentTest extends DefaultClientTest { private GetAuditTrailsMessageFactory testMessageFactory; private DatatypeFactory datatypeFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void beforeMethodSetup() throws DatatypeConfigurationException { testMessageFactory = new GetAuditTrailsMessageFactory(settingsForTestClient.getComponentID()); @@ -78,16 +79,17 @@ public void beforeMethodSetup() throws DatatypeConfigurationException { datatypeFactory = DatatypeFactory.newInstance(); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void verifyAuditTrailClientFromFactory() { - Assert.assertTrue(AccessComponentFactory.getInstance().createAuditTrailClient( + Assertions.assertTrue(AccessComponentFactory.getInstance().createAuditTrailClient( settingsForCUT, securityManager, settingsForTestClient.getComponentID()) instanceof ConversationBasedAuditTrailClient, "The default AuditTrailClient from the Access factory should be of the type '" + ConversationBasedAuditTrailClient.class.getName() + "'."); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getAllAuditTrailsTest() throws InterruptedException { addDescription("Tests the simplest case of getting all audit trail event for all contributors."); @@ -175,7 +177,7 @@ public void getAllAuditTrailsTest() throws InterruptedException { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getSomeAuditTrailsTest() throws InterruptedException { addDescription("Tests the client maps a AuditTrail query correctly to a GetAuditTrail request."); @@ -234,7 +236,7 @@ public void getSomeAuditTrailsTest() throws InterruptedException { OperationEvent.OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void negativeGetAuditTrailsResponseTest() throws InterruptedException { addDescription("Verify that the GetAuditTrail client works correct when receiving a negative " + "GetAuditTrails response from one contributors."); @@ -309,7 +311,7 @@ public void negativeGetAuditTrailsResponseTest() throws InterruptedException { OperationEvent.OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void progressEventsTest() throws InterruptedException { addDescription("Tests that progress events are handled correctly."); @@ -378,7 +380,7 @@ public void progressEventsTest() throws InterruptedException { OperationEvent.OperationEventType.PROGRESS); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void incompleteSetOfFinalResponsesTest() throws Exception { addDescription("Verify that the GetAuditTrail client works correct without receiving responses from all " + "contributors."); @@ -421,7 +423,7 @@ public void incompleteSetOfFinalResponsesTest() throws Exception { assertNotNull(requestPillar1); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void noFinalResponsesTest() throws Exception { addDescription("Tests the the AuditTrailClient handles lack of Final Responses gracefully "); addStep("Set a 100 ms timeout for the operation.", ""); 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 769a7eeca..55dbb602c 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 @@ -22,17 +22,20 @@ package org.bitrepository.access.getaudittrails; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; public class AuditTrailQueryTest extends ExtendedTestCase { private static final int DEFAULT_MAX_NUMBER_OF_RESULTS = 10000; String componentId = "componentId"; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testNoSequenceNumbers() throws Exception { addDescription("Test that a AuditTrailQuery can be created without any sequence numbers."); AuditTrailQuery query = new AuditTrailQuery(componentId, null, null, DEFAULT_MAX_NUMBER_OF_RESULTS); @@ -41,7 +44,8 @@ public void testNoSequenceNumbers() throws Exception { assertNull(query.getMinSequenceNumber()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testOnlyMinSequenceNumber() throws Exception { addDescription("Test the creation of a AuditTrailQuery with only the minSequenceNumber"); Long minSeq = 1L; @@ -51,7 +55,7 @@ public void testOnlyMinSequenceNumber() throws Exception { assertNull(query.getMaxSequenceNumber()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testBothSequenceNumberSuccess() throws Exception { addDescription("Test the creation of a AuditTrailQuery with both SequenceNumber, where max is larger than min."); Long minSeq = 1L; @@ -62,11 +66,13 @@ public void testBothSequenceNumberSuccess() throws Exception { assertEquals(query.getMaxSequenceNumber(), maxSeq); } - @Test(groups = {"regressiontest"}, expectedExceptions=IllegalArgumentException.class) + @Test @Tag("regressiontest") public void testBothSequenceNumberFailure() throws Exception { - addDescription("Test the creation of a AuditTrailQuery with both SequenceNumber, where max is smalle than min."); - Long minSeq = 2L; - Long maxSeq = 1L; - new AuditTrailQuery(componentId, minSeq, maxSeq, DEFAULT_MAX_NUMBER_OF_RESULTS); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Test the creation of a AuditTrailQuery with both SequenceNumber, where max is smalle than min."); + Long minSeq = 2L; + Long maxSeq = 1L; + new AuditTrailQuery(componentId, minSeq, maxSeq, DEFAULT_MAX_NUMBER_OF_RESULTS); + }); } } 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 0828000cd..edbc04820 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 @@ -57,9 +57,11 @@ import org.bitrepository.client.eventhandler.OperationEvent.OperationEventType; import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.protocol.bus.MessageReceiver; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.math.BigInteger; import java.net.URL; @@ -67,7 +69,8 @@ import java.util.Date; import java.util.LinkedList; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test class for the 'GetFileClient'. @@ -82,20 +85,21 @@ public class GetChecksumsClientComponentTest extends DefaultClientTest { DEFAULT_CHECKSUM_SPECS.setChecksumType(ChecksumType.MD5); } - @BeforeMethod (alwaysRun=true) + @BeforeEach public void beforeMethodSetup() throws Exception { messageFactory = new TestGetChecksumsMessageFactory(settingsForTestClient.getComponentID()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void verifyGetChecksumsClientFromFactory() throws Exception { - Assert.assertTrue(AccessComponentFactory.getInstance().createGetChecksumsClient(settingsForCUT, securityManager, + Assertions.assertTrue(AccessComponentFactory.getInstance().createGetChecksumsClient(settingsForCUT, securityManager, settingsForTestClient.getComponentID()) instanceof ConversationBasedGetChecksumsClient, "The default GetFileClient from the Access factory should be of the type '" + ConversationBasedGetChecksumsClient.class.getName() + "'."); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getChecksumsFromSinglePillar() throws Exception { addDescription("Tests that the client can retrieve checksums from a single pillar."); @@ -154,7 +158,7 @@ public void getChecksumsFromSinglePillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getChecksumsDeliveredAtUrl() throws Exception { addDescription("Tests the delivery of checksums from all pillars at a given URL."); @@ -213,7 +217,7 @@ public void getChecksumsDeliveredAtUrl() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testNoSuchFile() throws Exception { addDescription("Testing how a request for a non-existing file is handled."); addStep("Setting up variables and such.", "Should be OK."); @@ -267,7 +271,7 @@ public void testNoSuchFile() throws Exception { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testPaging() throws Exception { addDescription("Tests the GetChecksums client correctly handles functionality for limiting results, either by " + "timestamp or result count."); @@ -317,7 +321,7 @@ public void testPaging() throws Exception { "Unexpected MaxNumberOfResults in GetChecksumsRequest to pillar2."); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void getChecksumsFromOtherCollection() throws Exception { addDescription("Tests the getChecksums client will correctly try to get from a second collection if required"); addFixture("Configure collection1 to contain both pillars and collection 2 to only contain pillar2"); diff --git a/bitrepository-client/src/test/java/org/bitrepository/access/getfile/AbstractGetFileClientTest.java b/bitrepository-client/src/test/java/org/bitrepository/access/getfile/AbstractGetFileClientTest.java index f02b1f14f..af7d6c969 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/access/getfile/AbstractGetFileClientTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/access/getfile/AbstractGetFileClientTest.java @@ -40,7 +40,8 @@ package org.bitrepository.access.getfile; import org.bitrepository.client.DefaultFixtureClientTest; -import org.testng.annotations.BeforeMethod; +import org.junit.jupiter.api.BeforeEach; + /** * Runs the DefaultFixtureClient test using a TestGetFileMessageFactory as the message factory. @@ -49,7 +50,7 @@ public abstract class AbstractGetFileClientTest extends DefaultFixtureClientTest { protected TestGetFileMessageFactory messageFactory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void beforeMethodSetup() throws Exception { messageFactory = new TestGetFileMessageFactory(settingsForTestClient.getComponentID()); } 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 4d2f65834..588ed39e5 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 @@ -38,16 +38,19 @@ import org.bitrepository.client.eventhandler.ContributorEvent; import org.bitrepository.client.eventhandler.IdentificationCompleteEvent; import org.bitrepository.client.eventhandler.OperationEvent.OperationEventType; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.math.BigInteger; import java.net.URL; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test class for the 'GetFileClient'. @@ -58,21 +61,21 @@ public class GetFileClientComponentTest extends AbstractGetFileClientTest { private DatatypeFactory datatypeFactory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUpFactory() throws DatatypeConfigurationException { datatypeFactory = DatatypeFactory.newInstance(); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void verifyGetFileClientFromFactory() { - Assert.assertTrue(AccessComponentFactory.getInstance().createGetFileClient( + Assertions.assertTrue(AccessComponentFactory.getInstance().createGetFileClient( settingsForCUT, securityManager, settingsForTestClient.getComponentID()) instanceof ConversationBasedGetFileClient, "The default GetFileClient from the Access factory should be of the type '" + ConversationBasedGetFileClient.class.getName() + "'."); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getFileFromSpecificPillar() throws Exception { addDescription("Tests that the GetClient client works correctly when requesting a file from a specific pillar"); @@ -86,7 +89,7 @@ public void getFileFromSpecificPillar() throws Exception { PILLAR2_ID, testEventHandler, auditTrailInformation); IdentifyPillarsForGetFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetFileRequest.class); assertEquals(receivedIdentifyRequestMessage.getCollectionID(), collectionID); - Assert.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); + Assertions.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); assertEquals(receivedIdentifyRequestMessage.getReplyTo(), settingsForCUT.getReceiverDestinationID()); assertEquals(receivedIdentifyRequestMessage.getFileID(), DEFAULT_FILE_ID); assertEquals(receivedIdentifyRequestMessage.getFrom(), settingsForTestClient.getComponentID()); @@ -142,7 +145,8 @@ public void getFileFromSpecificPillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void getFileFromSpecificPillarWithFilePart() throws Exception { addDescription("Tests that the GetClient client works for a single pillar " + "participates. Also validate, that the 'FilePart' can be used."); @@ -203,7 +207,7 @@ public void getFileFromSpecificPillarWithFilePart() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void chooseFastestPillarGetFileClient() throws Exception { addDescription("Set the GetClient to retrieve a file as fast as " + "possible, where it has to choose between to pillars with " @@ -272,7 +276,7 @@ public void chooseFastestPillarGetFileClient() throws Exception { pillar1Receiver.waitForMessage(GetFileRequest.class); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getFileClientWithIdentifyTimeout() throws Exception { addDescription("Verify that the GetFile works correct without receiving responses from all pillars."); addFixture("Set the identification timeout to 500ms"); @@ -320,7 +324,7 @@ public void getFileClientWithIdentifyTimeout() throws Exception { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void noIdentifyResponse() throws Exception { addDescription("Tests the the GetFileClient handles lack of IdentifyPillarResponses gracefully "); addStep("Set a 500 ms timeout for identifying pillar.", ""); @@ -345,7 +349,7 @@ public void noIdentifyResponse() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void conversationTimeout() throws Exception { addDescription("Tests the the GetFileClient handles lack of IdentifyPillarResponses gracefully "); addStep("Set the number of pillars to 100ms and a 300 ms timeout for the conversation.", ""); @@ -384,7 +388,7 @@ public void conversationTimeout() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testNoSuchFileSpecificPillar() throws Exception { addDescription("Testing how a request for a non-existing file is handled on a specific pillar request."); addStep("Define 1 pillar.", ""); @@ -417,7 +421,7 @@ public void testNoSuchFileSpecificPillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testNoSuchFileMultiplePillars() throws Exception { addDescription("Testing how a request for a non-existing file is handled when all pillars miss the file."); @@ -457,7 +461,7 @@ public void testNoSuchFileMultiplePillars() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getFileClientWithChecksumPillarInvolved() throws Exception { addDescription("Verify that the GetFile works correctly when a checksum pillar respond."); @@ -503,7 +507,7 @@ public void getFileClientWithChecksumPillarInvolved() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void singleComponentFailureDuringIdentify() throws Exception { addDescription("Verify that the GetFile reports a complete (not failed), in case of a component failing " + "during the identify phase."); @@ -550,7 +554,7 @@ public void singleComponentFailureDuringIdentify() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void failureDuringPerform() throws Exception { addDescription("Verify that the GetFile reports a failed operation, in case of a component failing " + "during the performing phase."); @@ -591,7 +595,7 @@ public void failureDuringPerform() throws Exception { } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void getFileFromOtherCollection() throws Exception { addDescription("Tests the getFiles client will correctly try to get from a second collection if required"); addFixture("Configure collection1 to contain both pillars and collection 2 to only contain pillar2"); 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 66ea0c8fa..35be16280 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 @@ -46,16 +46,19 @@ import org.bitrepository.client.eventhandler.OperationEvent.OperationEventType; import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.protocol.bus.MessageReceiver; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.bind.JAXBException; import java.math.BigInteger; import java.net.URL; import java.util.Date; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** * Test class for the 'GetFileIDsClient'. @@ -68,21 +71,22 @@ public class GetFileIDsClientComponentTest extends DefaultClientTest { * Set up the test scenario before running the tests in this class. * @throws javax.xml.bind.JAXBException */ - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUp() throws JAXBException { // TODO getFileIDsFromFastestPillar settings messageFactory = new TestGetFileIDsMessageFactory(settingsForTestClient.getComponentID()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void verifyGetFileIDsClientFromFactory() throws Exception { - Assert.assertTrue(AccessComponentFactory.getInstance().createGetFileIDsClient(settingsForCUT, securityManager, + Assertions.assertTrue(AccessComponentFactory.getInstance().createGetFileIDsClient(settingsForCUT, securityManager, settingsForTestClient.getComponentID()) instanceof ConversationBasedGetFileIDsClient, "The default GetFileClient from the Access factory should be of the type '" + ConversationBasedGetFileIDsClient.class.getName() + "'."); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") 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.", @@ -104,7 +108,7 @@ public void getFileIDsDeliveredAtUrl() throws Exception { IdentifyPillarsForGetFileIDsRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForGetFileIDsRequest.class); assertEquals(receivedIdentifyRequestMessage.getCollectionID(), collectionID); - Assert.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); + Assertions.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); assertEquals(receivedIdentifyRequestMessage.getReplyTo(), settingsForCUT.getReceiverDestinationID()); assertEquals(receivedIdentifyRequestMessage.getTo(), PILLAR1_ID); assertEquals(receivedIdentifyRequestMessage.getFrom(), settingsForTestClient.getComponentID()); @@ -151,15 +155,15 @@ public void getFileIDsDeliveredAtUrl() throws Exception { FileIDsCompletePillarEvent event = (FileIDsCompletePillarEvent) testEventHandler.waitForEvent(); assertEquals(event.getEventType(), OperationEventType.COMPONENT_COMPLETE); ResultingFileIDs resFileIDs = event.getFileIDs(); - Assert.assertNotNull(resFileIDs, "The ResultingFileIDs may not be null."); - Assert.assertTrue(resFileIDs.getResultAddress().contains(deliveryUrl.toExternalForm()), + Assertions.assertNotNull(resFileIDs, "The ResultingFileIDs may not be null."); + Assertions.assertTrue(resFileIDs.getResultAddress().contains(deliveryUrl.toExternalForm()), "The resulting address'" + resFileIDs.getResultAddress() + "' should contain the argument address: '" + deliveryUrl.toExternalForm() + "'"); - Assert.assertNull(resFileIDs.getFileIDsData(), "No FileIDsData should be returned."); + Assertions.assertNull(resFileIDs.getFileIDsData(), "No FileIDsData should be returned."); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getFileIDsDeliveredThroughMessage() throws Exception { addDescription("Tests the delivery of fileIDs from a pillar at a given URL."); addStep("Initialise the variables for this test.", @@ -230,10 +234,10 @@ public void getFileIDsDeliveredThroughMessage() throws Exception { FileIDsCompletePillarEvent event = (FileIDsCompletePillarEvent) testEventHandler.waitForEvent(); assertEquals(event.getEventType(), OperationEventType.COMPONENT_COMPLETE); ResultingFileIDs resFileIDs = event.getFileIDs(); - Assert.assertNotNull(resFileIDs, "The ResultingFileIDs may not be null."); - Assert.assertNull(resFileIDs.getResultAddress(), "The results should be sent back through the message, " + Assertions.assertNotNull(resFileIDs, "The ResultingFileIDs may not be null."); + Assertions.assertNull(resFileIDs.getResultAddress(), "The results should be sent back through the message, " + "and therefore no resulting address should be returned."); - Assert.assertNotNull(resFileIDs.getFileIDsData(), "No FileIDsData should be returned."); + Assertions.assertNotNull(resFileIDs.getFileIDsData(), "No FileIDsData should be returned."); assertEquals(resFileIDs.getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size(), 1, "Response should contain same amount of fileids as requested."); } @@ -241,7 +245,7 @@ public void getFileIDsDeliveredThroughMessage() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testNoSuchFile() throws Exception { addDescription("Testing how a request for a non-existing file is handled."); addStep("Setting up variables and such.", "Should be OK."); @@ -295,7 +299,7 @@ public void testNoSuchFile() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testPaging() throws Exception { addDescription("Tests the GetFileIDs client correctly handles functionality for limiting results, either by " + "timestamp or result count."); @@ -344,7 +348,7 @@ public void testPaging() throws Exception { "Unexpected MaxNumberOfResults in GetFileIDsRequest to pillar2."); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void getFileIDsFromOtherCollection() throws Exception { addDescription("Tests the getFileIDs client will correctly try to get from a second collection if required"); addFixture("Configure collection1 to contain both pillars and collection 2 to only contain pillar2"); 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 65154587b..913c42607 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 @@ -36,20 +36,23 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.protocol.message.TestGetStatusMessageFactory; import org.bitrepository.settings.repositorysettings.GetStatusSettings; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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 java.util.List; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class GetStatusClientComponentTest extends DefaultFixtureClientTest { private TestGetStatusMessageFactory testMessageFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void beforeMethodSetup() { testMessageFactory = new TestGetStatusMessageFactory(settingsForTestClient.getComponentID()); @@ -62,16 +65,17 @@ public void beforeMethodSetup() { contributors.add(PILLAR2_ID); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void verifyGetStatusClientFromFactory() { - Assert.assertTrue(AccessComponentFactory.getInstance().createGetStatusClient( + Assertions.assertTrue(AccessComponentFactory.getInstance().createGetStatusClient( settingsForCUT, securityManager, settingsForTestClient.getComponentID()) instanceof ConversationBasedGetStatusClient, "The default GetStatusClient from the Access factory should be of the type '" + ConversationBasedGetStatusClient.class.getName() + "'."); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void incompleteSetOfIdendifyResponses() throws Exception { addDescription("Verify that the GetStatus client works correct without receiving responses from all " + "contributors."); @@ -113,7 +117,7 @@ public void incompleteSetOfIdendifyResponses() throws Exception { pillar1Receiver.waitForMessage(GetStatusRequest.class); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void getAllStatuses() throws InterruptedException { addDescription("Tests the simplest case of getting status for all contributors."); 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 3d34ee8a1..95239b053 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/DefaultClientTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/DefaultClientTest.java @@ -27,14 +27,17 @@ import org.bitrepository.client.eventhandler.OperationEvent; import org.bitrepository.client.eventhandler.OperationEvent.OperationEventType; import org.bitrepository.protocol.bus.MessageReceiver; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + /** * Tests the general client functionality. A number of abstract methods with needs to be implemented with concrete @@ -44,12 +47,13 @@ public abstract class DefaultClientTest extends DefaultFixtureClientTest { protected final TestEventHandler testEventHandler = new TestEventHandler(testEventManager); private DatatypeFactory datatypeFactory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUpFactory() throws DatatypeConfigurationException { datatypeFactory = DatatypeFactory.newInstance(); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void identificationNegativeTest() throws Exception { addDescription("Verify that the client works correctly when a contributor sends a negative response."); @@ -91,7 +95,7 @@ public void identificationNegativeTest() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void identificationFailureTest() throws Exception { addDescription("Verify that the client works correctly when a contributor sends a failure response."); @@ -132,7 +136,7 @@ public void identificationFailureTest() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void oneContributorNotRespondingTest() throws Exception { addDescription("Verify that the client works correct without receiving identification responses from all " + "contributors."); @@ -173,7 +177,7 @@ public void oneContributorNotRespondingTest() throws Exception { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void noContributorsRespondingTest() throws Exception { addDescription("Tests the the client handles lack of a IdentifyResponse gracefully. " + "More concrete this means that the occurrence of a identification timeout should be handled correctly"); @@ -194,7 +198,7 @@ public void noContributorsRespondingTest() throws Exception { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void operationTimeoutTest() throws Exception { addDescription("Tests the the client handles lack of final responses gracefully."); @@ -228,7 +232,7 @@ public void operationTimeoutTest() throws Exception { OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void collectionIDIncludedInEventsTest() throws Exception { addDescription("Tests the the client provides collectionID in events."); @@ -279,7 +283,7 @@ public void collectionIDIncludedInEventsTest() throws Exception { assertEquals(event6.getCollectionID(), collectionID); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void conversationTimeoutTest() throws Exception { addDescription("Tests the the client handles lack of IdentifyPillarResponses gracefully "); 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 f8cb988d3..f1728c28d 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/TestEventHandler.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/TestEventHandler.java @@ -32,7 +32,8 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNull; + /** Used to listen for operation event and store them for later retrieval by a test. */ public class TestEventHandler implements EventHandler { diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java index c1ecc5073..741bae3bb 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java @@ -25,9 +25,10 @@ package org.bitrepository.client.conversation.mediator; import org.bitrepository.common.settings.Settings; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; -@Test + +//@Test public class CollectionBasedConversationMediatorTest extends ConversationMediatorTest { @Override diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java index f5b757094..b1f40db26 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java @@ -31,12 +31,14 @@ import org.bitrepository.protocol.MessageContext; import org.bitrepository.protocol.security.DummySecurityManager; import org.bitrepository.protocol.security.SecurityManager; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + /** * Test the general ConversationMediator functionality. */ -@Test +//@Test public abstract class ConversationMediatorTest { protected Settings settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); protected SecurityManager securityManager = new DummySecurityManager(); @@ -45,7 +47,8 @@ public abstract class ConversationMediatorTest { * Validates the core mediator functionality of delegating messages from the message bus to the relevant * conversation. */ - @Test (groups = {"testfirst"}) + @Test + @Tag("testfirst") public void messagedelegationTest() { ConversationMediator mediator = createMediator(settings); 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 b99f6ec45..c10060f29 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 @@ -24,12 +24,15 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.client.exceptions.NegativeResponseException; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class NegativeResponseExceptionTest extends ExtendedTestCase { - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testNegativeResponse() { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -41,10 +44,10 @@ public void testNegativeResponse() { try { throw new NegativeResponseException(errMsg, responseCode); } catch (Exception e) { - Assert.assertTrue(e instanceof NegativeResponseException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertEquals(((NegativeResponseException) e).getErrorCode(), responseCode); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof NegativeResponseException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertEquals(((NegativeResponseException) e).getErrorCode(), responseCode); + Assertions.assertNull(e.getCause()); } } } 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 b9c7e0f1f..516620475 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 @@ -23,12 +23,15 @@ import org.bitrepository.client.exceptions.UnexpectedResponseException; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class UnexpectedResponseExceptionTest extends ExtendedTestCase { - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest") public void testUnexpectedResponse() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -39,20 +42,20 @@ public void testUnexpectedResponse() throws Exception { try { throw new UnexpectedResponseException(errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof UnexpectedResponseException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof UnexpectedResponseException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new UnexpectedResponseException(errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof UnexpectedResponseException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof UnexpectedResponseException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } } 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 be7a3ac5d..1f9e2c91c 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/CommandLineTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/CommandLineTest.java @@ -24,46 +24,54 @@ import org.apache.commons.cli.Option; import org.bitrepository.commandline.utils.CommandLineArgumentsHandler; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +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; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; public class CommandLineTest extends ExtendedTestCase { private static final String SETTINGS_DIR = "SettingsDir"; private static final String KEY_FILE = "KeyFile"; private static final String DUMMY_DATA = "DummyData"; - @Test(groups = { "regressiontest" }, expectedExceptions = Exception.class) + @Test + @Tag( "regressiontest") public void argumentsTesterUnknownArgument() throws Exception { - addDescription("Test the handling of arguments by the CommandLineArgumentHandler."); - CommandLineArgumentsHandler clah = new CommandLineArgumentsHandler(); + assertThrows(Exception.class, () -> { + addDescription("Test the handling of arguments by the CommandLineArgumentHandler."); + CommandLineArgumentsHandler clah = new CommandLineArgumentsHandler(); - addStep("Validate arguments without any options.", "Ok, when no arguments, but fails when arguments given."); - clah.parseArguments(new String[0]); + addStep("Validate arguments without any options.", "Ok, when no arguments, but fails when arguments given."); + clah.parseArguments(new String[0]); - clah.parseArguments("-Xunknown..."); + clah.parseArguments("-Xunknown..."); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = Exception.class) + @Test @Tag( "regressiontest") public void argumentsTesterWrongArgument() throws Exception { - addDescription("Test the handling of arguments by the CommandLineArgumentHandler."); - CommandLineArgumentsHandler clah = new CommandLineArgumentsHandler(); + assertThrows(Exception.class, () -> { + addDescription("Test the handling of arguments by the CommandLineArgumentHandler."); + CommandLineArgumentsHandler clah = new CommandLineArgumentsHandler(); - addStep("Validate the default options", "Ok, when both given. Fails if either is missing"); - clah = new CommandLineArgumentsHandler(); - clah.createDefaultOptions(); - clah.parseArguments("-s" + SETTINGS_DIR, "-k" + KEY_FILE); - assertEquals(clah.getOptionValue("s"), SETTINGS_DIR); - assertEquals(clah.getOptionValue("k"), KEY_FILE); + addStep("Validate the default options", "Ok, when both given. Fails if either is missing"); + clah = new CommandLineArgumentsHandler(); + clah.createDefaultOptions(); + clah.parseArguments("-s" + SETTINGS_DIR, "-k" + KEY_FILE); + assertEquals(clah.getOptionValue("s"), SETTINGS_DIR); + assertEquals(clah.getOptionValue("k"), KEY_FILE); - clah = new CommandLineArgumentsHandler(); - clah.createDefaultOptions(); - clah.parseArguments(); + clah = new CommandLineArgumentsHandler(); + clah.createDefaultOptions(); + clah.parseArguments(); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void newArgumentTester() throws Exception { addDescription("Test the handling of a new argument."); CommandLineArgumentsHandler clah = new CommandLineArgumentsHandler(); 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 2ffe6119a..a1beeb9db 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/DeleteFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/DeleteFileCmdTest.java @@ -22,11 +22,15 @@ package org.bitrepository.commandline; import org.bitrepository.client.DefaultFixtureClientTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.util.Date; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class DeleteFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; @@ -34,12 +38,13 @@ public class DeleteFileCmdTest extends DefaultFixtureClientTest { private String DEFAULT_COLLECTION_ID; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setupClient() throws Exception { DEFAULT_COLLECTION_ID = settingsForTestClient.getCollections().get(0).getID(); } - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -51,52 +56,60 @@ public void defaultSuccessScenarioTest() throws Exception { new DeleteFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingCollectionArgumentTest() throws Exception { - addDescription("Tests the scenario, where the collection arguments is missing."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-C" + DEFAULT_CHECKSUM, - "-i" + DEFAULT_FILE_ID}; - new DeleteFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where the collection arguments is missing."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-C" + DEFAULT_CHECKSUM, + "-i" + DEFAULT_FILE_ID}; + new DeleteFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingPillarArgumentTest() throws Exception { - addDescription("Tests the different scenarios, with the pillar argument."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-i" + DEFAULT_FILE_ID}; - new DeleteFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the different scenarios, with the pillar argument."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-C" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-i" + DEFAULT_FILE_ID}; + new DeleteFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void unknownPillarArgumentTest() throws Exception { - addStep("Testing against a non-existing pillar id", "Should fail"); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-p" + "Random" + (new Date()).getTime() + "pillar", - "-i" + DEFAULT_FILE_ID}; - new DeleteFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addStep("Testing against a non-existing pillar id", "Should fail"); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-C" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-p" + "Random" + (new Date()).getTime() + "pillar", + "-i" + DEFAULT_FILE_ID}; + new DeleteFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingFileIDArgumentTest() throws Exception { - addDescription("Tests the scenario, where no arguments for file id argument is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-c" + DEFAULT_COLLECTION_ID, - "-C" + DEFAULT_CHECKSUM}; - new DeleteFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no arguments for file id argument is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-c" + DEFAULT_COLLECTION_ID, + "-C" + DEFAULT_CHECKSUM}; + new DeleteFileCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { addDescription("Test MD5 checksum without salt -> no failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -109,7 +122,7 @@ public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { new DeleteFileCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentSaltAlgorithmWithSaltTest() throws Exception { addDescription("Test HMAC_SHA256 checksum with salt -> No failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, 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 300fa7aa1..bff79ad8e 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetChecksumsCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetChecksumsCmdTest.java @@ -22,23 +22,27 @@ package org.bitrepository.commandline; import org.bitrepository.client.DefaultFixtureClientTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.util.Date; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class GetChecksumsCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; private String DEFAULT_COLLECTION_ID; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setupClient() throws Exception { DEFAULT_COLLECTION_ID = settingsForTestClient.getCollections().get(0).getID(); } - @Test(groups = { "regressiontest" }) + @Test @Tag("regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -47,16 +51,18 @@ public void defaultSuccessScenarioTest() throws Exception { new GetChecksumsCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingCollectionArgumentTest() throws Exception { + assertThrows(IllegalArgumentException.class, () -> { addDescription("Tests the scenario, where the collection arguments is missing."); String[] args = new String[]{"-s" + SETTINGS_DIR, "-k" + KEY_FILE, "-i" + DEFAULT_FILE_ID}; new GetChecksumsCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void specificPillarArgumentTest() throws Exception { addDescription("Test argument for a specific pillar"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -67,19 +73,21 @@ public void specificPillarArgumentTest() throws Exception { new GetChecksumsCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void unknownPillarArgumentTest() throws Exception { - addDescription("Testing against a non-existing pillar id -> Should fail"); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, - "-p" + "Random" + (new Date()).getTime() + "pillar", - "-i" + DEFAULT_FILE_ID}; + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Testing against a non-existing pillar id -> Should fail"); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-c" + DEFAULT_COLLECTION_ID, + "-p" + "Random" + (new Date()).getTime() + "pillar", + "-i" + DEFAULT_FILE_ID}; - new GetChecksumsCmd(args); + new GetChecksumsCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void fileArgumentTest() throws Exception { addDescription("Tests the argument for a specific file."); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -89,7 +97,7 @@ public void fileArgumentTest() throws Exception { new GetChecksumsCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { addDescription("Test MD5 checksum without salt -> no failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -100,7 +108,7 @@ public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { new GetChecksumsCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentSaltAlgorithmWithSaltTest() throws Exception { addDescription("Test HMAC_SHA256 checksum with salt -> No failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, 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 13443cfbd..b3771ab7c 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileCmdTest.java @@ -22,23 +22,27 @@ package org.bitrepository.commandline; import org.bitrepository.client.DefaultFixtureClientTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.util.Date; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class GetFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; private String DEFAULT_COLLECTION_ID; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setupClient() throws Exception { DEFAULT_COLLECTION_ID = settingsForTestClient.getCollections().get(0).getID(); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -48,16 +52,19 @@ public void defaultSuccessScenarioTest() throws Exception { new GetFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test + @Tag( "regressiontest") public void missingCollectionArgumentTest() throws Exception { - addDescription("Tests the scenario, where the collection arguments is missing."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-i" + DEFAULT_FILE_ID}; - new GetFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where the collection arguments is missing."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-i" + DEFAULT_FILE_ID}; + new GetFileCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest" ) public void specificPillarArgumentTest() throws Exception { addDescription("Test argument for a specific pillar"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -68,23 +75,27 @@ public void specificPillarArgumentTest() throws Exception { new GetFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void unknownPillarArgumentTest() throws Exception { - addDescription("Testing against a non-existing pillar id -> Should fail"); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, - "-p" + "Random" + (new Date()).getTime() + "pillar", - "-i" + DEFAULT_FILE_ID}; - new GetFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Testing against a non-existing pillar id -> Should fail"); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-c" + DEFAULT_COLLECTION_ID, + "-p" + "Random" + (new Date()).getTime() + "pillar", + "-i" + DEFAULT_FILE_ID}; + new GetFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingFileIDArgumentTest() throws Exception { - addDescription("Tests the scenario, where no arguments for file id argument is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID}; - new GetFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no arguments for file id argument is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-c" + DEFAULT_COLLECTION_ID}; + new GetFileCmd(args); + }); } } 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 8ef5aec53..a46d96e46 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileIDsCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/GetFileIDsCmdTest.java @@ -22,23 +22,28 @@ package org.bitrepository.commandline; import org.bitrepository.client.DefaultFixtureClientTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.util.Date; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class GetFileIDsCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; private String DEFAULT_COLLECTION_ID; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setupClient() throws Exception { DEFAULT_COLLECTION_ID = settingsForTestClient.getCollections().get(0).getID(); } - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -48,16 +53,18 @@ public void defaultSuccessScenarioTest() throws Exception { } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingCollectionArgumentTest() throws Exception { - addDescription("Tests the scenario, where the collection arguments is missing."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-i" + DEFAULT_FILE_ID}; - new GetFileIDsCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where the collection arguments is missing."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-i" + DEFAULT_FILE_ID}; + new GetFileIDsCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void specificPillarArgumentTest() throws Exception { addDescription("Test argument for a specific pillar"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -68,18 +75,20 @@ public void specificPillarArgumentTest() throws Exception { new GetFileIDsCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void unknownPillarArgumentTest() throws Exception { - addDescription("Testing against a non-existing pillar id -> Should fail"); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, - "-p" + "Random" + (new Date()).getTime() + "pillar", - "-i" + DEFAULT_FILE_ID}; - new GetFileIDsCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Testing against a non-existing pillar id -> Should fail"); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-c" + DEFAULT_COLLECTION_ID, + "-p" + "Random" + (new Date()).getTime() + "pillar", + "-i" + DEFAULT_FILE_ID}; + new GetFileIDsCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void fileArgumentTest() throws Exception { addDescription("Tests the argument for a specific file."); String[] args = new String[]{"-s" + SETTINGS_DIR, 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 09f429e0a..19b792b6c 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/PutFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/PutFileCmdTest.java @@ -22,11 +22,15 @@ package org.bitrepository.commandline; import org.bitrepository.client.DefaultFixtureClientTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.util.Date; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class PutFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; @@ -34,12 +38,13 @@ public class PutFileCmdTest extends DefaultFixtureClientTest { private String DEFAULT_COLLECTION_ID; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setupClient() throws Exception { DEFAULT_COLLECTION_ID = settingsForTestClient.getCollections().get(0).getID(); } - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest") public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -49,7 +54,7 @@ public void defaultSuccessScenarioTest() throws Exception { new PutFileCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void urlSuccessScenarioTest() throws Exception { addDescription("Tests arguments for putting a file on a given URL"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -61,40 +66,46 @@ public void urlSuccessScenarioTest() throws Exception { new PutFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingCollectionArgumentTest() throws Exception { - addDescription("Tests the scenario, where the collection arguments is missing."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-u" + DEFAULT_UPLOAD_FILE_ADDRESS, - "-C" + DEFAULT_CHECKSUM, - "-i" + DEFAULT_FILE_ID}; - new PutFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where the collection arguments is missing."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-u" + DEFAULT_UPLOAD_FILE_ADDRESS, + "-C" + DEFAULT_CHECKSUM, + "-i" + DEFAULT_FILE_ID}; + new PutFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingFileOrURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where no arguments for file or url is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, - "-C" + DEFAULT_CHECKSUM, - "-i" + DEFAULT_FILE_ID}; - new PutFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no arguments for file or url is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-c" + DEFAULT_COLLECTION_ID, + "-C" + DEFAULT_CHECKSUM, + "-i" + DEFAULT_FILE_ID}; + new PutFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingChecksumWhenURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-i" + DEFAULT_FILE_ID}; - new PutFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-c" + DEFAULT_COLLECTION_ID, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-i" + DEFAULT_FILE_ID}; + new PutFileCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void missingChecksumWhenFileArgumentTest() throws Exception { addDescription("Tests the scenario, where no checksum argument is given, but a file is given."); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -105,18 +116,20 @@ public void missingChecksumWhenFileArgumentTest() throws Exception { new PutFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingFileIDWhenURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-c" + DEFAULT_COLLECTION_ID, - "-C" + DEFAULT_CHECKSUM, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS}; - new PutFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-c" + DEFAULT_COLLECTION_ID, + "-C" + DEFAULT_CHECKSUM, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS}; + new PutFileCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void missingFileIDWhenFileArgumentTest() throws Exception { addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -127,7 +140,7 @@ public void missingFileIDWhenFileArgumentTest() throws Exception { new PutFileCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { addDescription("Test MD5 checksum without salt -> no failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -140,7 +153,7 @@ public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { new PutFileCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentSaltAlgorithmWithSaltTest() throws Exception { addDescription("Test HMAC_SHA256 checksum with salt -> No failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, 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 843fd12b5..26412164d 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/commandline/ReplaceFileCmdTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/commandline/ReplaceFileCmdTest.java @@ -22,11 +22,15 @@ package org.bitrepository.commandline; import org.bitrepository.client.DefaultFixtureClientTest; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.util.Date; +import static org.junit.jupiter.api.Assertions.assertThrows; + public class ReplaceFileCmdTest extends DefaultFixtureClientTest { private static final String SETTINGS_DIR = "settings/xml/bitrepository-devel"; private static final String KEY_FILE = "KeyFile"; @@ -34,12 +38,13 @@ public class ReplaceFileCmdTest extends DefaultFixtureClientTest { private String DEFAULT_COLLECTION_ID; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setupClient() throws Exception { DEFAULT_COLLECTION_ID = settingsForTestClient.getCollections().get(0).getID(); } - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest" ) public void defaultSuccessScenarioTest() throws Exception { addDescription("Tests simplest arguments for running the CmdLineClient"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -51,7 +56,7 @@ public void defaultSuccessScenarioTest() throws Exception { new ReplaceFileCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void URLSuccessScenarioTest() throws Exception { addDescription("Tests the scenario, where a URL instead of a file is used for the replacement file."); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -65,88 +70,100 @@ public void URLSuccessScenarioTest() throws Exception { new ReplaceFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingCollectionArgumentTest() throws Exception { - addDescription("Tests the scenario, where the collection arguments is missing."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-r" + DEFAULT_CHECKSUM, - "-C" + DEFAULT_CHECKSUM, - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where the collection arguments is missing."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-r" + DEFAULT_CHECKSUM, + "-C" + DEFAULT_CHECKSUM, + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingPillarArgumentTest() throws Exception { - addDescription("Tests the different scenarios, with the pillar argument."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-r" + DEFAULT_CHECKSUM, - "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the different scenarios, with the pillar argument."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-r" + DEFAULT_CHECKSUM, + "-C" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void unknownPillarArgumentTest() throws Exception { - addStep("Testing against a non-existing pillar id", "Should fail"); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-r" + DEFAULT_CHECKSUM, - "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-p" + "Random" + (new Date()).getTime() + "pillar", - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addStep("Testing against a non-existing pillar id", "Should fail"); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-r" + DEFAULT_CHECKSUM, + "-C" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-p" + "Random" + (new Date()).getTime() + "pillar", + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingFileOrURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where no arguments for file or url is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-r" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-C" + DEFAULT_CHECKSUM, - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no arguments for file or url is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-r" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-C" + DEFAULT_CHECKSUM, + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void bothFileAndURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where both arguments for file or url is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-r" + DEFAULT_CHECKSUM, - "-f" + DEFAULT_FILE_ID, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-c" + DEFAULT_COLLECTION_ID, - "-C" + DEFAULT_CHECKSUM, - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where both arguments for file or url is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-r" + DEFAULT_CHECKSUM, + "-f" + DEFAULT_FILE_ID, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-c" + DEFAULT_COLLECTION_ID, + "-C" + DEFAULT_CHECKSUM, + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingFileIDWhenURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-r" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-C" + DEFAULT_CHECKSUM}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-r" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-C" + DEFAULT_CHECKSUM}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void missingFileIDWhenFileArgumentTest() throws Exception { addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -158,20 +175,22 @@ public void missingFileIDWhenFileArgumentTest() throws Exception { new ReplaceFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingChecksumForNewFileWhenUsingURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-C" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-C" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void missingChecksumForNewFileWhenUsingFileArgumentTest() throws Exception { addDescription("Tests the scenario, where no checksum argument is given, but a File is given."); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -184,33 +203,37 @@ public void missingChecksumForNewFileWhenUsingFileArgumentTest() throws Exceptio new ReplaceFileCmd(args); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingChecksumForExistingFileWhenUsingURLArgumentTest() throws Exception { - addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, - "-r" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no checksum argument is given, but a URL is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-u" + DEFAULT_DOWNLOAD_FILE_ADDRESS, + "-r" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }, expectedExceptions = IllegalArgumentException.class) + @Test @Tag( "regressiontest") public void missingChecksumForExistingFileWhenUsingFileArgumentTest() throws Exception { - addDescription("Tests the scenario, where no checksum argument is given, but a File is given."); - String[] args = new String[]{"-s" + SETTINGS_DIR, - "-k" + KEY_FILE, - "-p" + PILLAR1_ID, - "-f" + DEFAULT_FILE_ID, - "-r" + DEFAULT_CHECKSUM, - "-c" + DEFAULT_COLLECTION_ID, - "-i" + DEFAULT_FILE_ID}; - new ReplaceFileCmd(args); + assertThrows(IllegalArgumentException.class, () -> { + addDescription("Tests the scenario, where no checksum argument is given, but a File is given."); + String[] args = new String[]{"-s" + SETTINGS_DIR, + "-k" + KEY_FILE, + "-p" + PILLAR1_ID, + "-f" + DEFAULT_FILE_ID, + "-r" + DEFAULT_CHECKSUM, + "-c" + DEFAULT_COLLECTION_ID, + "-i" + DEFAULT_FILE_ID}; + new ReplaceFileCmd(args); + }); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { addDescription("Test MD5 checksum without salt -> no failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, @@ -225,7 +248,7 @@ public void checksumArgumentNonSaltAlgorithmWitoutSaltTest() throws Exception { new ReplaceFileCmd(args); } - @Test(groups = { "regressiontest" }) + @Test @Tag( "regressiontest") public void checksumArgumentSaltAlgorithmWithSaltTest() throws Exception { addDescription("Test HMAC_SHA256 checksum with salt -> No failure"); String[] args = new String[]{"-s" + SETTINGS_DIR, 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 e669ea875..0dbc0d189 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 @@ -26,19 +26,20 @@ import org.bitrepository.client.DefaultFixtureClientTest; import org.bitrepository.commandline.Constants; import org.bitrepository.commandline.output.OutputHandler; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.mock; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotEquals; -import static org.testng.Assert.assertTrue; public class ChecksumExtractionUtilsTest extends DefaultFixtureClientTest { CommandLineArgumentsHandler cmdHandler; OutputHandler output; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setup() { cmdHandler = new CommandLineArgumentsHandler(); cmdHandler.addOption(new Option(Constants.REQUEST_CHECKSUM_SALT_ARG, Constants.HAS_ARGUMENT, "")); @@ -46,7 +47,7 @@ public void setup() { output = mock(OutputHandler.class); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testDefaultChecksumSpec() throws Exception { addDescription("Test that the default checksum is retrieved when no arguments are given."); cmdHandler.parseArguments(new String[]{}); @@ -54,7 +55,8 @@ public void testDefaultChecksumSpec() throws Exception { assertEquals(type.name(), settingsForCUT.getRepositorySettings().getProtocolSettings().getDefaultChecksumType()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testDefaultChecksumSpecWithSaltArgument() throws Exception { addDescription("Test that the HMAC version of default checksum is retrieved when the salt arguments are given."); cmdHandler.parseArguments(new String[]{"-" + Constants.REQUEST_CHECKSUM_SALT_ARG + "0110"}); @@ -62,7 +64,7 @@ public void testDefaultChecksumSpecWithSaltArgument() throws Exception { assertEquals(type.name(), "HMAC_" + settingsForCUT.getRepositorySettings().getProtocolSettings().getDefaultChecksumType()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testNonSaltChecksumSpecWithoutSaltArgument() throws Exception { addDescription("Test that a non-salt checksum type is retrieved when it is given as argument, and no salt arguments are given."); ChecksumType enteredType = ChecksumType.SHA384; @@ -71,7 +73,7 @@ public void testNonSaltChecksumSpecWithoutSaltArgument() throws Exception { assertEquals(type, enteredType); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testNonSaltChecksumSpecWithSaltArgument() throws Exception { addDescription("Test that a salt checksum type is retrieved even though a non-salt checksum algorithm it is given as argument, " + "but a salt argument also is given."); @@ -83,7 +85,7 @@ public void testNonSaltChecksumSpecWithSaltArgument() throws Exception { assertEquals(type.name(), "HMAC_" + enteredType.name()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testSaltChecksumSpecWithoutSaltArgument() throws Exception { addDescription("Test that a non-salt checksum type is retrieved even though a salt checksum algorithm it is given as argument, " + "but no salt argument also is given."); @@ -95,7 +97,7 @@ public void testSaltChecksumSpecWithoutSaltArgument() throws Exception { assertEquals(type.name(), enteredType.name().replace("HMAC_", "")); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testSaltChecksumSpecWithSaltArgument() throws Exception { addDescription("Test that a salt checksum type is retrieved when the salt checksum algorithm it is given as argument, " + "and a salt argument also is given."); 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 d2f989307..09bf3c756 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 @@ -41,9 +41,11 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.common.utils.TestFileHelper; import org.bitrepository.modify.ModifyComponentFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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 java.nio.charset.StandardCharsets; @@ -52,24 +54,25 @@ public class DeleteFileClientComponentTest extends DefaultFixtureClientTest { private TestDeleteFileMessageFactory messageFactory; private DatatypeFactory datatypeFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialise() throws Exception { messageFactory = new TestDeleteFileMessageFactory(collectionID); datatypeFactory = DatatypeFactory.newInstance(); } - @Test(groups={"regressiontest"}) + @Test + @Tag("regressiontest") public void verifyDeleteClientFromFactory() { addDescription("Testing the initialization through the ModifyComponentFactory."); addStep("Use the ModifyComponentFactory to instantiate a PutFileClient.", "It should be an instance of SimplePutFileClient"); DeleteFileClient dfc = ModifyComponentFactory.getInstance().retrieveDeleteFileClient( settingsForCUT, securityManager, settingsForTestClient.getComponentID()); - Assert.assertTrue(dfc instanceof ConversationBasedDeleteFileClient, "The DeleteFileClient '" + dfc + Assertions.assertTrue(dfc instanceof ConversationBasedDeleteFileClient, "The DeleteFileClient '" + dfc + "' should be instance of '" + ConversationBasedDeleteFileClient.class.getName() + "'"); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void deleteClientTester() throws Exception { addDescription("Tests the DeleteClient. Makes a whole conversation for the delete client for a 'good' scenario."); addStep("Initialise the number of pillars to one", "Should be OK."); @@ -98,14 +101,14 @@ public void deleteClientTester() throws Exception { IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForDeleteFileRequest.class); - Assert.assertEquals(receivedIdentifyRequestMessage.getCollectionID(), collectionID); - Assert.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); - Assert.assertEquals(receivedIdentifyRequestMessage.getReplyTo(), settingsForCUT.getReceiverDestinationID()); - Assert.assertEquals(receivedIdentifyRequestMessage.getFileID(), DEFAULT_FILE_ID); - Assert.assertEquals(receivedIdentifyRequestMessage.getFrom(), settingsForTestClient.getComponentID()); - Assert.assertEquals(receivedIdentifyRequestMessage.getDestination(), settingsForTestClient.getCollectionDestination()); + Assertions.assertEquals(receivedIdentifyRequestMessage.getCollectionID(), collectionID); + Assertions.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); + Assertions.assertEquals(receivedIdentifyRequestMessage.getReplyTo(), settingsForCUT.getReceiverDestinationID()); + Assertions.assertEquals(receivedIdentifyRequestMessage.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(receivedIdentifyRequestMessage.getFrom(), settingsForTestClient.getComponentID()); + Assertions.assertEquals(receivedIdentifyRequestMessage.getDestination(), settingsForTestClient.getCollectionDestination()); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Make response for the pillar.", "The client receive the response, identify the pillar and send the request."); @@ -115,26 +118,26 @@ public void deleteClientTester() throws Exception { PILLAR1_ID, pillar1DestinationId, DEFAULT_FILE_ID); messageBus.sendMessage(identifyResponse); receivedDeleteFileRequest = pillar1Receiver.waitForMessage(DeleteFileRequest.class); - Assert.assertEquals(receivedDeleteFileRequest.getCollectionID(), collectionID); - Assert.assertEquals(receivedDeleteFileRequest.getCorrelationID(), receivedIdentifyRequestMessage.getCorrelationID()); - Assert.assertEquals(receivedDeleteFileRequest.getReplyTo(), settingsForCUT.getReceiverDestinationID()); - Assert.assertEquals(receivedDeleteFileRequest.getFileID(), DEFAULT_FILE_ID); - Assert.assertEquals(receivedDeleteFileRequest.getFrom(), settingsForTestClient.getComponentID()); - Assert.assertEquals(receivedDeleteFileRequest.getDestination(), pillar1DestinationId); + Assertions.assertEquals(receivedDeleteFileRequest.getCollectionID(), collectionID); + Assertions.assertEquals(receivedDeleteFileRequest.getCorrelationID(), receivedIdentifyRequestMessage.getCorrelationID()); + Assertions.assertEquals(receivedDeleteFileRequest.getReplyTo(), settingsForCUT.getReceiverDestinationID()); + Assertions.assertEquals(receivedDeleteFileRequest.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(receivedDeleteFileRequest.getFrom(), settingsForTestClient.getComponentID()); + Assertions.assertEquals(receivedDeleteFileRequest.getDestination(), pillar1DestinationId); addStep("Validate the steps of the DeleteClient by going through the events.", "Should be 'PillarIdentified', " + "'PillarSelected' and 'RequestSent'"); for(int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("The pillar sends a progress response to the DeleteClient.", "Should be caught by the event handler."); DeleteFileProgressResponse deleteFileProgressResponse = messageFactory.createDeleteFileProgressResponse( receivedDeleteFileRequest, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(deleteFileProgressResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.PROGRESS); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.PROGRESS); addStep("Send a final response message to the DeleteClient.", "Should be caught by the event handler. First a PartiallyComplete, then a Complete."); @@ -143,14 +146,14 @@ public void deleteClientTester() throws Exception { messageBus.sendMessage(deleteFileFinalResponse); for(int i = 1; i < 2* settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { OperationEventType eventType = testEventHandler.waitForEvent().getEventType(); - Assert.assertTrue( (eventType == OperationEventType.COMPONENT_COMPLETE) + Assertions.assertTrue( (eventType == OperationEventType.COMPONENT_COMPLETE) || (eventType == OperationEventType.PROGRESS), "Expected either PartiallyComplete or Progress, but was: " + eventType); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") 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"); @@ -164,7 +167,7 @@ public void fileAlreadyDeletedFromPillar() throws Exception { IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForDeleteFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Send a identify response from Pillar1 with a missing file response.", "The client should generate a COMPONENT_IDENTIFIED, a COMPONENT_COMPLETE and " + @@ -173,20 +176,20 @@ public void fileAlreadyDeletedFromPillar() throws Exception { receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId, DEFAULT_FILE_ID); identifyResponse.getResponseInfo().setResponseCode(ResponseCode.FILE_NOT_FOUND_FAILURE); messageBus.sendMessage(identifyResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); addStep("The client should then continue to the performing phase and finish immediately as the pillar " + "has already had the file removed apparently .", "The client should generate a COMPLETE event."); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); addStep("Send a identify response from Pillar2", "The response should be ignored"); testEventHandler.verifyNoEventsAreReceived(); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void deleteClientIdentificationTimeout() throws Exception { addDescription("Tests the handling of a failed identification for the DeleteClient"); addStep("Initialise the number of pillars and the DeleteClient. Sets the identification timeout to 1 sec.", @@ -216,16 +219,16 @@ public void deleteClientIdentificationTimeout() throws Exception { testEventHandler, null); collectionReceiver.waitForMessage(IdentifyPillarsForDeleteFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Do not respond. Just await the timeout.", "Should make send a Failure event to the event handler."); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_TIMEOUT); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_TIMEOUT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void deleteClientOperationTimeout() throws Exception { addDescription("Tests the handling of a failed operation for the DeleteClient"); addStep("Initialise the number of pillars and the DeleteClient. Sets the operation timeout to 100 ms.", @@ -255,7 +258,7 @@ public void deleteClientOperationTimeout() throws Exception { IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForDeleteFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Make response for the pillar.", "The client receive the response, identify the pillar and send the request."); @@ -268,17 +271,17 @@ public void deleteClientOperationTimeout() throws Exception { addStep("Validate the steps of the DeleteClient by going through the events.", "Should be 'PillarIdentified', " + "'PillarSelected' and 'RequestSent'"); for(int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("Do not respond. Just await the timeout.", "Should make send a Failure event to the event handler."); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void deleteClientPillarFailedDuringPerform() throws Exception { addDescription("Tests the handling of a operation failure for the DeleteClient. "); addStep("Initialise the number of pillars to one", "Should be OK."); @@ -305,7 +308,7 @@ public void deleteClientPillarFailedDuringPerform() throws Exception { IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForDeleteFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Make response for the pillar.", "The client receive the response, identify the pillar and send the request."); @@ -318,10 +321,10 @@ public void deleteClientPillarFailedDuringPerform() throws Exception { addStep("Validate the steps of the DeleteClient by going through the events.", "Should be 'PillarIdentified', " + "'PillarSelected' and 'RequestSent'"); for(int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("Send a failed response message to the DeleteClient.", "Should be caught by the event handler. First a COMPONENT_FAILED, then a COMPLETE."); @@ -332,11 +335,11 @@ public void deleteClientPillarFailedDuringPerform() throws Exception { ri.setResponseText("Verifying that a failure can be understood!"); deleteFileFinalResponse.setResponseInfo(ri); messageBus.sendMessage(deleteFileFinalResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @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); @@ -359,12 +362,12 @@ public void deleteClientSpecifiedPillarFailedDuringIdentification() throws Excep identifyResponse.getResponseInfo().setResponseCode(ResponseCode.IDENTIFICATION_NEGATIVE); messageBus.sendMessage(identifyResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @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); @@ -374,7 +377,7 @@ public void deleteClientOtherPillarFailedDuringIdentification() throws Exception "A IdentifyPillarsForDeleteFileRequest should be sent and a IDENTIFY_REQUEST_SENT event should be generated."); deleteClient.deleteFile(collectionID, DEFAULT_FILE_ID, PILLAR1_ID, TestFileHelper.getDefaultFileChecksum(), null, testEventHandler, null); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForDeleteFileRequest.class); @@ -395,20 +398,20 @@ public void deleteClientOtherPillarFailedDuringIdentification() throws Exception messageFactory.createIdentifyPillarsForDeleteFileResponse(receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId, DEFAULT_FILE_ID); messageBus.sendMessage(identifyResponse2); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); DeleteFileRequest receivedDeleteFileRequest = pillar1Receiver.waitForMessage(DeleteFileRequest.class); addStep("Send a final response message from pillar 1 to the DeleteClient.", "Should produce a COMPONENT_COMPLETE event followed by a COMPLETE event."); messageBus.sendMessage(messageFactory.createDeleteFileFinalResponse( receivedDeleteFileRequest, PILLAR1_ID, pillar1DestinationId, DEFAULT_FILE_ID)); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups={"regressiontest"}) + @Test @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); @@ -418,7 +421,7 @@ public void deleteOnChecksumPillar() throws Exception { "A IdentifyPillarsForDeleteFileRequest should be sent and a IDENTIFY_REQUEST_SENT event should be generated."); deleteClient.deleteFile(collectionID, DEFAULT_FILE_ID, PILLAR1_ID, TestFileHelper.getDefaultFileChecksum(), null, testEventHandler, null); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForDeleteFileRequest.class); @@ -442,14 +445,14 @@ public void deleteOnChecksumPillar() throws Exception { checksumSpecTYPEFromPillar.setChecksumType(ChecksumType.MD5); identifyResponse.setPillarChecksumSpec(checksumSpecTYPEFromPillar); messageBus.sendMessage(identifyResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); - Assert.assertNotNull(pillar1Receiver.waitForMessage(DeleteFileRequest.class)); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertNotNull(pillar1Receiver.waitForMessage(DeleteFileRequest.class)); pillar2Receiver.checkNoMessageIsReceived(DeleteFileRequest.class); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void deleteOnChecksumPillarWithDefaultReturnChecksumType() throws Exception { addDescription("Verify that the DeleteClient works correctly when a return checksum of the default type" + "is requested. "); @@ -464,7 +467,7 @@ public void deleteOnChecksumPillarWithDefaultReturnChecksumType() throws Excepti checksumSpecTYPE.setChecksumType(ChecksumType.MD5); deleteClient.deleteFile(collectionID, DEFAULT_FILE_ID, PILLAR1_ID, TestFileHelper.getDefaultFileChecksum(), checksumSpecTYPE, testEventHandler, null); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForDeleteFileRequest.class); @@ -480,14 +483,14 @@ public void deleteOnChecksumPillarWithDefaultReturnChecksumType() throws Excepti checksumSpecTYPEFromPillar.setChecksumType(ChecksumType.MD5); identifyResponse.setPillarChecksumSpec(checksumSpecTYPEFromPillar); messageBus.sendMessage(identifyResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); DeleteFileRequest receivedPutFileRequest1 = pillar1Receiver.waitForMessage(DeleteFileRequest.class); - Assert.assertEquals(receivedPutFileRequest1.getChecksumRequestForExistingFile(), checksumSpecTYPE); + Assertions.assertEquals(receivedPutFileRequest1.getChecksumRequestForExistingFile(), checksumSpecTYPE); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void deleteOnChecksumPillarWithSaltedReturnChecksumType() throws Exception { addDescription("Verify that the DeleteClient works correctly when a return checksum with a salt " + "is requested. "); @@ -502,7 +505,7 @@ public void deleteOnChecksumPillarWithSaltedReturnChecksumType() throws Exceptio checksumSpecTYPE.setChecksumSalt(Base16Utils.encodeBase16("aa")); deleteClient.deleteFile(collectionID, DEFAULT_FILE_ID, PILLAR1_ID, TestFileHelper.getDefaultFileChecksum(), checksumSpecTYPE, testEventHandler, null); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); IdentifyPillarsForDeleteFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForDeleteFileRequest.class); @@ -517,11 +520,11 @@ public void deleteOnChecksumPillarWithSaltedReturnChecksumType() throws Exceptio checksumSpecTYPEFromPillar.setChecksumType(ChecksumType.MD5); identifyResponse.setPillarChecksumSpec(checksumSpecTYPEFromPillar); messageBus.sendMessage(identifyResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); DeleteFileRequest receivedPutFileRequest1 = pillar1Receiver.waitForMessage(DeleteFileRequest.class); - Assert.assertNull(receivedPutFileRequest1.getChecksumRequestForExistingFile()); + Assertions.assertNull(receivedPutFileRequest1.getChecksumRequestForExistingFile()); } /** 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 8fc300a60..81c2f942e 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 @@ -40,38 +40,42 @@ import org.bitrepository.common.utils.Base16Utils; import org.bitrepository.common.utils.TestFileHelper; import org.bitrepository.modify.ModifyComponentFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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 java.math.BigInteger; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class PutFileClientComponentTest extends DefaultFixtureClientTest { private TestPutFileMessageFactory messageFactory; private DatatypeFactory datatypeFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialise() throws Exception { messageFactory = new TestPutFileMessageFactory(settingsForTestClient.getComponentID()); datatypeFactory = DatatypeFactory.newInstance(); } - @Test(groups={"regressiontest"}) + @Test + @Tag("regressiontest") public void verifyPutClientFromFactory() { addDescription("Testing the initialization through the ModifyComponentFactory."); addStep("Use the ModifyComponentFactory to instantiate a PutFileClient.", "It should be an instance of SimplePutFileClient"); PutFileClient pfc = ModifyComponentFactory.getInstance().retrievePutClient( settingsForCUT, securityManager, settingsForTestClient.getComponentID()); - Assert.assertTrue(pfc instanceof ConversationBasedPutFileClient, "The PutFileClient '" + pfc + "' should be instance of '" + Assertions.assertTrue(pfc instanceof ConversationBasedPutFileClient, "The PutFileClient '" + pfc + "' should be instance of '" + ConversationBasedPutFileClient.class.getName() + "'"); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void normalPutFile() throws Exception { addDescription("Tests the PutClient. Makes a whole conversation for the put client for a 'good' scenario."); addFixture("Initialise the number of pillars to one"); @@ -92,7 +96,7 @@ public void normalPutFile() throws Exception { IdentifyPillarsForPutFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForPutFileRequest.class); assertEquals(receivedIdentifyRequestMessage.getCollectionID(), collectionID); - Assert.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); + Assertions.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); assertEquals(receivedIdentifyRequestMessage.getReplyTo(), settingsForCUT.getReceiverDestinationID()); assertEquals(receivedIdentifyRequestMessage.getFileID(), DEFAULT_FILE_ID); assertEquals(receivedIdentifyRequestMessage.getFrom(), settingsForTestClient.getComponentID()); @@ -133,14 +137,14 @@ public void normalPutFile() throws Exception { messageBus.sendMessage(putFileFinalResponse); for(int i = 1; i < 2* settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { OperationEventType eventType = testEventHandler.waitForEvent().getEventType(); - Assert.assertTrue( (eventType == OperationEventType.COMPONENT_COMPLETE) + Assertions.assertTrue( (eventType == OperationEventType.COMPONENT_COMPLETE) || (eventType == OperationEventType.PROGRESS), "Expected either PartiallyComplete or Progress, but was: " + eventType); } assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void noPillarsResponding() throws Exception { addDescription("Tests the handling of missing identification responses from all pillar"); addFixture("Sets the identification timeout to 100 ms."); @@ -160,12 +164,12 @@ public void noPillarsResponding() throws Exception { addStep("Do not respond. Just await the timeout.", "An IDENTIFY_TIMEOUT event should be generate, followed by a FAILED event."); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_TIMEOUT); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @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"); @@ -197,7 +201,7 @@ public void onePillarRespondingWithPartialPutAllowed() throws Exception { 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."); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_TIMEOUT); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); addStep("The client should proceed to send a putFileOperation request to the responding pillar.", @@ -214,7 +218,7 @@ public void onePillarRespondingWithPartialPutAllowed() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void onePillarRespondingWithPartialPutDisallowed() throws Exception { addDescription("Tests the handling of missing identification responses from one pillar, " + "when partial put are allowed"); @@ -245,12 +249,12 @@ public void onePillarRespondingWithPartialPutDisallowed() throws Exception { "event for the non-responding pillar, an IDENTIFICATION_COMPLETE and " + "lastly a OperationEventType.FAILED event should be generated."); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_TIMEOUT); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void putClientOperationTimeout() throws Exception { addDescription("Tests the handling of a failed operation for the PutClient"); addStep("Initialise the number of pillars and the PutClient. Sets the operation timeout to 100 ms.", @@ -291,7 +295,7 @@ public void putClientOperationTimeout() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void putClientPillarOperationFailed() throws Exception { addDescription("Tests the handling of a operation failure for the PutClient. "); addStep("Initialise the number of pillars to one", "Should be OK."); @@ -339,7 +343,7 @@ public void putClientPillarOperationFailed() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") 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. "); @@ -372,7 +376,7 @@ public void fileExistsOnPillarNoChecksumFromPillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") 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. "); @@ -410,7 +414,7 @@ public void fileExistsOnPillarDifferentChecksumFromPillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") 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)."); @@ -465,7 +469,7 @@ public void sameFileExistsOnOnePillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") 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. "); @@ -501,7 +505,7 @@ public void fileExistsOnPillarChecksumFromPillarNoClientChecksum() throws Except assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void saltedReturnChecksumsWithChecksumPillar() throws Exception { addDescription("Tests that PutClient handles the presence of a ChecksumPillar correctly, when a salted return" + " checksum (which a checksum pillar can't provide) is requested. "); @@ -548,7 +552,7 @@ public void saltedReturnChecksumsWithChecksumPillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); PutFileRequest receivedPutFileRequest1 = pillar1Receiver.waitForMessage(PutFileRequest.class); - Assert.assertNull(receivedPutFileRequest1.getChecksumRequestForNewFile()); + Assertions.assertNull(receivedPutFileRequest1.getChecksumRequestForNewFile()); PutFileRequest receivedPutFileRequest2 = pillar2Receiver.waitForMessage(PutFileRequest.class); @@ -556,7 +560,7 @@ public void saltedReturnChecksumsWithChecksumPillar() throws Exception { } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") 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). "); @@ -607,7 +611,7 @@ public void defaultReturnChecksumsWithChecksumPillar() throws Exception { assertEquals(receivedPutFileRequest2.getChecksumRequestForNewFile(), checksumSpecTYPE); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void noReturnChecksumsWithChecksumPillar() throws Exception { addDescription("Tests that PutClient handles the presence of a ChecksumPillar correctly, when no return" + " checksum is requested."); @@ -647,13 +651,13 @@ public void noReturnChecksumsWithChecksumPillar() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); PutFileRequest receivedPutFileRequest1 = pillar1Receiver.waitForMessage(PutFileRequest.class); - Assert.assertNull(receivedPutFileRequest1.getChecksumRequestForNewFile()); + Assertions.assertNull(receivedPutFileRequest1.getChecksumRequestForNewFile()); PutFileRequest receivedPutFileRequest2 = pillar2Receiver.waitForMessage(PutFileRequest.class); - Assert.assertNull(receivedPutFileRequest2.getChecksumRequestForNewFile()); + Assertions.assertNull(receivedPutFileRequest2.getChecksumRequestForNewFile()); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void onePillarPutRetrySuccess() throws Exception { addReference("" + "BITMAG-810 Reference client should be able to retry failed file transfers"); @@ -705,7 +709,7 @@ public void onePillarPutRetrySuccess() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void onePillarPutRetryFailure() throws Exception { addReference("" + "BITMAG-810 Reference client should be able to retry failed file transfers"); @@ -768,7 +772,7 @@ public void onePillarPutRetryFailure() throws Exception { assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups={"regressiontest"}) + @Test @Tag("regressiontest") public void putToOtherCollection() throws Exception { addReference("" + "BITMAG-925 Client will always try to put to the pillars defined in the first collection"); 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 917840ae9..f78799008 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 @@ -41,9 +41,11 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.common.utils.ChecksumUtils; import org.bitrepository.modify.ModifyComponentFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; @@ -57,7 +59,7 @@ public class ReplaceFileClientComponentTest extends DefaultFixtureClientTest { private TestReplaceFileMessageFactory messageFactory; private DatatypeFactory datatypeFactory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void initialise() throws DatatypeConfigurationException { messageFactory = new TestReplaceFileMessageFactory(settingsForTestClient.getComponentID()); DEFAULT_CHECKSUM_SPEC = ChecksumUtils.getDefault(settingsForCUT); @@ -66,18 +68,20 @@ public void initialise() throws DatatypeConfigurationException { datatypeFactory = DatatypeFactory.newInstance(); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void verifyReplaceFileClientFromFactory() { addDescription("Testing the initialization through the ModifyComponentFactory."); addStep("Use the ModifyComponentFactory to instantiate a ReplaceFileClient.", "It should be an instance of ConversationBasedReplaceFileClient"); ReplaceFileClient rfc = ModifyComponentFactory.getInstance().retrieveReplaceFileClient( settingsForCUT, securityManager, settingsForTestClient.getComponentID()); - Assert.assertTrue(rfc instanceof ConversationBasedReplaceFileClient, "The ReplaceFileClient '" + rfc + Assertions.assertTrue(rfc instanceof ConversationBasedReplaceFileClient, "The ReplaceFileClient '" + rfc + "' should be instance of '" + ConversationBasedReplaceFileClient.class.getName() + "'"); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void replaceClientTester() throws Exception { addDescription("Tests the ReplaceFileClient. Makes a whole conversation for the replace client for a " + "'good' scenario."); @@ -100,13 +104,13 @@ public void replaceClientTester() throws Exception { IdentifyPillarsForReplaceFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForReplaceFileRequest.class); - Assert.assertEquals(receivedIdentifyRequestMessage.getCollectionID(), collectionID); - Assert.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); - Assert.assertEquals(receivedIdentifyRequestMessage.getReplyTo(), settingsForCUT.getReceiverDestinationID()); - Assert.assertEquals(receivedIdentifyRequestMessage.getFileID(), DEFAULT_FILE_ID); - Assert.assertEquals(receivedIdentifyRequestMessage.getFrom(), settingsForTestClient.getComponentID()); - Assert.assertEquals(receivedIdentifyRequestMessage.getDestination(), settingsForTestClient.getCollectionDestination()); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(receivedIdentifyRequestMessage.getCollectionID(), collectionID); + Assertions.assertNotNull(receivedIdentifyRequestMessage.getCorrelationID()); + Assertions.assertEquals(receivedIdentifyRequestMessage.getReplyTo(), settingsForCUT.getReceiverDestinationID()); + Assertions.assertEquals(receivedIdentifyRequestMessage.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(receivedIdentifyRequestMessage.getFrom(), settingsForTestClient.getComponentID()); + Assertions.assertEquals(receivedIdentifyRequestMessage.getDestination(), settingsForTestClient.getCollectionDestination()); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Make response for the pillar.", "The client receive the response, identify the pillar and send the " + "request."); @@ -117,26 +121,26 @@ public void replaceClientTester() throws Exception { PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(identifyResponse); receivedReplaceFileRequest = pillar1Receiver.waitForMessage(ReplaceFileRequest.class); - Assert.assertEquals(receivedReplaceFileRequest.getCollectionID(), collectionID); - Assert.assertEquals(receivedReplaceFileRequest.getCorrelationID(), receivedIdentifyRequestMessage.getCorrelationID()); - Assert.assertEquals(receivedReplaceFileRequest.getReplyTo(), settingsForCUT.getReceiverDestinationID()); - Assert.assertEquals(receivedReplaceFileRequest.getFileID(), DEFAULT_FILE_ID); - Assert.assertEquals(receivedReplaceFileRequest.getFrom(), settingsForTestClient.getComponentID()); - Assert.assertEquals(receivedReplaceFileRequest.getDestination(), pillar1DestinationId); + Assertions.assertEquals(receivedReplaceFileRequest.getCollectionID(), collectionID); + Assertions.assertEquals(receivedReplaceFileRequest.getCorrelationID(), receivedIdentifyRequestMessage.getCorrelationID()); + Assertions.assertEquals(receivedReplaceFileRequest.getReplyTo(), settingsForCUT.getReceiverDestinationID()); + Assertions.assertEquals(receivedReplaceFileRequest.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(receivedReplaceFileRequest.getFrom(), settingsForTestClient.getComponentID()); + Assertions.assertEquals(receivedReplaceFileRequest.getDestination(), pillar1DestinationId); addStep("Validate the steps of the ReplaceClient by going through the events.", "Should be 'PillarIdentified', " + "'PillarSelected' and 'RequestSent'"); for (int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("The pillar sends a progress response to the ReplaceClient.", "Should be caught by the event handler."); ReplaceFileProgressResponse putFileProgressResponse = messageFactory.createReplaceFileProgressResponse( receivedReplaceFileRequest, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(putFileProgressResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.PROGRESS); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.PROGRESS); addStep("Send a final response message to the ReplaceClient.", "Should be caught by the event handler. First a PillarComplete, then a Complete."); @@ -145,14 +149,15 @@ public void replaceClientTester() throws Exception { messageBus.sendMessage(replaceFileFinalResponse); for (int i = 1; i < 2 * settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { OperationEventType eventType = testEventHandler.waitForEvent().getEventType(); - Assert.assertTrue((eventType == OperationEventType.COMPONENT_COMPLETE) + Assertions.assertTrue((eventType == OperationEventType.COMPONENT_COMPLETE) || (eventType == OperationEventType.PROGRESS), "Expected either PartiallyComplete or Progress, but was: " + eventType); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void replaceClientIdentificationTimeout() throws Exception { addDescription("Tests the handling of a failed identification for the ReplaceClient"); addStep("Initialise the number of pillars and the DeleteClient. Sets the identification timeout to 100 ms.", @@ -175,16 +180,17 @@ public void replaceClientIdentificationTimeout() throws Exception { address, 10, DEFAULT_NEW_CHECKSUM_DATA, checksumRequest, testEventHandler, null); collectionReceiver.waitForMessage(IdentifyPillarsForReplaceFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Do not respond. Just await the timeout.", "Should make send a Failure event to the eventhandler."); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_TIMEOUT); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_TIMEOUT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void replaceClientOperationTimeout() throws Exception { addDescription("Tests the handling of a failed operation for the ReplaceClient"); addStep("Initialise the number of pillars and the DeleteClient. Sets the operation timeout to 100 ms.", @@ -209,7 +215,7 @@ public void replaceClientOperationTimeout() throws Exception { IdentifyPillarsForReplaceFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForReplaceFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Make response for the pillar.", "The client receive the response, identify the pillar and send the " + "request."); @@ -218,22 +224,23 @@ public void replaceClientOperationTimeout() throws Exception { messageFactory.createIdentifyPillarsForReplaceFileResponse(receivedIdentifyRequestMessage, PILLAR1_ID, pillar1DestinationId); messageBus.sendMessage(identifyResponse); - Assert.assertNotNull(pillar1Receiver.waitForMessage(ReplaceFileRequest.class)); + Assertions.assertNotNull(pillar1Receiver.waitForMessage(ReplaceFileRequest.class)); addStep("Validate the steps of the ReplaceClient by going through the events.", "Should be 'PillarIdentified', " + "'PillarSelected' and 'RequestSent'"); for (int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("Do not respond. Just await the timeout.", "Should make send a Failure event to the eventhandler."); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void replaceClientPillarFailed() throws Exception { addDescription("Tests the handling of a operation failure for the ReplaceClient. "); addStep("Initialise the number of pillars to one", "Should be OK."); @@ -256,7 +263,7 @@ public void replaceClientPillarFailed() throws Exception { IdentifyPillarsForReplaceFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForReplaceFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Make response for the pillar.", "The client receive the response, identify the pillar and send the " + "request."); @@ -271,10 +278,10 @@ public void replaceClientPillarFailed() throws Exception { addStep("Validate the steps of the ReplaceClient by going through the events.", "Should be 'PillarIdentified', " + "'PillarSelected' and 'RequestSent'"); for (int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("Send a failed response message to the ReplaceClient.", "Should be caught by the event handler. First a PillarFailed, then a Complete."); @@ -285,11 +292,11 @@ public void replaceClientPillarFailed() throws Exception { ri.setResponseText("Verifying that a failure can be understood!"); replaceFileFinalResponse.setResponseInfo(ri); messageBus.sendMessage(replaceFileFinalResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") 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."); @@ -309,7 +316,7 @@ public void saltedReturnChecksumsForNewFileWithChecksumPillar() throws Exception IdentifyPillarsForReplaceFileRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForReplaceFileRequest.class); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Send an identification response with a PillarChecksumSpec element set, indicating that this is a " + "checksum pillar.", @@ -321,11 +328,11 @@ public void saltedReturnChecksumsForNewFileWithChecksumPillar() throws Exception PILLAR1_ID, pillar1DestinationId); markAsChecksumPillarResponse(identifyResponse); messageBus.sendMessage(identifyResponse); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - Assert.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); ReplaceFileRequest receivedReplaceFileRequest1 = pillar1Receiver.waitForMessage(ReplaceFileRequest.class); - Assert.assertNull(receivedReplaceFileRequest1.getChecksumRequestForNewFile()); + Assertions.assertNull(receivedReplaceFileRequest1.getChecksumRequestForNewFile()); } /** 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 dba52b70e..d2febcbb2 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 @@ -33,7 +33,8 @@ public class StreamUtilsTest extends ExtendedTestCase { String DATA = "The data for the streams."; - @Test @Tag("regressiontest") + @Test + @Tag("regressiontest") public void streamTester() throws Exception { addDescription("Tests the SteamUtils class."); addStep("Setup variables", ""); 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 651f9187c..8d0178f6d 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 @@ -121,7 +121,8 @@ private static > void assertBetweenExclusive(T actual, T Assertions.assertTrue(actual.compareTo(maxExclusive) < 0); } - @Test @Tag("regressiontest") + @Test + @Tag("regressiontest") public void tooManyDecimalsAreRejected() { assertThrows(ArithmeticException.class, () -> { addDescription("Tests that xmlDurationToDuration() rejects more than 9 decimals on seconds"); 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 8a417cdc8..355a27f6e 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 @@ -64,7 +64,8 @@ public void initializeSettings() { * Tests the amount of messages sent over a message bus, which is not placed locally. * Require sending at least five messages per second. */ - @Test @Tag("StressTest") + @Test + @Tag("StressTest") public void SendManyMessagesDistributed() throws Exception { addDescription("Tests how many messages can be handled within a given timeframe."); addStep("Define constants", "This should not be possible to fail."); 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 b08fcebf0..63e69a045 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 @@ -70,7 +70,7 @@ public void initializeSettings() { * Tests the amount of messages sent over a message bus, which is not placed locally. * Requires sending at least five per second. */ - /* @Test( groups = {"StressTest"} ) */ + /* @Test @Tag("StressTest"} ) */ public void SendLargeMessagesDistributed() throws Exception { addDescription("Tests how many messages can be handled within a given timeframe."); addStep("Define constants", "This should not be possible to fail."); 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 ddbb37155..e36e5f91c 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 @@ -70,7 +70,7 @@ public void initializeSettings() { * Tests the amount of messages sent over a message bus, which is not placed locally. * Require sending at least five per second. */ - /* @Test( groups = {"StressTest"} ) */ + /* @Test @Tag("StressTest"} ) */ 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."); 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 3fce32456..be20bdf14 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 @@ -82,12 +82,12 @@ public void negativeCertificateRetrievalTest() throws Exception { assertEquals(positiveCertificate, certificateFromStore); } - //@Test(groups = {"regressiontest"}) + //@Test @Tag("regressiontest"}) public void certificatePermissionCheckTest() { addDescription("Tests that a certificate only allows for the expected permission."); } - //@Test(groups = {"regressiontest"}) + //@Test @Tag("regressiontest"}) public void unknownCertificatePermissionCheckTest() { addDescription("Tests that a unknown certificate results in expected refusal."); } 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 3065ff497..fe20c09b3 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 @@ -26,11 +26,15 @@ import org.bitrepository.integrityservice.alerter.IntegrityAlarmDispatcher; import org.bitrepository.integrityservice.alerter.IntegrityAlerter; import org.bitrepository.protocol.IntegrationTest; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + public class IntegrityAlerterTest extends IntegrationTest { - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testIntegrityFailed() { addDescription("Test the IntegrityFailed method for the IntegrityAlerter"); @@ -38,10 +42,12 @@ public void testIntegrityFailed() { IntegrityAlerter alerter = new IntegrityAlarmDispatcher(settingsForCUT, messageBus, null); alerter.integrityFailed("Testaintegrity alarm", collectionID); AlarmMessage alarmMessage = alarmReceiver.waitForMessage(AlarmMessage.class); - Assert.assertEquals(alarmMessage.getAlarm().getAlarmCode(), AlarmCode.INTEGRITY_ISSUE); + Assertions.assertEquals(alarmMessage.getAlarm().getAlarmCode(), AlarmCode.INTEGRITY_ISSUE); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testOperationFailed() { addDescription("Test the OperationFailed method for the IntegrityAlerter"); @@ -51,6 +57,6 @@ public void testOperationFailed() { alerter.operationFailed("Testing the ability to fail.", collectionID); AlarmMessage alarmMessage = alarmReceiver.waitForMessage(AlarmMessage.class); - Assert.assertEquals(alarmMessage.getAlarm().getAlarmCode(), AlarmCode.FAILED_OPERATION); + Assertions.assertEquals(alarmMessage.getAlarm().getAlarmCode(), AlarmCode.FAILED_OPERATION); } } 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 95aa07bcf..7002b166f 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 @@ -34,8 +34,9 @@ import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; + import javax.xml.datatype.DatatypeConfigurationException; import java.math.BigInteger; @@ -44,7 +45,7 @@ public abstract class IntegrityDatabaseTestCase extends ExtendedTestCase { protected Settings settings; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("IntegrityCheckingUnderTest"); customizeSettings(); @@ -56,7 +57,7 @@ public void setup() throws Exception { integrityDatabaseCreator.createIntegrityDatabase(settings, null); } - @AfterMethod (alwaysRun = true) + @AfterEach public void clearDatabase() throws Exception { DBConnector connector = new DBConnector(settings.getReferenceSettings().getIntegrityServiceSettings().getIntegrityDatabase()); DatabaseUtils.executeStatement(connector, "DELETE FROM fileinfo", new Object[0]); 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 743a48350..45c118b73 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 @@ -27,9 +27,9 @@ //import org.bitrepository.integrityservice.scheduler.TimerBasedScheduler; //import org.bitrepository.integrityservice.scheduler.workflow.Workflow; //import org.jaccept.structure.ExtendedTestCase; -//import org.testng.Assert; -//import org.testng.annotations.BeforeClass; -//import org.testng.annotations.Test; +// +// +// // ///** // * Test that scheduler calls triggers. @@ -44,33 +44,33 @@ // settings = TestSettingsProvider.reloadSettings("IntegrityWorkflowSchedulerUnderTest"); // } // -// @Test(groups = {"regressiontest", "integritytest"}) +// @Test @Tag("regressiontest", "integritytest"}) // public void testSchedulerContainingWorkflows() { // addDescription("Test that schedulers call all workflow at the given intervals."); // addStep("Setup a scheduler and validate initial state", "No errors and no workflows"); // TimerBasedScheduler scheduler = new TimerBasedScheduler(settings); -// Assert.assertEquals(scheduler.getJobs().size(), 0, "Should not be any workflows in the scheduler."); +// Assertions.assertEquals(scheduler.getJobs().size(), 0, "Should not be any workflows in the scheduler."); // // addStep("Make a new workflow, add it to the scheduler and extract it afterwards.", // "Should extract the same workflow"); // Workflow testWorkflow = new MockWorkflow(3600000L, "testWorkflow"); // scheduler.putWorkflow(testWorkflow); -// Assert.assertEquals(scheduler.getJobs().size(), 1, "Should only be one workflow in the scheduler."); -// Assert.assertEquals(scheduler.getJobs().get(0), testWorkflow, "Should be the same workflow."); +// Assertions.assertEquals(scheduler.getJobs().size(), 1, "Should only be one workflow in the scheduler."); +// Assertions.assertEquals(scheduler.getJobs().get(0), testWorkflow, "Should be the same workflow."); // // addStep("Add the workflow again to the scheduler", "Should still be only the one and same workflow in the scheduler"); // scheduler.putWorkflow(testWorkflow); -// Assert.assertEquals(scheduler.getJobs().size(), 1, "Should only be one workflow in the scheduler."); -// Assert.assertEquals(scheduler.getJobs().get(0), testWorkflow, "Should be the same workflow."); +// Assertions.assertEquals(scheduler.getJobs().size(), 1, "Should only be one workflow in the scheduler."); +// Assertions.assertEquals(scheduler.getJobs().get(0), testWorkflow, "Should be the same workflow."); // // addStep("Remove the workflow from the scheduler two times", // "Should not be any workflows in the scheduler, and only successfully remove workflow once."); -// Assert.assertTrue(scheduler.removeWorkflow(testWorkflow.getPrimitiveName())); -// Assert.assertEquals(scheduler.getJobs().size(), 0, "Should not be any workflows in the scheduler."); -// Assert.assertFalse(scheduler.removeWorkflow(testWorkflow.getPrimitiveName())); +// Assertions.assertTrue(scheduler.removeWorkflow(testWorkflow.getPrimitiveName())); +// Assertions.assertEquals(scheduler.getJobs().size(), 0, "Should not be any workflows in the scheduler."); +// Assertions.assertFalse(scheduler.removeWorkflow(testWorkflow.getPrimitiveName())); // } // -// @Test(groups = {"regressiontest", "integrationtest"}) +// @Test @Tag("regressiontest", "integrationtest"}) // public void schedulerTester() throws Exception { // addDescription("Tests that the scheduler is able make calls to the collector at given intervals."); // addStep("Setup the variables and such.", "Should not be able to fail here."); @@ -80,16 +80,16 @@ // // addStep("Create a workflow", "Should not have been called yet been called."); // MockWorkflow workflow = new MockWorkflow(INTERVAL + INTERVAL_DELAY, taskName); -// Assert.assertEquals(workflow.getCallsForNextRun(), 0); -// Assert.assertEquals(workflow.getCallsForRunWorkflow(), 0); +// Assertions.assertEquals(workflow.getCallsForNextRun(), 0); +// Assertions.assertEquals(workflow.getCallsForRunWorkflow(), 0); // // addStep("Add the workflow", "Validate that it initially calls the "); // scheduler.putWorkflow(workflow); // synchronized(this) { // wait(INTERVAL_DELAY); // } -// Assert.assertEquals(workflow.getCallsForNextRun(), 1); -// Assert.assertEquals(workflow.getCallsForRunWorkflow(), 1); +// Assertions.assertEquals(workflow.getCallsForNextRun(), 1); +// Assertions.assertEquals(workflow.getCallsForRunWorkflow(), 1); // // addStep("Wait 4 * the interval (plus delay for instantiation), stop the trigger and validate the results.", // "Should have checked the date 5 times, but only run the workflow 3 times."); @@ -97,8 +97,8 @@ // wait(4*INTERVAL); // } // scheduler.removeWorkflow(taskName); -// Assert.assertEquals(workflow.getCallsForNextRun(), 5); -// Assert.assertEquals(workflow.getCallsForRunWorkflow(), 3); +// Assertions.assertEquals(workflow.getCallsForNextRun(), 5); +// Assertions.assertEquals(workflow.getCallsForRunWorkflow(), 3); // // addStep("Wait another 2 seconds and validate that the trigger has been cancled.", // "Should have made no more calls to the workflow."); @@ -106,7 +106,7 @@ // wait(2*INTERVAL + INTERVAL_DELAY); // } // scheduler.removeWorkflow(taskName); -// Assert.assertEquals(workflow.getCallsForNextRun(), 5); -// Assert.assertEquals(workflow.getCallsForRunWorkflow(), 3); +// Assertions.assertEquals(workflow.getCallsForNextRun(), 5); +// Assertions.assertEquals(workflow.getCallsForRunWorkflow(), 3); // } //} 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 0d9530b3e..d0dc24e1c 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 @@ -23,8 +23,10 @@ import org.bitrepository.common.utils.CalendarUtils; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import javax.xml.datatype.DatatypeConstants; import javax.xml.datatype.XMLGregorianCalendar; @@ -40,37 +42,39 @@ public class FileInfoTest extends ExtendedTestCase { private static final String PILLAR_ID = "test-pillar"; private static final Long FILE_SIZE = 12345L; - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testFileInfo() { addDescription("Tests the FileInfo element. Adds all data and extracts it again."); addStep("Setup the file info.", "Should be possible to extract all the data again."); FileInfo fi = new FileInfo(FILE_ID, LAST_FILE_CHECK, CHECKSUM, FILE_SIZE, LAST_CHECKSUM_CHECK, PILLAR_ID); - Assert.assertEquals(fi.getFileId(), FILE_ID); - Assert.assertEquals(fi.getDateForLastFileIDCheck().toGregorianCalendar().getTimeInMillis(), LAST_FILE_CHECK_MILLIS); - Assert.assertEquals(fi.getChecksum(), CHECKSUM); - Assert.assertEquals(fi.getDateForLastChecksumCheck().toGregorianCalendar().getTimeInMillis(), LAST_CHECKSUM_CHECK_MILLIS); - Assert.assertEquals(fi.getPillarId(), PILLAR_ID); - Assert.assertEquals(fi.getFileSize(), FILE_SIZE); + Assertions.assertEquals(fi.getFileId(), FILE_ID); + Assertions.assertEquals(fi.getDateForLastFileIDCheck().toGregorianCalendar().getTimeInMillis(), LAST_FILE_CHECK_MILLIS); + Assertions.assertEquals(fi.getChecksum(), CHECKSUM); + Assertions.assertEquals(fi.getDateForLastChecksumCheck().toGregorianCalendar().getTimeInMillis(), LAST_CHECKSUM_CHECK_MILLIS); + Assertions.assertEquals(fi.getPillarId(), PILLAR_ID); + Assertions.assertEquals(fi.getFileSize(), FILE_SIZE); addStep("Change the checksum", "Should be possible to extract it again."); String newChecksum = "NEW-CHECKSUM"; fi.setChecksum(newChecksum); - Assert.assertNotEquals(newChecksum, CHECKSUM); - Assert.assertEquals(fi.getChecksum(), newChecksum); + Assertions.assertNotEquals(newChecksum, CHECKSUM); + Assertions.assertEquals(fi.getChecksum(), newChecksum); addStep("Change the date for last file id check", "Should be possible to extract it again."); long newLastFileMillis = 1234567; XMLGregorianCalendar newLastFileCheck = CalendarUtils.getFromMillis(newLastFileMillis); fi.setDateForLastFileIDCheck(newLastFileCheck); - Assert.assertNotEquals(DatatypeConstants.EQUAL, LAST_FILE_CHECK.compare(newLastFileCheck)); - Assert.assertEquals(fi.getDateForLastFileIDCheck().toGregorianCalendar().getTimeInMillis(), newLastFileMillis); + Assertions.assertNotEquals(DatatypeConstants.EQUAL, LAST_FILE_CHECK.compare(newLastFileCheck)); + Assertions.assertEquals(fi.getDateForLastFileIDCheck().toGregorianCalendar().getTimeInMillis(), newLastFileMillis); addStep("Change the date for last checksum check", "Should be possible to extract it again."); long newLastChecksumMillis = 7654321; XMLGregorianCalendar newLastChecksumCheck = CalendarUtils.getFromMillis(newLastChecksumMillis); fi.setDateForLastChecksumCheck(newLastChecksumCheck); - Assert.assertNotEquals(DatatypeConstants.EQUAL, LAST_CHECKSUM_CHECK.compare(newLastChecksumCheck)); - Assert.assertEquals(fi.getDateForLastChecksumCheck().toGregorianCalendar().getTimeInMillis(), newLastChecksumMillis); + Assertions.assertNotEquals(DatatypeConstants.EQUAL, LAST_CHECKSUM_CHECK.compare(newLastChecksumCheck)); + Assertions.assertEquals(fi.getDateForLastChecksumCheck().toGregorianCalendar().getTimeInMillis(), newLastChecksumMillis); } } 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 6b66e35fa..8204fc08b 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 @@ -36,9 +36,11 @@ import org.bitrepository.integrityservice.cache.database.IntegrityDAO; import org.bitrepository.integrityservice.cache.database.IntegrityIssueIterator; import org.bitrepository.service.database.DatabaseManager; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.math.BigInteger; import java.text.ParseException; @@ -63,7 +65,7 @@ public class IntegrityDAOTest extends IntegrityDatabaseTestCase { String TEST_COLLECTIONID; public static final String EXTRA_COLLECTION = "extra-collection"; - @BeforeMethod (alwaysRun = true) + @BeforeEach @Override public void setup() throws Exception { super.setup(); @@ -91,14 +93,14 @@ protected void customizeSettings() { settings.getRepositorySettings().getCollections().getCollection().add(extraCollection); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void instantiationTest() throws Exception { addDescription("Testing the connection to the integrity database."); IntegrityDAO cache = createDAO(); - Assert.assertNotNull(cache); + Assertions.assertNotNull(cache); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void reinitialiseDatabaseTest() throws Exception { addDescription("Testing the connection to the integrity database."); addStep("Setup manually.", "Should be created."); @@ -106,7 +108,7 @@ public void reinitialiseDatabaseTest() throws Exception { settings.getReferenceSettings().getIntegrityServiceSettings().getIntegrityDatabase()); IntegrityDAO cache = new DerbyIntegrityDAO(dm.getConnector()); - Assert.assertNotNull(cache); + Assertions.assertNotNull(cache); addStep("Close the connection and create another one.", "Should not fail"); dm.getConnector().getConnection().close(); @@ -122,23 +124,25 @@ public void reinitialiseDatabaseTest() throws Exception { cache = new DerbyIntegrityDAO(newdm.getConnector()); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void initialStateExtractionTest() throws Exception { addDescription("Tests the initial state of the IntegrityModel. Should not contain any data."); IntegrityDAO cache = createDAO(); List pillersInDB = cache.getAllPillars(); - Assert.assertTrue(pillersInDB.containsAll(Arrays.asList(TEST_PILLAR_1, TEST_PILLAR_2, EXTRA_PILLAR))); - Assert.assertEquals(pillersInDB.size(), 3); + Assertions.assertTrue(pillersInDB.containsAll(Arrays.asList(TEST_PILLAR_1, TEST_PILLAR_2, EXTRA_PILLAR))); + Assertions.assertEquals(pillersInDB.size(), 3); List collectionsInDB = cache.getCollections(); - Assert.assertTrue(collectionsInDB.containsAll(Arrays.asList(TEST_COLLECTIONID, EXTRA_COLLECTION))); - Assert.assertEquals(collectionsInDB.size(), 2); + Assertions.assertTrue(collectionsInDB.containsAll(Arrays.asList(TEST_COLLECTIONID, EXTRA_COLLECTION))); + Assertions.assertEquals(collectionsInDB.size(), 2); - Assert.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(0)); - Assert.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") @Tag("integritytest") public void testCorrectDateHandling() throws ParseException { addDescription("Testing the correct ingest and extraction of file and checksum dates"); IntegrityDAO cache = createDAO(); @@ -146,11 +150,11 @@ public void testCorrectDateHandling() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT); Date summertimeTS = sdf.parse("2015-10-25T02:59:54.000+02:00"); Date summertimeUnix = new Date(1445734794000L); - Assert.assertEquals(summertimeTS, summertimeUnix); + Assertions.assertEquals(summertimeTS, summertimeUnix); Date wintertimeTS = sdf.parse("2015-10-25T02:59:54.000+01:00"); Date wintertimeUnix = new Date(1445738394000L); - Assert.assertEquals(wintertimeTS, wintertimeUnix); + Assertions.assertEquals(wintertimeTS, wintertimeUnix); FileIDsData summertimeData = getFileIDsData("summertime"); summertimeData.getFileIDsDataItems().getFileIDsDataItem().get(0) @@ -169,23 +173,26 @@ public void testCorrectDateHandling() throws ParseException { cache.updateChecksums(wintertimeCsData, TEST_PILLAR_1, TEST_COLLECTIONID); List fis = cache.getFileInfosForFile("summertime", TEST_COLLECTIONID); - Assert.assertEquals(fis.size(), 1, fis.toString()); - Assert.assertEquals( + Assertions.assertEquals(fis.size(), 1, fis.toString()); + Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(fis.get(0).getDateForLastChecksumCheck()), summertimeUnix); fis = cache.getFileInfosForFile("wintertime", TEST_COLLECTIONID); - Assert.assertEquals(fis.size(), 1, fis.toString()); - Assert.assertEquals( + Assertions.assertEquals(fis.size(), 1, fis.toString()); + Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(fis.get(0).getDateForLastChecksumCheck()), wintertimeUnix); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") + @Tag("integritytest") public void testIngestOfFileIDsData() throws Exception { addDescription("Tests the ingesting of file ids data"); IntegrityDAO cache = createDAO(); - Assert.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(0)); - Assert.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); addStep("Create data", "Should be ingested into the database"); FileIDsData data1 = getFileIDsData(TEST_FILE_ID); @@ -194,27 +201,29 @@ public void testIngestOfFileIDsData() throws Exception { addStep("Extract the data", "Should be identical to the ingested data"); Collection fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); + Assertions.assertNotNull(fileinfos); for(FileInfo fi : fileinfos) { - Assert.assertEquals(fi.getFileId(), TEST_FILE_ID); - Assert.assertNull(fi.getChecksum()); - Assert.assertEquals(fi.getDateForLastChecksumCheck(), CalendarUtils.getEpoch()); - Assert.assertEquals(fi.getDateForLastFileIDCheck(), data1.getFileIDsDataItems().getFileIDsDataItem().get(0).getLastModificationTime()); - Assert.assertEquals(fi.getFileSize(), Long.valueOf(data1.getFileIDsDataItems().getFileIDsDataItem().get(0).getFileSize().longValue())); + Assertions.assertEquals(fi.getFileId(), TEST_FILE_ID); + Assertions.assertNull(fi.getChecksum()); + Assertions.assertEquals(fi.getDateForLastChecksumCheck(), CalendarUtils.getEpoch()); + Assertions.assertEquals(fi.getDateForLastFileIDCheck(), data1.getFileIDsDataItems().getFileIDsDataItem().get(0).getLastModificationTime()); + Assertions.assertEquals(fi.getFileSize(), Long.valueOf(data1.getFileIDsDataItems().getFileIDsDataItem().get(0).getFileSize().longValue())); } addStep("Check that the extra collection is untouched by the ingest", "should deliver an empty collection and no errors"); - Assert.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(1)); - Assert.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(1)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") @Tag("integritytest") public void testIngestOfChecksumsData() throws Exception { addDescription("Tests the ingesting of checksums data"); IntegrityDAO cache = createDAO(); - Assert.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(0)); - Assert.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); addStep("Create data", "Should be ingested into the database"); List csData = getChecksumResults(TEST_FILE_ID, TEST_CHECKSUM); @@ -223,28 +232,29 @@ public void testIngestOfChecksumsData() throws Exception { addStep("Extract the data", "Should be identical to the ingested data"); Collection fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); + Assertions.assertNotNull(fileinfos); for(FileInfo fi : fileinfos) { - Assert.assertEquals(fi.getFileId(), TEST_FILE_ID); - Assert.assertEquals(fi.getChecksum(), TEST_CHECKSUM); - Assert.assertEquals(fi.getDateForLastChecksumCheck(), csData.get(0).getCalculationTimestamp()); + Assertions.assertEquals(fi.getFileId(), TEST_FILE_ID); + Assertions.assertEquals(fi.getChecksum(), TEST_CHECKSUM); + Assertions.assertEquals(fi.getDateForLastChecksumCheck(), csData.get(0).getCalculationTimestamp()); } addStep("Check that the extra collection is untouched by the ingest", "should deliver an empty collection and no errors"); - Assert.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(1)); - Assert.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(1)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testDeletingEntry() throws Exception { addDescription("Tests the deletion of an FileID entry from a collection. " + "Checks that it does not effect another collection with a fileID equal to the deleted"); IntegrityDAO cache = createDAO(); Collection fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 0); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 0); addStep("Create data", "Should be ingested into the database"); FileIDsData data1 = getFileIDsData(TEST_FILE_ID); @@ -256,32 +266,32 @@ public void testDeletingEntry() throws Exception { addStep("Ensure that the data is present", "the data is present"); fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 2); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 2); fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, EXTRA_COLLECTION); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 2); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 2); addStep("Delete the entry for the first pillar", "No fileinfos should be extracted from the pillar in the collection."); cache.removeFile(TEST_COLLECTIONID, TEST_PILLAR_1, TEST_FILE_ID); List fis = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fis); - Assert.assertEquals(fis.size(), 1); - Assert.assertEquals(fis.get(0).getPillarId(), TEST_PILLAR_2); + Assertions.assertNotNull(fis); + Assertions.assertEquals(fis.size(), 1); + Assertions.assertEquals(fis.get(0).getPillarId(), TEST_PILLAR_2); addStep("Delete the entry for the second pillar", "No fileinfos should be extracted from the collection."); cache.removeFile(TEST_COLLECTIONID, TEST_PILLAR_2, TEST_FILE_ID); fis = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fis); - Assert.assertEquals(fis.size(), 0); + Assertions.assertNotNull(fis); + Assertions.assertEquals(fis.size(), 0); addStep("Check that the data in the extra collection is still present", "the data is present"); fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, EXTRA_COLLECTION); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 2); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 2); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testDeletingNonExistingEntry() throws Exception { addDescription("Tests the deletion of an nonexisting FileID entry."); IntegrityDAO cache = createDAO(); @@ -294,22 +304,22 @@ public void testDeletingNonExistingEntry() throws Exception { cache.updateFileIDs(data1, TEST_PILLAR_2, TEST_COLLECTIONID); Collection fileinfos = cache.getFileInfosForFile(nonexistingFileEntry, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 0); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 0); fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 2); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 2); addStep("Delete a nonexisting entry", "Should not change the state of the database."); cache.removeFile(TEST_COLLECTIONID, TEST_PILLAR_1, nonexistingFileEntry); cache.removeFile(TEST_COLLECTIONID, TEST_PILLAR_2, nonexistingFileEntry); fileinfos = cache.getFileInfosForFile(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 2); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 2); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testFindOrphanFiles() throws Exception { addDescription("Tests the ability to find orphan files."); IntegrityDAO cache = createDAO(); @@ -323,8 +333,8 @@ public void testFindOrphanFiles() throws Exception { cache.updateFileIDs(data1, TEST_PILLAR_2, TEST_COLLECTIONID); cache.updateFileIDs(data3, TEST_PILLAR_1, TEST_COLLECTIONID); cache.updateFileIDs(data3, TEST_PILLAR_2, TEST_COLLECTIONID); - Assert.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(2)); - Assert.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), Long.valueOf(2)); + Assertions.assertEquals(cache.getNumberOfFilesInCollection(EXTRA_COLLECTION), Long.valueOf(0)); Thread.sleep(100); Date updateTime = new Date(); cache.updateFileIDs(data1, TEST_PILLAR_1, TEST_COLLECTIONID); @@ -333,13 +343,13 @@ public void testFindOrphanFiles() throws Exception { List orphanFilesPillar1 = getIssuesFromIterator(cache.getOrphanFilesOnPillar(TEST_COLLECTIONID, TEST_PILLAR_1, updateTime)); - Assert.assertEquals(orphanFilesPillar1.size(), 0); + Assertions.assertEquals(orphanFilesPillar1.size(), 0); List orphanFilesPillar2 = getIssuesFromIterator(cache.getOrphanFilesOnPillar(TEST_COLLECTIONID, TEST_PILLAR_2, updateTime)); - Assert.assertEquals(orphanFilesPillar2.size(), 1); + Assertions.assertEquals(orphanFilesPillar2.size(), 1); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testFindInconsistentChecksum() throws Exception { addDescription("Testing the localization of inconsistent checksums"); IntegrityDAO cache = createDAO(); @@ -372,10 +382,10 @@ public void testFindInconsistentChecksum() throws Exception { addStep("Find the files with inconsistent checksums", "Bad file 1 and 2"); List filesWithChecksumError = getIssuesFromIterator(cache.findFilesWithChecksumInconsistencies(TEST_COLLECTIONID)); - Assert.assertEquals(filesWithChecksumError, Arrays.asList(BAD_FILE_ID_1, BAD_FILE_ID_2)); + Assertions.assertEquals(filesWithChecksumError, Arrays.asList(BAD_FILE_ID_1, BAD_FILE_ID_2)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testNoChecksums() throws Exception { addDescription("Testing the checksum validation, when no checksums exists."); IntegrityDAO cache = createDAO(); @@ -389,10 +399,10 @@ public void testNoChecksums() throws Exception { addStep("Finding the files with inconsistent checksums", "No checksum thus no errors"); List filesWithChecksumError = getIssuesFromIterator(cache.findFilesWithChecksumInconsistencies(TEST_COLLECTIONID)); - Assert.assertEquals(filesWithChecksumError, Collections.emptyList()); + Assertions.assertEquals(filesWithChecksumError, Collections.emptyList()); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testMissingChecksums() throws Exception { addDescription("Testing the checksum validation, when only one pillar has a checksum for a file."); IntegrityDAO cache = createDAO(); @@ -407,17 +417,17 @@ public void testMissingChecksums() throws Exception { addStep("Finding the files with inconsistent checksums", "No checksum thus no errors"); List filesWithChecksumError = getIssuesFromIterator(cache.findFilesWithChecksumInconsistencies(TEST_COLLECTIONID)); - Assert.assertEquals(filesWithChecksumError, Collections.emptyList()); + Assertions.assertEquals(filesWithChecksumError, Collections.emptyList()); List fileWithMissingChecksumPillar1 = getIssuesFromIterator(cache.getFilesWithMissingChecksums(TEST_COLLECTIONID, TEST_PILLAR_1, testStart)); - Assert.assertEquals(fileWithMissingChecksumPillar1, Collections.emptyList()); + Assertions.assertEquals(fileWithMissingChecksumPillar1, Collections.emptyList()); List fileWithMissingChecksumPillar2 = getIssuesFromIterator(cache.getFilesWithMissingChecksums(TEST_COLLECTIONID, TEST_PILLAR_2, testStart)); - Assert.assertEquals(fileWithMissingChecksumPillar2, Collections.singletonList(TEST_FILE_ID)); + Assertions.assertEquals(fileWithMissingChecksumPillar2, Collections.singletonList(TEST_FILE_ID)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testMissingChecksumsChecksumNotUpdated() throws Exception { addDescription("Testing the checksum validation, when only one pillar has a checksum for a file."); IntegrityDAO cache = createDAO(); @@ -433,14 +443,14 @@ public void testMissingChecksumsChecksumNotUpdated() throws Exception { addStep("Finding the files with inconsistent checksums", "No checksum thus no errors"); List filesWithChecksumError = getIssuesFromIterator(cache.findFilesWithChecksumInconsistencies(TEST_COLLECTIONID)); - Assert.assertEquals(filesWithChecksumError, Collections.emptyList()); + Assertions.assertEquals(filesWithChecksumError, Collections.emptyList()); List fileWithMissingChecksumPillar1 = getIssuesFromIterator(cache.getFilesWithMissingChecksums(TEST_COLLECTIONID, TEST_PILLAR_1, testStart)); - Assert.assertEquals(fileWithMissingChecksumPillar1, Collections.emptyList()); + Assertions.assertEquals(fileWithMissingChecksumPillar1, Collections.emptyList()); List fileWithMissingChecksumPillar2 = getIssuesFromIterator(cache.getFilesWithMissingChecksums(TEST_COLLECTIONID, TEST_PILLAR_2, testStart)); - Assert.assertEquals(fileWithMissingChecksumPillar2, Collections.emptyList()); + Assertions.assertEquals(fileWithMissingChecksumPillar2, Collections.emptyList()); addStep("Updating the checksum for one pillar, and checking that the other pillars checksum is now missing", "The second pillar is reported to be missing the checksum for the file"); @@ -449,18 +459,18 @@ public void testMissingChecksumsChecksumNotUpdated() throws Exception { cache.updateChecksums(getChecksumResults(TEST_FILE_ID, TEST_CHECKSUM), TEST_PILLAR_1, TEST_COLLECTIONID); addStep("Finding the files with inconsistent checksums", "No checksum thus no errors"); filesWithChecksumError = getIssuesFromIterator(cache.findFilesWithChecksumInconsistencies(TEST_COLLECTIONID)); - Assert.assertEquals(filesWithChecksumError, Collections.emptyList()); + Assertions.assertEquals(filesWithChecksumError, Collections.emptyList()); fileWithMissingChecksumPillar1 = getIssuesFromIterator(cache.getFilesWithMissingChecksums(TEST_COLLECTIONID, TEST_PILLAR_1, secondUpdate)); - Assert.assertEquals(fileWithMissingChecksumPillar1, Collections.emptyList()); + Assertions.assertEquals(fileWithMissingChecksumPillar1, Collections.emptyList()); fileWithMissingChecksumPillar2 = getIssuesFromIterator(cache.getFilesWithMissingChecksums(TEST_COLLECTIONID, TEST_PILLAR_2, secondUpdate)); - Assert.assertEquals(fileWithMissingChecksumPillar2, Collections.singletonList(TEST_FILE_ID)); + Assertions.assertEquals(fileWithMissingChecksumPillar2, Collections.singletonList(TEST_FILE_ID)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testOutdatedChecksums() throws Exception { addDescription("Testing the checksum validation, when only one pillar has a checksum for a file."); IntegrityDAO cache = createDAO(); @@ -480,18 +490,18 @@ public void testOutdatedChecksums() throws Exception { addStep("Finding the files with inconsistent checksums", "No checksum thus no errors"); List filesWithChecksumError = getIssuesFromIterator(cache.findFilesWithChecksumInconsistencies(TEST_COLLECTIONID)); - Assert.assertEquals(filesWithChecksumError, Collections.emptyList()); + Assertions.assertEquals(filesWithChecksumError, Collections.emptyList()); List fileWithOutdatedChecksumsPillar1 = getIssuesFromIterator(cache.getFilesWithOutdatedChecksums(TEST_COLLECTIONID, TEST_PILLAR_1, maxDate)); - Assert.assertEquals(fileWithOutdatedChecksumsPillar1, Collections.emptyList()); + Assertions.assertEquals(fileWithOutdatedChecksumsPillar1, Collections.emptyList()); List fileWithOutdatedChecksumPillar2 = getIssuesFromIterator(cache.getFilesWithOutdatedChecksums(TEST_COLLECTIONID, TEST_PILLAR_2, maxDate)); - Assert.assertEquals(fileWithOutdatedChecksumPillar2, Collections.singletonList(TEST_FILE_ID)); + Assertions.assertEquals(fileWithOutdatedChecksumPillar2, Collections.singletonList(TEST_FILE_ID)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testExtractingAllKnownFilesForPillars() throws Exception { addDescription("Tests that known files can be extracted for specific pillars."); IntegrityDAO cache = createDAO(); @@ -506,26 +516,26 @@ public void testExtractingAllKnownFilesForPillars() throws Exception { addStep("Extract all the existing file ids for the pillar for collection '" + TEST_COLLECTIONID + "'", "Both file ids is found."); IntegrityIssueIterator it = cache.getAllFileIDsOnPillar(TEST_COLLECTIONID, TEST_PILLAR_1, 0L, Long.MAX_VALUE); Collection fileIDs = getIssuesFromIterator(it); - Assert.assertEquals(fileIDs.size(), 2, "Number of files: " + fileIDs.size()); - Assert.assertTrue(fileIDs.contains(TEST_FILE_ID)); - Assert.assertTrue(fileIDs.contains(file2)); - Assert.assertFalse(fileIDs.contains(file3)); + Assertions.assertEquals(fileIDs.size(), 2, "Number of files: " + fileIDs.size()); + Assertions.assertTrue(fileIDs.contains(TEST_FILE_ID)); + Assertions.assertTrue(fileIDs.contains(file2)); + Assertions.assertFalse(fileIDs.contains(file3)); addStep("Extract the single fileID for the extra collection", "Only the one file id exists"); it = cache.getAllFileIDsOnPillar(EXTRA_COLLECTION, TEST_PILLAR_1, 0L, Long.MAX_VALUE); fileIDs = getIssuesFromIterator(it); - Assert.assertEquals(fileIDs.size(), 1, "Number of files: " + fileIDs.size()); - Assert.assertTrue(fileIDs.contains(file3)); - Assert.assertFalse(fileIDs.contains(file2)); - Assert.assertFalse(fileIDs.contains(TEST_FILE_ID)); + Assertions.assertEquals(fileIDs.size(), 1, "Number of files: " + fileIDs.size()); + Assertions.assertTrue(fileIDs.contains(file3)); + Assertions.assertFalse(fileIDs.contains(file2)); + Assertions.assertFalse(fileIDs.contains(TEST_FILE_ID)); addStep("Extract all the existing file ids for another pillar", "No files are found."); it = cache.getAllFileIDsOnPillar(TEST_COLLECTIONID, TEST_PILLAR_2, 0L, Long.MAX_VALUE); fileIDs = getIssuesFromIterator(it); - Assert.assertTrue(fileIDs.isEmpty()); + Assertions.assertTrue(fileIDs.isEmpty()); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testExtractingAllKnownFilesForPillarsLimits() throws Exception { addDescription("Tests the limits for extracting files for specific pillars."); IntegrityDAO cache = createDAO(); @@ -537,17 +547,17 @@ public void testExtractingAllKnownFilesForPillarsLimits() throws Exception { addStep("Extract with a maximum of 1", "The first file."); IntegrityIssueIterator it = cache.getAllFileIDsOnPillar(TEST_COLLECTIONID, TEST_PILLAR_1, 0L, 1L); Collection fileIDs = getIssuesFromIterator(it); - Assert.assertEquals(fileIDs.size(), 1); - Assert.assertTrue(fileIDs.contains(TEST_FILE_ID)); + Assertions.assertEquals(fileIDs.size(), 1); + Assertions.assertTrue(fileIDs.contains(TEST_FILE_ID)); addStep("Extract with a minimum of 1 and maximum of infinite", "The last file."); it = cache.getAllFileIDsOnPillar(TEST_COLLECTIONID, TEST_PILLAR_1, 1L, Long.MAX_VALUE); fileIDs = getIssuesFromIterator(it); - Assert.assertEquals(fileIDs.size(), 1); - Assert.assertTrue(fileIDs.contains(file2)); + Assertions.assertEquals(fileIDs.size(), 1); + Assertions.assertTrue(fileIDs.contains(file2)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testExtractingAllMissingFiles() throws Exception { addDescription("Tests that missing files can be extracted."); IntegrityDAO cache = createDAO(); @@ -561,18 +571,18 @@ public void testExtractingAllMissingFiles() throws Exception { addStep("Check the number of files in collection and on pillars", "The collection should have two files, the first pillar two, the second one"); - Assert.assertEquals((long) cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), 2); + Assertions.assertEquals((long) cache.getNumberOfFilesInCollection(TEST_COLLECTIONID), 2); Map metrics = cache.getPillarCollectionMetrics(TEST_COLLECTIONID); - Assert.assertEquals(metrics.get(TEST_PILLAR_1).getPillarFileCount(), 2); - Assert.assertEquals(metrics.get(TEST_PILLAR_2).getPillarFileCount(), 1); + Assertions.assertEquals(metrics.get(TEST_PILLAR_1).getPillarFileCount(), 2); + Assertions.assertEquals(metrics.get(TEST_PILLAR_2).getPillarFileCount(), 1); addStep("Extract missing files", "one file should be missing"); List missingFiles = getIssuesFromIterator(cache.findFilesWithMissingCopies(TEST_COLLECTIONID, 2, 0L, 10L)); - Assert.assertEquals(missingFiles, Collections.singletonList(file2)); + Assertions.assertEquals(missingFiles, Collections.singletonList(file2)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testExtractingAllMissingFilesForPillarsLimits() throws Exception { addDescription("Tests the limits for extracting missing files for specific pillars."); IntegrityDAO cache = createDAO(); @@ -587,25 +597,25 @@ public void testExtractingAllMissingFilesForPillarsLimits() throws Exception { addStep("Extract with a maximum of 1", "The first file."); IntegrityIssueIterator it = cache.findFilesWithMissingCopies(TEST_COLLECTIONID, 2, 0L, 1L); Collection fileIDs = getIssuesFromIterator(it); - Assert.assertEquals(fileIDs.size(), 1); - Assert.assertTrue(fileIDs.contains(file2)); + Assertions.assertEquals(fileIDs.size(), 1); + Assertions.assertTrue(fileIDs.contains(file2)); addStep("Extract with a minimum of 1 and maximum of infinite", "The last file."); it = cache.findFilesWithMissingCopies(TEST_COLLECTIONID, 2, 1L, Long.MAX_VALUE); fileIDs = getIssuesFromIterator(it); - Assert.assertEquals(fileIDs.size(), 1); - Assert.assertTrue(fileIDs.contains(file3)); + Assertions.assertEquals(fileIDs.size(), 1); + Assertions.assertTrue(fileIDs.contains(file3)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testGetLatestFileDateEntryForCollection() throws Exception { addDescription("Tests that checksum date entries can be retrieved and manipulated."); IntegrityDAO cache = createDAO(); addStep("Create data", "Should be ingested into the database"); - Assert.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_1)); - Assert.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2)); + Assertions.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_1)); + Assertions.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2)); FileIDsData fidsPillar1 = getFileIDsData(TEST_FILE_ID); Date expectedLatestFileDatePillar1 = CalendarUtils.convertFromXMLGregorianCalendar( @@ -618,40 +628,40 @@ public void testGetLatestFileDateEntryForCollection() throws Exception { .setLastModificationTime(CalendarUtils.getXmlGregorianCalendar(expectedLatestFileDatePillar2)); cache.updateFileIDs(fidsPillar2, TEST_PILLAR_2, TEST_COLLECTIONID); - Assert.assertEquals(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_1), expectedLatestFileDatePillar1); - Assert.assertEquals(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2), expectedLatestFileDatePillar2); + Assertions.assertEquals(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_1), expectedLatestFileDatePillar1); + Assertions.assertEquals(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2), expectedLatestFileDatePillar2); - Assert.assertEquals(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2), + Assertions.assertEquals(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2), cache.getLatestFileDateInCollection(TEST_COLLECTIONID)); cache.resetFileCollectionProgress(TEST_COLLECTIONID); - Assert.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_1)); - Assert.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2)); + Assertions.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_1)); + Assertions.assertNull(cache.getLatestFileDate(TEST_COLLECTIONID, TEST_PILLAR_2)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testGetLatestChecksumDateEntryForCollection() throws Exception { addDescription("Tests that checksum date entries can be retrieved and manipulated."); IntegrityDAO cache = createDAO(); addStep("Create data", "Should be ingested into the database"); - Assert.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_1)); - Assert.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_2)); + Assertions.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_1)); + Assertions.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_2)); List csData = getChecksumResults(TEST_FILE_ID, TEST_CHECKSUM); cache.updateChecksums(csData, TEST_PILLAR_1, TEST_COLLECTIONID); cache.updateChecksums(csData, TEST_PILLAR_2, TEST_COLLECTIONID); Date expectedLatestChecksum = CalendarUtils.convertFromXMLGregorianCalendar(csData.get(0).getCalculationTimestamp()); - Assert.assertEquals(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_1), expectedLatestChecksum); - Assert.assertEquals(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_2), expectedLatestChecksum); + Assertions.assertEquals(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_1), expectedLatestChecksum); + Assertions.assertEquals(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_2), expectedLatestChecksum); cache.resetChecksumCollectionProgress(TEST_COLLECTIONID); - Assert.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_1)); - Assert.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_2)); + Assertions.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_1)); + Assertions.assertNull(cache.getLatestChecksumDate(TEST_COLLECTIONID, TEST_PILLAR_2)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testExtractCollectionFileSize() throws Exception { addDescription("Tests that the accumulated size of the collection can be extracted"); IntegrityDAO cache = createDAO(); @@ -676,20 +686,20 @@ public void testExtractCollectionFileSize() throws Exception { Map metrics = cache.getPillarCollectionMetrics(TEST_COLLECTIONID); addStep("Check the reported size of the first pillar in the collection", "The reported size matches the precalculated"); - Assert.assertEquals(metrics.get(TEST_PILLAR_1).getPillarCollectionSize(), pillar1Size); + Assertions.assertEquals(metrics.get(TEST_PILLAR_1).getPillarCollectionSize(), pillar1Size); addStep("Check the reported size of the second pillar in the collection", "The reported size matches the precalculated"); - Assert.assertEquals(metrics.get(TEST_PILLAR_2).getPillarCollectionSize(), pillar2Size); + Assertions.assertEquals(metrics.get(TEST_PILLAR_2).getPillarCollectionSize(), pillar2Size); addStep("Check the reported size of the whole collection", "The reported size matches the precalculated"); - Assert.assertEquals(cache.getCollectionSize(TEST_COLLECTIONID), collectionSize); + Assertions.assertEquals(cache.getCollectionSize(TEST_COLLECTIONID), collectionSize); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testGetFileIDAtIndex() throws Exception { addDescription("Tests that a fileID at a given index can be extracted."); IntegrityDAO cache = createDAO(); addStep("Extract a fileID from the empty database", "Returns a null"); - Assert.assertNull(cache.getFileIdAtIndex(TEST_COLLECTIONID, 0L)); + Assertions.assertNull(cache.getFileIdAtIndex(TEST_COLLECTIONID, 0L)); addStep("Insert test data into database", "Data is ingested"); FileIDsData data = makeFileIDsDataWithGivenFileSize(TEST_FILE_ID, 100L); @@ -697,10 +707,10 @@ public void testGetFileIDAtIndex() throws Exception { cache.updateFileIDs(data, TEST_PILLAR_2, TEST_COLLECTIONID); addStep("Extract the first fileID", "The inserted fileID"); - Assert.assertEquals(cache.getFileIdAtIndex(TEST_COLLECTIONID, 0L), TEST_FILE_ID); + Assertions.assertEquals(cache.getFileIdAtIndex(TEST_COLLECTIONID, 0L), TEST_FILE_ID); addStep("Extract a fileID at an incomprehendable index from the database", "Returns a null"); - Assert.assertNull(cache.getFileIdAtIndex(TEST_COLLECTIONID, Long.MAX_VALUE)); + Assertions.assertNull(cache.getFileIdAtIndex(TEST_COLLECTIONID, Long.MAX_VALUE)); } private FileIDsData makeFileIDsDataWithGivenFileSize(String fileID, Long size) { 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 b834bbd73..d16bbe660 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 @@ -35,16 +35,17 @@ import org.bitrepository.integrityservice.cache.database.IntegrityDBTools; import org.bitrepository.service.database.DBConnector; import org.bitrepository.service.database.DatabaseManager; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.math.BigInteger; import java.util.ArrayList; import java.util.List; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; +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 { @@ -55,7 +56,7 @@ public class IntegrityDBToolsTest extends IntegrityDatabaseTestCase { String TEST_FILE_ID = "TEST-FILE-ID"; String TEST_COLLECTIONID; - @BeforeMethod (alwaysRun = true) + @BeforeEach @Override public void setup() throws Exception { super.setup(); @@ -83,7 +84,7 @@ protected void customizeSettings() { settings.getRepositorySettings().getCollections().getCollection().add(extraCollection); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testAddCollectionSuccess() { addDescription("Tests that a new collection can be added to the integrity database"); String newCollectionID = "new-collectionid"; @@ -106,7 +107,7 @@ public void testAddCollectionSuccess() { assertTrue(collections.contains(newCollectionID)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testAddExistingCollection() { addDescription("Tests that an existing collectionID cannot be added to the integrity database."); DatabaseManager dm = new IntegrityDatabaseManager( @@ -131,7 +132,9 @@ public void testAddExistingCollection() { assertTrue(collections.contains(EXTRA_COLLECTION)); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") @Tag("integritytest") public void testRemoveNonExistingCollection() { addDescription("Tests that a non existing collection can't be removed from the integrity database."); String nonExistingCollectionID = "non-existing-collectionid"; @@ -158,7 +161,7 @@ public void testRemoveNonExistingCollection() { assertTrue(collections.contains(EXTRA_COLLECTION)); } - /*@Test(groups = {"regressiontest", "databasetest", "integritytest"}) + /*@Test @Tag("regressiontest", "databasetest", "integritytest"}) public void testRemoveExistingCollection() { addDescription("Tests the removal of an existing collection and references to it in the integrity database"); DatabaseManager dm = new IntegrityDatabaseManager( 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 593b6258c..c817b1257 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 @@ -35,9 +35,11 @@ import org.bitrepository.integrityservice.IntegrityDatabaseTestCase; import org.bitrepository.integrityservice.cache.database.IntegrityIssueIterator; import org.bitrepository.service.audit.AuditTrailManager; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.math.BigInteger; import java.util.ArrayList; @@ -58,7 +60,7 @@ public class IntegrityDatabaseTest extends IntegrityDatabaseTestCase { String TEST_COLLECTIONID; - @BeforeMethod (alwaysRun = true) + @BeforeEach @Override public void setup() throws Exception { super.setup(); @@ -77,14 +79,15 @@ protected void customizeSettings() { settings.getRepositorySettings().getCollections().getCollection().add(c0); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void instantiationTest() { addDescription("Tests that the connection can be instantaited."); IntegrityDatabase integrityCache = new IntegrityDatabase(settings); - Assert.assertNotNull(integrityCache); + Assertions.assertNotNull(integrityCache); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void initialStateExtractionTest() { addDescription("Tests the initial state of the IntegrityModel. Should not contain any data."); IntegrityModel model = new IntegrityDatabase(settings); @@ -92,37 +95,37 @@ public void initialStateExtractionTest() { addStep("Test the 'findChecksumsOlderThan'", "Should deliver an empty collection"); Collection oldChecksums = getIssuesFromIterator(model.findChecksumsOlderThan( new Date(0), TEST_PILLAR_1, TEST_COLLECTIONID)); - Assert.assertNotNull(oldChecksums); - Assert.assertEquals(oldChecksums.size(), 0); + Assertions.assertNotNull(oldChecksums); + Assertions.assertEquals(oldChecksums.size(), 0); addStep("Test the 'findMissingChecksums'", "Should deliver an empty collection"); for(String pillar : SettingsUtils.getPillarIDsForCollection(TEST_COLLECTIONID)) { Collection missingChecksums = getIssuesFromIterator(model.findFilesWithMissingChecksum(TEST_COLLECTIONID, pillar, new Date(0))); - Assert.assertNotNull(missingChecksums); - Assert.assertEquals(missingChecksums.size(), 0); + Assertions.assertNotNull(missingChecksums); + Assertions.assertEquals(missingChecksums.size(), 0); } addStep("Test the 'findMissingFiles'", "Should deliver an empty collection"); Collection missingFiles = getIssuesFromIterator(model.findFilesWithMissingCopies(TEST_COLLECTIONID, SettingsUtils.getPillarIDsForCollection(TEST_COLLECTIONID).size(), 0L, Long.MAX_VALUE)); - Assert.assertNotNull(missingFiles); - Assert.assertEquals(missingFiles.size(), 0); + Assertions.assertNotNull(missingFiles); + Assertions.assertEquals(missingFiles.size(), 0); addStep("Test the 'getAllFileIDs'", "Should deliver an empty collection"); - Assert.assertEquals(model.getNumberOfFilesInCollection(TEST_COLLECTIONID), 0); + Assertions.assertEquals(model.getNumberOfFilesInCollection(TEST_COLLECTIONID), 0); addStep("Test the 'getFileInfos'", "Should deliver an empty collection"); Collection fileInfos = model.getFileInfos(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileInfos); - Assert.assertEquals(fileInfos.size(), 0); + Assertions.assertNotNull(fileInfos); + Assertions.assertEquals(fileInfos.size(), 0); addStep("Test the 'getPillarCollectionMetrics'", "The set of metrics should be empty."); Map metrics = model.getPillarCollectionMetrics(TEST_COLLECTIONID); - Assert.assertTrue(metrics.isEmpty()); + Assertions.assertTrue(metrics.isEmpty()); } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testIngestOfFileIDsData() { addDescription("Tests the ingesting of file ids data"); IntegrityModel model = new IntegrityDatabase(settings); @@ -134,16 +137,16 @@ public void testIngestOfFileIDsData() { addStep("Extract the data", "Should be identical to the ingested data"); Collection fileinfos = model.getFileInfos(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); + Assertions.assertNotNull(fileinfos); for(FileInfo fi : fileinfos) { - Assert.assertEquals(fi.getFileId(), TEST_FILE_ID); - Assert.assertNull(fi.getChecksum()); - Assert.assertEquals(fi.getDateForLastChecksumCheck(), CalendarUtils.getEpoch()); - Assert.assertEquals(fi.getDateForLastFileIDCheck(), data1.getFileIDsDataItems().getFileIDsDataItem().get(0).getLastModificationTime()); + Assertions.assertEquals(fi.getFileId(), TEST_FILE_ID); + Assertions.assertNull(fi.getChecksum()); + Assertions.assertEquals(fi.getDateForLastChecksumCheck(), CalendarUtils.getEpoch()); + Assertions.assertEquals(fi.getDateForLastFileIDCheck(), data1.getFileIDsDataItems().getFileIDsDataItem().get(0).getLastModificationTime()); } } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testIngestOfChecksumsData() { addDescription("Tests the ingesting of checksums data"); IntegrityModel model = new IntegrityDatabase(settings); @@ -155,15 +158,15 @@ public void testIngestOfChecksumsData() { addStep("Extract the data", "Should be identical to the ingested data"); Collection fileinfos = model.getFileInfos(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); + Assertions.assertNotNull(fileinfos); for(FileInfo fi : fileinfos) { - Assert.assertEquals(fi.getFileId(), TEST_FILE_ID); - Assert.assertEquals(fi.getChecksum(), TEST_CHECKSUM); - Assert.assertEquals(fi.getDateForLastChecksumCheck(), csData.get(0).getCalculationTimestamp()); + Assertions.assertEquals(fi.getFileId(), TEST_FILE_ID); + Assertions.assertEquals(fi.getChecksum(), TEST_CHECKSUM); + Assertions.assertEquals(fi.getDateForLastChecksumCheck(), csData.get(0).getCalculationTimestamp()); } } - @Test(groups = {"regressiontest", "databasetest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("databasetest") @Tag("integritytest") public void testDeletingEntry() { addDescription("Tests the deletion of an FileID entry."); IntegrityModel model = new IntegrityDatabase(settings); @@ -174,18 +177,18 @@ public void testDeletingEntry() { model.addFileIDs(data1, TEST_PILLAR_2, TEST_COLLECTIONID); Collection fileinfos = model.getFileInfos(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 2); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 2); addStep("Delete the entry", "No fileinfos should be extracted."); model.deleteFileIdEntry(TEST_COLLECTIONID, TEST_PILLAR_1, TEST_FILE_ID); fileinfos = model.getFileInfos(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 1); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 1); model.deleteFileIdEntry(TEST_COLLECTIONID, TEST_PILLAR_2, TEST_FILE_ID); fileinfos = model.getFileInfos(TEST_FILE_ID, TEST_COLLECTIONID); - Assert.assertNotNull(fileinfos); - Assert.assertEquals(fileinfos.size(), 0); + Assertions.assertNotNull(fileinfos); + Assertions.assertEquals(fileinfos.size(), 0); } private List getChecksumResults(String fileID, String checksum) { 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 93fd86f83..9de994dd0 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 @@ -23,25 +23,27 @@ import org.bitrepository.settings.referencesettings.ObsoleteChecksumSettings; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import java.time.Duration; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class MaxChecksumAgeProviderTest extends ExtendedTestCase{ DatatypeFactory factory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUpFactory() throws DatatypeConfigurationException { factory = DatatypeFactory.newInstance(); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testNoSettings() { addDescription("Test the MaxChecksumAge when no settings are defined"); addStep("Create a MaxChecksumAgeProvider with null settings and a default MaxAge of 100", @@ -52,7 +54,9 @@ public void testNoSettings() { assertEquals(maxChecksumAgeProvider.getMaxChecksumAge(""), defaultMaxAge); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testNoPillarSpecificSetting() { addDescription("Test the MaxChecksumAge when no settings are defined for the specific pillar"); @@ -66,7 +70,9 @@ public void testNoPillarSpecificSetting() { assertEquals(maxChecksumAgeProvider.getMaxChecksumAge(""), Duration.ofMillis(10)); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testPillarSpecificSetting() { addDescription("Test the MaxChecksumAge when a value has been defined for specific pillars"); 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 8a379491d..9e22727d4 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 @@ -33,7 +33,9 @@ import org.bitrepository.client.eventhandler.EventHandler; import org.bitrepository.modify.putfile.PutFileClient; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import java.net.URL; import java.util.Arrays; @@ -56,7 +58,8 @@ public class IntegrityInformationCollectorTest extends ExtendedTestCase { public final static String collectionID = "dummy-collection"; public final static String fileId = "FILE_ID"; - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testCollectorGetFileIDs() throws Exception { addDescription("Tests that the collector calls the GetFileClient"); addStep("Define variables", "No errors"); @@ -86,7 +89,7 @@ public void testCollectorGetFileIDs() throws Exception { verifyNoMoreInteractions(eventHandler); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testCollectorGetChecksums() throws Exception { addDescription("Tests that the collector calls the GetChecksumsClient"); addStep("Define variables", "No errors"); @@ -121,7 +124,7 @@ public void testCollectorGetChecksums() throws Exception { } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testCollectorGetFile() throws Exception { addDescription("Tests that the collector calls the GetFileClient"); addStep("Define variables", "No errors"); @@ -149,7 +152,7 @@ public void testCollectorGetFile() throws Exception { verifyNoMoreInteractions(eventHandler); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testCollectorPutFile() throws Exception { addDescription("Tests that the collector calls the PutFileClient"); addStep("Define variables", "No errors"); @@ -180,7 +183,7 @@ public void testCollectorPutFile() throws Exception { verifyNoMoreInteractions(eventHandler); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testCollectorHandleChecksumClientFailures() throws Exception { addDescription("Test that the IntegrityInformationCollector works as a fault-barrier."); addStep("Setup variables for the test", "Should be OK"); @@ -202,7 +205,7 @@ public void testCollectorHandleChecksumClientFailures() throws Exception { collector.getChecksums(collectionID, Arrays.asList(pillarID), csType, null, auditTrailInformation, contributorQueries, null); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testCollectorHandleGetFileIDsClientFailures() throws Exception { addDescription("Test that the IntegrityInformationCollector works as a fault-barrier."); addStep("Setup variables for the test", "Should be OK"); @@ -221,7 +224,7 @@ public void testCollectorHandleGetFileIDsClientFailures() throws Exception { collector.getFileIDs(collectionID, Arrays.asList(pillarID), auditTrailInformation, contributorQueries, null); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testCollectorHandleGetFileClientFailures() throws Exception { addDescription("Test that the IntegrityInformationCollector works as a fault-barrier."); addStep("Define variables", "No errors"); @@ -241,7 +244,7 @@ public void testCollectorHandleGetFileClientFailures() throws Exception { collector.getFile(collectionID, fileId, uploadUrl, eventHandler, auditTrailInformation); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testCollectorHandlePutFileClientFailures() throws Exception { addDescription("Test that the IntegrityInformationCollector works as a fault-barrier."); addStep("Define variables", "No errors"); 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 ac9f83e44..459308129 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 @@ -55,8 +55,10 @@ import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.service.exception.WorkflowAbortedException; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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; @@ -69,6 +71,7 @@ import java.util.List; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -77,7 +80,7 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; + public class MissingChecksumTests extends ExtendedTestCase { private static final String PILLAR_1 = "pillar1"; @@ -95,7 +98,7 @@ public class MissingChecksumTests extends ExtendedTestCase { IntegrityReporter reporter; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("IntegrityCheckingUnderTest"); @@ -124,7 +127,8 @@ public void setup() throws Exception { SettingsUtils.initialize(settings); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testMissingChecksumAndStep() throws Exception { addDescription("Test that files initially are set to checksum-state unknown, and to missing in the " + "missing checksum step."); @@ -142,7 +146,7 @@ public void testMissingChecksumAndStep() throws Exception { } } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testMissingChecksumForFirstGetChecksums() throws WorkflowAbortedException { addDescription("Test that checksums are set to missing, when not found during GetChecksum."); addStep("Ingest file to database", ""); @@ -187,7 +191,7 @@ public void testMissingChecksumForFirstGetChecksums() throws WorkflowAbortedExce assertEquals(missingChecksumsPillar2.get(0), TEST_FILE_1); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testMissingChecksumDuringSecondIngest() throws WorkflowAbortedException { addDescription("Test that checksums are set to missing, when not found during GetChecksum, " + "even though they have been found before."); 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 c39fb3183..3b5bd3313 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 @@ -23,43 +23,45 @@ package org.bitrepository.integrityservice.reports; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.File; -import static org.testng.AssertJUnit.assertEquals; -import static org.testng.AssertJUnit.assertFalse; -import static org.testng.AssertJUnit.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class BasicIntegrityReporterTest extends ExtendedTestCase { private static final String REPORT_SUMMARY_START = "The following integrity issues were found:\n"; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void deletedFilesTest() throws Exception { addDescription("Verifies that the hasIntegrityIssues() reports deleted files correctly"); addStep("Report a delete file for a new Reporter", "hasIntegrityIssues() should return false and the summary " + "report should inform that no issues where found."); BasicIntegrityReporter reporter = new BasicIntegrityReporter("CollectionWithIssues", "test", new File("target/")); reporter.reportDeletedFile("TestFile", "Pillar1"); - assertFalse("Reporter interpreted delete file as a integrity issue", reporter.hasIntegrityIssues()); + assertFalse(reporter.hasIntegrityIssues(), "Reporter interpreted delete file as a integrity issue"); String expectedReport = "No integrity issues found"; assertEquals("Reporter didn't create clean report", expectedReport, reporter.generateSummaryOfReport()); reporter.generateReport(); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void noIntegrityIssuesTest() { addDescription("Verifies that missing files are reported correctly"); addStep("Create a clean reporter", "hasIntegrityIssues() should return false and the summary report should " + "state that no inform of the missing file."); BasicIntegrityReporter reporter = new BasicIntegrityReporter("CollectionWithoutIssues", "test", new File("target/")); - assertFalse("Reporter interpreted delete file as a integrity issue", reporter.hasIntegrityIssues()); + assertFalse(reporter.hasIntegrityIssues(), "Reporter interpreted delete file as a integrity issue"); String expectedReport = "No integrity issues found"; assertEquals("Reporter didn't create clean report", expectedReport, reporter.generateSummaryOfReport()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void missingFilesTest() throws Exception { addDescription("Verifies that missing files are reported correctly"); @@ -67,7 +69,7 @@ public void missingFilesTest() throws Exception { "correctly inform of the missing file."); BasicIntegrityReporter reporter = new BasicIntegrityReporter("CollectionWithIssues", "test", new File("target/")); reporter.reportMissingFile("TestFile", "Pillar1"); - assertTrue("Reporter didn't interpreted missing file as a integrity issue", reporter.hasIntegrityIssues()); + assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted missing file as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 1 file."; assertEquals("Wrong report returned on missing file", expectedReport, reporter.generateSummaryOfReport()); @@ -83,7 +85,7 @@ public void missingFilesTest() throws Exception { assertEquals("Wrong report returned on missing file", expectedReport, reporter.generateSummaryOfReport()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void checksumIssuesTest() throws Exception { addDescription("Verifies that missing files are reported correctly"); @@ -91,7 +93,7 @@ public void checksumIssuesTest() throws Exception { "correctly inform of the checksum issue."); BasicIntegrityReporter reporter = new BasicIntegrityReporter("CollectionWithIssues", "test", new File("target/")); reporter.reportChecksumIssue("TestFile", "Pillar1"); - assertTrue("Reporter didn't interpreted checksum issue as a integrity issue", reporter.hasIntegrityIssues()); + assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted checksum issue as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 has 1 potentially corrupt file."; assertEquals("Wrong report returned on checksum issue", expectedReport, reporter.generateSummaryOfReport()); @@ -109,7 +111,7 @@ public void checksumIssuesTest() throws Exception { assertEquals("Wrong report returned on checksum issue", expectedReport, reporter.generateSummaryOfReport()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void missingChecksumTest() throws Exception { addDescription("Verifies that missing checksums are reported correctly"); @@ -117,7 +119,7 @@ public void missingChecksumTest() throws Exception { "correctly inform of the missing checksum."); BasicIntegrityReporter reporter = new BasicIntegrityReporter("CollectionWithIssues", "test", new File("target/")); reporter.reportMissingChecksum("TestChecksum", "Pillar1"); - assertTrue("Reporter didn't interpreted missing checksum as a integrity issue", reporter.hasIntegrityIssues()); + assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted missing checksum as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 1 checksum."; assertEquals("Wrong report returned on missing checksum", expectedReport, reporter.generateSummaryOfReport()); @@ -135,7 +137,7 @@ public void missingChecksumTest() throws Exception { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void obsoleteChecksumTest() throws Exception { addDescription("Verifies that obsolete checksums are reported correctly"); @@ -143,7 +145,7 @@ public void obsoleteChecksumTest() throws Exception { "correctly inform of the obsolete checksum."); BasicIntegrityReporter reporter = new BasicIntegrityReporter("CollectionWithIssues", "test", new File("target/")); reporter.reportObsoleteChecksum("TestChecksum", "Pillar1"); - assertTrue("Reporter didn't interpreted obsolete checksum as a integrity issue", reporter.hasIntegrityIssues()); + assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted obsolete checksum as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 has 1 obsolete checksum."; assertEquals("Wrong report returned on obsolete checksum", expectedReport, reporter.generateSummaryOfReport()); 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 4d69a810b..280fc8c05 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 @@ -22,7 +22,8 @@ package org.bitrepository.integrityservice.reports; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; + import java.io.BufferedReader; import java.io.File; 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 89f738fde..934238c97 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 @@ -37,10 +37,11 @@ import org.bitrepository.service.database.DatabaseUtils; import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.jaccept.structure.ExtendedTestCase; -import org.testng.AssertJUnit; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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; @@ -59,7 +60,7 @@ public class DatabaseStressTests extends ExtendedTestCase { protected Settings settings; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("IntegrityCheckingUnderTest"); @@ -98,18 +99,20 @@ protected void populateDatabase(IntegrityDAO cache) { cache.updateFileIDs(data, PILLAR_4, collectionID); } - @AfterMethod (alwaysRun = true) + @AfterEach public void clearDatabase() { DBConnector connector = new DBConnector(settings.getReferenceSettings().getIntegrityServiceSettings().getIntegrityDatabase()); DatabaseUtils.executeStatement(connector, "DELETE FROM fileinfo"); DatabaseUtils.executeStatement(connector, "DELETE FROM pillar"); } - @Test(groups = {"stresstest", "integritytest"}) + @Test + @Tag("stresstest") + @Tag("integritytest") public void testDatabasePerformance() { addDescription("Testing the performance of the SQL queries to the database."); IntegrityDAO cache = createDAO(); - AssertJUnit.assertNotNull(cache); + Assertions.assertNotNull(cache); long startTime = System.currentTimeMillis(); populateDatabase(cache); diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/web/PillarDetailsDtoTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/web/PillarDetailsDtoTest.java index b25ef9a33..e59acf740 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/web/PillarDetailsDtoTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/web/PillarDetailsDtoTest.java @@ -1,11 +1,11 @@ package org.bitrepository.integrityservice.web; import com.fasterxml.jackson.databind.ObjectMapper; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Test; import java.io.IOException; -import static org.testng.Assert.*; +import static org.junit.jupiter.api.Assertions.assertTrue; public class PillarDetailsDtoTest { private final ObjectMapper objectMapper = new ObjectMapper(); // Use ObjectMapper for JSON diff --git a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityContributorsTest.java b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityContributorsTest.java index cd9853a7a..f443dfc2f 100644 --- a/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityContributorsTest.java +++ b/bitrepository-integrity-service/src/test/java/org/bitrepository/integrityservice/workflow/IntegrityContributorsTest.java @@ -21,8 +21,12 @@ */ package org.bitrepository.integrityservice.workflow; -import org.testng.Assert; -import org.testng.annotations.Test; + + + +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.Arrays; import java.util.Set; @@ -33,75 +37,76 @@ public class IntegrityContributorsTest { private final static String PILLAR1 = "pillar1"; private final static String PILLAR2 = "pillar2"; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testConstructor() { IntegrityContributors ic = new IntegrityContributors(Arrays.asList(PILLAR1, PILLAR2), 3); Set activeContributors = ic.getActiveContributors(); - Assert.assertTrue(activeContributors.contains(PILLAR1)); - Assert.assertTrue(activeContributors.contains(PILLAR2)); - Assert.assertTrue(ic.getFailedContributors().isEmpty()); - Assert.assertTrue(ic.getFinishedContributors().isEmpty()); + Assertions.assertTrue(activeContributors.contains(PILLAR1)); + Assertions.assertTrue(activeContributors.contains(PILLAR2)); + Assertions.assertTrue(ic.getFailedContributors().isEmpty()); + Assertions.assertTrue(ic.getFinishedContributors().isEmpty()); } - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testFailContributor() { IntegrityContributors ic = new IntegrityContributors(Arrays.asList(PILLAR1, PILLAR2), 1); ic.failContributor(PILLAR1); - Assert.assertTrue(ic.getFailedContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getActiveContributors().contains(PILLAR2)); - Assert.assertTrue(ic.getFinishedContributors().isEmpty()); + Assertions.assertTrue(ic.getFailedContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getActiveContributors().contains(PILLAR2)); + Assertions.assertTrue(ic.getFinishedContributors().isEmpty()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testRetry() { IntegrityContributors ic = new IntegrityContributors(Arrays.asList(PILLAR1, PILLAR2), 3); ic.failContributor(PILLAR1); - Assert.assertTrue(ic.getActiveContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getFailedContributors().isEmpty()); + Assertions.assertTrue(ic.getActiveContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getFailedContributors().isEmpty()); ic.failContributor(PILLAR1); - Assert.assertTrue(ic.getActiveContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getFailedContributors().isEmpty()); + Assertions.assertTrue(ic.getActiveContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getFailedContributors().isEmpty()); ic.failContributor(PILLAR1); - Assert.assertFalse(ic.getActiveContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getFailedContributors().contains(PILLAR1)); + Assertions.assertFalse(ic.getActiveContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getFailedContributors().contains(PILLAR1)); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testSucceed() { IntegrityContributors ic = new IntegrityContributors(Arrays.asList(PILLAR1, PILLAR2), 2); ic.failContributor(PILLAR1); ic.failContributor(PILLAR2); - Assert.assertTrue(ic.getActiveContributors().containsAll(Arrays.asList(PILLAR1, PILLAR2))); + Assertions.assertTrue(ic.getActiveContributors().containsAll(Arrays.asList(PILLAR1, PILLAR2))); ic.succeedContributor(PILLAR1); ic.failContributor(PILLAR1); ic.failContributor(PILLAR2); - Assert.assertTrue(ic.getActiveContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getFailedContributors().contains(PILLAR2)); + Assertions.assertTrue(ic.getActiveContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getFailedContributors().contains(PILLAR2)); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testFinishContributor() { IntegrityContributors ic = new IntegrityContributors(Arrays.asList(PILLAR1, PILLAR2), 3); ic.finishContributor(PILLAR1); - Assert.assertTrue(ic.getFinishedContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getActiveContributors().contains(PILLAR2)); - Assert.assertTrue(ic.getFailedContributors().isEmpty()); + Assertions.assertTrue(ic.getFinishedContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getActiveContributors().contains(PILLAR2)); + Assertions.assertTrue(ic.getFailedContributors().isEmpty()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testReloadContributors() { IntegrityContributors ic = new IntegrityContributors(Arrays.asList(PILLAR1, PILLAR2), 1); ic.finishContributor(PILLAR1); ic.failContributor(PILLAR2); - Assert.assertTrue(ic.getActiveContributors().isEmpty()); - Assert.assertTrue(ic.getFinishedContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getFailedContributors().contains(PILLAR2)); + Assertions.assertTrue(ic.getActiveContributors().isEmpty()); + Assertions.assertTrue(ic.getFinishedContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getFailedContributors().contains(PILLAR2)); ic.reloadActiveContributors(); - Assert.assertTrue(ic.getFinishedContributors().isEmpty()); - Assert.assertTrue(ic.getActiveContributors().contains(PILLAR1)); - Assert.assertTrue(ic.getFailedContributors().contains(PILLAR2)); + Assertions.assertTrue(ic.getFinishedContributors().isEmpty()); + Assertions.assertTrue(ic.getActiveContributors().contains(PILLAR1)); + Assertions.assertTrue(ic.getFailedContributors().contains(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 bddd5fb37..533a7d589 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 @@ -33,20 +33,22 @@ import org.bitrepository.settings.referencesettings.WorkflowConfiguration; import org.bitrepository.settings.referencesettings.WorkflowSettings; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; +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.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; public class IntegrityWorkflowManagerTest extends ExtendedTestCase { private Settings settings; @@ -57,7 +59,7 @@ public class IntegrityWorkflowManagerTest extends ExtendedTestCase { private TestWorkflow workflow1, workflow2; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setup() throws DatatypeConfigurationException { scheduler = mock(TimerBasedScheduler.class); factory = DatatypeFactory.newInstance(); @@ -80,7 +82,7 @@ public void setup() throws DatatypeConfigurationException { workflow2 = new TestWorkflow(collection2ID); } - @Test (groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void normalWorkflowSettings() { addDescription("Verifies that the IntegrityWorkflowManager loads correctly for at normally defined workflow."); @@ -94,7 +96,8 @@ public void normalWorkflowSettings() { verifyNoMoreInteractions(scheduler); } - @Test (groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void noWorkflowPackage() { addDescription("Verifies that the IntegrityWorkflowManager loads correctly for at workflow configuration with " + "a workflow class name without a package scope (located in the default workflow package)."); @@ -110,7 +113,7 @@ public void noWorkflowPackage() { verifyNoMoreInteractions(scheduler); } - @Test (groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void noWorkflowSettings() { addDescription("Verifies that the IntegrityWorkflowManager loads correctly for missing reference settings a " + "workflow settings element."); @@ -131,7 +134,7 @@ public void noWorkflowSettings() { verifyNoMoreInteractions(scheduler); } - @Test (groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void collectionSpecificWorkflows() { addDescription("Verifies that the IntegrityWorkflowManager loads correctly for workflows configured for " + "specific collection."); @@ -159,7 +162,7 @@ public void collectionSpecificWorkflows() { verifyNoMoreInteractions(scheduler); } - @Test (groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void unscheduledWorkflow() { addDescription("Verifies that the IntegrityWorkflowManager loads workflow correctly for workflows without a " + "defined schedule meaning they are never run automatically."); @@ -175,7 +178,7 @@ public void unscheduledWorkflow() { assertEquals(manager.getRunInterval(workflow1.getJobID()), -1); } - @Test (groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void startWorkflow() { addDescription("Verifies that the that it is possible to manually start a workflow."); 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 acca352b1..7f22dac18 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 @@ -37,10 +37,13 @@ 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; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; @@ -78,7 +81,7 @@ public class RepairMissingFilesWorkflowTest extends ExtendedTestCase { protected IntegrityModel model; protected AuditTrailManager auditManager; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("IntegrityWorkflowTest"); @@ -102,7 +105,8 @@ public void setup() throws Exception { auditManager = mock(AuditTrailManager.class); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testNoMissingFiles() { addDescription("Test that the workflow does nothing, when it has no missing files."); addStep("Prepare for calls to mocks", ""); @@ -125,7 +129,7 @@ public void testNoMissingFiles() { verifyNoMoreInteractions(model); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testSuccessRepair() { addDescription("Test that the workflow makes calls to the collector, when a file is missing"); addStep("Prepare for calls to mocks to handle a repair", ""); @@ -173,7 +177,7 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(model); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testFailedGetFile() { addDescription("Test that the workflow does not try to put a file, if it fails to get it."); addStep("Prepare for calls to mocks to fail when performing get-file", ""); @@ -213,7 +217,7 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(model); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testFailedPutFile() { addDescription("Test that the workflow makes calls to the collector for get and put file, even when put file fails."); addStep("Prepare for calls to mocks", ""); 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 c41453cbc..9b3694093 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 @@ -43,9 +43,12 @@ 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; import org.mockito.stubbing.Answer; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + import java.util.Arrays; @@ -75,7 +78,7 @@ public class SaltedChecksumWorkflowTest extends ExtendedTestCase { protected IntegrityModel model; protected AuditTrailManager auditManager; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("IntegrityWorkflowTest"); @@ -93,7 +96,9 @@ public void setup() throws Exception { auditManager = mock(AuditTrailManager.class); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testNoFilesInCollection() { addDescription("Test that the workflow does nothing, when it has no files in the collection."); addStep("Prepare for calls to mocks", ""); @@ -116,7 +121,9 @@ public void testNoFilesInCollection() { verifyNoMoreInteractions(model); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testSuccess() { addDescription("Test that the workflow works when both pillars deliver the same checksum."); addStep("Prepare for calls to mocks", ""); @@ -156,7 +163,8 @@ public void testSuccess() { verifyNoMoreInteractions(auditManager); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testOneComponentFailureAndTwoOtherAgreeOnChecksum() { addDescription("Test that the workflow works when both pillars deliver the same checksum."); addStep("Prepare for calls to mocks", ""); @@ -199,7 +207,9 @@ public void testOneComponentFailureAndTwoOtherAgreeOnChecksum() { verifyNoMoreInteractions(auditManager); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testOneComponentFailureAndTwoOtherDisagreeOnChecksum() throws Exception { addDescription("Test that the workflow works when both pillars deliver the same checksum."); addStep("Prepare for calls to mocks", ""); @@ -243,7 +253,8 @@ public void testOneComponentFailureAndTwoOtherDisagreeOnChecksum() throws Except verifyNoMoreInteractions(auditManager); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testInconsistentChecksums() { addDescription("Test that the workflow discovers and handles inconsistent checksums"); addStep("Prepare for calls to mocks", ""); @@ -286,7 +297,9 @@ public void testInconsistentChecksums() { verifyNoMoreInteractions(alerter); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") + @Tag("integritytest") public void testNoReceivedChecksums() { addDescription("Test that the workflow handles the case, when no checksums are received"); addStep("Prepare for calls to mocks", ""); 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 b9f40d0ca..a2bb1aa3d 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 @@ -36,10 +36,14 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.common.utils.ChecksumUtils; import org.bitrepository.integrityservice.workflow.IntegrityContributors; +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.mockito.stubbing.Answer; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import javax.xml.datatype.DatatypeConfigurationException; import java.util.Arrays; @@ -66,7 +70,7 @@ public class GetChecksumForFileStepTest extends WorkflowstepTest { public static final String FILE_1 = "test-file-1"; String TEST_COLLECTION = "test-collection"; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setup() throws DatatypeConfigurationException { super.setup(); settings.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); @@ -77,7 +81,8 @@ public void setup() throws DatatypeConfigurationException { } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testNoResults() throws Exception { addDescription("Test step for retrieving the checksum of a single file, when no results are delivered."); ChecksumSpecTYPE checksumType = ChecksumUtils.getDefault(settings); @@ -97,13 +102,13 @@ public void testNoResults() throws Exception { addStep("Validate the checksum results", "Should not have any results"); step.performStep(); - Assert.assertTrue(step.getResults().isEmpty()); + Assertions.assertTrue(step.getResults().isEmpty()); verifyNoInteractions(alerter); verify(collector).getChecksums(anyString(), any(), eq(checksumType), eq(FILE_1), anyString(), any(), any(EventHandler.class)); verifyNoMoreInteractions(collector); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testFullData() throws Exception { addDescription("Test step for retrieving the checksum of a single file, when all three pillars deliver results."); ChecksumSpecTYPE checksumType = ChecksumUtils.getDefault(settings); @@ -134,18 +139,18 @@ public void testFullData() throws Exception { addStep("Validate the checksum results", "Should have checksum for each pillar."); step.performStep(); - Assert.assertFalse(step.getResults().isEmpty()); - Assert.assertEquals(step.getResults().size(), 3); - Assert.assertTrue(step.getResults().containsKey(TEST_PILLAR_1)); - Assert.assertTrue(step.getResults().containsKey(TEST_PILLAR_2)); - Assert.assertTrue(step.getResults().containsKey(TEST_PILLAR_3)); + Assertions.assertFalse(step.getResults().isEmpty()); + Assertions.assertEquals(step.getResults().size(), 3); + Assertions.assertTrue(step.getResults().containsKey(TEST_PILLAR_1)); + Assertions.assertTrue(step.getResults().containsKey(TEST_PILLAR_2)); + Assertions.assertTrue(step.getResults().containsKey(TEST_PILLAR_3)); verifyNoInteractions(alerter); verify(collector).getChecksums(anyString(), any(), eq(checksumType), eq(FILE_1), anyString(), any(), any(EventHandler.class)); verifyNoMoreInteractions(collector); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testComponentFailure() throws Exception { addDescription("Test step for retrieving the checksum of a single file, when one pillar fails."); ChecksumSpecTYPE checksumType = ChecksumUtils.getDefault(settings); @@ -175,11 +180,11 @@ public void testComponentFailure() throws Exception { addStep("Validate the file ids", "Should not have integrity issues."); step.performStep(); - Assert.assertFalse(step.getResults().isEmpty()); - Assert.assertEquals(step.getResults().size(), 2); - Assert.assertTrue(step.getResults().containsKey(TEST_PILLAR_1)); - Assert.assertTrue(step.getResults().containsKey(TEST_PILLAR_2)); - Assert.assertFalse(step.getResults().containsKey(TEST_PILLAR_3)); + Assertions.assertFalse(step.getResults().isEmpty()); + Assertions.assertEquals(step.getResults().size(), 2); + Assertions.assertTrue(step.getResults().containsKey(TEST_PILLAR_1)); + Assertions.assertTrue(step.getResults().containsKey(TEST_PILLAR_2)); + Assertions.assertFalse(step.getResults().containsKey(TEST_PILLAR_3)); verify(alerter).integrityFailed(anyString(), eq(TEST_COLLECTION)); verifyNoMoreInteractions(alerter); 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 2e0e234ab..3d4bf68b5 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 @@ -25,12 +25,15 @@ import org.bitrepository.client.eventhandler.EventHandler; import org.bitrepository.client.eventhandler.OperationFailedEvent; import org.bitrepository.integrityservice.workflow.IntegrityWorkflowContext; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + import java.net.URL; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -43,7 +46,7 @@ public class GetFileStepTest extends WorkflowstepTest { public static final String TEST_PILLAR_1 = "test-pillar-1"; public static final String TEST_FILE_1 = "test-file-1"; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testPositiveReply() throws Exception { addDescription("Test the step for getting the file can handle COMPLETE operation event."); doAnswer(new Answer() { @@ -67,23 +70,26 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(model); } - @Test(groups = {"regressiontest"}, expectedExceptions = IllegalStateException.class) + @Test + @Tag("regressiontest") public void testNegativeReply() throws Exception { - addDescription("Test the step for getting the file can handle FAILURE operation event."); - doAnswer(new Answer() { - public Void answer(InvocationOnMock invocation) { - EventHandler eventHandler = (EventHandler) invocation.getArguments()[3]; - eventHandler.handleEvent(new OperationFailedEvent(TEST_COLLECTION, "Problem encountered", null)); - return null; - } - }).when(collector).getFile( - eq(TEST_COLLECTION), eq(TEST_FILE_1), any(URL.class), any(EventHandler.class), anyString()); + assertThrows(IllegalStateException.class, () -> { + addDescription("Test the step for getting the file can handle FAILURE operation event."); + doAnswer(new Answer() { + public Void answer(InvocationOnMock invocation) { + EventHandler eventHandler = (EventHandler) invocation.getArguments()[3]; + eventHandler.handleEvent(new OperationFailedEvent(TEST_COLLECTION, "Problem encountered", null)); + return null; + } + }).when(collector).getFile( + eq(TEST_COLLECTION), eq(TEST_FILE_1), any(URL.class), any(EventHandler.class), anyString()); - IntegrityWorkflowContext context = new IntegrityWorkflowContext(settings, collector, model, alerter, auditManager); - URL uploadUrl = new URL("http://localhost/dav/test.txt"); - GetFileStep step = new GetFileStep(context, TEST_COLLECTION, TEST_FILE_1, uploadUrl); + IntegrityWorkflowContext context = new IntegrityWorkflowContext(settings, collector, model, alerter, auditManager); + URL uploadUrl = new URL("http://localhost/dav/test.txt"); + GetFileStep step = new GetFileStep(context, TEST_COLLECTION, TEST_FILE_1, uploadUrl); - step.performStep(); + step.performStep(); + }); } } 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 d6ad4f327..d5df84ec5 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 @@ -36,8 +36,10 @@ import org.bitrepository.integrityservice.statistics.StatisticsCollector; import org.bitrepository.service.audit.AuditTrailDatabaseResults; import org.bitrepository.service.audit.AuditTrailManager; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; @@ -77,7 +79,8 @@ protected void customizeSettings() throws DatatypeConfigurationException { auditManager = mock(AuditTrailManager.class); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test + @Tag("regressiontest") @Tag("integritytest") public void testNoData() throws Exception { addDescription("Test the checksum integrity validator without any data in the cache."); IntegrityModel cache = getIntegrityModel(); @@ -88,10 +91,10 @@ public void testNoData() throws Exception { addStep("Validate the file ids", "Should not have integrity issues."); step.performStep(); - Assert.assertFalse(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); + Assertions.assertFalse(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testSimilarData() throws Exception { addDescription("Test the checksum integrity validator when all pillars have similar data."); IntegrityModel cache = getIntegrityModel(); @@ -109,17 +112,17 @@ public void testSimilarData() throws Exception { step.performStep(); addStep("Validate the file ids", "Should not have integrity issues."); - Assert.assertFalse(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); - Assert.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(0)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_3).getChecksumErrors(), Long.valueOf(0)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(0)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(0)); + Assertions.assertFalse(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); + Assertions.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(0)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_3).getChecksumErrors(), Long.valueOf(0)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(0)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(0)); for(FileInfo fi : cache.getFileInfos(FILE_1, TEST_COLLECTION)) { - Assert.assertEquals(fi.getChecksum(), "1234cccc4321"); + Assertions.assertEquals(fi.getChecksum(), "1234cccc4321"); } } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testMissingAtOnePillar() throws Exception { addDescription("Test the checksum integrity validator when one pillar is missing the data."); IntegrityModel cache = getIntegrityModel(); @@ -136,10 +139,10 @@ public void testMissingAtOnePillar() throws Exception { step.performStep(); addStep("Validate the file ids", "No integrity issues."); - Assert.assertFalse(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); + Assertions.assertFalse(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testTwoDisagreeingChecksums() throws Exception { addDescription("Test the checksum integrity validator when only two pillar has data, but it it different."); IntegrityModel cache = getIntegrityModel(); @@ -157,16 +160,16 @@ public void testTwoDisagreeingChecksums() throws Exception { step.performStep(); addStep("Validate the file ids", "Should have integrity issues. No entry should be valid."); - Assert.assertTrue(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); - Assert.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(1)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(1)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(1)); + Assertions.assertTrue(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); + Assertions.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(1)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(1)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(1)); /*for(FileInfo fi : cache.getFileInfos(FILE_1, TEST_COLLECTION)) { - Assert.assertTrue(fi.getChecksumState() != ChecksumState.VALID); + Assertions.assertTrue(fi.getChecksumState() != ChecksumState.VALID); }*/ } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testThreeDisagreeingChecksums() throws Exception { addDescription("Test the checksum integrity validator when all pillars have different checksums."); IntegrityModel cache = getIntegrityModel(); @@ -186,14 +189,14 @@ public void testThreeDisagreeingChecksums() throws Exception { step.performStep(); addStep("Validate the file ids", "Should have integrity issues."); - Assert.assertTrue(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); - Assert.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(1)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_3).getChecksumErrors(), Long.valueOf(1)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(1)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(1)); + Assertions.assertTrue(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); + Assertions.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(1)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_3).getChecksumErrors(), Long.valueOf(1)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(1)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(1)); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testChecksumMajority() throws Exception { addDescription("Test the checksum integrity validator when two pillars have one checksum and the last pillar " + "has another checksum."); @@ -214,14 +217,14 @@ public void testChecksumMajority() throws Exception { step.performStep(); addStep("Validate the file ids", "Should only have integrity issues on pillar 3."); - Assert.assertTrue(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); - Assert.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(1)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_3).getChecksumErrors(), Long.valueOf(1)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(0)); - Assert.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(0)); + Assertions.assertTrue(reporter.hasIntegrityIssues(), reporter.generateSummaryOfReport()); + Assertions.assertEquals(cs.getCollectionStat().getChecksumErrors(), Long.valueOf(1)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_3).getChecksumErrors(), Long.valueOf(1)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_2).getChecksumErrors(), Long.valueOf(0)); + Assertions.assertEquals(cs.getPillarCollectionStat(TEST_PILLAR_1).getChecksumErrors(), Long.valueOf(0)); } - @Test(groups = {"regressiontest", "integritytest"}) + @Test @Tag("regressiontest") @Tag("integritytest") public void testAuditTrailsForChecksumErrors() throws Exception { addDescription("Test audit trails for checksum errors. Verify that a pillar with a single checksum will" + " be pointed out as the possible cause."); @@ -237,7 +240,7 @@ public void testAuditTrailsForChecksumErrors() throws Exception { insertChecksumDataForModel(cache, csData, TEST_PILLAR_2, TEST_COLLECTION); insertChecksumDataForModel(cache, csData, TEST_PILLAR_3, TEST_COLLECTION); step.performStep(); - Assert.assertNull(auditManager.latestAuditInfo); + Assertions.assertNull(auditManager.latestAuditInfo); addStep("Test step on data where only two pillars have the file and they disagree about the checksum.", "An audit trail with fileID and collectionID, but no pillar pointed out as cause"); @@ -247,15 +250,15 @@ public void testAuditTrailsForChecksumErrors() throws Exception { List fis = (List) cache.getFileInfos(FILE_1, TEST_COLLECTION); System.out.println("number of files in the collection" + cache.getNumberOfFilesInCollection(TEST_COLLECTION)); System.out.println("number of file infos: " + fis.size()); - Assert.assertNotNull(fis.get(0).getChecksum()); + Assertions.assertNotNull(fis.get(0).getChecksum()); step.performStep(); - Assert.assertNotNull(auditManager.latestAuditInfo); - Assert.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_1), auditManager.latestAuditInfo); - Assert.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_2), auditManager.latestAuditInfo); - Assert.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_3), auditManager.latestAuditInfo); - Assert.assertTrue(auditManager.latestAuditInfo.contains(FILE_2), auditManager.latestAuditInfo); - Assert.assertTrue(auditManager.latestAuditInfo.contains(TEST_COLLECTION), auditManager.latestAuditInfo); + Assertions.assertNotNull(auditManager.latestAuditInfo); + Assertions.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_1), auditManager.latestAuditInfo); + Assertions.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_2), auditManager.latestAuditInfo); + Assertions.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_3), auditManager.latestAuditInfo); + Assertions.assertTrue(auditManager.latestAuditInfo.contains(FILE_2), auditManager.latestAuditInfo); + Assertions.assertTrue(auditManager.latestAuditInfo.contains(TEST_COLLECTION), auditManager.latestAuditInfo); addStep("remove the last audit info", ""); auditManager.latestAuditInfo = null; @@ -266,12 +269,12 @@ public void testAuditTrailsForChecksumErrors() throws Exception { insertChecksumDataForModel(cache, createChecksumData("cc12344321cc", FILE_2), TEST_PILLAR_2, TEST_COLLECTION); insertChecksumDataForModel(cache, createChecksumData("cc12344321cc", FILE_2), TEST_PILLAR_3, TEST_COLLECTION); step.performStep(); - Assert.assertNotNull(auditManager.latestAuditInfo); - Assert.assertTrue(auditManager.latestAuditInfo.contains(TEST_PILLAR_1), auditManager.latestAuditInfo); - Assert.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_2), auditManager.latestAuditInfo); - Assert.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_3), auditManager.latestAuditInfo); - Assert.assertTrue(auditManager.latestAuditInfo.contains(FILE_2), auditManager.latestAuditInfo); - Assert.assertTrue(auditManager.latestAuditInfo.contains(TEST_COLLECTION), auditManager.latestAuditInfo); + Assertions.assertNotNull(auditManager.latestAuditInfo); + Assertions.assertTrue(auditManager.latestAuditInfo.contains(TEST_PILLAR_1), auditManager.latestAuditInfo); + Assertions.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_2), auditManager.latestAuditInfo); + Assertions.assertFalse(auditManager.latestAuditInfo.contains(TEST_PILLAR_3), auditManager.latestAuditInfo); + Assertions.assertTrue(auditManager.latestAuditInfo.contains(FILE_2), auditManager.latestAuditInfo); + Assertions.assertTrue(auditManager.latestAuditInfo.contains(TEST_COLLECTION), auditManager.latestAuditInfo); } private List createChecksumData(String checksum, String ... fileids) { 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 682846310..b6957813e 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 @@ -26,12 +26,15 @@ import org.bitrepository.client.eventhandler.EventHandler; import org.bitrepository.client.eventhandler.OperationFailedEvent; import org.bitrepository.integrityservice.workflow.IntegrityWorkflowContext; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + import java.net.URL; +import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -45,7 +48,7 @@ public class PutFileStepTest extends WorkflowstepTest { public static final String TEST_FILE_1 = "test-file-1"; public static final String TEST_CHECKSUM = "1234567890abba0987654321"; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testPositiveReply() throws Exception { addDescription("Test the step for getting the file can handle COMPLETE operation event."); doAnswer(new Answer() { @@ -69,23 +72,27 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(model); } - @Test(groups = {"regressiontest"}, expectedExceptions = IllegalStateException.class) + @Test + @Tag("regressiontest") public void testNegativeReply() throws Exception { - addDescription("Test the step for getting the file can handle FAILURE operation event."); - doAnswer(new Answer() { - public Void answer(InvocationOnMock invocation) { - EventHandler eventHandler = (EventHandler) invocation.getArguments()[4]; - eventHandler.handleEvent(new OperationFailedEvent(TEST_COLLECTION, "Problem encountered", null)); - return null; - } - }).when(collector).putFile( - eq(TEST_COLLECTION), eq(TEST_FILE_1), any(URL.class), any(ChecksumDataForFileTYPE.class), any(EventHandler.class), anyString()); + assertThrows(IllegalStateException.class, () -> { - IntegrityWorkflowContext context = new IntegrityWorkflowContext(settings, collector, model, alerter, auditManager); - URL uploadUrl = new URL("http://localhost/dav/test.txt"); - PutFileStep step = new PutFileStep(context, TEST_COLLECTION, TEST_FILE_1, uploadUrl, TEST_CHECKSUM); + addDescription("Test the step for getting the file can handle FAILURE operation event."); + doAnswer(new Answer() { + public Void answer(InvocationOnMock invocation) { + EventHandler eventHandler = (EventHandler) invocation.getArguments()[4]; + eventHandler.handleEvent(new OperationFailedEvent(TEST_COLLECTION, "Problem encountered", null)); + return null; + } + }).when(collector).putFile( + eq(TEST_COLLECTION), eq(TEST_FILE_1), any(URL.class), any(ChecksumDataForFileTYPE.class), any(EventHandler.class), anyString()); - step.performStep(); + IntegrityWorkflowContext context = new IntegrityWorkflowContext(settings, collector, model, alerter, auditManager); + URL uploadUrl = new URL("http://localhost/dav/test.txt"); + PutFileStep step = new PutFileStep(context, TEST_COLLECTION, TEST_FILE_1, uploadUrl, TEST_CHECKSUM); + + step.performStep(); + }); } } 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 8146ddf86..1e7cc3717 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 @@ -39,10 +39,13 @@ import org.bitrepository.common.utils.SettingsUtils; import org.bitrepository.integrityservice.cache.IntegrityModel; import org.bitrepository.service.exception.WorkflowAbortedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.Assert; -import org.testng.annotations.Test; + + import java.util.ArrayList; import java.util.Arrays; @@ -65,7 +68,8 @@ public class UpdateChecksumsStepTest extends WorkflowstepTest { public static final String TEST_FILE_1 = "test-file-1"; public static final String DEFAULT_CHECKSUM = "0123456789"; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testPositiveReply() throws WorkflowAbortedException { addDescription("Test the step for updating the checksums can handle COMPLETE operation event."); doAnswer(new Answer() { @@ -89,7 +93,7 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(alerter); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testAbortWorkflowWhenNegativeReply() { addDescription("Test the step for updating the checksums will abort the workflow in case " + "of FAILURE operation event and AbortOnFailedContributor = true ."); @@ -114,7 +118,7 @@ public Void answer(InvocationOnMock invocation) { settings, TEST_COLLECTION, integrityContributors); try { step.performStep(); - Assert.fail("The step should have thrown an WorkflowAbortedException"); + Assertions.fail("The step should have thrown an WorkflowAbortedException"); } catch (WorkflowAbortedException e) { // nothing to do here } @@ -124,7 +128,7 @@ public Void answer(InvocationOnMock invocation) { verify(alerter).integrityFailed(anyString(), eq(TEST_COLLECTION)); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testRetryCollectionWhenNegativeReply() throws WorkflowAbortedException { addDescription("Test the step for updating the file ids will retry on a FAILED event"); @@ -168,7 +172,7 @@ public Void answer(InvocationOnMock invocation) { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testContinueWorkflowNegativeReply() throws WorkflowAbortedException { addDescription("Test the step for updating the checksums will continue the workflow in case " + "of FAILURE operation event and AbortOnFailedContributor = false ."); @@ -199,7 +203,7 @@ public Void answer(InvocationOnMock invocation) { verify(alerter).integrityFailed(anyString(), eq(TEST_COLLECTION)); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testIngestOfResults() throws WorkflowAbortedException { addDescription("Test the step for updating the checksums delivers the results to the integrity model."); final ResultingChecksums resultingChecksums = createResultingChecksums(DEFAULT_CHECKSUM, TEST_FILE_1); @@ -230,7 +234,7 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(alerter); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testCallForChangingChecksumStates() throws WorkflowAbortedException { addDescription("Test the step for updating the checksums delivers the results to the integrity model."); final ResultingChecksums resultingChecksums = createResultingChecksums(DEFAULT_CHECKSUM, TEST_FILE_1); @@ -260,7 +264,7 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(alerter); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testPartialResults() throws WorkflowAbortedException { addDescription("Test that the number of partial is used for generating more than one request."); final ResultingChecksums resultingChecksums = createResultingChecksums(DEFAULT_CHECKSUM, TEST_FILE_1); @@ -298,7 +302,7 @@ public Void answer(InvocationOnMock invocation) { any(ChecksumSpecTYPE.class), any(), anyString(), any(ContributorQuery[].class), any(EventHandler.class)); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testFullChecksumCollection() throws WorkflowAbortedException { addDescription("Test that the full list of checksums is requested."); @@ -329,7 +333,7 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(alerter); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testIncrementalChecksumCollection() throws WorkflowAbortedException { addDescription("Test that only the list of new checksums is requested."); 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 bc019e992..a266ba6ab 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 @@ -35,10 +35,13 @@ import org.bitrepository.client.eventhandler.OperationFailedEvent; import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.service.exception.WorkflowAbortedException; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.Assert; -import org.testng.annotations.Test; + + import java.math.BigInteger; import java.util.Arrays; @@ -58,7 +61,8 @@ public class UpdateFileIDsStepTest extends WorkflowstepTest { public static final String TEST_PILLAR_1 = "test-pillar-1"; public static final String TEST_FILE_1 = "test-file-1"; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void testPositiveReply() throws WorkflowAbortedException { addDescription("Test the step for updating the file ids can handle COMPLETE operation event."); doAnswer(new Answer() { @@ -83,7 +87,7 @@ public Void answer(InvocationOnMock invocation) { verifyNoMoreInteractions(alerter); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testAbortWorkflowWhenNegativeReply() { addDescription("Test the step for updating the file ids will throw an WorkflowAbortedException" + "when AbortOnFailedContributor is set to true and a FAILED event is received."); @@ -109,7 +113,7 @@ public Void answer(InvocationOnMock invocation) { try { step.performStep(); - Assert.fail("The step should have thrown an WorkflowAbortedException"); + Assertions.fail("The step should have thrown an WorkflowAbortedException"); } catch (WorkflowAbortedException e) { // nothing to do here } @@ -121,7 +125,7 @@ public Void answer(InvocationOnMock invocation) { verify(alerter).integrityFailed(anyString(), anyString()); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testRetryCollectionWhenNegativeReply() throws WorkflowAbortedException { addDescription("Test the step for updating the file ids will retry on a FAILED event"); final ResultingFileIDs resultingFileIDs = createResultingFileIDs(TEST_FILE_1); @@ -165,7 +169,7 @@ public Void answer(InvocationOnMock invocation) { verify(integrityContributors).finishContributor(eq(TEST_PILLAR_1)); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testContinueWorkflowWhenNegativeReply() throws WorkflowAbortedException { addDescription("Test the step for updating the file ids will continue when getting an FAILED operation event" + " when AbortOnFailedContributor is set to false"); @@ -198,7 +202,7 @@ public Void answer(InvocationOnMock invocation) { - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testIngestOfResults() throws WorkflowAbortedException { addDescription("Test the step for updating the file ids can ingest the data correctly into the store."); final ResultingFileIDs resultingFileIDs = createResultingFileIDs(TEST_FILE_1); @@ -226,7 +230,7 @@ public Void answer(InvocationOnMock invocation) { } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest") public void testPartialResults() throws WorkflowAbortedException { addDescription("Test that the number of partial is used for generating more than one request."); final ResultingFileIDs resultingFileIDs = createResultingFileIDs(TEST_FILE_1); 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 f6740ed49..b06e53410 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 @@ -31,7 +31,8 @@ import org.bitrepository.integrityservice.workflow.IntegrityContributors; import org.bitrepository.service.audit.AuditTrailManager; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.BeforeMethod; +import org.junit.jupiter.api.BeforeEach; + import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; @@ -50,7 +51,7 @@ public class WorkflowstepTest extends ExtendedTestCase { protected AuditTrailManager auditManager; protected IntegrityContributors integrityContributors; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setup() throws DatatypeConfigurationException { settings = TestSettingsProvider.reloadSettings(this.getClass().getSimpleName()); settings.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().clear(); 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 360a3d294..88b421ab9 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 @@ -31,8 +31,8 @@ import org.bitrepository.monitoringservice.status.ComponentStatusCode; import org.bitrepository.protocol.IntegrationTest; import org.bitrepository.settings.referencesettings.AlarmLevel; -import org.testng.Assert; -import org.testng.annotations.Test; + + import java.math.BigInteger; import java.util.HashMap; @@ -40,7 +40,7 @@ public class MonitorAlerterTest extends IntegrationTest { - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void testMonitorAlerter() throws Exception { addDescription("Tests the " + BasicMonitoringServiceAlerter.class.getName()); addStep("Setup", ""); @@ -52,12 +52,12 @@ public void testMonitorAlerter() throws Exception { BasicMonitoringServiceAlerter alerter = new BasicMonitoringServiceAlerter( settingsForCUT, messageBus, AlarmLevel.ERROR, store); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); addStep("Check statuses with an empty map.", "Should only make a call for GetStatusMap"); store.statuses = new HashMap<>(); alerter.checkStatuses(); - Assert.assertEquals(store.getCallsForGetStatusMap(), 1); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 1); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); addStep("Check the status when a positive entry exists.", "Should make another call for the GetStatusMap"); @@ -65,7 +65,7 @@ public void testMonitorAlerter() throws Exception { cs.updateStatus(createPositiveStatus()); store.statuses.put(componentID, cs); alerter.checkStatuses(); - Assert.assertEquals(store.getCallsForGetStatusMap(), 2); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 2); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); addStep("Check the status when a negative entry exists.", @@ -73,10 +73,10 @@ public void testMonitorAlerter() throws Exception { cs.updateReplies(); store.statuses.put(componentID, cs); alerter.checkStatuses(); - Assert.assertEquals(store.getCallsForGetStatusMap(), 3); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 3); alarmReceiver.waitForMessage(AlarmMessage.class); - Assert.assertEquals(cs.getStatus(), ComponentStatusCode.UNRESPONSIVE); + Assertions.assertEquals(cs.getStatus(), ComponentStatusCode.UNRESPONSIVE); } private ResultingStatus createPositiveStatus() { 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 1d9a3c877..3f580905d 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 @@ -27,9 +27,9 @@ import org.bitrepository.monitoringservice.MockGetStatusClient; import org.bitrepository.monitoringservice.MockStatusStore; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + + + import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; @@ -45,7 +45,7 @@ public void setup() { settings = TestSettingsProvider.reloadSettings("StatusCollectorUnderTest"); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void testStatusCollector() throws Exception { addDescription("Tests the status collector."); addStep("Setup", ""); @@ -57,11 +57,11 @@ public void testStatusCollector() throws Exception { settings.getReferenceSettings().getMonitoringServiceSettings().setCollectionInterval(intervalXmlDur); addStep("Create the collector", ""); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(client.getCallsToGetStatus(), 0); - Assert.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(client.getCallsToGetStatus(), 0); + Assertions.assertEquals(client.getCallsToShutdown(), 0); StatusCollector collector = new StatusCollector(client, settings, store, alerter); addStep("Start the collector", "It should immediately call the client and store."); @@ -69,11 +69,11 @@ public void testStatusCollector() throws Exception { synchronized(this) { wait(INTERVAL_DELAY); } - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 1); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(client.getCallsToGetStatus(), 1); - Assert.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 1); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(client.getCallsToGetStatus(), 1); + Assertions.assertEquals(client.getCallsToShutdown(), 0); addStep("wait 2 * the interval", "It should call the client and store two times more."); synchronized(this) { @@ -81,21 +81,21 @@ public void testStatusCollector() throws Exception { } collector.stop(); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 3); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(client.getCallsToGetStatus(), 3); - Assert.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 3); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(client.getCallsToGetStatus(), 3); + Assertions.assertEquals(client.getCallsToShutdown(), 0); addStep("wait the interval + delay again", "It should not have made any more calls"); synchronized(this) { wait(INTERVAL + INTERVAL_DELAY); } - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 3); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(client.getCallsToGetStatus(), 3); - Assert.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 3); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(client.getCallsToGetStatus(), 3); + Assertions.assertEquals(client.getCallsToShutdown(), 0); } } 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 2660c6806..812cd800c 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 @@ -30,14 +30,14 @@ import org.bitrepository.monitoringservice.MockAlerter; import org.bitrepository.monitoringservice.MockStatusStore; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; + + public class StatusEventHandlerTest extends ExtendedTestCase { public static final String TEST_COLLECTION = "collection1"; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void testStatusEventHandler() throws Exception { addDescription("Test the GetStatusEventHandler handling of events"); addStep("Setup", ""); @@ -46,43 +46,43 @@ public void testStatusEventHandler() throws Exception { GetStatusEventHandler eventHandler = new GetStatusEventHandler(store, alerter); addStep("Validate initial calls to the mocks", "No calls expected"); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(alerter.getCallsForCheckStatuses(), 0); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 0); addStep("Test an unhandled event.", "Should not make any calls."); AbstractOperationEvent event = new DefaultEvent(TEST_COLLECTION); event.setEventType(OperationEventType.WARNING); eventHandler.handleEvent(event); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(alerter.getCallsForCheckStatuses(), 0); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 0); addStep("Test the Complete event", "Should make a call to the alerter"); event = new CompleteEvent(TEST_COLLECTION, null); eventHandler.handleEvent(event); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(alerter.getCallsForCheckStatuses(), 1); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 1); addStep("Test the Failed event", "Should make another call to the alerter"); event = new OperationFailedEvent(null, "info", null); eventHandler.handleEvent(event); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assert.assertEquals(store.getCallsForUpdateStatus(), 0); - Assert.assertEquals(alerter.getCallsForCheckStatuses(), 2); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); + Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 2); addStep("Test the component complete status", "Should attempt to update the store"); event = new StatusCompleteContributorEvent("ContributorID", "dummy-collection", null); eventHandler.handleEvent(event); - Assert.assertEquals(store.getCallsForGetStatusMap(), 0); - Assert.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assert.assertEquals(store.getCallsForUpdateStatus(), 1); - Assert.assertEquals(alerter.getCallsForCheckStatuses(), 2); + Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); + Assertions.assertEquals(store.getCallsForUpdateStatus(), 1); + Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 2); } } 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 c93d24701..daf9db5d6 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 @@ -28,9 +28,9 @@ import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.common.utils.CalendarUtils; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + + + import java.util.HashSet; import java.util.Map; @@ -44,7 +44,7 @@ public void setup() { settings = TestSettingsProvider.reloadSettings("ComponentStatusStoreUnderTest"); } - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void testComponentStatus() throws Exception { addDescription("Tests the compontent status"); addStep("Setup", ""); @@ -55,45 +55,45 @@ public void testComponentStatus() throws Exception { addStep("Validate the initial content", "Should be one component with a 'new and empty' component status."); Map statuses = store.getStatusMap(); - Assert.assertEquals(statuses.size(), 1); + Assertions.assertEquals(statuses.size(), 1); ComponentStatus newStatus = new ComponentStatus(); - Assert.assertNotNull(statuses.get(componentId)); - Assert.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); - Assert.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), newStatus.getNumberOfMissingReplies()); - Assert.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); - Assert.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); + Assertions.assertNotNull(statuses.get(componentId)); + Assertions.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); + Assertions.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), newStatus.getNumberOfMissingReplies()); + Assertions.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); + Assertions.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); addStep("Update the replay counts and validate ", "it should increases the 'number of missing replies' by 1"); store.updateReplyCounts(); statuses = store.getStatusMap(); - Assert.assertEquals(statuses.size(), 1); - Assert.assertNotNull(statuses.get(componentId)); - Assert.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); - Assert.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 1); - Assert.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); - Assert.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); + Assertions.assertEquals(statuses.size(), 1); + Assertions.assertNotNull(statuses.get(componentId)); + Assertions.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); + Assertions.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 1); + Assertions.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); + Assertions.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); addStep("Test what happens when an invalid component id attempted to be updated.", "Should not affect content."); store.updateStatus("BAD-COMPONENT-ID", null); statuses = store.getStatusMap(); - Assert.assertEquals(statuses.size(), 1); - Assert.assertNotNull(statuses.get(componentId)); - Assert.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); - Assert.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 1); - Assert.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); - Assert.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); + Assertions.assertEquals(statuses.size(), 1); + Assertions.assertNotNull(statuses.get(componentId)); + Assertions.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); + Assertions.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 1); + Assertions.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); + Assertions.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); addStep("Try giving it a positive status", "Should be inserted into the store."); ResultingStatus resStatus = createPositiveStatus(); store.updateStatus(componentId, resStatus); statuses = store.getStatusMap(); - Assert.assertEquals(statuses.size(), 1); - Assert.assertNotNull(statuses.get(componentId)); - Assert.assertEquals(statuses.get(componentId).getInfo(), resStatus.getStatusInfo().getStatusText()); - Assert.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 0); - Assert.assertEquals(statuses.get(componentId).getLastReplyDate(), resStatus.getStatusTimestamp()); - Assert.assertEquals(statuses.get(componentId).getStatus().value(), resStatus.getStatusInfo().getStatusCode().name()); + Assertions.assertEquals(statuses.size(), 1); + Assertions.assertNotNull(statuses.get(componentId)); + Assertions.assertEquals(statuses.get(componentId).getInfo(), resStatus.getStatusInfo().getStatusText()); + Assertions.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 0); + Assertions.assertEquals(statuses.get(componentId).getLastReplyDate(), resStatus.getStatusTimestamp()); + Assertions.assertEquals(statuses.get(componentId).getStatus().value(), resStatus.getStatusInfo().getStatusCode().name()); } private ResultingStatus createPositiveStatus() { 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 0866dc3cf..c7628b5a7 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 @@ -35,9 +35,9 @@ import org.bitrepository.service.audit.MockAuditManager; import org.bitrepository.service.contributor.ResponseDispatcher; import org.bitrepository.service.contributor.handler.RequestHandler; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import java.math.BigInteger; import java.util.ArrayList; @@ -60,7 +60,7 @@ public void initialiseTest() { audits); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testMediatorRuntimeExceptionHandling() { addDescription("Tests the handling of a runtime exception"); addStep("Setup create and start the mediator.", ""); @@ -84,8 +84,8 @@ public void testMediatorRuntimeExceptionHandling() { messageBus.sendMessage(request); MessageResponse response = clientReceiver.waitForMessage(IdentifyContributorsForGetStatusResponse.class); - Assert.assertEquals(response.getResponseInfo().getResponseCode(), ResponseCode.FAILURE); - Assert.assertNotNull(alarmReceiver.waitForMessage(AlarmMessage.class)); + Assertions.assertEquals(response.getResponseInfo().getResponseCode(), ResponseCode.FAILURE); + Assertions.assertNotNull(alarmReceiver.waitForMessage(AlarmMessage.class)); } finally { mediator.close(); } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java index c64ba2f3f..c2a70ce53 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java @@ -25,14 +25,14 @@ import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.settings.repositorysettings.Collection; import org.bitrepository.settings.repositorysettings.PillarIDs; -import org.testng.annotations.Test; + import java.util.ArrayList; import java.util.Arrays; import java.util.List; public class SettingsHelperTest { - @Test( groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void getPillarCollectionsTest() { String myPillarID = "myPillarID"; String otherPillarID = "OtherPillar"; @@ -43,14 +43,14 @@ public void getPillarCollectionsTest() { collection.add(createCollection("otherCollection", new String[] {otherPillarID})); List myCollections = SettingsHelper.getPillarCollections(myPillarID, collection); - Assert.assertEquals(myCollections.size(), 2); - Assert.assertEquals("myFirstCollection", myCollections.get(0)); - Assert.assertEquals("mySecondCollection", myCollections.get(1)); + Assertions.assertEquals(myCollections.size(), 2); + Assertions.assertEquals("myFirstCollection", myCollections.get(0)); + Assertions.assertEquals("mySecondCollection", myCollections.get(1)); List otherCollections = SettingsHelper.getPillarCollections(otherPillarID, collection); - Assert.assertEquals(otherCollections.size(), 2); - Assert.assertEquals("mySecondCollection", otherCollections.get(0)); - Assert.assertEquals("otherCollection", otherCollections.get(1)); + Assertions.assertEquals(otherCollections.size(), 2); + Assertions.assertEquals("mySecondCollection", otherCollections.get(0)); + Assertions.assertEquals("otherCollection", otherCollections.get(1)); } private Collection createCollection(String collectionID, String[] pillarIDs) { 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 352e4f9ff..a72794c8c 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 @@ -48,13 +48,6 @@ import org.bitrepository.protocol.security.PermissionStore; import org.bitrepository.protocol.security.SecurityManager; import org.jaccept.TestEventManager; -import org.testng.ITestContext; -import org.testng.ITestResult; -import org.testng.annotations.AfterClass; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.AfterSuite; -import org.testng.annotations.BeforeClass; - import javax.jms.JMSException; import java.io.IOException; import java.io.InputStream; 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 bcf9a5713..bea255ea2 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 @@ -26,11 +26,11 @@ import org.bitrepository.bitrepositorymessages.MessageRequest; import org.bitrepository.bitrepositorymessages.MessageResponse; import org.bitrepository.pillar.PillarTestGroups; -import org.testng.annotations.Test; + public abstract class DefaultPillarIdentificationTest extends DefaultPillarMessagingTest { - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void irrelevantCollectionTest() { addDescription("Verifies identification works correctly for a collection not defined for the pillar"); addStep("Sending a putFile identification with a irrelevant collectionID. eg. the " + @@ -44,7 +44,7 @@ public void irrelevantCollectionTest() { protected void assertPositivResponseIsReceived() { MessageResponse receivedResponse = receiveResponse(); - Assert.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), ResponseCode.IDENTIFICATION_POSITIVE); } } 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 211a8d0b7..72ca8edb2 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 @@ -26,7 +26,10 @@ import org.bitrepository.bitrepositorymessages.MessageRequest; import org.bitrepository.bitrepositorymessages.MessageResponse; import org.bitrepository.pillar.PillarTestGroups; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + /** * Contains the tests for exploringa pillars handling of general messaging. The concrete class needs to @@ -35,7 +38,7 @@ */ public abstract class DefaultPillarMessagingTest extends PillarFunctionTest { - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void missingCollectionIDTest() { addDescription("Verifies the a missing collectionID in the request is rejected"); addStep("Sending a request without a collectionID.", @@ -45,11 +48,13 @@ public void missingCollectionIDTest() { messageBus.sendMessage(request); MessageResponse receivedResponse = receiveResponse(); - Assert.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), ResponseCode.REQUEST_NOT_UNDERSTOOD_FAILURE); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void otherCollectionTest() { addDescription("Verifies identification works correctly for a second collection defined for pillar"); addStep("Sending a identify request with a non-default collectionID (not the first collection) " + diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java index 597e1f40b..7cdad591b 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java @@ -29,7 +29,7 @@ public abstract class DefaultPillarOperationTest extends DefaultPillarMessagingT protected void assertPositivResponseIsReceived() { MessageResponse receivedResponse = receiveResponse(); - Assert.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); } } 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 31e3c5a6a..8f187c09c 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 @@ -24,7 +24,7 @@ import org.bitrepository.pillar.integration.PillarIntegrationTest; import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; import org.bitrepository.protocol.bus.MessageReceiver; -import org.testng.annotations.BeforeMethod; + import java.lang.reflect.Method; import java.util.Arrays; 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 f8491c66b..7ba9b3461 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 @@ -37,9 +37,9 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.DeleteFileMessageFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; @@ -60,7 +60,7 @@ public void initialiseReferenceTest(Method method) throws Exception { null, null, null); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void normalDeleteFileTest() { addDescription("Tests a normal DeleteFile sequence"); addStep("Send a DeleteFile request to " + testConfiguration.getPillarUnderTestID(), @@ -72,22 +72,22 @@ public void normalDeleteFileTest() { DeleteFileProgressResponse progressResponse = clientReceiver.waitForMessage(DeleteFileProgressResponse.class, getOperationTimeout(), TimeUnit.SECONDS); - Assert.assertNotNull(progressResponse); - Assert.assertEquals(progressResponse.getCorrelationID(), deleteRequest.getCorrelationID()); - Assert.assertEquals(progressResponse.getFrom(), getPillarID()); - Assert.assertEquals(progressResponse.getPillarID(), getPillarID()); - Assert.assertEquals(progressResponse.getResponseInfo().getResponseCode(), + Assertions.assertNotNull(progressResponse); + Assertions.assertEquals(progressResponse.getCorrelationID(), deleteRequest.getCorrelationID()); + Assertions.assertEquals(progressResponse.getFrom(), getPillarID()); + Assertions.assertEquals(progressResponse.getPillarID(), getPillarID()); + Assertions.assertEquals(progressResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_ACCEPTED_PROGRESS); DeleteFileFinalResponse finalResponse = (DeleteFileFinalResponse) receiveResponse(); - Assert.assertNotNull(finalResponse); - Assert.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - Assert.assertEquals(finalResponse.getCorrelationID(), deleteRequest.getCorrelationID()); - Assert.assertEquals(finalResponse.getFrom(), getPillarID()); - Assert.assertEquals(finalResponse.getPillarID(), getPillarID()); + Assertions.assertNotNull(finalResponse); + Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(finalResponse.getCorrelationID(), deleteRequest.getCorrelationID()); + Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); + Assertions.assertEquals(finalResponse.getPillarID(), getPillarID()); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void requestNewChecksumDeleteFileTest() { addDescription("Tests a normal DeleteFile sequence"); addStep("Send a DeleteFile request to " + testConfiguration.getPillarUnderTestID(), @@ -108,22 +108,22 @@ public void requestNewChecksumDeleteFileTest() { DeleteFileProgressResponse progressResponse = clientReceiver.waitForMessage(DeleteFileProgressResponse.class, getOperationTimeout(), TimeUnit.SECONDS); - Assert.assertNotNull(progressResponse); - Assert.assertEquals(progressResponse.getCorrelationID(), deleteRequest.getCorrelationID()); - Assert.assertEquals(progressResponse.getFrom(), getPillarID()); - Assert.assertEquals(progressResponse.getPillarID(), getPillarID()); - Assert.assertEquals(progressResponse.getResponseInfo().getResponseCode(), + Assertions.assertNotNull(progressResponse); + Assertions.assertEquals(progressResponse.getCorrelationID(), deleteRequest.getCorrelationID()); + Assertions.assertEquals(progressResponse.getFrom(), getPillarID()); + Assertions.assertEquals(progressResponse.getPillarID(), getPillarID()); + Assertions.assertEquals(progressResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_ACCEPTED_PROGRESS); DeleteFileFinalResponse finalResponse = (DeleteFileFinalResponse) receiveResponse(); - Assert.assertNotNull(finalResponse); - Assert.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - Assert.assertEquals(finalResponse.getCorrelationID(), deleteRequest.getCorrelationID()); - Assert.assertEquals(finalResponse.getFrom(), getPillarID()); - Assert.assertNotNull(finalResponse.getChecksumDataForExistingFile()); - Assert.assertEquals(finalResponse.getChecksumDataForExistingFile().getChecksumSpec(), + Assertions.assertNotNull(finalResponse); + Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(finalResponse.getCorrelationID(), deleteRequest.getCorrelationID()); + Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); + Assertions.assertNotNull(finalResponse.getChecksumDataForExistingFile()); + Assertions.assertEquals(finalResponse.getChecksumDataForExistingFile().getChecksumSpec(), requestedChecksumSpec); - Assert.assertEquals(finalResponse.getPillarID(), getPillarID()); + Assertions.assertEquals(finalResponse.getPillarID(), getPillarID()); } @Override 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 9f6998afc..ec354fb04 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 @@ -31,8 +31,8 @@ import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.DeleteFileMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + public class IdentifyPillarsForDeleteFileIT extends DefaultPillarIdentificationTest { protected DeleteFileMessageFactory msgFactory; @@ -43,7 +43,7 @@ public void initialiseReferenceTest() throws Exception { } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for deleteFile identification"); addStep("Sending a deleteFile identification.", @@ -53,18 +53,18 @@ public void normalIdentificationTest() { IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - Assert.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); - Assert.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); - Assert.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); - Assert.assertEquals(receivedIdentifyResponse.getFileID(), DEFAULT_FILE_ID); - Assert.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); - Assert.assertNull(receivedIdentifyResponse.getPillarChecksumSpec()); - Assert.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); + Assertions.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); + Assertions.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); + Assertions.assertEquals(receivedIdentifyResponse.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); + Assertions.assertNull(receivedIdentifyResponse.getPillarChecksumSpec()); + Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), ResponseCode.IDENTIFICATION_POSITIVE); - Assert.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); + Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test( groups = {PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void identificationTestForChecksumPillar() { addDescription("Verifies the normal behaviour for deleteFile identification for a checksum pillar"); addStep("Sending a deleteFile identification.", @@ -75,18 +75,18 @@ public void identificationTestForChecksumPillar() { IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - Assert.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); - Assert.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); - Assert.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); - Assert.assertEquals(receivedIdentifyResponse.getPillarChecksumSpec().getChecksumType(), + Assertions.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); + Assertions.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); + Assertions.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); + Assertions.assertEquals(receivedIdentifyResponse.getPillarChecksumSpec().getChecksumType(), ChecksumUtils.getDefault(settingsForCUT).getChecksumType()); - Assert.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); - Assert.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); + Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), ResponseCode.IDENTIFICATION_POSITIVE); - Assert.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); + Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void fileDoesNotExistsTest() { addDescription("Verifies that a request for a non-existing file is handled correctly"); addStep("Sending a deleteFile identification for a file not in the pillar.", @@ -97,7 +97,7 @@ public void fileDoesNotExistsTest() { IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - Assert.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); } 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 50224a84f..e4892d25b 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 @@ -27,12 +27,12 @@ import org.bitrepository.client.exceptions.NegativeResponseException; import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; -import org.testng.annotations.Test; + import java.util.List; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertTrue; + + public class GetAuditTrailsTest extends PillarFunctionTest { @Override @@ -41,7 +41,7 @@ protected void initializeCUT() { settingsForTestClient.getRepositorySettings().getGetAuditTrailSettings().getNonPillarContributorIDs().clear(); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void eventSortingTest() throws NegativeResponseException{ addDescription("Test whether the audit trails are sorted based on sequence numbers, with the largest " + "sequence number last.."); @@ -62,7 +62,7 @@ public void eventSortingTest() throws NegativeResponseException{ } } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void maxNumberOfResultTest() { 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"); @@ -84,7 +84,7 @@ public void maxNumberOfResultTest() { "The returned event wasn't equal to the first event"); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void minSequenceNumberTest() { addDescription("Test the pillar support for only retrieving events with sequence number higher than the " + "provided MinSequenceNumber" + @@ -119,7 +119,7 @@ public void minSequenceNumberTest() { "First event in second page different from last element in first page"); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void maxSequenceNumberTest() { addDescription("Test the pillar support for only retrieving audit event with SequenceNumbers lower than " + "MaxSequenceNumber."); 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 507fd185f..ca37bb956 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 @@ -27,7 +27,7 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.pillar.integration.func.PillarFunctionTest; -import org.testng.annotations.Test; + import javax.xml.datatype.XMLGregorianCalendar; import java.util.GregorianCalendar; @@ -35,7 +35,7 @@ public class GetChecksumQueryTest extends PillarFunctionTest { - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void checksumSortingTest() { addDescription("Test whether the checksum result is sorted oldest to newest."); addFixture("Ensure at least two files are present on the pillar"); @@ -46,14 +46,14 @@ public void checksumSortingTest() { List originalChecksumList = pillarFileManager.getChecksums(null, null, null); for (int counter = 0 ; counter < originalChecksumList.size() - 1 ; counter ++) { - Assert.assertTrue(originalChecksumList.get(counter).getCalculationTimestamp().compare( + Assertions.assertTrue(originalChecksumList.get(counter).getCalculationTimestamp().compare( originalChecksumList.get(counter + 1).getCalculationTimestamp()) <= 0, "Checksum (" + counter + ") " + originalChecksumList.get(counter) + " newer than following checksum(" + counter + ") " + originalChecksumList.get(counter + 1)); } } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void maxNumberOfResultTest() { 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"); @@ -68,12 +68,12 @@ public void maxNumberOfResultTest() { ContributorQuery singleChecksumQuery = new ContributorQuery(getPillarID(), null, null, 1); List singleChecksumList = pillarFileManager.getChecksums(null, singleChecksumQuery, null); - Assert.assertEquals(singleChecksumList.size(), 1, "The result didn't contain a single checksum"); - Assert.assertEquals(singleChecksumList.get(0), originalChecksumList.get(0), + Assertions.assertEquals(singleChecksumList.size(), 1, "The result didn't contain a single checksum"); + Assertions.assertEquals(singleChecksumList.get(0), originalChecksumList.get(0), "The returned checksum wasn't equal to the oldest checksum"); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void minTimeStampTest() { addDescription("Test the pillar support for only retrieving checksums newer that a given time. " + "Note that this test assumes there is at least 2 checksums with different timestamps." + @@ -86,7 +86,7 @@ public void minTimeStampTest() { "A list with at least 2 different timestamps (it is not the fault of the pillar if this fails, but " + "the test needs this to be satisfied to make sense)."); List originalChecksumList = pillarFileManager.getChecksums(null, null, null); - Assert.assertTrue(originalChecksumList.get(0).getCalculationTimestamp().compare( + Assertions.assertTrue(originalChecksumList.get(0).getCalculationTimestamp().compare( originalChecksumList.get(originalChecksumList.size()-1).getCalculationTimestamp()) != 0, "The timestamps of the first and last checksum are the same."); @@ -96,13 +96,13 @@ public void minTimeStampTest() { ContributorQuery query = new ContributorQuery(getPillarID(), oldestTimestamp.toGregorianCalendar().getTime(), null, null); List limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assert.assertEquals(limitedChecksumList.size(), originalChecksumList.size(), + Assertions.assertEquals(limitedChecksumList.size(), originalChecksumList.size(), "Differing size of checksum lists"); - Assert.assertEquals(limitedChecksumList.get(0), originalChecksumList.get(0), + Assertions.assertEquals(limitedChecksumList.get(0), originalChecksumList.get(0), "Different first list element when setting oldest minTimestamp"); - Assert.assertEquals(limitedChecksumList.get(limitedChecksumList.size()-1), originalChecksumList.get(originalChecksumList.size()-1), + Assertions.assertEquals(limitedChecksumList.get(limitedChecksumList.size()-1), originalChecksumList.get(originalChecksumList.size()-1), "Different last list element when setting oldest minTimestamp"); - Assert.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare( + Assertions.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare( limitedChecksumList.get(limitedChecksumList.size()-1).getCalculationTimestamp()) <= 0, "First checksum has newer timestamp than last checksum"); @@ -111,9 +111,9 @@ public void minTimeStampTest() { XMLGregorianCalendar newestTimestamp = originalChecksumList.get(originalChecksumList.size()-1).getCalculationTimestamp(); query = new ContributorQuery(getPillarID(), newestTimestamp.toGregorianCalendar().getTime(), null, null); limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assert.assertFalse(limitedChecksumList.isEmpty(), + Assertions.assertFalse(limitedChecksumList.isEmpty(), "Empty list returned when when minTimestamp is set to newest calculated checksum timestamp"); - Assert.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare(newestTimestamp) == 0, + Assertions.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare(newestTimestamp) == 0, "Different timestamps in the set of newest checksums." + limitedChecksumList); addStep("Request checksums with MinTimeStamp set to the timestamp of the newest checksum + 10 ms", @@ -122,12 +122,12 @@ public void minTimeStampTest() { newerThanNewestTimestamp.add(GregorianCalendar.MILLISECOND, 10); query = new ContributorQuery(getPillarID(), newerThanNewestTimestamp.getTime(), null, null); limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assert.assertEmpty(limitedChecksumList, + Assertions.assertEmpty(limitedChecksumList, "Non-empty checksum list returned with newerThanNewestTimestamp(" + CalendarUtils.getXmlGregorianCalendar(newerThanNewestTimestamp) + ") query"); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void maxTimeStampTest() { addDescription("Test the pillar support for only retrieving checksums older than a given time. " + "Note that this test assumes there is at least 2 checksums with different timestamps. " + @@ -141,7 +141,7 @@ public void maxTimeStampTest() { "A list with at least 2 different timestamps (it is not the fault of the pillar if this fails, but " + "the test needs this to be satisfied to make sense)."); List originalChecksumList = pillarFileManager.getChecksums(null, null, null); - Assert.assertTrue(originalChecksumList.get(0).getCalculationTimestamp().compare( + Assertions.assertTrue(originalChecksumList.get(0).getCalculationTimestamp().compare( originalChecksumList.get(originalChecksumList.size()-1).getCalculationTimestamp()) != 0, "The timestamps of the first and last checksum are the same."); @@ -151,13 +151,13 @@ public void maxTimeStampTest() { ContributorQuery query = new ContributorQuery(getPillarID(), null, newestTimestamp.toGregorianCalendar().getTime(), null); List limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assert.assertEquals(limitedChecksumList.size(), originalChecksumList.size(), + Assertions.assertEquals(limitedChecksumList.size(), originalChecksumList.size(), "Differing size of checksum lists"); - Assert.assertEquals(limitedChecksumList.get(0), originalChecksumList.get(0), + Assertions.assertEquals(limitedChecksumList.get(0), originalChecksumList.get(0), "Different first list element when setting newest maxTimestamp"); - Assert.assertEquals(limitedChecksumList.get(limitedChecksumList.size()-1), originalChecksumList.get(originalChecksumList.size()-1), + Assertions.assertEquals(limitedChecksumList.get(limitedChecksumList.size()-1), originalChecksumList.get(originalChecksumList.size()-1), "Different last list element when setting newest maxTimestamp"); - Assert.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare( + Assertions.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare( limitedChecksumList.get(limitedChecksumList.size()-1).getCalculationTimestamp()) <= 0, "First checksum has newer timestamp than last checksum"); @@ -167,8 +167,8 @@ public void maxTimeStampTest() { query = new ContributorQuery(getPillarID(), null, oldestTimestamp.toGregorianCalendar().getTime(), null); limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assert.assertFalse(limitedChecksumList.isEmpty(), "At least one checksum with the oldest timestamp should be returned."); - Assert.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare(oldestTimestamp) == 0, + Assertions.assertFalse(limitedChecksumList.isEmpty(), "At least one checksum with the oldest timestamp should be returned."); + Assertions.assertTrue(limitedChecksumList.get(0).getCalculationTimestamp().compare(oldestTimestamp) == 0, "Different timestamps in the set of oldest checksums." + limitedChecksumList); addStep("Request checksums with MaxTimeStamp set to the timestamp of the oldest checksum - 10 ms", @@ -177,7 +177,7 @@ public void maxTimeStampTest() { olderThanOldestTimestamp.add(GregorianCalendar.MILLISECOND, -10); query = new ContributorQuery(getPillarID(), null, olderThanOldestTimestamp.getTime(), null); limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assert.assertEmpty(limitedChecksumList, + Assertions.assertEmpty(limitedChecksumList, "Non-empty checksum list returned with olderThanOldestTimestamp(" + CalendarUtils.getXmlGregorianCalendar(olderThanOldestTimestamp) + ") query"); } 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 0d43ddef6..fdf0b1769 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,13 +29,13 @@ import org.bitrepository.common.utils.Base16Utils; import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; + + import java.util.List; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; + + public class GetChecksumTest extends PillarFunctionTest { @@ -44,7 +44,7 @@ public void retrieveFirst2Files() { //ToDo } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void md5ChecksumsForAllFilesTest() throws NegativeResponseException { addDescription("Test the pillar support for MD5 type checksums"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); @@ -62,7 +62,7 @@ public void md5ChecksumsForAllFilesTest() throws NegativeResponseException { // ToDo implement this } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) public void sha1ChecksumsForDefaultTest() throws NegativeResponseException { addDescription("Test the pillar support for SHA1 type checksums"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); @@ -76,7 +76,7 @@ public void sha1ChecksumsForDefaultTest() throws NegativeResponseException { assertNotNull(checksums.get(0)); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) public void md5SaltChecksumsForDefaultTest() throws NegativeResponseException { addDescription("Test the pillar support for MD5 type checksums with a salt"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); @@ -95,7 +95,7 @@ public void md5SaltChecksumsForDefaultTest() throws NegativeResponseException { assertNotNull(checksums.get(0)); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) public void sha1SaltChecksumsForDefaultTest() throws NegativeResponseException { addDescription("Test the pillar support for SHA1 type checksums with a salt"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); 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 51fd55102..d0a5ce0e1 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 @@ -33,11 +33,11 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.GetChecksumsMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; + + + + public class IdentifyPillarsForGetChecksumsIT extends DefaultPillarIdentificationTest { protected GetChecksumsMessageFactory msgFactory; @@ -48,7 +48,7 @@ public void initialiseReferenceTest() throws Exception { clearReceivers(); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for getChecksums identification"); addStep("Setup for test", "2 files on the pillar"); @@ -84,7 +84,7 @@ public void normalIdentificationTest() { "Received unexpected 'Response' in response."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void nonExistingFileTest() { addDescription("Tests that the pillar is able to reject a GetChecksums requests for a file, which it " + "does not have during the identification phase."); @@ -110,7 +110,7 @@ public void nonExistingFileTest() { "Received unexpected 'ResponseCode' in response."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void allFilesTest() { addDescription("Tests that the pillar accepts a GetChecksums requests for all files, even though it does not have any files."); FileIDs fileids = FileIDsUtils.getAllFileIDs(); 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 0dc4088cf..7ccc88dff 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 @@ -18,9 +18,9 @@ import org.bitrepository.protocol.ProtocolComponentFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import java.io.IOException; import java.io.InputStream; @@ -30,9 +30,9 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; + + + public class GetFileRequestIT extends PillarFunctionTest { private final Logger log = LoggerFactory.getLogger(this.getClass()); @@ -57,7 +57,7 @@ public void cleanUp(Method method) { } } - @Test(groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void normalGetFileTest() throws IOException { addDescription("Tests a normal GetFile sequence"); addStep("Send a getFile request to " + testConfiguration.getPillarUnderTestID(), @@ -109,7 +109,7 @@ public void normalGetFileTest() throws IOException { } } - @Test(groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void getFileWithFilePartTest() throws IOException { addDescription("Tests that a pillar is able to return a specified FilePart in the final response"); addStep("Send a getFile request to " + testConfiguration.getPillarUnderTestID() + " with a specified " + @@ -139,7 +139,7 @@ public void getFileWithFilePartTest() throws IOException { } } - @Test(groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void getMissingFileTest() { addDescription("Tests that a pillar gives an error when trying to get a non-existing file"); addStep("Send a getFile request to " + testConfiguration.getPillarUnderTestID() + " with a " + @@ -154,7 +154,7 @@ public void getMissingFileTest() { "Received unexpected 'ResponseCode' element."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) public void missingCollectionIDTest() { addDescription("Verifies the a missing collectionID in the request is rejected"); addStep("Sending a request without a collectionID.", @@ -164,11 +164,11 @@ public void missingCollectionIDTest() { messageBus.sendMessage(request); MessageResponse receivedResponse = receiveResponse(); - Assert.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), ResponseCode.REQUEST_NOT_UNDERSTOOD_FAILURE); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) public void otherCollectionTest() { addDescription("Verifies identification works correctly for a second collection defined for pillar"); addStep("Sending a identify request with a non-default collectionID (not the first collection) " + @@ -204,7 +204,7 @@ public String lookupGetFileDestination() { protected void assertPositivResponseIsReceived() { MessageResponse receivedResponse = receiveResponse(); - Assert.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); } } 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 49d453d36..b143d6bcd 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 @@ -27,10 +27,10 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; import org.bitrepository.pillar.messagefactories.GetFileMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; + + + public class IdentifyPillarsForGetFileIT extends PillarFunctionTest { protected GetFileMessageFactory msgFactory; @@ -40,7 +40,7 @@ public void initialiseReferenceTest() throws Exception { msgFactory = new GetFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void goodCaseIdentificationIT() { addDescription("Tests the general IdentifyPillarsForGetFile functionality of the pillar for the successful scenario."); addStep("Create and send the identify request message.", @@ -69,7 +69,7 @@ public void goodCaseIdentificationIT() { "Received unexpected 'ReplyTo' in response."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void nonExistingFileIdentificationIT() { addDescription("Tests the IdentifyPillarsForGetFile functionality of the pillar for a IdentificationForGetFile " + "for a non existing file."); 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 fb0794b65..4a086605f 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 @@ -26,20 +26,20 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; -import org.testng.annotations.Test; + import javax.xml.datatype.XMLGregorianCalendar; import java.util.GregorianCalendar; import java.util.List; -import static org.bitrepository.pillar.integration.func.Assert.assertEmpty; -import static org.bitrepository.pillar.integration.func.Assert.assertEquals; -import static org.bitrepository.pillar.integration.func.Assert.assertTrue; -import static org.testng.Assert.assertFalse; +import static org.bitrepository.pillar.integration.func.Assertions.assertEmpty; +import static org.bitrepository.pillar.integration.func.Assertions.assertEquals; +import static org.bitrepository.pillar.integration.func.Assertions.assertTrue; + public class GetFileIDsQueryTest extends PillarFunctionTest { - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void fileidsSortingTest() { addDescription("Test whether the file id result is sorted oldest to newest."); addFixture("Ensure at least two files are present on the pillar"); @@ -60,7 +60,7 @@ public void fileidsSortingTest() { } } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void maxNumberOfResultTest() { 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"); @@ -81,7 +81,7 @@ public void maxNumberOfResultTest() { "The returned file id wasn't equal to the oldest file id"); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void minTimeStampTest() { addDescription("Test the pillar support for only retrieving file ids newer that a given time. " + "Note that this test assumes there is at least 2 file ids with different timestamps."); @@ -127,7 +127,7 @@ public void minTimeStampTest() { CalendarUtils.getXmlGregorianCalendar(newerThanNewestTimestamp) + ") query"); } - @Test ( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) public void maxTimeStampTest() { addDescription("Test the pillar support for only retrieving file ids older that a given time. " + "Note that this test assumes there is at least 2 file ids with different timestamps."); 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 2114671b2..a94b2f1b0 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 @@ -33,17 +33,17 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.GetFileIDsMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; + + + + + public class GetFileIDsTest extends DefaultPillarOperationTest { protected GetFileIDsMessageFactory msgFactory; @@ -59,7 +59,7 @@ public void initialiseReferenceTest(Method method) throws Exception { clearReceivers(); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void pillarGetFileIDsTestSuccessCase() throws Exception { addDescription("Tests the GetFileIDs functionality of the pillar for the successful scenario."); @@ -98,7 +98,7 @@ public void pillarGetFileIDsTestSuccessCase() throws Exception { "Should be at least 2 files, but found: " + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void pillarGetFileIDsTestFailedNoSuchFileInOperation() throws Exception { addDescription("Tests that the pillar is able to handle requests for a non-existing file correctly during " + "the operation phase."); @@ -112,7 +112,7 @@ public void pillarGetFileIDsTestFailedNoSuchFileInOperation() throws Exception { assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void pillarGetFileIDsSpecificFileIDRequest() throws Exception { addDescription("Tests that the pillar is able to handle requests for a non-existing file correctly during " + "the operation phase."); @@ -132,7 +132,7 @@ public void pillarGetFileIDsSpecificFileIDRequest() throws Exception { assertFalse(finalResponse.isSetPartialResult() && finalResponse.isPartialResult()); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void pillarGetFileIDsTestBadDeliveryURL() throws Exception { addDescription("Test the case when the delivery URL is unaccessible."); String badURL = "http://localhost:61616/¾"; @@ -147,7 +147,7 @@ public void pillarGetFileIDsTestBadDeliveryURL() throws Exception { ResponseCode.FILE_TRANSFER_FAILURE); } - @Test( groups = { + @Test @Tag( PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST, PillarTestGroups.RESULT_UPLOAD}) 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 8d946361e..5d6a8361c 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 @@ -31,11 +31,11 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.GetFileIDsMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; + + + + public class IdentifyPillarsForGetFileIDsIT extends DefaultPillarIdentificationTest { protected GetFileIDsMessageFactory msgFactory; @@ -46,7 +46,7 @@ public void initialiseReferenceTest() throws Exception { clearReceivers(); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for getFileIDs identification"); addStep("Setup for test", "2 files on the pillar"); @@ -82,7 +82,7 @@ public void normalIdentificationTest() { "Received unexpected 'Response' in response."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void nonExistingFileTest() { addDescription("Tests that the pillar is able to reject a GetFileIDs requests for a file, which it " + "does not have during the identification phase."); @@ -107,7 +107,7 @@ public void nonExistingFileTest() { "Received unexpected 'ResponseCode' in response."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void allFilesTest() { addDescription("Tests that the pillar accepts a GetFileIDs requests for all files, even though it does not have any files."); FileIDs fileids = FileIDsUtils.getAllFileIDs(); 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 3b786cb70..3528c3b1c 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 @@ -32,9 +32,9 @@ import org.bitrepository.pillar.integration.func.PillarFunctionTest; import org.bitrepository.pillar.messagefactories.GetStatusMessageFactory; import org.bitrepository.settings.referencesettings.AlarmLevel; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import java.lang.reflect.Method; @@ -49,7 +49,7 @@ public void initialiseReferenceTest(Method method) throws Exception { msgFactory = new GetStatusMessageFactory(null, settingsForTestClient, getPillarID(), pillarDestination); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void normalGetStatusTest() { addDescription("Tests the GetStatus functionality of a pillar for the successful scenario."); @@ -60,13 +60,13 @@ public void normalGetStatusTest() { addStep("Receive and validate the final response", "Should be sent by the pillar."); GetStatusFinalResponse finalResponse = clientReceiver.waitForMessage(GetStatusFinalResponse.class); - Assert.assertNotNull(finalResponse); - Assert.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - Assert.assertEquals(finalResponse.getCorrelationID(), request.getCorrelationID()); - Assert.assertEquals(finalResponse.getFrom(), getPillarID()); + Assertions.assertNotNull(finalResponse); + Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(finalResponse.getCorrelationID(), request.getCorrelationID()); + Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); } - @Test( groups = {"failing"}) + @Test @Tag("failing"}) public void checksumPillarGetStatusWrongContributor() { addDescription("Tests the GetStatus functionality of the reference pillar for the bad scenario, where a wrong " + "contributor id is given."); @@ -80,7 +80,7 @@ public void checksumPillarGetStatusWrongContributor() { messageBus.sendMessage(request); addStep("The pillar should send an alarm.", ""); - Assert.assertNotNull(alarmReceiver.waitForMessage(AlarmMessage.class)); + Assertions.assertNotNull(alarmReceiver.waitForMessage(AlarmMessage.class)); } 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 15ede00e3..10a2961d4 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 @@ -28,12 +28,12 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; import org.bitrepository.pillar.messagefactories.GetStatusMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + import java.lang.reflect.Method; -import static org.testng.Assert.assertEquals; + public class IdentifyContributorsForGetStatusIT extends PillarFunctionTest { protected GetStatusMessageFactory msgFactory; @@ -43,7 +43,7 @@ public void initialiseReferenceTest(Method method) throws Exception { msgFactory = new GetStatusMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void normalGetStatusTest() { addDescription("Tests the GetStatus functionality of a pillar for the successful scenario."); 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 46c8c6f8d..4a3d87d70 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 @@ -28,7 +28,7 @@ import org.bitrepository.pillar.integration.PillarIntegrationTest; import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.protocol.bus.MessageReceiver; -import org.testng.annotations.Test; + import java.util.Arrays; import java.util.Collection; @@ -37,7 +37,7 @@ public class MultipleCollectionIT extends PillarIntegrationTest { /** Used for receiving responses from the pillar */ protected MessageReceiver clientReceiver; - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void fileInOtherCollectionTest() throws Exception { addDescription("Tests that a file is put correctly to a second collection, and that the file can be access " + "with getFile, getChecksums, getFileIDs and can be replaced and deleted correctly."); @@ -48,14 +48,14 @@ public void fileInOtherCollectionTest() throws Exception { addStep("Send a getFileIDs for the file in the second collection", "The fileID should be retrieved"); ContributorQuery query = new ContributorQuery(getPillarID(), null, null, null); - Assert.assertEquals(1, clientProvider.getGetFileIDsClient().getGetFileIDs( + Assertions.assertEquals(1, clientProvider.getGetFileIDsClient().getGetFileIDs( nonDefaultCollectionId, new ContributorQuery[] {query}, NON_DEFAULT_FILE_ID, DEFAULT_FILE_URL, null).size()); addStep("Send a getFileIDs for the file in the other collections", "The file should not be found here"); try { clientProvider.getGetFileIDsClient().getGetFileIDs( collectionID, new ContributorQuery[] {query}, NON_DEFAULT_FILE_ID, DEFAULT_FILE_URL, null).size(); - Assert.fail("Should have throw a NegativeResponseException as the file doesn't exist in the default " + + Assertions.fail("Should have throw a NegativeResponseException as the file doesn't exist in the default " + "collection"); } catch (NegativeResponseException nre){ //Expected 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 ebcfce9fe..680080a43 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 @@ -30,11 +30,11 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import static org.bitrepository.pillar.integration.func.Assert.assertEquals; -import static org.bitrepository.pillar.integration.func.Assert.assertNull; + + +import static org.bitrepository.pillar.integration.func.Assertions.assertEquals; +import static org.bitrepository.pillar.integration.func.Assertions.assertNull; public class IdentifyPillarsForPutFileIT extends DefaultPillarIdentificationTest { protected PutFileMessageFactory msgFactory; @@ -44,7 +44,7 @@ public void initialiseReferenceTest() throws Exception { msgFactory = new PutFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for putFile identification"); addStep("Sending a putFile identification request.", @@ -86,7 +86,7 @@ public void normalIdentificationTest() { "Received unexpected ReplyTo"); } - @Test( groups = {PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void identificationTestForChecksumPillar() { addDescription("Verifies the normal behaviour for putFile identification for a checksum pillar"); addStep("Sending a putFile identification.", @@ -110,7 +110,7 @@ public void identificationTestForChecksumPillar() { assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void fileExistsTest() { addDescription("Verifies the exists of a file with the same ID is handled correctly. " + "This means that a checksum for the existing file is returned, enabling the client to continue with " + 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 eff5fbac7..1d8340dfd 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 @@ -34,15 +34,15 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; + + + public class PutFileRequestIT extends DefaultPillarOperationTest { protected PutFileMessageFactory msgFactory; @@ -54,7 +54,7 @@ public void initialiseReferenceTest(Method method) throws Exception { msgFactory = new PutFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), pillarDestination); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void normalPutFileTest() { addDescription("Tests a normal PutFile sequence"); addStep("Send a putFile request to " + testConfiguration.getPillarUnderTestID(), @@ -102,7 +102,7 @@ public void normalPutFileTest() { "Received unexpected 'ResponseCode' element."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void putFileWithMD5ReturnChecksumTest() { addDescription("Tests that the pillar is able to return the default type checksum in the final response"); addStep("Send a putFile request to " + testConfiguration.getPillarUnderTestID() + " with the ", @@ -120,7 +120,7 @@ public void putFileWithMD5ReturnChecksumTest() { "Return MD5 checksum was not equals to checksum for default file."); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST, + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST, PillarTestGroups.OPERATION_ACCEPTED_PROGRESS}) public void putFileOperationAcceptedProgressTest() { addDescription("Tests a that a pillar sends progress response after receiving a putFile request."); 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 efab1dc2d..6249578bf 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 @@ -31,8 +31,8 @@ import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.ReplaceFileMessageFactory; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + public class IdentifyPillarsForReplaceFileIT extends DefaultPillarIdentificationTest { protected ReplaceFileMessageFactory msgFactory; @@ -43,7 +43,7 @@ public void initialiseReferenceTest() throws Exception { } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for replaceFile identification"); addStep("Sending a replaceFile identification.", @@ -54,18 +54,18 @@ public void normalIdentificationTest() { IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - Assert.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); - Assert.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); - Assert.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); - Assert.assertEquals(receivedIdentifyResponse.getFileID(), DEFAULT_FILE_ID); - Assert.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); - Assert.assertNull(receivedIdentifyResponse.getPillarChecksumSpec()); - Assert.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); + Assertions.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); + Assertions.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); + Assertions.assertEquals(receivedIdentifyResponse.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); + Assertions.assertNull(receivedIdentifyResponse.getPillarChecksumSpec()); + Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), ResponseCode.IDENTIFICATION_POSITIVE); - Assert.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); + Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test( groups = {PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void identificationTestForChecksumPillar() { addDescription("Verifies the normal behaviour for replaceFile identification for a checksum pillar"); addStep("Sending a replaceFile identification.", @@ -77,18 +77,18 @@ public void identificationTestForChecksumPillar() { IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - Assert.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); - Assert.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); - Assert.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); - Assert.assertEquals(receivedIdentifyResponse.getPillarChecksumSpec().getChecksumType(), + Assertions.assertEquals(receivedIdentifyResponse.getCollectionID(), identifyRequest.getCollectionID()); + Assertions.assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); + Assertions.assertEquals(receivedIdentifyResponse.getFrom(), getPillarID()); + Assertions.assertEquals(receivedIdentifyResponse.getPillarChecksumSpec().getChecksumType(), ChecksumUtils.getDefault(settingsForCUT).getChecksumType()); - Assert.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); - Assert.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); + Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), ResponseCode.IDENTIFICATION_POSITIVE); - Assert.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); + Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void fileDoesNotExistsTest() { addDescription("Verifies that a request for a non-existing file is handled correctly"); addStep("Sending a replaceFile identification for a file not in the pillar.", @@ -99,7 +99,7 @@ public void fileDoesNotExistsTest() { IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - Assert.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), + Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); } 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 b11857b8c..24e4aa1cd 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 @@ -33,9 +33,9 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.ReplaceFileMessageFactory; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; @@ -56,7 +56,7 @@ public void initialiseReferenceTest(Method method) throws Exception { null, null, null); } - @Test( groups = {PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) public void normalReplaceFileTest() { addDescription("Tests a normal ReplaceFile sequence"); addStep("Send a ReplaceFile request to " + testConfiguration.getPillarUnderTestID(), @@ -69,21 +69,21 @@ public void normalReplaceFileTest() { ReplaceFileProgressResponse progressResponse = clientReceiver.waitForMessage(ReplaceFileProgressResponse.class, getOperationTimeout(), TimeUnit.SECONDS); - Assert.assertNotNull(progressResponse); - Assert.assertEquals(progressResponse.getCorrelationID(), replaceRequest.getCorrelationID()); - Assert.assertEquals(progressResponse.getFrom(), getPillarID()); - Assert.assertEquals(progressResponse.getPillarID(), getPillarID()); - Assert.assertEquals(progressResponse.getResponseInfo().getResponseCode(), + Assertions.assertNotNull(progressResponse); + Assertions.assertEquals(progressResponse.getCorrelationID(), replaceRequest.getCorrelationID()); + Assertions.assertEquals(progressResponse.getFrom(), getPillarID()); + Assertions.assertEquals(progressResponse.getPillarID(), getPillarID()); + Assertions.assertEquals(progressResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_ACCEPTED_PROGRESS); ReplaceFileFinalResponse finalResponse = (ReplaceFileFinalResponse) receiveResponse(); - Assert.assertNotNull(finalResponse); - Assert.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - Assert.assertEquals(finalResponse.getCorrelationID(), replaceRequest.getCorrelationID()); - Assert.assertEquals(finalResponse.getFrom(), getPillarID()); - Assert.assertNull(finalResponse.getChecksumDataForExistingFile()); - Assert.assertNull(finalResponse.getChecksumDataForNewFile()); - Assert.assertEquals(finalResponse.getPillarID(), getPillarID()); + Assertions.assertNotNull(finalResponse); + Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(finalResponse.getCorrelationID(), replaceRequest.getCorrelationID()); + Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); + Assertions.assertNull(finalResponse.getChecksumDataForExistingFile()); + Assertions.assertNull(finalResponse.getChecksumDataForNewFile()); + Assertions.assertEquals(finalResponse.getPillarID(), getPillarID()); } @Override 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 a6c00a404..d8fe4415c 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 @@ -27,8 +27,8 @@ import org.bitrepository.client.eventhandler.EventHandler; import org.bitrepository.pillar.integration.perf.metrics.Metrics; import org.bitrepository.protocol.security.DummySecurityManager; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + public class GetAuditTrailsFileStressIT extends PillarPerformanceTest { protected AuditTrailClient auditTrailClient; @@ -40,7 +40,7 @@ settingsForCUT, new DummySecurityManager(), settingsForCUT.getComponentID() ); } - @Test( groups = {"pillar-stress-test"}, dependsOnGroups={"stress-test-pillar-population"}) + @Test @Tag("pillar-stress-test"}, dependsOnGroups={"stress-test-pillar-population"}) public void singleTreadedGetAuditTrails() throws Exception { final int NUMBER_OF_AUDITS = 100; final int PART_STATISTIC_INTERVAL = NUMBER_OF_AUDITS/5; @@ -58,7 +58,7 @@ public void singleTreadedGetAuditTrails() throws Exception { } } - @Test( groups = {"pillar-stress-test"}) + @Test @Tag("pillar-stress-test"}) public void parallelGetAuditTrails() throws Exception { final int NUMBER_OF_AUDITS = 10; final int PART_STATISTIC_INTERVAL = NUMBER_OF_AUDITS/5; 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 0b341c9ba..18c96f77e 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,8 +32,8 @@ import org.bitrepository.pillar.integration.perf.metrics.Metrics; import org.bitrepository.pillar.messagefactories.GetFileMessageFactory; import org.bitrepository.protocol.bus.MessageReceiver; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + public class GetFileStressIT extends PillarPerformanceTest { protected GetFileClient getFileClient; @@ -45,7 +45,7 @@ settingsForTestClient, createSecurityManager(), settingsForTestClient.getCompone ); } - @Test( groups = {"pillar-stress-test"}) + @Test @Tag("pillar-stress-test"}) public void singleGetFilePerformanceTest() throws Exception { final int NUMBER_OF_FILES = 1000; final int PART_STATISTIC_INTERVAL = 100; @@ -64,7 +64,7 @@ public void singleGetFilePerformanceTest() throws Exception { } } - @Test( groups = {"pillar-stress-test"}) + @Test @Tag("pillar-stress-test"}) public void parallelGetFilePerformanceTest() throws Exception { final int numberOfFiles = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.numberOfFiles"); final int partStatisticsInterval = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.partStatisticsInterval"); @@ -89,7 +89,7 @@ public void parallelGetFilePerformanceTest() throws Exception { awaitAsynchronousCompletion(metrics, numberOfFiles); } - @Test( groups = {"pillar-stress-test"}) + @Test @Tag("pillar-stress-test"}) public void noIdentfyGetFilePerformanceTest() throws Exception { final int numberOfFiles = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.numberOfFiles"); final int partStatisticsInterval = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.partStatisticsInterval"); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java index 4ad5af7cf..327afd03a 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java @@ -37,9 +37,6 @@ import org.bitrepository.protocol.messagebus.MessageListener; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.ITestContext; -import org.testng.annotations.BeforeSuite; - import java.util.LinkedList; import java.util.List; import java.util.concurrent.BlockingQueue; 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 76b212d9f..f7257e19e 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 @@ -28,8 +28,8 @@ import org.bitrepository.modify.putfile.BlockingPutFileClient; import org.bitrepository.modify.putfile.PutFileClient; import org.bitrepository.pillar.integration.perf.metrics.Metrics; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; @@ -44,7 +44,7 @@ settingsForTestClient, createSecurityManager(), settingsForTestClient.getCompone ); } - @Test( groups = {"pillar-stress-test", "stress-test-pillar-population"}) + @Test @Tag("pillar-stress-test", "stress-test-pillar-population"}) public void singleTreadedPut() throws Exception { final int NUMBER_OF_FILES = 10; final int PART_STATISTIC_INTERVAL = 2; @@ -65,7 +65,7 @@ public void singleTreadedPut() throws Exception { //ToDo assert that the files are present } - @Test( groups = {"pillar-stress-test"}) + @Test @Tag("pillar-stress-test"}) public void parallelPut() throws Exception { final int numberOfFiles = testConfiguration.getInt("pillarintegrationtest.PutFileStressIT.parallelPut.numberOfFiles"); final int partStatisticsInterval = testConfiguration.getInt("pillarintegrationtest.PutFileStressIT.parallelPut.partStatisticsInterval"); 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 fa3e760c6..b918490f4 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 @@ -37,13 +37,13 @@ import org.bitrepository.pillar.messagefactories.DeleteFileMessageFactory; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + 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.testng.Assert.assertEquals; + /** * Tests the PutFile functionality on the ReferencePillar. @@ -58,7 +58,7 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseIdentification() throws Exception { 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!"); @@ -96,7 +96,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a DeleteFile operation on the checksum pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -134,7 +134,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationNoFile() throws Exception { addDescription("Tests the DeleteFile functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -171,7 +171,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationMissingVerification() throws Exception { addDescription("Tests the DeleteFile functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -213,7 +213,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - //@Test( groups = {"regressiontest", "pillartest"}) + //@Test @Tag("regressiontest", "pillartest"}) // FAILS, when combined with other tests... public void goodCaseOperation() throws Exception { addDescription("Tests the DeleteFile functionality of the pillar for the success scenario, where the file is uploaded."); 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 53cb1068b..64691e4d0 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 @@ -32,9 +32,9 @@ import org.bitrepository.pillar.store.StorageModel; import org.bitrepository.protocol.MessageContext; import org.bitrepository.service.exception.RequestHandlerException; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + public class GeneralMessageHandlingTest extends MockedPillarTest { @@ -45,7 +45,7 @@ public void setup() { this.requestHandler = new MockRequestHandler(context, model); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarMessageHandler() { addDescription("Test the handling of the PillarMessageHandler super-class."); addStep("Setup", "Should be OK."); @@ -54,55 +54,55 @@ public void testPillarMessageHandler() { requestHandler.validatePillarID(getPillarID()); try { requestHandler.validatePillarID("asdfghjklæwetyguvpbmopijå.døtphstiøyizhdfvgnayegtxtæhjmdtuilsfm,s"); - Assert.fail("Should throw an IllegalArgumentException here!"); + Assertions.fail("Should throw an IllegalArgumentException here!"); } catch (IllegalArgumentException e) { // expected } } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarMessageHandlerValidateFileIDFormatDefaultFileId() throws Exception { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on the default file id"); requestHandler.validateFileIDFormat(DEFAULT_FILE_ID); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarMessageHandlerValidateFileIDFormatFolderFileId() throws Exception { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id with directory path"); requestHandler.validateFileIDFormat("path/" + DEFAULT_FILE_ID); } - @Test( groups = {"regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) public void testPillarMessageHandlerValidateFileIDFormatParentFolderFileId() throws Exception { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id containing path to a parent directory"); requestHandler.validateFileIDFormat("../../OTHER_COLLECTION/folderDir/test.txt"); } - @Test( groups = {"regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) public void testPillarMessageHandlerValidateFileIDFormatRootPathFileId() throws Exception { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id containing path from the root folder"); requestHandler.validateFileIDFormat("/usr/local/bin/execute.sh"); } - @Test( groups = {"regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) public void testPillarMessageHandlerValidateFileIDFormatSubFolderToParentFolderFileId() throws Exception { 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"); requestHandler.validateFileIDFormat("OTHER_COLLECTION/../../folderDir/test.txt"); } - @Test( groups = {"regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) public void testPillarMessageHandlerValidateFileIDFormatEnvHomePathFileId() throws Exception { 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"); requestHandler.validateFileIDFormat("$HOME/bin/execute.sh"); } - @Test( groups = {"regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) public void testPillarMessageHandlerValidateFileIDFormatTildeHomePathFileId() throws Exception { 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"); requestHandler.validateFileIDFormat("~/bin/execute.sh"); } - @Test( groups = {"regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) public void testPillarMessageHandlerValidateFileIDFormatTooLong() throws Exception { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id which has more characters than required"); String fileId = ""; 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 10ee4ed1d..3f5b01479 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 @@ -32,15 +32,15 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.pillar.MockedPillarTest; import org.bitrepository.pillar.messagefactories.GetAuditTrailsMessageFactory; -import org.testng.annotations.Test; + import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigInteger; import java.util.Date; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertTrue; + + + public class GetAuditTrailsTest extends MockedPillarTest { private GetAuditTrailsMessageFactory msgFactory; @@ -51,7 +51,7 @@ public void initializeCUT() { msgFactory = new GetAuditTrailsMessageFactory(collectionID, settingsForTestClient); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void checksumPillarGetAuditTrailsSuccessful() { addDescription("Tests the GetAuditTrails functionality of the pillar for the successful scenario, " + "where all audit trails are requested."); @@ -100,7 +100,7 @@ public void checksumPillarGetAuditTrailsSuccessful() { assertEquals(finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size(), 1); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void checksumPillarGetAuditTrailsSpecificRequests() { addDescription("Tests the GetAuditTrails functionality of the pillar for the successful scenario, " + "where a specific audit trail are requested."); @@ -172,7 +172,7 @@ public void checksumPillarGetAuditTrailsSpecificRequests() { assertFalse(finalResponse.isPartialResult()); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void checksumPillarGetAuditTrailsMaximumNumberOfResults() { addDescription("Tests the GetAuditTrails functionality of the pillar for the successful scenario, " + "where a limited number of audit trails are requested."); 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 3625ecb76..f03d3052e 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 @@ -41,7 +41,7 @@ import org.bitrepository.pillar.store.checksumdatabase.ExtractedChecksumResultSet; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; @@ -50,8 +50,8 @@ import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; + + /** * Tests the PutFile functionality on the ReferencePillar. @@ -67,7 +67,7 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseIdentification() throws Exception { addDescription("Tests the identification for a GetChecksums operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -106,7 +106,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a GetChecksums operation on the pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -145,7 +145,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseOperationSingleFile() throws Exception { addDescription("Tests the GetChecksums operation on the pillar for the successful scenario when requesting one specific file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -193,7 +193,7 @@ public ExtractedChecksumResultSet answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseOperationAllFiles() throws Exception { addDescription("Tests the GetChecksums operation on the pillar for the successful scenario, when requesting all files."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -235,7 +235,7 @@ public ExtractedChecksumResultSet answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationNoFile() throws Exception { addDescription("Tests the GetChecksums functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -272,7 +272,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testRestrictions() throws Exception { addDescription("Tests that the restrictions are correctly passed on to the cache."); 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 2d1c5e0c9..cc678c486 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 @@ -39,7 +39,7 @@ import org.bitrepository.pillar.store.checksumdatabase.ExtractedFileIDsResultSet; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; @@ -50,8 +50,8 @@ import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isNull; import static org.mockito.Mockito.doAnswer; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNull; + + /** * Tests the PutFile functionality on the ReferencePillar. @@ -67,7 +67,7 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseIdentification() throws Exception { 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!"); @@ -106,7 +106,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a GetFileIDs operation on the pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -145,7 +145,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - //@Test( groups = {"regressiontest", "pillartest"}) + //@Test @Tag("regressiontest", "pillartest"}) // FAILS, when combined with other tests... public void goodCaseOperationSingleFile() throws Exception { addDescription("Tests the GetFileIDs operation on the pillar for the successful scenario when requesting one specific file."); @@ -194,7 +194,7 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - //@Test( groups = {"regressiontest", "pillartest"}) + //@Test @Tag("regressiontest", "pillartest"}) // FAILS, when combined with other tests... public void goodCaseOperationAllFiles() throws Exception { addDescription("Tests the GetFileIDs operation on the pillar for the successful scenario, when requesting all files."); @@ -244,7 +244,7 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationNoFile() throws Exception { addDescription("Tests the GetFileIDs functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -282,7 +282,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - //@Test( groups = {"regressiontest", "pillartest"}) + //@Test @Tag("regressiontest", "pillartest"}) // FAILS, when combined with other tests... public void testRestrictions() throws Exception { addDescription("Tests that the restrictions are correctly passed on to the cache."); 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 7b511a005..1886be1d0 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 @@ -40,14 +40,14 @@ import org.bitrepository.service.exception.RequestHandlerException; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + import java.io.ByteArrayInputStream; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; -import static org.testng.Assert.assertEquals; + /** * Tests the PutFile functionality on the ReferencePillar. @@ -62,7 +62,7 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseIdentification() throws Exception { addDescription("Tests the identification for a GetFile operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -95,7 +95,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a GetFile operation on the checksum pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -133,7 +133,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - //@Test( groups = {"regressiontest", "pillartest"}) + //@Test @Tag("regressiontest", "pillartest"}) // FAILS, when combined with other tests... public void badCaseOperationNoFile() throws Exception { addDescription("Tests the GetFile functionality of the pillar for the failure scenario, where it does not have the file."); @@ -171,7 +171,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - //@Test( groups = {"regressiontest", "pillartest"}) + //@Test @Tag("regressiontest", "pillartest"}) // FAILS, when combined with other tests... public void goodCaseOperation() throws Exception { addDescription("Tests the GetFile functionality of the pillar for the success scenario, where the file is uploaded."); 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 a14b096f3..cf029e64a 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 @@ -40,16 +40,16 @@ import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + 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.when; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; + + + /** * Tests the PutFile functionality on the ReferencePillar. @@ -66,7 +66,7 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseIdentification() throws Exception { addDescription("Tests the identification for a PutFile operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -106,7 +106,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a PutFile operation on the pillar for the failure scenario, when the file already exists."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -144,7 +144,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationFileAlreadyExists() throws Exception { addDescription("Tests the PutFile operation on the pillar for the failure scenario, when the file already exists."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -182,7 +182,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCasePutOperationNoValidationChecksum() throws Exception { addDescription("Tests the PutFile operation on the pillar for the failure scenario, when no validation checksum is given but required."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -222,7 +222,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - //@Test( groups = {"regressiontest", "pillartest"}) + //@Test @Tag("regressiontest", "pillartest"}) // FAILS, when combined with other tests... public void goodCaseOperation() throws Exception { addDescription("Tests the PutFile operation on the pillar for the success scenario."); @@ -268,7 +268,7 @@ public String answer(InvocationOnMock invocation) { @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseOperationWithChecksumReturn() throws Exception { addDescription("Tests the PutFile operation on the pillar for the success scenario, when requesting the cheksum of the file returned."); addStep("Set up constants and variables.", "Should not fail here!"); 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 fca9c2e9f..8abf11f31 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 @@ -41,15 +41,15 @@ import org.bitrepository.pillar.messagefactories.ReplaceFileMessageFactory; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; -import org.testng.annotations.Test; + 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.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; + + + /** * Tests the ReplaceFile functionality on the ReferencePillar. @@ -66,7 +66,7 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseIdentification() { addDescription("Tests the identification for a ReplaceFile operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -96,7 +96,7 @@ public void goodCaseIdentification() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseIdentification() { addDescription("Tests the identification for a ReplaceFile operation on the pillar for the failure scenario, when the file does not exist."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -126,7 +126,7 @@ public void badCaseIdentification() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationMissingFile() { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -158,7 +158,7 @@ public String answer(InvocationOnMock invocation) { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationNoDestructiveChecksum() { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when no validation " + "checksum is given for the destructive action, but though is required."); @@ -191,7 +191,7 @@ public void badCaseOperationNoDestructiveChecksum() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationNoValidationChecksum() { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when no validation " + "checksum is given for the new file, but though is required."); @@ -224,7 +224,7 @@ public void badCaseOperationNoValidationChecksum() { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void badCaseOperationWrongDestructiveChecksum() throws Exception { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when the checksum for " +"the destructive action is different from the one in the cache."); @@ -257,7 +257,7 @@ public void badCaseOperationWrongDestructiveChecksum() throws Exception { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseOperation() throws Exception { addDescription("Tests the ReplaceFile operation on the pillar for the success scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -294,7 +294,7 @@ public void goodCaseOperation() throws Exception { } @SuppressWarnings("rawtypes") - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void goodCaseOperationWithChecksumsReturn() throws Exception { addDescription("Tests the ReplaceFile operation on the pillar for the success scenario, when requesting both the cheksums of the file returned."); addStep("Set up constants and variables.", "Should not fail here!"); 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 c9c76bfbf..18fb44aed 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 @@ -23,9 +23,9 @@ import org.bitrepository.pillar.DefaultPillarTest; import org.bitrepository.service.workflow.SchedulableJob; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; @@ -40,12 +40,12 @@ public void setUpFactory() throws DatatypeConfigurationException { factory = DatatypeFactory.newInstance(); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testWorkflowRecalculatesChecksum() throws Exception { addDescription("Test that the workflow recalculates the workflows, when the maximum age has been met."); Date beforeWorkflowDate = csCache.getCalculationDate(DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(csCache.getAllFileIDs(collectionID).size(), 1); - Assert.assertEquals(archives.getAllFileIds(collectionID).size(), 1); + Assertions.assertEquals(csCache.getAllFileIDs(collectionID).size(), 1); + Assertions.assertEquals(archives.getAllFileIds(collectionID).size(), 1); settingsForCUT.getReferenceSettings().getPillarSettings().setMaxAgeForChecksums(factory.newDuration(0)); synchronized(this) { @@ -57,17 +57,17 @@ public void testWorkflowRecalculatesChecksum() throws Exception { workflow.start(); Date afterWorkflowDate = csCache.getCalculationDate(DEFAULT_FILE_ID, collectionID); - Assert.assertTrue(beforeWorkflowDate.getTime() < afterWorkflowDate.getTime(), + Assertions.assertTrue(beforeWorkflowDate.getTime() < afterWorkflowDate.getTime(), beforeWorkflowDate.getTime() + " < "+ afterWorkflowDate.getTime()); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testWorkflowDoesNotRecalculateWhenNotNeeded() throws Exception { addDescription("Test that the workflow does not recalculates the workflows, when the maximum age has " + "not yet been met."); Date beforeWorkflowDate = csCache.getCalculationDate(DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(csCache.getAllFileIDs(collectionID).size(), 1); - Assert.assertEquals(archives.getAllFileIds(collectionID).size(), 1); + Assertions.assertEquals(csCache.getAllFileIDs(collectionID).size(), 1); + Assertions.assertEquals(archives.getAllFileIds(collectionID).size(), 1); settingsForCUT.getReferenceSettings().getPillarSettings() .setMaxAgeForChecksums(factory.newDuration(Long.MAX_VALUE)); @@ -80,7 +80,7 @@ public void testWorkflowDoesNotRecalculateWhenNotNeeded() throws Exception { workflow.start(); Date afterWorkflowDate = csCache.getCalculationDate(DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(beforeWorkflowDate.getTime(), afterWorkflowDate.getTime(), + Assertions.assertEquals(beforeWorkflowDate.getTime(), afterWorkflowDate.getTime(), beforeWorkflowDate.getTime() + " == "+ afterWorkflowDate.getTime()); } } 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 14ff080f2..398ec9feb 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 @@ -29,15 +29,15 @@ import org.bitrepository.pillar.store.checksumdatabase.ChecksumStore; import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.settings.referencesettings.ChecksumPillarFileDownload; -import org.testng.annotations.Test; + import java.util.Date; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + + + + + public class ChecksumPillarModelTest extends DefaultFixturePillarTest { ChecksumStorageModel pillarModel; @@ -61,7 +61,7 @@ protected void initializeCUT() { nonDefaultCsType.setChecksumSalt(new byte[]{'a', 'z'}); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarModelBasicFunctionality() { addDescription("Test the basic functions of the full reference pillar model."); addStep("Check the pillar id in the pillar model", "Identical to the one from the test."); @@ -95,7 +95,7 @@ public void testPillarModelBasicFunctionality() { } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarModelHasFile() throws Exception { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -186,7 +186,7 @@ public void testPillarModelHasFile() throws Exception { } } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarModelNoFile() { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); 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 206293b33..3149d525b 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 @@ -32,16 +32,16 @@ import org.bitrepository.pillar.store.filearchive.CollectionArchiveManager; import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.service.exception.RequestHandlerException; -import org.testng.annotations.Test; + import java.io.ByteArrayInputStream; import java.io.IOException; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertFalse; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; -import static org.testng.Assert.fail; + + + + + public class FullPillarModelTest extends DefaultFixturePillarTest { FileStorageModel pillarModel; @@ -68,7 +68,7 @@ protected void initializeCUT() { nonDefaultCsType.setChecksumSalt(new byte[]{'a', 'z'}); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarModelBasicFunctionality() throws Exception { addDescription("Test the basic functions of the full reference pillar model."); addStep("Check the pillar id in the pillar model", "Identical to the one from the test."); @@ -92,7 +92,7 @@ public void testPillarModelBasicFunctionality() throws Exception { assertNull(pillarModel.getChecksumPillarSpec()); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarModelHasFile() throws Exception { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -114,7 +114,7 @@ public void testPillarModelHasFile() throws Exception { assertEquals(EMPTY_HMAC_SHA385_CHECKSUM, otherChecksum); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testPillarModelNoFile() throws Exception { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java index 0ca34e496..da703ba86 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java @@ -25,20 +25,20 @@ import org.bitrepository.common.settings.SettingsProvider; import org.bitrepository.common.settings.XMLFileSettingsLoader; import org.bitrepository.pillar.PillarSettingsProvider; -import org.testng.Assert; -import org.testng.annotations.Test; + + public class PillarSettingsProviderTest { private static final String PATH_TO_TEST_SETTINGS = "settings/xml/bitrepository-devel"; - @Test(groups = {"regressiontest"}) + @Test @Tag("regressiontest"}) public void componentIDTest() { SettingsProvider settingsLoader = new PillarSettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), null); Settings settings = settingsLoader.getSettings(); - Assert.assertEquals( + Assertions.assertEquals( settings.getReferenceSettings().getPillarSettings().getPillarID(), settings.getComponentID()); String componentID = "testPillarID"; @@ -46,7 +46,7 @@ public void componentIDTest() { new PillarSettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), "testPillarID"); settings = settingsLoader.getSettings(); - Assert.assertEquals( + Assertions.assertEquals( componentID, settings.getComponentID()); } } 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 97d62b8ea..6936f3ab5 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 @@ -25,9 +25,9 @@ import org.bitrepository.common.utils.TestFileHelper; import org.bitrepository.pillar.store.filearchive.ArchiveDirectory; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.Test; + + + import java.io.File; import java.io.FileOutputStream; @@ -53,7 +53,7 @@ public void shutdownTests() throws Exception { } } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryExistingFile() throws Exception { addDescription("Test the ArchiveDirectory when the file exists"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -62,17 +62,17 @@ public void testArchiveDirectoryExistingFile() throws Exception { createExistingFile(); addStep("Validate the existence of the file", "Should exist and be retrievable."); - Assert.assertTrue(directory.hasFile(FILE_ID)); - Assert.assertNotNull(directory.retrieveFile(FILE_ID)); - Assert.assertEquals(directory.getFileIds(), Arrays.asList(FILE_ID)); + Assertions.assertTrue(directory.hasFile(FILE_ID)); + Assertions.assertNotNull(directory.retrieveFile(FILE_ID)); + Assertions.assertEquals(directory.getFileIds(), Arrays.asList(FILE_ID)); addStep("Delete the file.", "Should not be extractable."); directory.removeFileFromArchive(FILE_ID); - Assert.assertFalse(directory.hasFile(FILE_ID)); - Assert.assertNull(directory.retrieveFile(FILE_ID)); + Assertions.assertFalse(directory.hasFile(FILE_ID)); + Assertions.assertNull(directory.retrieveFile(FILE_ID)); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryMissingFile() throws Exception { addDescription("Test the ArchiveDirectory when the file is missing."); addStep("Setup", "No file added to the directory."); @@ -80,20 +80,20 @@ public void testArchiveDirectoryMissingFile() throws Exception { ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); addStep("Validate the existence of the file", "Should exist and be retrievable."); - Assert.assertFalse(directory.hasFile(FILE_ID)); - Assert.assertNull(directory.retrieveFile(FILE_ID)); - Assert.assertEquals(directory.getFileIds(), Arrays.asList()); + Assertions.assertFalse(directory.hasFile(FILE_ID)); + Assertions.assertNull(directory.retrieveFile(FILE_ID)); + Assertions.assertEquals(directory.getFileIds(), Arrays.asList()); addStep("Delete the file.", "exception since the file does not exist."); try { directory.removeFileFromArchive(FILE_ID); - Assert.fail("Should not be possible to remove a non-existing file."); + Assertions.fail("Should not be possible to remove a non-existing file."); } catch (IllegalStateException e) { // exptected } } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryNewFile() throws Exception { addDescription("Testing the ArchiveDirectory handling of a new file."); addStep("Setup", "No file added to the directory."); @@ -102,35 +102,35 @@ public void testArchiveDirectoryNewFile() throws Exception { addStep("Retrieve tmp file", "Exception since files does not exist."); try { directory.getFileInTempDir(FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } addStep("Request a new file for the tmp dir", "Should be received and creatable."); File newFile = directory.getNewFileInTempDir(FILE_ID); - Assert.assertTrue(newFile.createNewFile()); + Assertions.assertTrue(newFile.createNewFile()); addStep("Retrieve tmp file", "Should be the newly created file."); File tmpFile = directory.getFileInTempDir(FILE_ID); - Assert.assertNotNull(tmpFile); - Assert.assertEquals(tmpFile.getAbsolutePath(), newFile.getAbsolutePath()); + Assertions.assertNotNull(tmpFile); + Assertions.assertEquals(tmpFile.getAbsolutePath(), newFile.getAbsolutePath()); addStep("Request another new file with the same name", "Should throw exception, since it already exists."); try { directory.getNewFileInTempDir(FILE_ID); - Assert.fail("Should throw exception, since the file already exists."); + Assertions.fail("Should throw exception, since the file already exists."); } catch (IllegalStateException e) { // expected } addStep("Move the file from tmp to archive", "Should exist in archive but not in tmp."); directory.moveFromTmpToArchive(FILE_ID); - Assert.assertTrue(directory.hasFile(FILE_ID)); - Assert.assertFalse(directory.hasFileInTempDir(FILE_ID)); + Assertions.assertTrue(directory.hasFile(FILE_ID)); + Assertions.assertFalse(directory.hasFileInTempDir(FILE_ID)); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) 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."); @@ -139,7 +139,7 @@ public void testArchiveDirectoryMoveFileToArchive() throws Exception { addStep("Moving file from tmp to archive", "Exception since it does not exist in the tmp-dir"); try { directory.moveFromTmpToArchive(FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } @@ -147,28 +147,28 @@ public void testArchiveDirectoryMoveFileToArchive() throws Exception { addStep("Create file in both tmp and archive.", ""); createExistingFile(); File newFile = directory.getNewFileInTempDir(FILE_ID); - Assert.assertTrue(newFile.createNewFile()); + Assertions.assertTrue(newFile.createNewFile()); addStep("Moving file from tmp to archive", "Exception since the file already exists within the archive."); try { directory.moveFromTmpToArchive(FILE_ID); - Assert.fail("Should throw exception since the file in archive already exists."); + Assertions.fail("Should throw exception since the file in archive already exists."); } catch (IllegalStateException e) { // exptected } addStep("Remove the file from archive and try again", "File in tmp moved to archive."); - Assert.assertTrue(directory.hasFile(FILE_ID)); - Assert.assertTrue(directory.hasFileInTempDir(FILE_ID)); + Assertions.assertTrue(directory.hasFile(FILE_ID)); + Assertions.assertTrue(directory.hasFileInTempDir(FILE_ID)); directory.removeFileFromArchive(FILE_ID); - Assert.assertFalse(directory.hasFile(FILE_ID)); - Assert.assertTrue(directory.hasFileInTempDir(FILE_ID)); + Assertions.assertFalse(directory.hasFile(FILE_ID)); + Assertions.assertTrue(directory.hasFileInTempDir(FILE_ID)); directory.moveFromTmpToArchive(FILE_ID); - Assert.assertTrue(directory.hasFile(FILE_ID)); - Assert.assertFalse(directory.hasFileInTempDir(FILE_ID)); + Assertions.assertTrue(directory.hasFile(FILE_ID)); + Assertions.assertFalse(directory.hasFileInTempDir(FILE_ID)); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryRemoveFile() throws Exception { addDescription("Testing the error scenarios when removing files from the archive."); addStep("Setup", "No file added to the directory."); @@ -178,7 +178,7 @@ public void testArchiveDirectoryRemoveFile() throws Exception { addStep("Remove nonexisting file from archive", "Exception since it does not exist"); try { directory.removeFileFromArchive(FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } @@ -186,7 +186,7 @@ public void testArchiveDirectoryRemoveFile() throws Exception { addStep("Remove nonexisting file from tmp", "Exception since it does not exist"); try { directory.removeFileFromTmp(FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } @@ -194,18 +194,18 @@ public void testArchiveDirectoryRemoveFile() throws Exception { addStep("Create file in both tmp, archive and retain directories.", ""); createExistingFile(); File tmpFile = directory.getNewFileInTempDir(FILE_ID); - Assert.assertTrue(tmpFile.createNewFile()); + Assertions.assertTrue(tmpFile.createNewFile()); File retainFile = new File(retainDir, FILE_ID); - Assert.assertTrue(retainFile.createNewFile()); - Assert.assertEquals(retainDir.list().length, 1); + Assertions.assertTrue(retainFile.createNewFile()); + Assertions.assertEquals(retainDir.list().length, 1); addStep("Remove the file from archive and tmp", "all 3 files in retain dir."); directory.removeFileFromArchive(FILE_ID); directory.removeFileFromTmp(FILE_ID); - Assert.assertEquals(retainDir.list().length, 3); + Assertions.assertEquals(retainDir.list().length, 3); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryExistingFolderFile() throws Exception { addDescription("Test the ArchiveDirectory when the file exists"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -214,17 +214,17 @@ public void testArchiveDirectoryExistingFolderFile() throws Exception { createExistingFolderFile(); addStep("Validate the existence of the file", "Should exist and be retrievable."); - Assert.assertTrue(directory.hasFile(FOLDER_FILE_ID)); - Assert.assertNotNull(directory.retrieveFile(FOLDER_FILE_ID)); - Assert.assertEquals(directory.getFileIds(), Arrays.asList(FOLDER_FILE_ID)); + Assertions.assertTrue(directory.hasFile(FOLDER_FILE_ID)); + Assertions.assertNotNull(directory.retrieveFile(FOLDER_FILE_ID)); + Assertions.assertEquals(directory.getFileIds(), Arrays.asList(FOLDER_FILE_ID)); addStep("Delete the file.", "Should not be retrievable."); directory.removeFileFromArchive(FOLDER_FILE_ID); - Assert.assertFalse(directory.hasFile(FOLDER_FILE_ID)); - Assert.assertNull(directory.retrieveFile(FOLDER_FILE_ID)); + Assertions.assertFalse(directory.hasFile(FOLDER_FILE_ID)); + Assertions.assertNull(directory.retrieveFile(FOLDER_FILE_ID)); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryMissingFolderFile() throws Exception { addDescription("Test the ArchiveDirectory when the file is missing."); addStep("Setup", "No file added to the directory."); @@ -232,20 +232,20 @@ public void testArchiveDirectoryMissingFolderFile() throws Exception { ArchiveDirectory directory = new ArchiveDirectory(DIR_NAME); addStep("Validate the existence of the file", "Should neither exist nor be retrievable."); - Assert.assertFalse(directory.hasFile(FOLDER_FILE_ID)); - Assert.assertNull(directory.retrieveFile(FOLDER_FILE_ID)); - Assert.assertEquals(directory.getFileIds(), Collections.EMPTY_LIST); + Assertions.assertFalse(directory.hasFile(FOLDER_FILE_ID)); + Assertions.assertNull(directory.retrieveFile(FOLDER_FILE_ID)); + Assertions.assertEquals(directory.getFileIds(), Collections.EMPTY_LIST); addStep("Delete the file.", "exception since the file does not exist."); try { directory.removeFileFromArchive(FOLDER_FILE_ID); - Assert.fail("Should not be possible to remove a non-existing file."); + Assertions.fail("Should not be possible to remove a non-existing file."); } catch (IllegalStateException e) { // exptected } } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryNewFolderFile() throws Exception { addDescription("Testing the ArchiveDirectory handling of a new file."); addStep("Setup", "No file added to the directory."); @@ -254,35 +254,35 @@ public void testArchiveDirectoryNewFolderFile() throws Exception { addStep("Retrieve tmp file", "Exception since files does not exist."); try { directory.getFileInTempDir(FOLDER_FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } addStep("Request a new file for the tmp dir", "Should be received and creatable."); File newFile = directory.getNewFileInTempDir(FOLDER_FILE_ID); - Assert.assertTrue(newFile.createNewFile()); + Assertions.assertTrue(newFile.createNewFile()); addStep("Retrieve tmp file", "Should be the newly created file."); File tmpFile = directory.getFileInTempDir(FOLDER_FILE_ID); - Assert.assertNotNull(tmpFile); - Assert.assertEquals(tmpFile.getAbsolutePath(), newFile.getAbsolutePath()); + Assertions.assertNotNull(tmpFile); + Assertions.assertEquals(tmpFile.getAbsolutePath(), newFile.getAbsolutePath()); addStep("Request another new file with the same name", "Should throw exception, since it already exists."); try { directory.getNewFileInTempDir(FOLDER_FILE_ID); - Assert.fail("Should throw exception, since the file already exists."); + Assertions.fail("Should throw exception, since the file already exists."); } catch (IllegalStateException e) { // expected } addStep("Move the file from tmp to archive", "Should exist in archive but not in tmp."); directory.moveFromTmpToArchive(FOLDER_FILE_ID); - Assert.assertTrue(directory.hasFile(FOLDER_FILE_ID)); - Assert.assertFalse(directory.hasFileInTempDir(FOLDER_FILE_ID)); + Assertions.assertTrue(directory.hasFile(FOLDER_FILE_ID)); + Assertions.assertFalse(directory.hasFileInTempDir(FOLDER_FILE_ID)); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) 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."); @@ -291,7 +291,7 @@ public void testArchiveDirectoryMoveFolderFileToArchive() throws Exception { addStep("Moving file from tmp to archive", "Exception since it does not exist in the tmp-dir"); try { directory.moveFromTmpToArchive(FOLDER_FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } @@ -299,30 +299,30 @@ public void testArchiveDirectoryMoveFolderFileToArchive() throws Exception { addStep("Create file in both tmp and archive.", ""); createExistingFolderFile(); File newFile = directory.getNewFileInTempDir(FOLDER_FILE_ID); - Assert.assertTrue(newFile.createNewFile()); + Assertions.assertTrue(newFile.createNewFile()); addStep("Moving file from tmp to archive", "Exception since the file already exists within the archive."); try { directory.moveFromTmpToArchive(FOLDER_FILE_ID); - Assert.fail("Should throw exception since the file in archive already exists."); + Assertions.fail("Should throw exception since the file in archive already exists."); } catch (IllegalStateException e) { // exptected } addStep("Remove the file from archive and try again", "File in tmp moved to archive."); - Assert.assertTrue(directory.hasFile(FOLDER_FILE_ID)); - Assert.assertTrue(directory.hasFileInTempDir(FOLDER_FILE_ID)); + Assertions.assertTrue(directory.hasFile(FOLDER_FILE_ID)); + Assertions.assertTrue(directory.hasFileInTempDir(FOLDER_FILE_ID)); directory.removeFileFromArchive(FOLDER_FILE_ID); - Assert.assertFalse(directory.hasFile(FOLDER_FILE_ID)); - Assert.assertTrue(directory.hasFileInTempDir(FOLDER_FILE_ID)); + Assertions.assertFalse(directory.hasFile(FOLDER_FILE_ID)); + Assertions.assertTrue(directory.hasFileInTempDir(FOLDER_FILE_ID)); directory.moveFromTmpToArchive(FOLDER_FILE_ID); - Assert.assertTrue(directory.hasFile(FOLDER_FILE_ID)); - Assert.assertFalse(directory.hasFileInTempDir(FOLDER_FILE_ID)); + Assertions.assertTrue(directory.hasFile(FOLDER_FILE_ID)); + Assertions.assertFalse(directory.hasFileInTempDir(FOLDER_FILE_ID)); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testArchiveDirectoryRemoveFolderFile() throws Exception { addDescription("Testing the error scenarios when removing files from the archive."); addStep("Setup", "No file added to the directory."); @@ -332,7 +332,7 @@ public void testArchiveDirectoryRemoveFolderFile() throws Exception { addStep("Remove nonexisting file from archive", "Exception since it does not exist"); try { directory.removeFileFromArchive(FOLDER_FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } @@ -340,7 +340,7 @@ public void testArchiveDirectoryRemoveFolderFile() throws Exception { addStep("Remove nonexisting file from tmp", "Exception since it does not exist"); try { directory.removeFileFromTmp(FOLDER_FILE_ID); - Assert.fail("Should throw exception since the file does not exist."); + Assertions.fail("Should throw exception since the file does not exist."); } catch (IllegalStateException e) { // exptected } @@ -348,19 +348,19 @@ public void testArchiveDirectoryRemoveFolderFile() throws Exception { addStep("Create file in both tmp, archive and retain directories.", ""); createExistingFolderFile(); File tmpFile = directory.getNewFileInTempDir(FOLDER_FILE_ID); - Assert.assertTrue(tmpFile.createNewFile()); + Assertions.assertTrue(tmpFile.createNewFile()); File retainFile = new File(retainDir, FOLDER_FILE_ID); if(!retainFile.getParentFile().isDirectory()) { - Assert.assertTrue(retainFile.getParentFile().mkdirs()); + Assertions.assertTrue(retainFile.getParentFile().mkdirs()); } - Assert.assertTrue(retainFile.createNewFile()); - Assert.assertEquals(retainDir.list().length, 1); + Assertions.assertTrue(retainFile.createNewFile()); + Assertions.assertEquals(retainDir.list().length, 1); addStep("Remove the file from archive and tmp", "all 3 files in retain dir."); directory.removeFileFromArchive(FOLDER_FILE_ID); directory.removeFileFromTmp(FOLDER_FILE_ID); List retainFiles = TestFileHelper.getAllFilesFromSubDirs(retainDir); - Assert.assertEquals(retainFiles.size(), 3); + Assertions.assertEquals(retainFiles.size(), 3); } private void createExistingFile() throws Exception { 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 892446721..28eba2c1c 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 @@ -31,8 +31,8 @@ import org.bitrepository.pillar.messagehandler.PillarMediator; import org.bitrepository.pillar.store.filearchive.ReferenceArchive; import org.bitrepository.service.audit.MockAuditManager; -import org.testng.Assert; -import org.testng.annotations.Test; + + import java.io.File; import java.io.FileInputStream; @@ -62,7 +62,7 @@ protected void shutdownCUT() { super.shutdownCUT(); } - @Test(groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testReferenceArchive() throws Exception { addDescription("Test the ReferenceArchive."); addStep("Setup", "Should be OK."); @@ -71,27 +71,27 @@ public void testReferenceArchive() throws Exception { createExistingFile(); addStep("test 'hasFile'", "Should be true for the existing one and false for the missing one."); - Assert.assertTrue(archive.hasFile(EXISTING_FILE)); - Assert.assertFalse(archive.hasFile(MISSING_FILE)); + Assertions.assertTrue(archive.hasFile(EXISTING_FILE)); + Assertions.assertFalse(archive.hasFile(MISSING_FILE)); addStep("Test 'getFile'", "Should be ok for the existing file and throw an exception on the missing"); archive.getFile(EXISTING_FILE); try { archive.getFile(MISSING_FILE); - Assert.fail("Should throw an exception when getting a missing file."); + Assertions.fail("Should throw an exception when getting a missing file."); } catch (Exception e) { // expected } addStep("Test getAllFileIDs", "Should only deliver the existing file"); - Assert.assertEquals(archive.getAllFileIds(), List.of(EXISTING_FILE)); + Assertions.assertEquals(archive.getAllFileIds(), List.of(EXISTING_FILE)); addStep("Test 'getFileAsInputStream'", "Should only be able to deliver the existing file."); FileInputStream fileAsInputStream = archive.getFileAsInputStream(EXISTING_FILE); assert fileAsInputStream != null; try { archive.getFileAsInputStream(MISSING_FILE); - Assert.fail("Should throw an exception when getting a missing file."); + Assertions.fail("Should throw an exception when getting a missing file."); } catch (Exception e) { // expected } @@ -101,12 +101,12 @@ public void testReferenceArchive() throws Exception { createExistingFile(); archive.deleteFile(EXISTING_FILE); createExistingFile(); - Assert.assertTrue(new File(DIR_NAME + "/retainDir/" + EXISTING_FILE + ".old").isFile()); + Assertions.assertTrue(new File(DIR_NAME + "/retainDir/" + EXISTING_FILE + ".old").isFile()); addStep("Try to delete missing file.", "Should throw an exception"); try { archive.deleteFile(MISSING_FILE); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalStateException e) { // Expected. } @@ -114,7 +114,7 @@ public void testReferenceArchive() throws Exception { addStep("Replace a file, which does not exist in the filedir.", "Should throw an exception"); try { archive.replaceFile(MISSING_FILE); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalStateException e) { // Expected. } @@ -124,13 +124,13 @@ public void testReferenceArchive() throws Exception { FileUtils.copyFile(new File(DIR_NAME + "/retainDir/" + EXISTING_FILE), new File(DIR_NAME + "/tmpDir/" + EXISTING_FILE)); archive.replaceFile(EXISTING_FILE); - Assert.assertFalse(new File(DIR_NAME + "/tmpDir/" + EXISTING_FILE).isFile()); - Assert.assertTrue(new File(DIR_NAME + "/retainDir/" + EXISTING_FILE + ".old.old").isFile()); + Assertions.assertFalse(new File(DIR_NAME + "/tmpDir/" + EXISTING_FILE).isFile()); + Assertions.assertTrue(new File(DIR_NAME + "/retainDir/" + EXISTING_FILE + ".old.old").isFile()); addStep("Try performing the replace, when the file in the tempdir has been removed.", "Should throw an exception"); try { archive.replaceFile(EXISTING_FILE); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalStateException e) { // Expected. } 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 04ec51809..2974398c9 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,10 +30,10 @@ import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + + import java.io.File; import java.util.Calendar; @@ -81,7 +81,7 @@ public void cleanup() throws Exception { } } -// @Test( groups = {"regressiontest", "pillartest"}) +// @Test @Tag("regressiontest", "pillartest"}) public void testMigratingChecksumDatabaseFromV1ToV2() throws Exception { addDescription("Tests that the checksums table can be migrated from version 1 to 2, e.g. getting the column " + "collectionid, which should be set to the default in settings."); @@ -94,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, CHECKSUM_TABLE); - Assert.assertEquals(versionBefore, 1, "Table version before migration"); + Assertions.assertEquals(versionBefore, 1, "Table version before migration"); addStep("Ingest a entry to the database without the collection id", "works only in version 1."); String insertSql = "INSERT INTO " + CHECKSUM_TABLE + " ( " + CS_FILE_ID + " , " + CS_CHECKSUM + " , " + CS_DATE @@ -105,16 +105,16 @@ public void testMigratingChecksumDatabaseFromV1ToV2() throws Exception { ChecksumDBMigrator migrator = new ChecksumDBMigrator(connector, settings); migrator.migrate(); int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); - Assert.assertEquals(versionAfter, 4, "Table version after migration"); + Assertions.assertEquals(versionAfter, 4, "Table version after migration"); addStep("Validate the entry", "The collection id has been set to the default collection id"); String retrieveCollectionIdSql = "SELECT " + CS_COLLECTION_ID + " FROM " + CHECKSUM_TABLE + " WHERE " + CS_FILE_ID + " = ?"; String collectionID = DatabaseUtils.selectStringValue(connector, retrieveCollectionIdSql, FILE_ID); - Assert.assertEquals(collectionID, settings.getCollections().get(0).getID()); + Assertions.assertEquals(collectionID, settings.getCollections().get(0).getID()); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { addDescription("Tests that the checksums table can be migrated from version 3 to 4, e.g. changing the column " + "calculatedchecksumdate from timestamp to bigint."); @@ -127,12 +127,12 @@ public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { connector = new DBConnector( settings.getReferenceSettings().getPillarSettings().getChecksumDatabase()); Date testDate = new Date(1453984303527L); - Assert.assertFalse(connector.getConnection().isClosed()); + Assertions.assertFalse(connector.getConnection().isClosed()); addStep("Validate setup", "Checksums table has version 3"); String extractVersionSql = "SELECT version FROM tableversions WHERE tablename = ?"; int versionBefore = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); - Assert.assertEquals(versionBefore, 3, "Table version before migration"); + Assertions.assertEquals(versionBefore, 3, "Table version before migration"); addStep("Ingest a entry to the database with a date for the calculationdate", "works in version 3."); String insertSql = "INSERT INTO " + CHECKSUM_TABLE + " ( " + CS_FILE_ID + " , " + CS_CHECKSUM + " , " + CS_DATE @@ -143,7 +143,7 @@ public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { ChecksumDBMigrator migrator = new ChecksumDBMigrator(connector, settings); migrator.migrate(); int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); - Assert.assertEquals(versionAfter, 4, "Table version after migration"); + Assertions.assertEquals(versionAfter, 4, "Table version after migration"); addStep("Validate the migration", "The timestamp is now the millis from epoch"); String retrieveCollectionIdSql = "SELECT " + CS_DATE + " FROM " + CHECKSUM_TABLE + " WHERE " @@ -153,6 +153,6 @@ public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { Date testDateAtTimeZone = new Date(testDate.getTime() + Calendar.getInstance(TimeZone.getDefault(), Locale.ROOT).getTimeZone().getRawOffset()); - Assert.assertEquals(extractedDate.longValue(), testDateAtTimeZone.getTime()); + Assertions.assertEquals(extractedDate.longValue(), testDateAtTimeZone.getTime()); } } 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 fba4c1698..8158a7b2f 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 @@ -36,9 +36,9 @@ import org.bitrepository.settings.referencesettings.DatabaseSpecifics; import org.bitrepository.settings.repositorysettings.PillarIDs; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; + + + import java.time.Instant; import java.util.Date; @@ -65,56 +65,56 @@ public void setup() throws Exception { checksumDatabaseCreator.createChecksumDatabase(settings, null); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testChecksumDatabaseExtraction() { addDescription("Test the extraction of data from the checksum database."); ChecksumDAO cache = getCacheWithData(); addStep("Check whether the default entry exists.", "It does!"); - Assert.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); + Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); addStep("Extract calculation date", "Should be identical to the default date."); - Assert.assertEquals(cache.getCalculationDate(DEFAULT_FILE_ID, collectionID), DEFAULT_DATE); + Assertions.assertEquals(cache.getCalculationDate(DEFAULT_FILE_ID, collectionID), DEFAULT_DATE); addStep("Extract the checksum", "Should be identical to the default checksum"); - Assert.assertEquals(cache.getChecksum(DEFAULT_FILE_ID, collectionID), DEFAULT_CHECKSUM); + Assertions.assertEquals(cache.getChecksum(DEFAULT_FILE_ID, collectionID), DEFAULT_CHECKSUM); addStep("Extract the whole entry", "Should have the default values."); ChecksumEntry entry = cache.getEntry(DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(entry.getFileId(), DEFAULT_FILE_ID); - Assert.assertEquals(entry.getChecksum(), DEFAULT_CHECKSUM); - Assert.assertEquals(entry.getCalculationDate(), DEFAULT_DATE); + Assertions.assertEquals(entry.getFileId(), DEFAULT_FILE_ID); + Assertions.assertEquals(entry.getChecksum(), DEFAULT_CHECKSUM); + Assertions.assertEquals(entry.getCalculationDate(), DEFAULT_DATE); addStep("Extract all entries", "Should only be the one default."); List entries = cache.getChecksumResults(null, null, null, collectionID).getEntries(); - Assert.assertEquals(entries.size(), 1); - Assert.assertEquals(entries.get(0).getFileID(), DEFAULT_FILE_ID); - Assert.assertEquals(Base16Utils.decodeBase16(entries.get(0).getChecksumValue()), DEFAULT_CHECKSUM); - Assert.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(entries.get(0).getCalculationTimestamp()), + Assertions.assertEquals(entries.size(), 1); + Assertions.assertEquals(entries.get(0).getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(Base16Utils.decodeBase16(entries.get(0).getChecksumValue()), DEFAULT_CHECKSUM); + Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(entries.get(0).getCalculationTimestamp()), DEFAULT_DATE); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testDeletion() { addDescription("Test that data can be deleted from the database."); ChecksumDAO cache = getCacheWithData(); addStep("Check whether the default entry exists.", "It does!"); - Assert.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); + Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); ExtractedFileIDsResultSet res = cache.getFileIDs(null, null, null, null, collectionID); - Assert.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assert.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), + Assertions.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + Assertions.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), DEFAULT_FILE_ID); addStep("Remove the default entry", "Should no longer exist"); cache.deleteEntry(DEFAULT_FILE_ID, collectionID); - Assert.assertFalse(cache.hasFile(DEFAULT_FILE_ID, collectionID)); + Assertions.assertFalse(cache.hasFile(DEFAULT_FILE_ID, collectionID)); res = cache.getFileIDs(null, null, null, null, collectionID); - Assert.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testReplacingExistingEntry() { addDescription("Test that an entry can be replaced by another in the database."); ChecksumDAO cache = getCacheWithData(); @@ -123,23 +123,23 @@ public void testReplacingExistingEntry() { Date newDate = new Date(System.currentTimeMillis() + 123456789L); addStep("Check whether the default entry exists.", "It does!"); - Assert.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); + Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); ChecksumEntry oldEntry = cache.getEntry(DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(oldEntry.getFileId(), DEFAULT_FILE_ID); - Assert.assertEquals(oldEntry.getChecksum(), DEFAULT_CHECKSUM); - Assert.assertEquals(oldEntry.getCalculationDate(), DEFAULT_DATE); + Assertions.assertEquals(oldEntry.getFileId(), DEFAULT_FILE_ID); + Assertions.assertEquals(oldEntry.getChecksum(), DEFAULT_CHECKSUM); + Assertions.assertEquals(oldEntry.getCalculationDate(), DEFAULT_DATE); addStep("Replace the checksum and date", "Should still exist, but have different values."); cache.insertChecksumCalculation(DEFAULT_FILE_ID, collectionID, newChecksum, newDate); - Assert.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); + Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); ChecksumEntry newEntry = cache.getEntry(DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(newEntry.getFileId(), DEFAULT_FILE_ID); - Assert.assertEquals(newEntry.getChecksum(), newChecksum); - Assert.assertFalse(oldEntry.getChecksum().equals(newEntry.getChecksum())); - Assert.assertFalse(oldEntry.getCalculationDate().getTime() == newEntry.getCalculationDate().getTime()); + Assertions.assertEquals(newEntry.getFileId(), DEFAULT_FILE_ID); + Assertions.assertEquals(newEntry.getChecksum(), newChecksum); + Assertions.assertFalse(oldEntry.getChecksum().equals(newEntry.getChecksum())); + Assertions.assertFalse(oldEntry.getCalculationDate().getTime() == newEntry.getCalculationDate().getTime()); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testExtractionOfMissingData() { addDescription("Test the handling of bad arguments."); ChecksumDAO cache = getCacheWithData(); @@ -148,7 +148,7 @@ public void testExtractionOfMissingData() { addStep("Try to get the date of a wrong file id.", "Should throw an exception"); try { cache.getCalculationDate(badFileId, collectionID); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalStateException e) { // expected } @@ -156,7 +156,7 @@ public void testExtractionOfMissingData() { addStep("Try to get the date of a wrong file id.", "Should throw an exception"); try { cache.getChecksum(badFileId, collectionID); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalStateException e) { // expected } @@ -164,13 +164,13 @@ public void testExtractionOfMissingData() { addStep("Try to remove a bad file id", "Should throw an exception"); try { cache.deleteEntry(badFileId, collectionID); - Assert.fail("Should throw an exception here."); + Assertions.fail("Should throw an exception here."); } catch (IllegalStateException e) { // expected } } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testSpecifiedEntryExtraction() { addDescription("Test that specific entries can be extracted. Has two entries in the database: " + "one for the current timestamp and one for the epoch."); @@ -182,40 +182,40 @@ public void testSpecifiedEntryExtraction() { addStep("Extract with out restrictions", "Both entries."); ExtractedChecksumResultSet extractedResults = cache.getChecksumResults(null, null, null, collectionID); - Assert.assertEquals(extractedResults.getEntries().size(), 2); + Assertions.assertEquals(extractedResults.getEntries().size(), 2); addStep("Extract with a maximum of 1 entry", "The oldest entry"); extractedResults = cache.getChecksumResults(null, null, 1L, collectionID); - Assert.assertEquals(extractedResults.getEntries().size(), 1); + Assertions.assertEquals(extractedResults.getEntries().size(), 1); ChecksumDataForChecksumSpecTYPE dataEntry = extractedResults.getEntries().get(0); - Assert.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime(), 0); - Assert.assertEquals(dataEntry.getFileID(), oldFile); + Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime(), 0); + Assertions.assertEquals(dataEntry.getFileID(), oldFile); addStep("Extract all dates older than this tests instantiation", "The oldest entry"); extractedResults = cache.getChecksumResults(null, CalendarUtils.getXmlGregorianCalendar(beforeTest), null, collectionID); - Assert.assertEquals(extractedResults.getEntries().size(), 1); + Assertions.assertEquals(extractedResults.getEntries().size(), 1); dataEntry = extractedResults.getEntries().get(0); - Assert.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime(), 0); - Assert.assertEquals(dataEntry.getFileID(), oldFile); + Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime(), 0); + Assertions.assertEquals(dataEntry.getFileID(), oldFile); addStep("Extract all dates newer than this tests instantiation", "The default entry"); extractedResults = cache.getChecksumResults(CalendarUtils.getXmlGregorianCalendar(beforeTest), null, null, collectionID); - Assert.assertEquals(extractedResults.getEntries().size(), 1); + Assertions.assertEquals(extractedResults.getEntries().size(), 1); dataEntry = extractedResults.getEntries().get(0); - Assert.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()), + Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()), DEFAULT_DATE); - Assert.assertEquals(dataEntry.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(dataEntry.getFileID(), DEFAULT_FILE_ID); addStep("Extract all dates older than the newest instance", "Both entries"); extractedResults = cache.getChecksumResults(null, CalendarUtils.getXmlGregorianCalendar(DEFAULT_DATE), null, collectionID); - Assert.assertEquals(extractedResults.getEntries().size(), 2); + Assertions.assertEquals(extractedResults.getEntries().size(), 2); addStep("Extract all dates newer than the oldest instantiation", "Both entries"); extractedResults = cache.getChecksumResults(CalendarUtils.getEpoch(), null, null, collectionID); - Assert.assertEquals(extractedResults.getEntries().size(), 2); + Assertions.assertEquals(extractedResults.getEntries().size(), 2); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testGetFileIDsRestrictions() { addDescription("Tests the restrictions on the GetFileIDs call to the database."); addStep("Instantiate database with appropriate data.", ""); @@ -230,54 +230,54 @@ public void testGetFileIDsRestrictions() { addStep("Test with no time restrictions and 10000 max_results", "Delivers both files."); ExtractedFileIDsResultSet efirs = cache.getFileIDs(null, null, 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); addStep("Test with minimum-date earlier than first file", "Delivers both files."); efirs = cache.getFileIDs(CalendarUtils.getFromMillis(0), null, 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); addStep("Test with maximum-date earlier than first file", "Delivers no files."); efirs = cache.getFileIDs(null, CalendarUtils.getFromMillis(0), 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); addStep("Test with minimum-date set to later than second file.", "Delivers no files."); efirs = cache.getFileIDs(CalendarUtils.getXmlGregorianCalendar(new Date()), null, 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); addStep("Test with maximum-date set to later than second file.", "Delivers both files."); efirs = cache.getFileIDs(null, CalendarUtils.getXmlGregorianCalendar(new Date()), 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); addStep("Test with minimum-date set to middle date.", "Delivers second file."); efirs = cache.getFileIDs(CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), null, 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_2); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_2); addStep("Test with maximum-date set to middle date.", "Delivers first file."); efirs = cache.getFileIDs(null, CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_1); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_1); addStep("Test with both minimum-date and maximum-date set to middle date.", "Delivers no files."); efirs = cache.getFileIDs(CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), 100000L, null, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); addStep("Test the first file-id, with no other restrictions", "Only delivers the requested file-id"); efirs = cache.getFileIDs(null, null, 100000L, FILE_ID_1, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_1); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_1); addStep("Test the second file-id, with no other restrictions", "Only delivers the requested file-id"); efirs = cache.getFileIDs(null, null, 100000L, FILE_ID_2, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_2); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_2); addStep("Test the date for the first file-id, while requesting the second file-id", "Should not deliver anything"); efirs = cache.getFileIDs(CalendarUtils.getFromMillis(0), CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), 100000L, FILE_ID_2, collectionID); - Assert.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testGetChecksumResult() { addDescription("Tests the restrictions on the GetChecksumResult call to the database."); addStep("Instantiate database with appropriate data.", ""); @@ -285,39 +285,39 @@ public void testGetChecksumResult() { addStep("Test with no time restrictions", "Retrieves the file"); ExtractedChecksumResultSet extractedChecksums = cache.getChecksumResult(null, null, DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 1); - Assert.assertEquals(extractedChecksums.getEntries().get(0).getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); + Assertions.assertEquals(extractedChecksums.getEntries().get(0).getFileID(), DEFAULT_FILE_ID); addStep("Test with time restrictions from epoc to now", "Retrieves the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getEpoch(), CalendarUtils.getNow(), DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 1); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); addStep("Test with very strict time restrictions around the default date", "Retrieves the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() - 1), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() + 1), DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 1); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); addStep("Test with too new a lower limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() + 1), CalendarUtils.getNow(), DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); addStep("Test with exact date as both upper and lower limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); addStep("Test with date limit from 1 millis before as lower and exact date a upper limit", "Does retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()-1), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 1); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); addStep("Test with date limit from exact date as lower and 1 millis after date a upper limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()+1), DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); addStep("Test with too old an upper limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getEpoch(), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() - 1), DEFAULT_FILE_ID, collectionID); - Assert.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); } - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testGetFileIDsWithOldChecksums() { addDescription("Tests the restrictions on the GetFileIDsWithOldChecksums call to the database."); addStep("Instantiate database with appropriate data.", ""); @@ -332,18 +332,18 @@ public void testGetFileIDsWithOldChecksums() { addStep("Extract all entries with checksum date older than now", "Returns both file ids"); List extractedFileIDs = cache.getFileIDsWithOldChecksums(Instant.now(), collectionID); - Assert.assertEquals(extractedFileIDs.size(), 2); - Assert.assertTrue(extractedFileIDs.contains(FILE_ID_1)); - Assert.assertTrue(extractedFileIDs.contains(FILE_ID_2)); + Assertions.assertEquals(extractedFileIDs.size(), 2); + Assertions.assertTrue(extractedFileIDs.contains(FILE_ID_1)); + Assertions.assertTrue(extractedFileIDs.contains(FILE_ID_2)); addStep("Extract all entries with checksum date older than epoch", "Returns no file ids"); extractedFileIDs = cache.getFileIDsWithOldChecksums(Instant.EPOCH, collectionID); - Assert.assertEquals(extractedFileIDs.size(), 0); + Assertions.assertEquals(extractedFileIDs.size(), 0); addStep("Extract all entries with checksum date older than middle date", "Returns the first file id"); extractedFileIDs = cache.getFileIDsWithOldChecksums(MIDDLE_DATE.toInstant(), collectionID); - Assert.assertEquals(extractedFileIDs.size(), 1); - Assert.assertTrue(extractedFileIDs.contains(FILE_ID_1)); + Assertions.assertEquals(extractedFileIDs.size(), 1); + Assertions.assertTrue(extractedFileIDs.contains(FILE_ID_1)); } 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 f52b9379a..f958b64db 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 @@ -23,8 +23,8 @@ import org.bitrepository.pillar.store.checksumdatabase.ChecksumEntry; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; + + import java.util.Date; @@ -33,13 +33,13 @@ public class ChecksumEntryTest extends ExtendedTestCase { private static final String CE_CHECKSUM = "checksum"; private static final Date CE_DATE = new Date(1234567890); - @Test( groups = {"regressiontest", "pillartest"}) + @Test @Tag("regressiontest", "pillartest"}) public void testExtendedTestCase() throws Exception { addDescription("Test the ChecksumEntry"); addStep("Create a ChecksumEntry", "The data should be extractable again."); ChecksumEntry ce = new ChecksumEntry(CE_FILE, CE_CHECKSUM, CE_DATE); - Assert.assertEquals(ce.getFileId(), CE_FILE); - Assert.assertEquals(ce.getChecksum(), CE_CHECKSUM); - Assert.assertEquals(ce.getCalculationDate(), CE_DATE); + Assertions.assertEquals(ce.getFileId(), CE_FILE); + Assertions.assertEquals(ce.getChecksum(), CE_CHECKSUM); + Assertions.assertEquals(ce.getCalculationDate(), CE_DATE); } } diff --git a/bitrepository-service/src/test/java/org/bitrepository/service/ServiceSettingsProviderTest.java b/bitrepository-service/src/test/java/org/bitrepository/service/ServiceSettingsProviderTest.java index 96e8ebff6..7a77a0ff5 100644 --- a/bitrepository-service/src/test/java/org/bitrepository/service/ServiceSettingsProviderTest.java +++ b/bitrepository-service/src/test/java/org/bitrepository/service/ServiceSettingsProviderTest.java @@ -26,8 +26,10 @@ import org.bitrepository.common.settings.SettingsProvider; import org.bitrepository.common.settings.XMLFileSettingsLoader; import org.bitrepository.settings.referencesettings.ServiceType; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + /** * jaccept report generating test of whether ServiceSettingsProvider actually knows the enum ServiceType. @@ -36,34 +38,35 @@ public class ServiceSettingsProviderTest { private static final String PATH_TO_TEST_SETTINGS = "settings/xml/bitrepository-devel"; - @Test(groups = {"regressiontest"}) + @Test + @Tag("regressiontest") public void componentIDTest() { SettingsProvider settingsLoader = new ServiceSettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), ServiceType.ALARM_SERVICE); Settings settings = settingsLoader.getSettings(); - Assert.assertEquals( + Assertions.assertEquals( settings.getReferenceSettings().getAlarmServiceSettings().getID(), settings.getComponentID()); settingsLoader = new ServiceSettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), ServiceType.AUDIT_TRAIL_SERVICE); settings = settingsLoader.getSettings(); - Assert.assertEquals( + Assertions.assertEquals( settings.getReferenceSettings().getAuditTrailServiceSettings().getID(), settings.getComponentID()); settingsLoader = new ServiceSettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), ServiceType.INTEGRITY_SERVICE); settings = settingsLoader.getSettings(); - Assert.assertEquals( + Assertions.assertEquals( settings.getReferenceSettings().getIntegrityServiceSettings().getID(), settings.getComponentID()); settingsLoader = new ServiceSettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), ServiceType.MONITORING_SERVICE); settings = settingsLoader.getSettings(); - Assert.assertEquals( + Assertions.assertEquals( settings.getReferenceSettings().getMonitoringServiceSettings().getID(), settings.getComponentID()); } 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 0be217d7c..666869cd6 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 @@ -29,9 +29,10 @@ import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.AfterMethod; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.File; @@ -39,7 +40,8 @@ import static org.bitrepository.service.audit.AuditDatabaseConstants.DATABASE_VERSION_ENTRY; import static org.bitrepository.service.audit.AuditDatabaseConstants.FILE_FILE_ID; import static org.bitrepository.service.audit.AuditDatabaseConstants.FILE_TABLE; -import static org.testng.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; + /** Test database migration. Generates jaccept reports. * @@ -52,7 +54,7 @@ public class AuditTrailContributorDatabaseMigrationTest extends ExtendedTestCase static final String FILE_ID = "default-file-id"; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("ReferencePillarTest"); @@ -66,12 +68,13 @@ public void setup() throws Exception { FileUtils.unzip(new File(PATH_TO_DATABASE_JAR_FILE), FileUtils.retrieveDirectory(PATH_TO_DATABASE_UNPACKED)); } - @AfterMethod (alwaysRun = true) + @AfterEach public void cleanup() throws Exception { FileUtils.deleteDirIfExists(new File(PATH_TO_DATABASE_UNPACKED)); } - @Test( groups = {"regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") @Tag("databasetest") public void testMigratingAuditContributorDatabase() { addDescription("Tests that the database can be migrated to latest version with the provided scripts."); DBConnector connector = new DBConnector( 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 f7e905d03..0c70e6f10 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 @@ -30,9 +30,11 @@ import org.bitrepository.service.database.DerbyDatabaseDestroyer; import org.bitrepository.settings.referencesettings.DatabaseSpecifics; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; +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.text.ParseException; import java.text.SimpleDateFormat; @@ -54,7 +56,7 @@ public class AuditTrailContributorDatabaseTest extends ExtendedTestCase { private static final String FILE_ID_1 = "FILE-ID-1"; private static final String FILE_ID_2 = "FILE-ID-2"; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings(getClass().getSimpleName()); @@ -69,7 +71,7 @@ public void setup() throws Exception { firstCollectionID = settings.getCollections().get(0).getID(); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest") @Tag("databasetest") public void testAuditTrailDatabaseExtraction() throws Exception { addDescription("Testing the basic functions of the audit trail database interface."); addStep("Setup varibles and the database connection.", "No errors."); @@ -86,47 +88,48 @@ public void testAuditTrailDatabaseExtraction() throws Exception { addStep("Test extracting all the events", "Should be all 5 events."); AuditTrailDatabaseResults events = daba.getAudits(firstCollectionID, null, null, null, null, null, null); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 5); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 5); addStep("Test extracting the events for fileID1", "Should be 2 events."); events = daba.getAudits(firstCollectionID, FILE_ID_1, null, null, null, null, null); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 2); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 2); addStep("Test extracting the events for fileID2", "Should be 3 events."); events = daba.getAudits(firstCollectionID, FILE_ID_2, null, null, null, null, null); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3); addStep("Test extracting the events with the sequence number at least equal to the largest sequence number.", "Should be 1 event."); Long seq = daba.extractLargestSequenceNumber(); events = daba.getAudits(firstCollectionID, null, seq, null, null, null, null); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1); addStep("Test extracting the events for fileID1 with sequence number 2 or more", "Should be 1 event."); events = daba.getAudits(firstCollectionID, FILE_ID_1, seq-3, null, null, null, null); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1); addStep("Test extracting the events for fileID1 with at most sequence number 2", "Should be 2 events."); events = daba.getAudits(firstCollectionID, FILE_ID_1, null, seq-3, null, null, null); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 2); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 2); addStep("Test extracting at most 3 events", "Should extract 3 events."); events = daba.getAudits(firstCollectionID, null, null, null, null, null, 3L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3); addStep("Test extracting at most 1000 events", "Should extract all 5 events."); events = daba.getAudits(firstCollectionID, null, null, null, null, null, 1000L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 5); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 5); addStep("Test extracting from another collection", "Should not extract anything."); String secondCollectionID = settings.getCollections().get(1).getID(); events = daba.getAudits(secondCollectionID, null, null, null, null, null, 1000L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 0); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 0); dm.getConnector().destroy(); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") @Tag("databasetest") public void testAuditTrailDatabaseExtractionOrder() throws Exception { addDescription("Test the order of extraction"); addStep("Setup variables and database connection", "No errors"); @@ -143,22 +146,22 @@ public void testAuditTrailDatabaseExtractionOrder() throws Exception { addStep("Extract 3 audit-trails", "Should give first 3 audit-trails in order."); AuditTrailDatabaseResults events = daba.getAudits(firstCollectionID, null, null, null, null, null, 3L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(0).getActionOnFile(), FileAction.PUT_FILE); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(0).getSequenceNumber().longValue(), 1L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(1).getActionOnFile(), FileAction.CHECKSUM_CALCULATED); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(1).getSequenceNumber().longValue(), 2L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(2).getActionOnFile(), FileAction.FILE_MOVED); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(2).getSequenceNumber().longValue(), 3L); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3L); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(0).getActionOnFile(), FileAction.PUT_FILE); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(0).getSequenceNumber().longValue(), 1L); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(1).getActionOnFile(), FileAction.CHECKSUM_CALCULATED); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(1).getSequenceNumber().longValue(), 2L); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(2).getActionOnFile(), FileAction.FILE_MOVED); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(2).getSequenceNumber().longValue(), 3L); long firstSeq = events.getAuditTrailEvents().getAuditTrailEvent().get(0).getSequenceNumber().longValue(); addStep("Extract 3 audit-trails, with larger seq-number than the first", "Should give audit-trail #2, #3, #4"); events = daba.getAudits(firstCollectionID, null, firstSeq+1, null, null, null, 3L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(0).getActionOnFile(), FileAction.CHECKSUM_CALCULATED); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(1).getActionOnFile(), FileAction.FILE_MOVED); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(2).getActionOnFile(), FileAction.FAILURE); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 3L); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(0).getActionOnFile(), FileAction.CHECKSUM_CALCULATED); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(1).getActionOnFile(), FileAction.FILE_MOVED); + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().get(2).getActionOnFile(), FileAction.FAILURE); dm.getConnector().destroy(); } @@ -173,11 +176,11 @@ public void contributorDatabaseCorrectTimestampTest() throws ParseException { SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSXXX", Locale.ROOT); Date summertimeTS = sdf.parse("2015-10-25T02:59:54.000+02:00"); Date summertimeUnix = new Date(1445734794000L); - Assert.assertEquals(summertimeTS, summertimeUnix); + Assertions.assertEquals(summertimeTS, summertimeUnix); Date wintertimeTS = sdf.parse("2015-10-25T02:59:54.000+01:00"); Date wintertimeUnix = new Date(1445738394000L); - Assert.assertEquals(wintertimeTS, wintertimeUnix); + Assertions.assertEquals(wintertimeTS, wintertimeUnix); daba.addAuditEvent(firstCollectionID, "summertime", summertimeTS, "actor", "info", "auditTrail", FileAction.OTHER, null, null); @@ -185,18 +188,18 @@ public void contributorDatabaseCorrectTimestampTest() throws ParseException { FileAction.OTHER, null, null); AuditTrailDatabaseResults events = daba.getAudits(firstCollectionID, "summertime", null, null, null, null, 2L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1, events.toString()); - Assert.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar( + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1, events.toString()); + Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar( events.getAuditTrailEvents().getAuditTrailEvent().get(0).getActionDateTime()), summertimeUnix); events = daba.getAudits(firstCollectionID, "wintertime", null, null, null, null, 2L); - Assert.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1, events.toString()); - Assert.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar( + Assertions.assertEquals(events.getAuditTrailEvents().getAuditTrailEvent().size(), 1, events.toString()); + Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar( events.getAuditTrailEvents().getAuditTrailEvent().get(0).getActionDateTime()), wintertimeUnix); } - @Test(groups = {"regressiontest", "databasetest"}) + @Test @Tag("regressiontest") @Tag("databasetest") public void testAuditTrailDatabaseIngest() throws Exception { addDescription("Testing the ingest of data."); addStep("Setup varibles and the database connection.", "No errors."); @@ -221,7 +224,7 @@ public void testAuditTrailDatabaseIngest() throws Exception { addStep("Test with no collection", "Throws exception"); try { daba.addAuditEvent(null, fileID1, actor, info, auditTrail, FileAction.FAILURE, operationID, certificateID); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalArgumentException e) { // expected } @@ -247,7 +250,7 @@ public void testAuditTrailDatabaseIngest() throws Exception { addStep("Test with with no action.", "Throws exception"); try { daba.addAuditEvent(firstCollectionID, fileID1, actor, info, auditTrail, null, operationID, certificateID); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalArgumentException e) { // expected } @@ -255,7 +258,7 @@ public void testAuditTrailDatabaseIngest() throws Exception { addStep("Test with with very large file id.", "Throws exception"); try { daba.addAuditEvent(firstCollectionID, veryLongString, actor, info, auditTrail, FileAction.FAILURE, operationID, certificateID); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalStateException e) { // expected } @@ -263,7 +266,7 @@ public void testAuditTrailDatabaseIngest() throws Exception { addStep("Test with with very large actor name.", "Throws exception"); try { daba.addAuditEvent(firstCollectionID, fileID1, veryLongString, info, auditTrail, FileAction.FAILURE, operationID, certificateID); - Assert.fail("Should throw an exception"); + Assertions.fail("Should throw an exception"); } catch (IllegalStateException e) { // expected } 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 1af69d41c..4e3ee220c 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 @@ -23,8 +23,10 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + /** * jaccept steps to validate that the exception thrown is the exception thrown. @@ -32,7 +34,8 @@ public class IdentifyContributorExceptionTest extends ExtendedTestCase { private final String TEST_COLLECTION_ID = "test-collection-id"; - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest") public void testIdentifyContributor() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -44,24 +47,24 @@ public void testIdentifyContributor() throws Exception { try { throw new IdentifyContributorException(errCode, errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof IdentifyContributorException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseCode(), errCode); - Assert.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseText(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof IdentifyContributorException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseCode(), errCode); + Assertions.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseText(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new IdentifyContributorException(errCode, errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof IdentifyContributorException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseCode(), errCode); - Assert.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseText(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertTrue(e instanceof IdentifyContributorException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseCode(), errCode); + Assertions.assertEquals(((IdentifyContributorException) e).getResponseInfo().getResponseText(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); } } } 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 111596fe7..e34690947 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 @@ -23,12 +23,14 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.jaccept.structure.ExtendedTestCase; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; -import static org.testng.Assert.assertEquals; -import static org.testng.Assert.assertNotNull; -import static org.testng.Assert.assertNull; -import static org.testng.Assert.assertTrue; /** * Test that IllegalOperationException behaves as expected. @@ -37,7 +39,8 @@ public class IllegalOperationExceptionTest extends ExtendedTestCase { private final String TEST_COLLECTION_ID = "test-collection-id"; - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest") public void testIdentifyContributor() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); 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 45aad12db..ee2629689 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 @@ -24,8 +24,10 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositoryelements.ResponseInfo; import org.jaccept.structure.ExtendedTestCase; -import org.testng.Assert; -import org.testng.annotations.Test; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + /** * Test that InvalidMessageException works as expected. @@ -33,7 +35,8 @@ public class InvalidMessageExceptionTest extends ExtendedTestCase { private final String TEST_COLLECTION_ID = "test-collection-id"; - @Test(groups = { "regressiontest" }) + @Test + @Tag( "regressiontest") public void testIdentifyContributor() throws Exception { addDescription("Test the instantiation of the exception"); addStep("Setup", ""); @@ -45,26 +48,26 @@ public void testIdentifyContributor() throws Exception { try { throw new InvalidMessageException(errCode, errMsg); } catch(Exception e) { - Assert.assertTrue(e instanceof InvalidMessageException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseCode(), errCode); - Assert.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseText(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof InvalidMessageException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseCode(), errCode); + Assertions.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseText(), errMsg); + Assertions.assertNull(e.getCause()); } addStep("Throw the exception with an embedded exception", "The embedded exception should be the same."); try { throw new InvalidMessageException(errCode, errMsg, new IllegalArgumentException(causeMsg)); } catch(Exception e) { - Assert.assertTrue(e instanceof InvalidMessageException); - Assert.assertTrue(e instanceof RequestHandlerException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseCode(), errCode); - Assert.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseText(), errMsg); - Assert.assertNotNull(e.getCause()); - Assert.assertTrue(e.getCause() instanceof IllegalArgumentException); - Assert.assertEquals(e.getCause().getMessage(), causeMsg); - Assert.assertNotNull(((RequestHandlerException) e).toString()); + Assertions.assertTrue(e instanceof InvalidMessageException); + Assertions.assertTrue(e instanceof RequestHandlerException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseCode(), errCode); + Assertions.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseText(), errMsg); + Assertions.assertNotNull(e.getCause()); + Assertions.assertTrue(e.getCause() instanceof IllegalArgumentException); + Assertions.assertEquals(e.getCause().getMessage(), causeMsg); + Assertions.assertNotNull(((RequestHandlerException) e).toString()); } addStep("Throw the exception with a ResponseInfo", "Should be caught and validated"); @@ -74,11 +77,11 @@ public void testIdentifyContributor() throws Exception { ri.setResponseText(errMsg); throw new InvalidMessageException(ri); } catch(Exception e) { - Assert.assertTrue(e instanceof InvalidMessageException); - Assert.assertEquals(e.getMessage(), errMsg); - Assert.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseCode(), errCode); - Assert.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseText(), errMsg); - Assert.assertNull(e.getCause()); + Assertions.assertTrue(e instanceof InvalidMessageException); + Assertions.assertEquals(e.getMessage(), errMsg); + Assertions.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseCode(), errCode); + Assertions.assertEquals(((InvalidMessageException) e).getResponseInfo().getResponseText(), errMsg); + Assertions.assertNull(e.getCause()); } } } diff --git a/pom.xml b/pom.xml index 16992397f..63616a3bf 100644 --- a/pom.xml +++ b/pom.xml @@ -186,12 +186,12 @@ test - - org.testng - testng - 7.1.0 - test - + + + + + + org.junit.platform junit-platform-suite-engine From 5888407eb13d9976a8f2d87eb6986a05072a75f7 Mon Sep 17 00:00:00 2001 From: kaah Date: Fri, 26 Dec 2025 22:21:37 +0100 Subject: [PATCH 09/14] All tests succeeds after having been migrated from TestNG to JUnit 5 --- .../alarm/handler/AlarmHandlerTest.java | 18 +- .../AlarmDatabaseExtractionModelTest.java | 5 +- .../audittrails/AuditTrailServiceTest.java | 15 +- .../collector/AuditCollectorTest.java | 1 + .../collector/IncrementalCollectorTest.java | 20 ++- .../preserver/AuditPackerTest.java | 20 ++- .../AuditPreservationEventHandlerTest.java | 7 +- .../preserver/LocalAuditPreservationTest.java | 16 +- .../audittrails/store/AuditDatabaseTest.java | 87 +++++----- .../AuditServiceDatabaseMigrationTest.java | 25 +-- .../reports/BasicIntegrityReporterTest.java | 31 ++-- .../alarm/MonitorAlerterTest.java | 17 +- .../collector/StatusCollectorTest.java | 53 +++--- .../collector/StatusEventHandlerTest.java | 47 +++--- .../status/ComponentStatusStoreTest.java | 29 ++-- .../pillar/BitrepositoryPillarTestSuite.java | 63 +++++++ .../bitrepository/pillar/MediatorTest.java | 14 +- .../pillar/common/SettingsHelperTest.java | 10 +- .../integration/PillarIntegrationTest.java | 42 ++--- .../pillar/integration/func/Assert.java | 4 +- .../func/DefaultPillarIdentificationTest.java | 11 +- .../func/DefaultPillarOperationTest.java | 5 +- .../integration/func/PillarFunctionTest.java | 8 +- .../func/deletefile/DeleteFileRequestIT.java | 31 ++-- .../IdentifyPillarsForDeleteFileIT.java | 28 ++-- .../getaudittrails/GetAuditTrailsTest.java | 27 ++- .../getchecksums/GetChecksumQueryTest.java | 25 ++- .../func/getchecksums/GetChecksumTest.java | 28 ++-- .../IdentifyPillarsForGetChecksumsIT.java | 33 ++-- .../func/getfile/GetFileRequestIT.java | 54 +++--- .../getfile/IdentifyPillarsForGetFileIT.java | 23 +-- .../func/getfileids/GetFileIDsQueryTest.java | 29 ++-- .../func/getfileids/GetFileIDsTest.java | 62 ++++--- .../IdentifyPillarsForGetFileIDsIT.java | 31 ++-- .../func/getstatus/GetStatusRequestIT.java | 20 ++- .../IdentifyContributorsForGetStatusIT.java | 19 ++- .../multicollection/MultipleCollectionIT.java | 7 +- .../putfile/IdentifyPillarsForPutFileIT.java | 29 ++-- .../func/putfile/PutFileRequestIT.java | 33 ++-- .../IdentifyPillarsForReplaceFileIT.java | 28 ++-- .../replacefile/ReplaceFileRequestIT.java | 20 ++- .../perf/GetAuditTrailsFileStressIT.java | 44 ++++- .../integration/perf/GetFileStressIT.java | 16 +- .../perf/PillarPerformanceTest.java | 7 - .../integration/perf/PutFileStressIT.java | 13 +- .../messagehandling/DeleteFileTest.java | 47 +++--- .../GeneralMessageHandlingTest.java | 88 ++++++---- .../messagehandling/GetAuditTrailsTest.java | 68 ++++---- .../messagehandling/GetChecksumsTest.java | 59 ++++--- .../messagehandling/GetFileIDsTest.java | 46 ++--- .../pillar/messagehandling/GetFileTest.java | 34 ++-- .../pillar/messagehandling/PutFileTest.java | 47 ++++-- .../messagehandling/ReplaceFileTest.java | 64 ++++--- .../RecalculateChecksumWorkflowTest.java | 23 ++- .../pillar/store/ChecksumPillarModelTest.java | 37 ++-- .../pillar/store/FullPillarModelTest.java | 28 ++-- .../store/PillarSettingsProviderTest.java | 7 +- .../store/archive/ArchiveDirectoryTest.java | 60 ++++--- .../store/archive/ReferenceArchiveTest.java | 8 +- .../ChecksumDatabaseMigrationTest.java | 26 +-- .../checksumcache/ChecksumDatabaseTest.java | 158 ++++++++++-------- .../checksumcache/ChecksumEntryTest.java | 15 +- 62 files changed, 1191 insertions(+), 779 deletions(-) create mode 100644 bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java 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 4361dc080..9ccb00266 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 @@ -30,6 +30,8 @@ import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + public class AlarmHandlerTest extends IntegrationTest { @Test @Tag("regressiontest") public void alarmMediatorTest() throws Exception { @@ -38,25 +40,25 @@ public void alarmMediatorTest() throws Exception { AlarmMediator mediator = new AlarmMediator(messageBus, alarmDestinationID); MockAlarmHandler alarmHandler = new MockAlarmHandler(); mediator.addHandler(alarmHandler); - Assertions.assertEquals(alarmHandler.getCallsForClose(), 0); - Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 0); + assertEquals(0, alarmHandler.getCallsForClose()); + assertEquals(0, alarmHandler.getCallsForHandleAlarm()); addStep("Try giving it a non-alarm message", "Should not call the alarm handler."); Message msg = new Message(); mediator.onMessage(msg, null); - assertEquals(alarmHandler.getCallsForClose(), 0); - Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 0); + assertEquals(0, alarmHandler.getCallsForClose()); + assertEquals(0, alarmHandler.getCallsForHandleAlarm()); addStep("Giv the mediator an AlarmMessage", "Should be sent to the alarm handler"); AlarmMessage alarmMsg = new AlarmMessage(); mediator.onMessage(alarmMsg, null); - Assertions.assertEquals(alarmHandler.getCallsForClose(), 0); - Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 1); + assertEquals(0, alarmHandler.getCallsForClose()); + assertEquals(1, alarmHandler.getCallsForHandleAlarm()); addStep("Close the mediator.", "Should also close the alarm handler."); mediator.close(); - Assertions.assertEquals(alarmHandler.getCallsForClose(), 1); - Assertions.assertEquals(alarmHandler.getCallsForHandleAlarm(), 1); + assertEquals(1, alarmHandler.getCallsForClose()); + assertEquals(1, alarmHandler.getCallsForHandleAlarm()); } protected class MockAlarmHandler implements AlarmHandler { 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 b5d7bfa83..35850d081 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 @@ -23,10 +23,9 @@ 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; /** @@ -50,7 +49,7 @@ public void alarmExceptionTest() throws Exception { Assertions.assertNull(model.getStartDate()); Assertions.assertNull(model.getCollectionID()); Assertions.assertEquals(model.getAscending(), ascending); - Assertions.assertEquals(model.getMaxCount().intValue(), Integer.MAX_VALUE); + Assertions.assertEquals(Integer.MAX_VALUE, model.getMaxCount().intValue()); addStep("Test the AlarmCode", "Should be able to put a new one in and extract it again."); AlarmCode defaultAlarmCode = AlarmCode.COMPONENT_FAILURE; 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 015dabcd7..133755e96 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,10 +38,11 @@ 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; +import org.junit.jupiter.api.TestInstance; import org.mockito.ArgumentCaptor; - - - import javax.xml.datatype.DatatypeFactory; import java.util.concurrent.ThreadFactory; @@ -53,6 +54,7 @@ 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. */ Settings settings; @@ -61,8 +63,7 @@ public class AuditTrailServiceTest extends ExtendedTestCase { public static final String DEFAULT_CONTRIBUTOR = "Contributor1"; private ThreadFactory threadFactory; - - @BeforeClass(alwaysRun = true) + @BeforeAll public void setup() { settings = TestSettingsProvider.reloadSettings("AuditTrailServiceUnderTest"); Collection c = settings.getRepositorySettings().getCollections().getCollection().get(0); @@ -72,7 +73,8 @@ public void setup() { threadFactory = new DefaultThreadFactory(this.getClass().getSimpleName(), Thread.NORM_PRIORITY); } - @Test @Tag("unstable"}) + @Test + @Tag("unstable") public void auditTrailServiceTest() throws Exception { addDescription("Test the Audit Trail Service"); DatatypeFactory factory = DatatypeFactory.newInstance(); @@ -124,7 +126,6 @@ public void auditTrailServiceTest() throws Exception { service.shutdown(); } - public static class CollectionRunner implements Runnable { private final AuditTrailService service; boolean finished = false; 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 9687eac88..32df99cbe 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 @@ -34,6 +34,7 @@ import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.settings.repositorysettings.Collection; 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; 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 eeecbb54d..3d55ca95b 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 @@ -39,6 +39,11 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.service.AlarmDispatcher; 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 org.mockito.ArgumentCaptor; @@ -60,6 +65,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class IncrementalCollectorTest extends ExtendedTestCase{ public static final String TEST_COLLECTION = "dummy-collection"; @@ -67,12 +73,13 @@ public class IncrementalCollectorTest extends ExtendedTestCase{ public static final String TEST_CONTRIBUTOR2 = "Contributor2"; private DefaultThreadFactory threadFactory; - @BeforeClass(alwaysRun = true) + @BeforeAll public void setup() throws Exception { threadFactory = new DefaultThreadFactory(this.getClass().getSimpleName(), Thread.NORM_PRIORITY, false); } - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void singleIncrementTest() throws InterruptedException { addDescription("Verifies the behaviour in the simplest case with just one result set "); AuditTrailClient client = mock(AuditTrailClient.class); @@ -123,7 +130,8 @@ public void singleIncrementTest() throws InterruptedException { verifyNoInteractions(alarmDispatcher); } - @Test @Tag("regressiontest"}) + @Test + @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."); @@ -198,7 +206,8 @@ public void multipleIncrementTest() throws Exception { verifyNoInteractions(alarmDispatcher); } - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void contributorFailureTest() throws Exception { addDescription("Tests that the collector is able to collect from the remaining contributors if a " + "contributor fails."); @@ -268,7 +277,8 @@ public void contributorFailureTest() throws Exception { verifyNoMoreInteractions(client); } - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void collectionIDFailureTest() throws Exception { addDescription("Tests what happens when a wrong collection id is received."); String FALSE_COLLECTION = "FalseCollection" + new Date().getTime(); 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 0f4585964..6a2689358 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 @@ -6,26 +6,28 @@ import org.bitrepository.common.utils.SettingsUtils; import org.bitrepository.settings.referencesettings.AuditTrailPreservation; import org.jaccept.structure.ExtendedTestCase; - - - +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import java.io.IOException; import java.util.List; import java.util.Map; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; - +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class AuditPackerTest extends ExtendedTestCase { private String collectionID; private AuditTrailPreservation preservationSettings; private AuditTrailStore store; - @BeforeClass(alwaysRun = true) + @BeforeAll public void setup() { Settings settings = TestSettingsProvider.reloadSettings("LocalAuditPreservationUnderTest"); preservationSettings = settings.getReferenceSettings().getAuditTrailServiceSettings().getAuditTrailPreservation(); @@ -38,8 +40,8 @@ public void setup() { public void testCreateNewPackage() throws IOException { AuditPacker packer = new AuditPacker(store, preservationSettings, collectionID); Map seqNumsReached = packer.getSequenceNumbersReached(); - assertEquals(seqNumsReached.entrySet().size(), 3); - assertEquals(packer.getPackedAuditCount(), 0); + assertEquals(3, seqNumsReached.entrySet().size()); + assertEquals(0, packer.getPackedAuditCount()); // Create a stubbed event iterator for each expected contributor containing only one event. List iterators = List.of( @@ -52,12 +54,12 @@ public void testCreateNewPackage() throws IOException { // Do the actual call to createNewPackage - this will fetch first event from the iterators. packer.createNewPackage(); Long[] expectedSeqNums = {1L, 1L, 1L}; - assertEquals(packer.getPackedAuditCount(), 3); + assertEquals(3, packer.getPackedAuditCount()); assertEquals(packer.getSequenceNumbersReached().values().toArray(new Long[0]), expectedSeqNums); // As the iterators have no new audits there should be no newly packed audits on a new call. packer.createNewPackage(); - assertEquals(packer.getPackedAuditCount(), 0); + assertEquals(0, packer.getPackedAuditCount()); assertEquals(packer.getSequenceNumbersReached().values().toArray(new Long[0]), expectedSeqNums); } } 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 b27d48667..f52ab84e1 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 @@ -24,8 +24,8 @@ 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; @@ -40,7 +40,8 @@ public class AuditPreservationEventHandlerTest extends ExtendedTestCase { String PILLARID = "pillarID"; public static final String TEST_COLLECTION = "dummy-collection"; - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void auditPreservationEventHandlerTest() throws Exception { addDescription("Test the handling of the audit trail event handler."); addStep("Setup", ""); 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 f88a6e8f9..c8b525e63 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 @@ -36,6 +36,11 @@ import org.bitrepository.protocol.FileExchange; import org.bitrepository.settings.repositorysettings.Collection; import org.jaccept.structure.ExtendedTestCase; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; @@ -47,6 +52,7 @@ import java.net.URL; import java.sql.Date; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.doAnswer; @@ -56,7 +62,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions; import static org.mockito.Mockito.when; - +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class LocalAuditPreservationTest extends ExtendedTestCase { /** The settings for the tests. Should be instantiated in the setup. */ Settings settings; @@ -66,8 +72,7 @@ public class LocalAuditPreservationTest extends ExtendedTestCase { private URL testUploadUrl; private DefaultThreadFactory threadFactory; - - @BeforeClass(alwaysRun = true) + @BeforeAll public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("LocalAuditPreservationUnderTest"); @@ -82,7 +87,7 @@ public void setup() throws Exception { } - @Test(enabled = false) + @Test // Fragile test, fails occasionally. @SuppressWarnings("rawtypes") public void auditPreservationSchedulingTest() throws Exception { @@ -144,7 +149,8 @@ public AuditEventIterator answer(InvocationOnMock invocation) { assertEquals(client.getCallsToPutFile(), 1); } - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") @SuppressWarnings("rawtypes") public void auditPreservationIngestTest() throws Exception { addDescription("Tests the ingest of the audit trail preservation."); 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 e58106536..538cba968 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 @@ -30,10 +30,10 @@ 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; @@ -58,7 +58,7 @@ public class AuditDatabaseTest extends ExtendedTestCase { static final String operationID2 = "4321"; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("AuditDatabaseUnderTest"); DerbyDatabaseDestroyer.deleteDatabase( @@ -69,8 +69,11 @@ public void setup() throws Exception { collectionID = settings.getCollections().get(0).getID(); } + - @Test @Tag("regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void AuditDatabaseExtractionTest() throws Exception { addDescription("Testing the connection to the audit trail service database especially with regards to " + "extracting the data from it."); @@ -83,108 +86,110 @@ public void AuditDatabaseExtractionTest() throws Exception { AuditTrailServiceDAO database = new AuditTrailServiceDAO(dm); addStep("Validate that the database is empty and then populate it.", "Should be possible."); - Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 0); + Assertions.assertEquals(0, database.largestSequenceNumber(pillarID, collectionID)); database.addAuditTrails(createEvents(), collectionID, pillarID); - Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 10); + Assertions.assertEquals(10, database.largestSequenceNumber(pillarID, collectionID)); addStep("Extract the audit trails", ""); List res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 2, res.toString()); + Assertions.assertEquals(2, res.size(), res.toString()); addStep("Test the extraction of FileID", "Should be able to extract the audit of each file individually."); res = getEventsFromIterator(database.getAuditTrailsByIterator(fileID, null, null, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID); res = getEventsFromIterator(database.getAuditTrailsByIterator(fileID2, null, null, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID2); addStep("Test the extraction of CollectionID", "Only results when the defined collection is used"); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, collectionID, null, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 2, res.toString()); + Assertions.assertEquals(2, res.size(), res.toString()); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, "NOT-THE-CORRECT-COLLECTION-ID" + System.currentTimeMillis(), null, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 0, res.toString()); + Assertions.assertEquals(0, res.size(), res.toString()); addStep("Perform extraction based on the component id.", ""); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, pillarID, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 2, res.toString()); + Assertions.assertEquals(2, res.size(), res.toString()); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, "NO COMPONENT", null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 0, res.toString()); + Assertions.assertEquals(0, res.size(), res.toString()); addStep("Perform extraction based on the sequence number restriction", "Should be possible to have both lower and upper sequence number restrictions."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, 5L, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID2); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, 5L, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID); addStep("Perform extraction based on actor id restriction.", "Should be possible to restrict on the id of the actor."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, actor1, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getActorOnFile(), actor1); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, actor2, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getActorOnFile(), actor2); addStep("Perform extraction based on operation restriction.", "Should be possible to restrict on the FileAction operation."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, FileAction.INCONSISTENCY, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); - Assertions.assertEquals(res.get(0).getActionOnFile(), FileAction.INCONSISTENCY); + Assertions.assertEquals(1, res.size(), res.toString()); + Assertions.assertEquals(FileAction.INCONSISTENCY, res.get(0).getActionOnFile()); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, FileAction.FAILURE, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); - Assertions.assertEquals(res.get(0).getActionOnFile(), FileAction.FAILURE); + Assertions.assertEquals(1, res.size(), res.toString()); + Assertions.assertEquals(FileAction.FAILURE, res.get(0).getActionOnFile()); addStep("Perform extraction based on date restriction.", "Should be possible to restrict on the date of the audit."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, restrictionDate, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID2); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, restrictionDate, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID); addStep("Perform extraction based on fingerprint restriction.", "Should be possible to restrict on the fingerprint of the audit."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, null, fingerprint1, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID); - Assertions.assertEquals(res.get(0).getCertificateID(), fingerprint1); + Assertions.assertEquals(fingerprint1, res.get(0).getCertificateID()); addStep("Perform extraction based on operationID restriction.", "Should be possible to restrict on the operationID of the audit."); res = getEventsFromIterator(database.getAuditTrailsByIterator(null, null, null, null, null, null, null, null, null, null, operationID2)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals(res.get(0).getFileID(), fileID2); - Assertions.assertEquals(res.get(0).getOperationID(), operationID2); + Assertions.assertEquals(operationID2, res.get(0).getOperationID()); database.close(); } - @Test @Tag("regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void AuditDatabasePreservationTest() throws Exception { addDescription("Tests the functions related to the preservation of the database."); addStep("Adds the variables to the settings and instantaites the database cache", "Should be connected."); @@ -192,14 +197,14 @@ public void AuditDatabasePreservationTest() throws Exception { settings.getReferenceSettings().getAuditTrailServiceSettings().getAuditTrailServiceDatabase()); AuditTrailServiceDAO database = new AuditTrailServiceDAO(dm); - Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 0); + Assertions.assertEquals(0, database.largestSequenceNumber(pillarID, collectionID)); database.addAuditTrails(createEvents(), collectionID, pillarID); - Assertions.assertEquals(database.largestSequenceNumber(pillarID, collectionID), 10); + Assertions.assertEquals(10, database.largestSequenceNumber(pillarID, collectionID)); addStep("Validate the preservation sequence number", "Should be zero, since it has not been updated yet."); long pindex = database.getPreservationSequenceNumber(pillarID, collectionID); - Assertions.assertEquals(pindex, 0); + Assertions.assertEquals(0, pindex); addStep("Validate the insertion of the preservation sequence number", "Should be the same value extracted afterwards."); @@ -210,7 +215,9 @@ public void AuditDatabasePreservationTest() throws Exception { database.close(); } - @Test @Tag("regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void auditDatabaseCorrectTimestampTest() throws ParseException { addDescription("Testing the correct ingest and extraction of audittrail dates"); DatabaseManager dm = new AuditTrailDatabaseManager( @@ -237,19 +244,21 @@ public void auditDatabaseCorrectTimestampTest() throws ParseException { List res = getEventsFromIterator(database.getAuditTrailsByIterator("summertime", null, null, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(res.get(0).getActionDateTime()), summertimeUnix); res = getEventsFromIterator(database.getAuditTrailsByIterator("wintertime", null, null, null, null, null, null, null, null, null, null)); - Assertions.assertEquals(res.size(), 1, res.toString()); + Assertions.assertEquals(1, res.size(), res.toString()); Assertions.assertEquals( CalendarUtils.convertFromXMLGregorianCalendar(res.get(0).getActionDateTime()), wintertimeUnix); } - @Test @Tag("regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void AuditDatabaseIngestTest() throws Exception { addDescription("Testing ingest of audittrails into the database"); addStep("Adds the variables to the settings and instantaites the database cache", "Should be connected."); @@ -363,7 +372,9 @@ public void AuditDatabaseIngestTest() throws Exception { } - @Test @Tag("regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void AuditDatabaseGoodIngestTest() throws Exception { addDescription("Testing good case ingest of audittrails into the database"); addStep("Adds the variables to the settings and instantaites the database cache", "Should be connected."); 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 fe60d0479..d8f886149 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 @@ -29,14 +29,15 @@ 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.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.File; import static org.bitrepository.audittrails.store.AuditDatabaseConstants.AUDIT_TRAIL_TABLE; import static org.bitrepository.audittrails.store.AuditDatabaseConstants.DATABASE_VERSION_ENTRY; +import static org.junit.jupiter.api.Assertions.assertEquals; // TODO: cannot test migration of version 1 to 2, since it requires a collection id. @@ -49,7 +50,7 @@ public class AuditServiceDatabaseMigrationTest extends ExtendedTestCase { static final String FILE_ID = "default-file-id"; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("ReferencePillarTest"); @@ -63,12 +64,14 @@ public void setup() throws Exception { FileUtils.unzip(new File(PATH_TO_DATABASE_JAR_FILE), FileUtils.retrieveDirectory(PATH_TO_DATABASE_UNPACKED)); } - @AfterMethod (alwaysRun = true) + @AfterEach public void cleanup() throws Exception { FileUtils.deleteDirIfExists(new File(PATH_TO_DATABASE_UNPACKED)); } - @Test @Tag("regressiontest", "databasetest"}) + @Test + @Tag("regressiontest") + @Tag("databasetest") public void testMigratingAuditServiceDatabase() { addDescription("Tests that the database can be migrated to latest version with the provided scripts."); DBConnector connector = new DBConnector( @@ -77,16 +80,16 @@ public void testMigratingAuditServiceDatabase() { addStep("Validate setup", "audit table has version 2 and database version 2"); String extractVersionSql = "SELECT version FROM tableversions WHERE tablename = ?"; int auditTableVersionBefore = DatabaseUtils.selectIntValue(connector, extractVersionSql, AUDIT_TRAIL_TABLE); - assertEquals(auditTableVersionBefore, 2, "Table version before migration"); + assertEquals(2, auditTableVersionBefore, "Table version before migration"); int dbTableVersionBefore = DatabaseUtils.selectIntValue(connector, extractVersionSql, DATABASE_VERSION_ENTRY); - assertEquals(dbTableVersionBefore, 2, "Table version before migration"); + assertEquals(2, dbTableVersionBefore, "Table version before migration"); addStep("Perform migration", "audit table version 5 and database-version is 6"); AuditTrailServiceDatabaseMigrator migrator = new AuditTrailServiceDatabaseMigrator(connector); migrator.migrate(); int auditTableVersionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, AUDIT_TRAIL_TABLE); - assertEquals(auditTableVersionAfter, 5, "Table version after migration"); + assertEquals(5, auditTableVersionAfter, "Table version after migration"); int dbTableVersionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, DATABASE_VERSION_ENTRY); - assertEquals(dbTableVersionAfter, 6, "Table version after migration"); + assertEquals(6, dbTableVersionAfter, "Table version after migration"); } } 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 3b5bd3313..ba3159b28 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 @@ -45,7 +45,7 @@ public void deletedFilesTest() throws Exception { reporter.reportDeletedFile("TestFile", "Pillar1"); assertFalse(reporter.hasIntegrityIssues(), "Reporter interpreted delete file as a integrity issue"); String expectedReport = "No integrity issues found"; - assertEquals("Reporter didn't create clean report", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); reporter.generateReport(); } @@ -58,7 +58,7 @@ public void noIntegrityIssuesTest() { BasicIntegrityReporter reporter = new BasicIntegrityReporter("CollectionWithoutIssues", "test", new File("target/")); assertFalse(reporter.hasIntegrityIssues(), "Reporter interpreted delete file as a integrity issue"); String expectedReport = "No integrity issues found"; - assertEquals("Reporter didn't create clean report", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); } @Test @Tag("regressiontest") @@ -71,21 +71,22 @@ public void missingFilesTest() throws Exception { reporter.reportMissingFile("TestFile", "Pillar1"); assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted missing file as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 1 file."; - assertEquals("Wrong report returned on missing file", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report another missing file on the same pillar", "The summary report should be update with the additional missing file."); reporter.reportMissingFile("TestFile2", "Pillar1"); expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 2 files."; - assertEquals("Wrong report returned on missing file", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report a missing file on another pillar", "The summary report should be update with the new pillar problem."); reporter.reportMissingFile("TestFile3", "Pillar2"); expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 2 files." + "\nPillar2 is missing 1 file."; - assertEquals("Wrong report returned on missing file", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); } - @Test @Tag("regressiontest") + @Test + @Tag("regressiontest") public void checksumIssuesTest() throws Exception { addDescription("Verifies that missing files are reported correctly"); @@ -95,20 +96,20 @@ public void checksumIssuesTest() throws Exception { reporter.reportChecksumIssue("TestFile", "Pillar1"); assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted checksum issue as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 has 1 potentially corrupt file."; - assertEquals("Wrong report returned on checksum issue", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report another checksum issue on the same pillar", "The summary report should be update with the " + "additional checksum issue."); reporter.reportChecksumIssue("TestFile2", "Pillar1"); expectedReport = REPORT_SUMMARY_START + "Pillar1 has 2 potentially corrupt files."; - assertEquals("Wrong report returned on checksum issue", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report a checksum issue on another pillar", "The summary report should be update with the new pillar problem."); reporter.reportChecksumIssue("TestFile3", "Pillar2"); expectedReport = REPORT_SUMMARY_START + "Pillar1 has 2 potentially corrupt files." + "\nPillar2 has 1 " + "potentially corrupt file."; - assertEquals("Wrong report returned on checksum issue", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); } @Test @Tag("regressiontest") @@ -121,19 +122,19 @@ public void missingChecksumTest() throws Exception { reporter.reportMissingChecksum("TestChecksum", "Pillar1"); assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted missing checksum as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 1 checksum."; - assertEquals("Wrong report returned on missing checksum", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report another missing checksum on the same pillar", "The summary report should be update with the " + "additional missing checksum."); reporter.reportMissingChecksum("TestChecksum2", "Pillar1"); expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 2 checksums."; - assertEquals("Wrong report returned on missing checksum", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report a missing checksum on another pillar", "The summary report should be update with the new pillar problem."); reporter.reportMissingChecksum("TestChecksum3", "Pillar2"); expectedReport = REPORT_SUMMARY_START + "Pillar1 is missing 2 checksums." + "\nPillar2 is missing 1 checksum."; - assertEquals("Wrong report returned on missing checksum", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); } @@ -147,18 +148,18 @@ public void obsoleteChecksumTest() throws Exception { reporter.reportObsoleteChecksum("TestChecksum", "Pillar1"); assertTrue(reporter.hasIntegrityIssues(), "Reporter didn't interpreted obsolete checksum as a integrity issue"); String expectedReport = REPORT_SUMMARY_START + "Pillar1 has 1 obsolete checksum."; - assertEquals("Wrong report returned on obsolete checksum", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report another obsolete checksum on the same pillar", "The summary report should be update with the " + "additional obsolete checksum."); reporter.reportObsoleteChecksum("TestChecksum2", "Pillar1"); expectedReport = REPORT_SUMMARY_START + "Pillar1 has 2 obsolete checksums."; - assertEquals("Wrong report returned on obsolete checksum", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); addStep("Report a obsolete checksum on another pillar", "The summary report should be update with the new pillar problem."); reporter.reportObsoleteChecksum("TestChecksum3", "Pillar2"); expectedReport = REPORT_SUMMARY_START + "Pillar1 has 2 obsolete checksums." + "\nPillar2 has 1 obsolete checksum."; - assertEquals("Wrong report returned on obsolete checksum", expectedReport, reporter.generateSummaryOfReport()); + assertEquals(expectedReport, reporter.generateSummaryOfReport()); } } 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 88b421ab9..1abc28a0c 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 @@ -31,7 +31,9 @@ import org.bitrepository.monitoringservice.status.ComponentStatusCode; import org.bitrepository.protocol.IntegrationTest; import org.bitrepository.settings.referencesettings.AlarmLevel; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.math.BigInteger; @@ -40,7 +42,8 @@ public class MonitorAlerterTest extends IntegrationTest { - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void testMonitorAlerter() throws Exception { addDescription("Tests the " + BasicMonitoringServiceAlerter.class.getName()); addStep("Setup", ""); @@ -52,12 +55,12 @@ public void testMonitorAlerter() throws Exception { BasicMonitoringServiceAlerter alerter = new BasicMonitoringServiceAlerter( settingsForCUT, messageBus, AlarmLevel.ERROR, store); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); addStep("Check statuses with an empty map.", "Should only make a call for GetStatusMap"); store.statuses = new HashMap<>(); alerter.checkStatuses(); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 1); + Assertions.assertEquals(1, store.getCallsForGetStatusMap()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); addStep("Check the status when a positive entry exists.", "Should make another call for the GetStatusMap"); @@ -65,7 +68,7 @@ public void testMonitorAlerter() throws Exception { cs.updateStatus(createPositiveStatus()); store.statuses.put(componentID, cs); alerter.checkStatuses(); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 2); + Assertions.assertEquals(2, store.getCallsForGetStatusMap()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); addStep("Check the status when a negative entry exists.", @@ -73,10 +76,10 @@ public void testMonitorAlerter() throws Exception { cs.updateReplies(); store.statuses.put(componentID, cs); alerter.checkStatuses(); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 3); + Assertions.assertEquals(3, store.getCallsForGetStatusMap()); alarmReceiver.waitForMessage(AlarmMessage.class); - Assertions.assertEquals(cs.getStatus(), ComponentStatusCode.UNRESPONSIVE); + Assertions.assertEquals(ComponentStatusCode.UNRESPONSIVE, cs.getStatus()); } private ResultingStatus createPositiveStatus() { 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 3f580905d..997d4cf52 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 @@ -27,25 +27,30 @@ import org.bitrepository.monitoringservice.MockGetStatusClient; import org.bitrepository.monitoringservice.MockStatusStore; 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 javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.Duration; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class StatusCollectorTest extends ExtendedTestCase { Settings settings; private int INTERVAL = 500; private int INTERVAL_DELAY = 250; - @BeforeClass (alwaysRun = true) + @BeforeAll public void setup() { settings = TestSettingsProvider.reloadSettings("StatusCollectorUnderTest"); } - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void testStatusCollector() throws Exception { addDescription("Tests the status collector."); addStep("Setup", ""); @@ -57,11 +62,11 @@ public void testStatusCollector() throws Exception { settings.getReferenceSettings().getMonitoringServiceSettings().setCollectionInterval(intervalXmlDur); addStep("Create the collector", ""); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(client.getCallsToGetStatus(), 0); - Assertions.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(0, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(0, client.getCallsToGetStatus()); + Assertions.assertEquals(0, client.getCallsToShutdown()); StatusCollector collector = new StatusCollector(client, settings, store, alerter); addStep("Start the collector", "It should immediately call the client and store."); @@ -69,11 +74,11 @@ public void testStatusCollector() throws Exception { synchronized(this) { wait(INTERVAL_DELAY); } - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 1); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(client.getCallsToGetStatus(), 1); - Assertions.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(1, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(1, client.getCallsToGetStatus()); + Assertions.assertEquals(0, client.getCallsToShutdown()); addStep("wait 2 * the interval", "It should call the client and store two times more."); synchronized(this) { @@ -81,21 +86,21 @@ public void testStatusCollector() throws Exception { } collector.stop(); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 3); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(client.getCallsToGetStatus(), 3); - Assertions.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(3, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(3, client.getCallsToGetStatus()); + Assertions.assertEquals(0, client.getCallsToShutdown()); addStep("wait the interval + delay again", "It should not have made any more calls"); synchronized(this) { wait(INTERVAL + INTERVAL_DELAY); } - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 3); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(client.getCallsToGetStatus(), 3); - Assertions.assertEquals(client.getCallsToShutdown(), 0); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(3, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(3, client.getCallsToGetStatus()); + Assertions.assertEquals(0, client.getCallsToShutdown()); } } 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 812cd800c..c126662a5 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 @@ -30,14 +30,17 @@ 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 { public static final String TEST_COLLECTION = "collection1"; - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void testStatusEventHandler() throws Exception { addDescription("Test the GetStatusEventHandler handling of events"); addStep("Setup", ""); @@ -46,43 +49,43 @@ public void testStatusEventHandler() throws Exception { GetStatusEventHandler eventHandler = new GetStatusEventHandler(store, alerter); addStep("Validate initial calls to the mocks", "No calls expected"); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 0); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(0, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(0, alerter.getCallsForCheckStatuses()); addStep("Test an unhandled event.", "Should not make any calls."); AbstractOperationEvent event = new DefaultEvent(TEST_COLLECTION); event.setEventType(OperationEventType.WARNING); eventHandler.handleEvent(event); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 0); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(0, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(0, alerter.getCallsForCheckStatuses()); addStep("Test the Complete event", "Should make a call to the alerter"); event = new CompleteEvent(TEST_COLLECTION, null); eventHandler.handleEvent(event); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 1); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(0, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(1, alerter.getCallsForCheckStatuses()); addStep("Test the Failed event", "Should make another call to the alerter"); event = new OperationFailedEvent(null, "info", null); eventHandler.handleEvent(event); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 0); - Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 2); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(0, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(0, store.getCallsForUpdateStatus()); + Assertions.assertEquals(2, alerter.getCallsForCheckStatuses()); addStep("Test the component complete status", "Should attempt to update the store"); event = new StatusCompleteContributorEvent("ContributorID", "dummy-collection", null); eventHandler.handleEvent(event); - Assertions.assertEquals(store.getCallsForGetStatusMap(), 0); - Assertions.assertEquals(store.getCallsForUpdateReplayCounts(), 0); - Assertions.assertEquals(store.getCallsForUpdateStatus(), 1); - Assertions.assertEquals(alerter.getCallsForCheckStatuses(), 2); + Assertions.assertEquals(0, store.getCallsForGetStatusMap()); + Assertions.assertEquals(0, store.getCallsForUpdateReplayCounts()); + Assertions.assertEquals(1, store.getCallsForUpdateStatus()); + Assertions.assertEquals(2, alerter.getCallsForCheckStatuses()); } } 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 daf9db5d6..3fcd9465d 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 @@ -28,23 +28,26 @@ import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.common.utils.CalendarUtils; 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 java.util.HashSet; import java.util.Map; import java.util.Set; +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ComponentStatusStoreTest extends ExtendedTestCase { Settings settings; - @BeforeClass (alwaysRun = true) + @BeforeAll public void setup() { settings = TestSettingsProvider.reloadSettings("ComponentStatusStoreUnderTest"); } - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void testComponentStatus() throws Exception { addDescription("Tests the compontent status"); addStep("Setup", ""); @@ -55,7 +58,7 @@ public void testComponentStatus() throws Exception { addStep("Validate the initial content", "Should be one component with a 'new and empty' component status."); Map statuses = store.getStatusMap(); - Assertions.assertEquals(statuses.size(), 1); + Assertions.assertEquals(1, statuses.size()); ComponentStatus newStatus = new ComponentStatus(); Assertions.assertNotNull(statuses.get(componentId)); @@ -67,20 +70,20 @@ public void testComponentStatus() throws Exception { addStep("Update the replay counts and validate ", "it should increases the 'number of missing replies' by 1"); store.updateReplyCounts(); statuses = store.getStatusMap(); - Assertions.assertEquals(statuses.size(), 1); + Assertions.assertEquals(1, statuses.size()); Assertions.assertNotNull(statuses.get(componentId)); Assertions.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); - Assertions.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 1); + Assertions.assertEquals(1, statuses.get(componentId).getNumberOfMissingReplies()); Assertions.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); Assertions.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); addStep("Test what happens when an invalid component id attempted to be updated.", "Should not affect content."); store.updateStatus("BAD-COMPONENT-ID", null); statuses = store.getStatusMap(); - Assertions.assertEquals(statuses.size(), 1); + Assertions.assertEquals(1, statuses.size()); Assertions.assertNotNull(statuses.get(componentId)); Assertions.assertEquals(statuses.get(componentId).getInfo(), newStatus.getInfo()); - Assertions.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 1); + Assertions.assertEquals(1, statuses.get(componentId).getNumberOfMissingReplies()); Assertions.assertEquals(statuses.get(componentId).getLastReplyDate(), newStatus.getLastReplyDate()); Assertions.assertEquals(statuses.get(componentId).getStatus(), newStatus.getStatus()); @@ -88,10 +91,10 @@ public void testComponentStatus() throws Exception { ResultingStatus resStatus = createPositiveStatus(); store.updateStatus(componentId, resStatus); statuses = store.getStatusMap(); - Assertions.assertEquals(statuses.size(), 1); + Assertions.assertEquals(1, statuses.size()); Assertions.assertNotNull(statuses.get(componentId)); Assertions.assertEquals(statuses.get(componentId).getInfo(), resStatus.getStatusInfo().getStatusText()); - Assertions.assertEquals(statuses.get(componentId).getNumberOfMissingReplies(), 0); + Assertions.assertEquals(0, statuses.get(componentId).getNumberOfMissingReplies()); Assertions.assertEquals(statuses.get(componentId).getLastReplyDate(), resStatus.getStatusTimestamp()); Assertions.assertEquals(statuses.get(componentId).getStatus().value(), resStatus.getStatusInfo().getStatusCode().name()); } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java new file mode 100644 index 000000000..a96d68393 --- /dev/null +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java @@ -0,0 +1,63 @@ +package org.bitrepository.pillar; + +import org.bitrepository.protocol.GlobalSuiteExtension; +import org.bitrepository.protocol.IntegrationTest; +import org.bitrepository.protocol.bus.ActiveMQMessageBusTest; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.platform.suite.api.ExcludeTags; +import org.junit.platform.suite.api.IncludeTags; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; + +/** + * BitrepositoryPillarTestSuite is a JUnit 5 suite class that groups and configures multiple test classes + * for the BitRepositoryPillar project. This suite uses JUnit 5 annotations to select test classes, packages, + * and tags, and extend the suite with custom extensions. + * + *

JUnit 5 Annotations Used:

+ *
    + *
  • {@link Suite}: Indicates that this class is a JUnit 5 suite. It groups multiple test classes + * into a single test suite.
  • + *
  • {@link SelectClasses}: Specifies the test classes to be included in the suite. The value is an array + * of class references to the test classes.
  • + *
  • {@link SelectPackages}: Specifies the test packages to be included in the suite. The value is an array + * of package names.
  • + *
  • {@link IncludeTags}: Specifies the tags to include in the suite. The value is an array of tag names.
  • + *
  • {@link ExcludeTags}: Specifies the tags to exclude from the suite. The value is an array of tag names.
  • + *
  • {@link ExtendWith}: Specifies the extensions to be applied to the suite. The value is an array of + * extension classes.
  • + *
+ * + *

Options in a JUnit 5 Suite:

+ *
    + *
  • Selecting Test Classes: Use the {@link SelectClasses} annotation to specify the test + * classes to be included in the suite. The value is an array of class references to the test classes.
  • + *
  • Selecting Test Packages: Use the {@link SelectPackages} annotation to specify the test + * packages to be included in the suite. The value is an array of package names.
  • + *
  • Selecting Tests by Tag: Use the {@link IncludeTags} and {@link ExcludeTags} annotations + * to specify the tags to include or exclude in the suite. The value is an array of tag names.
  • + *
  • Extending the Suite: Use the {@link ExtendWith} annotation to specify custom extensions + * to be applied to the suite. The value is an array of extension classes.
  • + *
+ * + *

Example Usage:

+ *
+ * {@code
+ * @Suite
+ * @SelectClasses({BitrepositoryPillarTest.class})  // List your test classes here
+ * @SelectPackages("org.bitrepository.pillar")  // List your test packages here
+ * @IncludeTags("integration")  // List your include tags here
+ * @ExcludeTags("slow")  // List your exclude tags here
+ * @ExtendWith(GlobalSuiteExtension.class)
+ * public class BitrepositoryTestSuite {
+ *     // No need for methods here; this just groups and extends
+ * }
+ * }
+ * 
+ */ +@Suite +@SelectClasses({IntegrationTest.class, ActiveMQMessageBusTest.class}) // List your test classes here +@ExtendWith(GlobalSuiteExtension.class) +public class BitrepositoryPillarTestSuite { +} 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 c7628b5a7..d567ab5b0 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 @@ -35,8 +35,10 @@ import org.bitrepository.service.audit.MockAuditManager; import org.bitrepository.service.contributor.ResponseDispatcher; import org.bitrepository.service.contributor.handler.RequestHandler; - - +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.math.BigInteger; @@ -49,7 +51,7 @@ public class MediatorTest extends DefaultFixturePillarTest { MessageHandlerContext context; StorageModel model = null; - @BeforeMethod (alwaysRun=true) + @BeforeEach public void initialiseTest() { audits = new MockAuditManager(); context = new MessageHandlerContext( @@ -60,7 +62,9 @@ public void initialiseTest() { audits); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testMediatorRuntimeExceptionHandling() { addDescription("Tests the handling of a runtime exception"); addStep("Setup create and start the mediator.", ""); @@ -84,7 +88,7 @@ public void testMediatorRuntimeExceptionHandling() { messageBus.sendMessage(request); MessageResponse response = clientReceiver.waitForMessage(IdentifyContributorsForGetStatusResponse.class); - Assertions.assertEquals(response.getResponseInfo().getResponseCode(), ResponseCode.FAILURE); + Assertions.assertEquals(ResponseCode.FAILURE, response.getResponseInfo().getResponseCode()); Assertions.assertNotNull(alarmReceiver.waitForMessage(AlarmMessage.class)); } finally { mediator.close(); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java index c2a70ce53..9180152de 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/common/SettingsHelperTest.java @@ -25,6 +25,9 @@ import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.settings.repositorysettings.Collection; import org.bitrepository.settings.repositorysettings.PillarIDs; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.ArrayList; @@ -32,7 +35,8 @@ import java.util.List; public class SettingsHelperTest { - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void getPillarCollectionsTest() { String myPillarID = "myPillarID"; String otherPillarID = "OtherPillar"; @@ -43,12 +47,12 @@ public void getPillarCollectionsTest() { collection.add(createCollection("otherCollection", new String[] {otherPillarID})); List myCollections = SettingsHelper.getPillarCollections(myPillarID, collection); - Assertions.assertEquals(myCollections.size(), 2); + Assertions.assertEquals(2, myCollections.size()); Assertions.assertEquals("myFirstCollection", myCollections.get(0)); Assertions.assertEquals("mySecondCollection", myCollections.get(1)); List otherCollections = SettingsHelper.getPillarCollections(otherPillarID, collection); - Assertions.assertEquals(otherCollections.size(), 2); + Assertions.assertEquals(2, otherCollections.size()); Assertions.assertEquals("mySecondCollection", otherCollections.get(0)); Assertions.assertEquals("otherCollection", otherCollections.get(1)); } 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 a72794c8c..448071081 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 @@ -48,6 +48,12 @@ import org.bitrepository.protocol.security.PermissionStore; import org.bitrepository.protocol.security.SecurityManager; import org.jaccept.TestEventManager; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.TestInfo; +import org.junit.jupiter.api.TestInstance; + import javax.jms.JMSException; import java.io.IOException; import java.io.InputStream; @@ -59,6 +65,7 @@ * Note That no setup/teardown is possible in this test of external pillars, so tests need to be written * to be invariant against the initial pillar state. */ +@TestInstance(TestInstance.Lifecycle.PER_CLASS) public abstract class PillarIntegrationTest extends IntegrationTest { /** The path to the directory containing the integration test configuration files */ protected static final String PATH_TO_CONFIG_DIR = System.getProperty( @@ -88,23 +95,7 @@ protected void initializeCUT() { clientEventHandler = new ClientEventLogger(testEventManager); } - @BeforeClass(alwaysRun = true) - @Override - public void initializeSuite(ITestContext testContext) { - testConfiguration = - new PillarIntegrationTestConfiguration(PATH_TO_TESTPROPS_DIR + "/" + TEST_CONFIGURATION_FILE_NAME); - super.initializeSuite(testContext); - //MessageBusManager.injectCustomMessageBus(MessageBusManager.DEFAULT_MESSAGE_BUS, messageBus); - setupRealMessageBus(); - startEmbeddedPillar(testContext); - reloadMessageBus(); - clientProvider = new ClientProvider(securityManager, settingsForTestClient, testEventManager); - nonDefaultCollectionId = settingsForTestClient.getCollections().get(1).getID(); - irrelevantCollectionId = settingsForTestClient.getCollections().get(2).getID(); - putDefaultFile(); - } - - @AfterClass(alwaysRun = true) + @AfterAll public void shutdownRealMessageBus() { if(!useEmbeddedMessageBus()) { MessageBusManager.clear(); @@ -119,15 +110,8 @@ public void shutdownRealMessageBus() { } } - @AfterSuite(alwaysRun = true) - @Override - public void shutdownSuite() { - stopEmbeddedReferencePillar(); - super.shutdownSuite(); - } - - @AfterMethod(alwaysRun = true) - public void addFailureContextInfo(ITestResult result) { + @AfterEach + public void addFailureContextInfo() { } protected void setupRealMessageBus() { @@ -156,12 +140,12 @@ public void initMessagebus() { * The type of pillar (full or checksum) is baed on the test group used, eg. if the group is * checksumPillarTest a checksum pillar is started, else a normal 'full' reference pillar is started. *

- * @param testContext + * @param testInfo */ - protected void startEmbeddedPillar(ITestContext testContext) { + protected void startEmbeddedPillar(TestInfo testInfo) { if (testConfiguration.useEmbeddedPillar()) { SettingsUtils.initialize(settingsForCUT); - if (Arrays.asList(testContext.getIncludedGroups()).contains(PillarTestGroups.CHECKSUM_PILLAR_TEST)) { + if (testInfo.getTags().contains(PillarTestGroups.CHECKSUM_PILLAR_TEST)) { embeddedPillar = EmbeddedPillar.createChecksumPillar(settingsForCUT); } else { embeddedPillar = EmbeddedPillar.createReferencePillar(settingsForCUT); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/Assert.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/Assert.java index a2739f3cd..34dbaa196 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/Assert.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/Assert.java @@ -24,7 +24,9 @@ import java.util.List; -public class Assert extends org.testng.Assert { +import static org.junit.jupiter.api.Assertions.fail; + +public class Assert extends org.junit.jupiter.api.Assertions { public static void assertEmpty(List list2Test, String message) { if (!list2Test.isEmpty()) { 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 bea255ea2..b52c7c0cc 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 @@ -26,11 +26,16 @@ import org.bitrepository.bitrepositorymessages.MessageRequest; import org.bitrepository.bitrepositorymessages.MessageResponse; import org.bitrepository.pillar.PillarTestGroups; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public abstract class DefaultPillarIdentificationTest extends DefaultPillarMessagingTest { - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void irrelevantCollectionTest() { addDescription("Verifies identification works correctly for a collection not defined for the pillar"); addStep("Sending a putFile identification with a irrelevant collectionID. eg. the " + @@ -44,7 +49,7 @@ public void irrelevantCollectionTest() { protected void assertPositivResponseIsReceived() { MessageResponse receivedResponse = receiveResponse(); - Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedResponse.getResponseInfo().getResponseCode()); } } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java index 7cdad591b..e3edd0b12 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/func/DefaultPillarOperationTest.java @@ -24,12 +24,13 @@ import org.bitrepository.bitrepositoryelements.ResponseCode; import org.bitrepository.bitrepositorymessages.MessageResponse; +import org.junit.jupiter.api.Assertions; public abstract class DefaultPillarOperationTest extends DefaultPillarMessagingTest { protected void assertPositivResponseIsReceived() { MessageResponse receivedResponse = receiveResponse(); - Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, + receivedResponse.getResponseInfo().getResponseCode()); } } 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 8f187c09c..b7e6b9491 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 @@ -24,6 +24,8 @@ import org.bitrepository.pillar.integration.PillarIntegrationTest; import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; import org.bitrepository.protocol.bus.MessageReceiver; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.TestInfo; import java.lang.reflect.Method; @@ -41,9 +43,9 @@ public abstract class PillarFunctionTest extends PillarIntegrationTest { /** Used for receiving responses from the pillar */ protected MessageReceiver clientReceiver; - @BeforeMethod(alwaysRun=true) - public void generalMethodSetup(Method method) throws Exception { - testSpecificFileID = method.getName() + "File-" + createDate(); + @BeforeEach + public void generalMethodSetup(TestInfo testInfo) throws Exception { + testSpecificFileID = testInfo.getTestMethod().get() + "File-" + createDate(); } @Override 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 7ba9b3461..402fe2978 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 @@ -37,10 +37,10 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.DeleteFileMessageFactory; - - - - +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.lang.reflect.Method; import java.util.concurrent.TimeUnit; @@ -48,8 +48,8 @@ public class DeleteFileRequestIT extends DefaultPillarOperationTest { protected DeleteFileMessageFactory msgFactory; private String pillarDestination; - @BeforeMethod(alwaysRun=true) - public void initialiseReferenceTest(Method method) throws Exception { + @BeforeEach + public void initialiseReferenceTest() throws Exception { pillarDestination = lookupDeleteFileDestination(); msgFactory = new DeleteFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), pillarDestination); clientProvider.getPutClient().putFile( @@ -60,7 +60,9 @@ public void initialiseReferenceTest(Method method) throws Exception { null, null, null); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag( PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalDeleteFileTest() { addDescription("Tests a normal DeleteFile sequence"); addStep("Send a DeleteFile request to " + testConfiguration.getPillarUnderTestID(), @@ -76,18 +78,19 @@ public void normalDeleteFileTest() { Assertions.assertEquals(progressResponse.getCorrelationID(), deleteRequest.getCorrelationID()); Assertions.assertEquals(progressResponse.getFrom(), getPillarID()); Assertions.assertEquals(progressResponse.getPillarID(), getPillarID()); - Assertions.assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); DeleteFileFinalResponse finalResponse = (DeleteFileFinalResponse) receiveResponse(); Assertions.assertNotNull(finalResponse); - Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(finalResponse.getCorrelationID(), deleteRequest.getCorrelationID()); Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); Assertions.assertEquals(finalResponse.getPillarID(), getPillarID()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void requestNewChecksumDeleteFileTest() { addDescription("Tests a normal DeleteFile sequence"); addStep("Send a DeleteFile request to " + testConfiguration.getPillarUnderTestID(), @@ -112,12 +115,12 @@ public void requestNewChecksumDeleteFileTest() { Assertions.assertEquals(progressResponse.getCorrelationID(), deleteRequest.getCorrelationID()); Assertions.assertEquals(progressResponse.getFrom(), getPillarID()); Assertions.assertEquals(progressResponse.getPillarID(), getPillarID()); - Assertions.assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); DeleteFileFinalResponse finalResponse = (DeleteFileFinalResponse) receiveResponse(); Assertions.assertNotNull(finalResponse); - Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(finalResponse.getCorrelationID(), deleteRequest.getCorrelationID()); Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); Assertions.assertNotNull(finalResponse.getChecksumDataForExistingFile()); 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 ec354fb04..c5a8cb9f2 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 @@ -31,19 +31,23 @@ import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.DeleteFileMessageFactory; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class IdentifyPillarsForDeleteFileIT extends DefaultPillarIdentificationTest { protected DeleteFileMessageFactory msgFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { msgFactory = new DeleteFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for deleteFile identification"); addStep("Sending a deleteFile identification.", @@ -59,12 +63,13 @@ public void normalIdentificationTest() { Assertions.assertEquals(receivedIdentifyResponse.getFileID(), DEFAULT_FILE_ID); Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); Assertions.assertNull(receivedIdentifyResponse.getPillarChecksumSpec()); - Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void identificationTestForChecksumPillar() { addDescription("Verifies the normal behaviour for deleteFile identification for a checksum pillar"); addStep("Sending a deleteFile identification.", @@ -81,12 +86,13 @@ public void identificationTestForChecksumPillar() { Assertions.assertEquals(receivedIdentifyResponse.getPillarChecksumSpec().getChecksumType(), ChecksumUtils.getDefault(settingsForCUT).getChecksumType()); Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); - Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag( PillarTestGroups.CHECKSUM_PILLAR_TEST) public void fileDoesNotExistsTest() { addDescription("Verifies that a request for a non-existing file is handled correctly"); addStep("Sending a deleteFile identification for a file not in the pillar.", @@ -97,8 +103,8 @@ public void fileDoesNotExistsTest() { IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); } @Override 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 e4892d25b..00e7ba460 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 @@ -27,11 +27,12 @@ import org.bitrepository.client.exceptions.NegativeResponseException; import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; - - +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.List; - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GetAuditTrailsTest extends PillarFunctionTest { @@ -41,7 +42,9 @@ protected void initializeCUT() { settingsForTestClient.getRepositorySettings().getGetAuditTrailSettings().getNonPillarContributorIDs().clear(); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void eventSortingTest() throws NegativeResponseException{ addDescription("Test whether the audit trails are sorted based on sequence numbers, with the largest " + "sequence number last.."); @@ -62,7 +65,9 @@ public void eventSortingTest() throws NegativeResponseException{ } } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @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."); addFixture("Ensure at least two files are present on the pillar"); @@ -79,12 +84,14 @@ public void maxNumberOfResultTest() { "audit event in the full list."); AuditTrailQuery singleEventQuery = new AuditTrailQuery(getPillarID(), null, null, 1); List singleEventList = getAuditTrails(singleEventQuery, null); - assertEquals(singleEventList.size(), 1, "The result didn't contain a single event"); + assertEquals(1, singleEventList.size(), "The result didn't contain a single event"); assertEquals(singleEventList.get(0), originalAuditTrailEventList.get(0), "The returned event wasn't equal to the first event"); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void minSequenceNumberTest() { addDescription("Test the pillar support for only retrieving events with sequence number higher than the " + "provided MinSequenceNumber" + @@ -119,7 +126,9 @@ public void minSequenceNumberTest() { "First event in second page different from last element in first page"); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void maxSequenceNumberTest() { addDescription("Test the pillar support for only retrieving audit event with SequenceNumbers lower than " + "MaxSequenceNumber."); @@ -148,7 +157,7 @@ public void maxSequenceNumberTest() { AuditTrailQuery firstSequenceNumberQuery = new AuditTrailQuery(getPillarID(), null, smallestSequenceNumber, null); limitedEventList = getAuditTrails(firstSequenceNumberQuery, null); - assertEquals(limitedEventList.size(), 1, "Received list with size of " + limitedEventList.size() + " " + + assertEquals(1, limitedEventList.size(), "Received list with size of " + limitedEventList.size() + " " + "when requesting audit trail with MaxSequenceNumber set to first event (expected 1 event)"); assertEquals(limitedEventList.get(0), originalAuditTrailEventList.get(0), 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 ca37bb956..26e3f9512 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 @@ -27,15 +27,18 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.pillar.integration.func.PillarFunctionTest; - - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.xml.datatype.XMLGregorianCalendar; import java.util.GregorianCalendar; import java.util.List; public class GetChecksumQueryTest extends PillarFunctionTest { - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag( PillarTestGroups.CHECKSUM_PILLAR_TEST) public void checksumSortingTest() { addDescription("Test whether the checksum result is sorted oldest to newest."); addFixture("Ensure at least two files are present on the pillar"); @@ -53,7 +56,9 @@ public void checksumSortingTest() { } } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @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."); addFixture("Ensure at least two files are present on the pillar"); @@ -68,12 +73,14 @@ public void maxNumberOfResultTest() { ContributorQuery singleChecksumQuery = new ContributorQuery(getPillarID(), null, null, 1); List singleChecksumList = pillarFileManager.getChecksums(null, singleChecksumQuery, null); - Assertions.assertEquals(singleChecksumList.size(), 1, "The result didn't contain a single checksum"); + Assertions.assertEquals(1, singleChecksumList.size(), "The result didn't contain a single checksum"); Assertions.assertEquals(singleChecksumList.get(0), originalChecksumList.get(0), "The returned checksum wasn't equal to the oldest checksum"); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void minTimeStampTest() { addDescription("Test the pillar support for only retrieving checksums newer that a given time. " + "Note that this test assumes there is at least 2 checksums with different timestamps." + @@ -122,12 +129,12 @@ public void minTimeStampTest() { newerThanNewestTimestamp.add(GregorianCalendar.MILLISECOND, 10); query = new ContributorQuery(getPillarID(), newerThanNewestTimestamp.getTime(), null, null); limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assertions.assertEmpty(limitedChecksumList, + Assertions.assertTrue(limitedChecksumList.isEmpty(), "Non-empty checksum list returned with newerThanNewestTimestamp(" + CalendarUtils.getXmlGregorianCalendar(newerThanNewestTimestamp) + ") query"); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void maxTimeStampTest() { addDescription("Test the pillar support for only retrieving checksums older than a given time. " + "Note that this test assumes there is at least 2 checksums with different timestamps. " + @@ -177,7 +184,7 @@ public void maxTimeStampTest() { olderThanOldestTimestamp.add(GregorianCalendar.MILLISECOND, -10); query = new ContributorQuery(getPillarID(), null, olderThanOldestTimestamp.getTime(), null); limitedChecksumList = pillarFileManager.getChecksums(null, query, null); - Assertions.assertEmpty(limitedChecksumList, + Assertions.assertTrue(limitedChecksumList.isEmpty(), "Non-empty checksum list returned with olderThanOldestTimestamp(" + CalendarUtils.getXmlGregorianCalendar(olderThanOldestTimestamp) + ") query"); } 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 fdf0b1769..5493cfdfc 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,22 +29,27 @@ 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.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.TestInstance; 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 { - @BeforeClass + @BeforeAll public void retrieveFirst2Files() { //ToDo } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void md5ChecksumsForAllFilesTest() throws NegativeResponseException { addDescription("Test the pillar support for MD5 type checksums"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); @@ -62,7 +67,8 @@ public void md5ChecksumsForAllFilesTest() throws NegativeResponseException { // ToDo implement this } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void sha1ChecksumsForDefaultTest() throws NegativeResponseException { addDescription("Test the pillar support for SHA1 type checksums"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); @@ -76,7 +82,8 @@ public void sha1ChecksumsForDefaultTest() throws NegativeResponseException { assertNotNull(checksums.get(0)); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void md5SaltChecksumsForDefaultTest() throws NegativeResponseException { addDescription("Test the pillar support for MD5 type checksums with a salt"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); @@ -95,7 +102,8 @@ public void md5SaltChecksumsForDefaultTest() throws NegativeResponseException { assertNotNull(checksums.get(0)); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void sha1SaltChecksumsForDefaultTest() throws NegativeResponseException { addDescription("Test the pillar support for SHA1 type checksums with a salt"); pillarFileManager.ensureNumberOfFilesOnPillar(2, testMethodName); 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 d0a5ce0e1..7a73fc171 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 @@ -33,22 +33,25 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.GetChecksumsMessageFactory; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class IdentifyPillarsForGetChecksumsIT extends DefaultPillarIdentificationTest { protected GetChecksumsMessageFactory msgFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { msgFactory = new GetChecksumsMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); clearReceivers(); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for getChecksums identification"); addStep("Setup for test", "2 files on the pillar"); @@ -79,12 +82,14 @@ public void normalIdentificationTest() { assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID(), "Received unexpected 'PillarID' in response."); assertNotNull(receivedIdentifyResponse.getReplyTo()); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE, + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'Response' in response."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void nonExistingFileTest() { addDescription("Tests that the pillar is able to reject a GetChecksums requests for a file, which it " + "does not have during the identification phase."); @@ -105,12 +110,14 @@ public void nonExistingFileTest() { IdentifyPillarsForGetChecksumsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetChecksumsResponse.class); assertNotNull(receivedIdentifyResponse.getFileIDs().getFileID()); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE, + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' in response."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void allFilesTest() { addDescription("Tests that the pillar accepts a GetChecksums requests for all files, even though it does not have any files."); FileIDs fileids = FileIDsUtils.getAllFileIDs(); @@ -126,8 +133,8 @@ public void allFilesTest() { "The pillar should make a response."); IdentifyPillarsForGetChecksumsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetChecksumsResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE, + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' in response."); } 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 7ccc88dff..03326a6ad 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 @@ -16,12 +16,14 @@ import org.bitrepository.pillar.messagefactories.GetFileMessageFactory; import org.bitrepository.protocol.FileExchange; import org.bitrepository.protocol.ProtocolComponentFactory; +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.TestInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - - - - import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Method; @@ -30,9 +32,9 @@ import java.nio.charset.StandardCharsets; import java.util.concurrent.TimeUnit; - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; public class GetFileRequestIT extends PillarFunctionTest { private final Logger log = LoggerFactory.getLogger(this.getClass()); @@ -40,24 +42,26 @@ public class GetFileRequestIT extends PillarFunctionTest { protected URL testFileURL = null; protected FileExchange fe = null; - @BeforeMethod(alwaysRun=true) - public void initialiseReferenceTest(Method method) throws Exception { + @BeforeEach + public void initialiseReferenceTest() throws Exception { String pillarDestination = lookupGetFileDestination(); msgFactory = new GetFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), pillarDestination); testFileURL = new URL(DEFAULT_FILE_URL.toExternalForm() + System.currentTimeMillis()); fe = ProtocolComponentFactory.getInstance().getFileExchange(settingsForCUT); } - @AfterMethod(alwaysRun=true) - public void cleanUp(Method method) { + @AfterEach + public void cleanUp(TestInfo testInfo) { try { fe.deleteFile(testFileURL); } catch (Exception e) { - log.warn("Could not clean up file '{}' after method '{}'", testFileURL, method.getName()); + log.warn("Could not clean up file '{}' after method '{}'", testFileURL, + testInfo.getTestMethod().get().getName()); } } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void normalGetFileTest() throws IOException { addDescription("Tests a normal GetFile sequence"); addStep("Send a getFile request to " + testConfiguration.getPillarUnderTestID(), @@ -97,7 +101,7 @@ public void normalGetFileTest() throws IOException { "Received unexpected 'FileAddress' element."); assertEquals(finalResponse.getPillarID(), getPillarID(), "Received unexpected 'PillarID' element."); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED, + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' element."); try (InputStream localFileIS = TestFileHelper.getDefaultFile(); @@ -109,7 +113,8 @@ public void normalGetFileTest() throws IOException { } } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void getFileWithFilePartTest() throws IOException { addDescription("Tests that a pillar is able to return a specified FilePart in the final response"); addStep("Send a getFile request to " + testConfiguration.getPillarUnderTestID() + " with a specified " + @@ -139,7 +144,8 @@ public void getFileWithFilePartTest() throws IOException { } } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void getMissingFileTest() { addDescription("Tests that a pillar gives an error when trying to get a non-existing file"); addStep("Send a getFile request to " + testConfiguration.getPillarUnderTestID() + " with a " + @@ -150,11 +156,12 @@ public void getMissingFileTest() { messageBus.sendMessage(getRequest); GetFileFinalResponse finalResponse = (GetFileFinalResponse) receiveResponse(); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE, + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' element."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST ) public void missingCollectionIDTest() { addDescription("Verifies the a missing collectionID in the request is rejected"); addStep("Sending a request without a collectionID.", @@ -164,11 +171,12 @@ public void missingCollectionIDTest() { messageBus.sendMessage(request); MessageResponse receivedResponse = receiveResponse(); - Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), - ResponseCode.REQUEST_NOT_UNDERSTOOD_FAILURE); + Assertions.assertEquals(ResponseCode.REQUEST_NOT_UNDERSTOOD_FAILURE, + receivedResponse.getResponseInfo().getResponseCode()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void otherCollectionTest() { addDescription("Verifies identification works correctly for a second collection defined for pillar"); addStep("Sending a identify request with a non-default collectionID (not the first collection) " + @@ -204,7 +212,7 @@ public String lookupGetFileDestination() { protected void assertPositivResponseIsReceived() { MessageResponse receivedResponse = receiveResponse(); - Assertions.assertEquals(receivedResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, + receivedResponse.getResponseInfo().getResponseCode()); } } 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 b143d6bcd..4d754208c 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 @@ -27,20 +27,22 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; import org.bitrepository.pillar.messagefactories.GetFileMessageFactory; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; - - - +import static org.junit.jupiter.api.Assertions.assertEquals; public class IdentifyPillarsForGetFileIT extends PillarFunctionTest { protected GetFileMessageFactory msgFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { msgFactory = new GetFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void goodCaseIdentificationIT() { addDescription("Tests the general IdentifyPillarsForGetFile functionality of the pillar for the successful scenario."); addStep("Create and send the identify request message.", @@ -62,14 +64,15 @@ public void goodCaseIdentificationIT() { "Received unexpected 'FileID' in response."); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID(), "Received unexpected 'PillarID' in response."); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE, + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' in response."); assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo(), "Received unexpected 'ReplyTo' in response."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void nonExistingFileIdentificationIT() { addDescription("Tests the IdentifyPillarsForGetFile functionality of the pillar for a IdentificationForGetFile " + "for a non existing file."); @@ -83,7 +86,7 @@ public void nonExistingFileIdentificationIT() { "The pillar should make a response."); IdentifyPillarsForGetFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); } } 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 4a086605f..6ee1d9433 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 @@ -26,20 +26,23 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; - - +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.xml.datatype.XMLGregorianCalendar; import java.util.GregorianCalendar; import java.util.List; -import static org.bitrepository.pillar.integration.func.Assertions.assertEmpty; -import static org.bitrepository.pillar.integration.func.Assertions.assertEquals; -import static org.bitrepository.pillar.integration.func.Assertions.assertTrue; +import static org.bitrepository.pillar.integration.func.Assert.assertEmpty; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GetFileIDsQueryTest extends PillarFunctionTest { - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void fileidsSortingTest() { addDescription("Test whether the file id result is sorted oldest to newest."); addFixture("Ensure at least two files are present on the pillar"); @@ -60,7 +63,9 @@ public void fileidsSortingTest() { } } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @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."); addFixture("Ensure at least two files are present on the pillar"); @@ -76,12 +81,14 @@ public void maxNumberOfResultTest() { "a single file id should be returned. The file id should be the oldest/first file id in the full list."); ContributorQuery singleFileIDQuery = new ContributorQuery(getPillarID(), null, null, 1); List singleFileIDList = pillarFileManager.getFileIDs(singleFileIDQuery); - assertEquals(singleFileIDList.size(), 1, "The result didn't contain a single file id"); + assertEquals(1, singleFileIDList.size(), "The result didn't contain a single file id"); assertEquals(singleFileIDList.get(0), originalFileIDsList.get(0), "The returned file id wasn't equal to the oldest file id"); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void minTimeStampTest() { addDescription("Test the pillar support for only retrieving file ids newer that a given time. " + "Note that this test assumes there is at least 2 file ids with different timestamps."); @@ -127,7 +134,9 @@ public void minTimeStampTest() { CalendarUtils.getXmlGregorianCalendar(newerThanNewestTimestamp) + ") query"); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST} ) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void maxTimeStampTest() { addDescription("Test the pillar support for only retrieving file ids older that a given time. " + "Note that this test assumes there is at least 2 file ids with different timestamps."); 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 a94b2f1b0..98b8e0cb3 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 @@ -33,24 +33,24 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.GetFileIDsMessageFactory; - - - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; - - - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GetFileIDsTest extends DefaultPillarOperationTest { protected GetFileIDsMessageFactory msgFactory; private String pillarDestination; - @BeforeMethod(alwaysRun=true) - public void initialiseReferenceTest(Method method) throws Exception { + @BeforeEach + public void initialiseReferenceTest() throws Exception { msgFactory = new GetFileIDsMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); pillarDestination = lookupPillarDestination(); msgFactory = new GetFileIDsMessageFactory(collectionID, settingsForTestClient, getPillarID(), @@ -59,7 +59,9 @@ public void initialiseReferenceTest(Method method) throws Exception { clearReceivers(); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void pillarGetFileIDsTestSuccessCase() throws Exception { addDescription("Tests the GetFileIDs functionality of the pillar for the successful scenario."); @@ -80,14 +82,14 @@ public void pillarGetFileIDsTestSuccessCase() throws Exception { assertEquals(progressResponse.getFrom(), getPillarID()); assertEquals(progressResponse.getPillarID(), getPillarID()); assertEquals(progressResponse.getReplyTo(), pillarDestination); - assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS); + 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."); GetFileIDsFinalResponse finalResponse = (GetFileIDsFinalResponse) receiveResponse(); assertNotNull(finalResponse); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getCorrelationID(), getFileIDsRequest.getCorrelationID()); assertEquals(finalResponse.getFileIDs(), FileIDsUtils.getAllFileIDs()); assertEquals(finalResponse.getFrom(), getPillarID()); @@ -98,7 +100,9 @@ public void pillarGetFileIDsTestSuccessCase() throws Exception { "Should be at least 2 files, but found: " + finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void pillarGetFileIDsTestFailedNoSuchFileInOperation() throws Exception { addDescription("Tests that the pillar is able to handle requests for a non-existing file correctly during " + "the operation phase."); @@ -109,10 +113,12 @@ public void pillarGetFileIDsTestFailedNoSuchFileInOperation() throws Exception { GetFileIDsRequest getFileIDsRequest = msgFactory.createGetFileIDsRequest(fileids, null); messageBus.sendMessage(getFileIDsRequest); GetFileIDsFinalResponse finalResponse = (GetFileIDsFinalResponse) receiveResponse(); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void pillarGetFileIDsSpecificFileIDRequest() throws Exception { addDescription("Tests that the pillar is able to handle requests for a non-existing file correctly during " + "the operation phase."); @@ -127,12 +133,14 @@ 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(); - assertEquals(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + assertEquals(1, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); assertEquals(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), DEFAULT_FILE_ID); assertFalse(finalResponse.isSetPartialResult() && finalResponse.isPartialResult()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void pillarGetFileIDsTestBadDeliveryURL() throws Exception { addDescription("Test the case when the delivery URL is unaccessible."); String badURL = "http://localhost:61616/¾"; @@ -143,14 +151,14 @@ public void pillarGetFileIDsTestBadDeliveryURL() throws Exception { addStep("Retrieve the FinalResponse for the GetFileIDs request.", "A FILE_TRANSFER_FAILURE final response is expected."); GetFileIDsFinalResponse finalResponse = (GetFileIDsFinalResponse) receiveResponse(); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_TRANSFER_FAILURE); + assertEquals(ResponseCode.FILE_TRANSFER_FAILURE, + finalResponse.getResponseInfo().getResponseCode()); } - @Test @Tag( - PillarTestGroups.FULL_PILLAR_TEST, - PillarTestGroups.CHECKSUM_PILLAR_TEST, - PillarTestGroups.RESULT_UPLOAD}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) + @Tag(PillarTestGroups.RESULT_UPLOAD) public void pillarGetFileIDsTestDeliveryThroughUpload() throws Exception { addDescription("Test the case when the results should be delivered through the message ."); GetFileIDsRequest getFileIDsRequest = msgFactory.createGetFileIDsRequest( @@ -160,8 +168,8 @@ public void pillarGetFileIDsTestDeliveryThroughUpload() throws Exception { addStep("Retrieve the FinalResponse for the GetFileIDs request.", "A OPERATION_COMPLETE final response is expected containing the result provided address."); GetFileIDsFinalResponse finalResponse = (GetFileIDsFinalResponse) receiveResponse(); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, + finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getResultingFileIDs().getResultAddress(), DEFAULT_UPLOAD_FILE_ADDRESS); } 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 5d6a8361c..b6a4b4c90 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 @@ -31,22 +31,25 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.GetFileIDsMessageFactory; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; public class IdentifyPillarsForGetFileIDsIT extends DefaultPillarIdentificationTest { protected GetFileIDsMessageFactory msgFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { msgFactory = new GetFileIDsMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); clearReceivers(); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for getFileIDs identification"); addStep("Setup for test", "2 files on the pillar"); @@ -77,12 +80,13 @@ public void normalIdentificationTest() { assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID(), "Received unexpected 'PillarID' in response."); assertNotNull(receivedIdentifyResponse.getReplyTo()); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE, + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'Response' in response."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void nonExistingFileTest() { addDescription("Tests that the pillar is able to reject a GetFileIDs requests for a file, which it " + "does not have during the identification phase."); @@ -102,12 +106,13 @@ public void nonExistingFileTest() { IdentifyPillarsForGetFileIDsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileIDsResponse.class); assertNotNull(receivedIdentifyResponse.getFileIDs().getFileID()); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE, + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' in response."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void allFilesTest() { addDescription("Tests that the pillar accepts a GetFileIDs requests for all files, even though it does not have any files."); FileIDs fileids = FileIDsUtils.getAllFileIDs(); @@ -122,8 +127,8 @@ public void allFilesTest() { "The pillar should make a response."); IdentifyPillarsForGetFileIDsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileIDsResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE, + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' in response."); } 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 3528c3b1c..de631850d 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 @@ -32,24 +32,25 @@ import org.bitrepository.pillar.integration.func.PillarFunctionTest; import org.bitrepository.pillar.messagefactories.GetStatusMessageFactory; import org.bitrepository.settings.referencesettings.AlarmLevel; - - - - +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.lang.reflect.Method; public class GetStatusRequestIT extends PillarFunctionTest { protected GetStatusMessageFactory msgFactory; private String pillarDestination; - @BeforeMethod(alwaysRun=true) - public void initialiseReferenceTest(Method method) throws Exception { + @BeforeEach + public void initialiseReferenceTest() throws Exception { msgFactory = new GetStatusMessageFactory(null, settingsForTestClient, getPillarID(), null); pillarDestination = lookupPillarDestination(); msgFactory = new GetStatusMessageFactory(null, settingsForTestClient, getPillarID(), pillarDestination); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalGetStatusTest() { addDescription("Tests the GetStatus functionality of a pillar for the successful scenario."); @@ -61,12 +62,13 @@ public void normalGetStatusTest() { addStep("Receive and validate the final response", "Should be sent by the pillar."); GetStatusFinalResponse finalResponse = clientReceiver.waitForMessage(GetStatusFinalResponse.class); Assertions.assertNotNull(finalResponse); - Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(finalResponse.getCorrelationID(), request.getCorrelationID()); Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); } - @Test @Tag("failing"}) + @Test + @Tag("failing") public void checksumPillarGetStatusWrongContributor() { addDescription("Tests the GetStatus functionality of the reference pillar for the bad scenario, where a wrong " + "contributor id is given."); 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 10a2961d4..09683997a 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 @@ -28,22 +28,25 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.PillarFunctionTest; import org.bitrepository.pillar.messagefactories.GetStatusMessageFactory; - - - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.lang.reflect.Method; +import static org.junit.jupiter.api.Assertions.assertEquals; public class IdentifyContributorsForGetStatusIT extends PillarFunctionTest { protected GetStatusMessageFactory msgFactory; - @BeforeMethod(alwaysRun=true) - public void initialiseReferenceTest(Method method) throws Exception { + @BeforeEach + public void initialiseReferenceTest() throws Exception { msgFactory = new GetStatusMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalGetStatusTest() { addDescription("Tests the GetStatus functionality of a pillar for the successful scenario."); @@ -61,8 +64,8 @@ public void normalGetStatusTest() { "Received unexpected 'CorrelationID' in response."); assertEquals(receivedIdentifyResponse.getFrom(), getPillarID(), "Received unexpected 'PillarID' in response."); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE, + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' in response."); assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo(), "Received unexpected 'To' in response."); 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 4a3d87d70..8c61d9ac7 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 @@ -28,6 +28,9 @@ import org.bitrepository.pillar.integration.PillarIntegrationTest; import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.protocol.bus.MessageReceiver; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.Arrays; @@ -37,7 +40,9 @@ public class MultipleCollectionIT extends PillarIntegrationTest { /** Used for receiving responses from the pillar */ protected MessageReceiver clientReceiver; - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void fileInOtherCollectionTest() throws Exception { addDescription("Tests that a file is put correctly to a second collection, and that the file can be access " + "with getFile, getChecksums, getFileIDs and can be replaced and deleted correctly."); 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 680080a43..72ede21d1 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 @@ -30,21 +30,22 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; - - - -import static org.bitrepository.pillar.integration.func.Assertions.assertEquals; -import static org.bitrepository.pillar.integration.func.Assertions.assertNull; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; public class IdentifyPillarsForPutFileIT extends DefaultPillarIdentificationTest { protected PutFileMessageFactory msgFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { msgFactory = new PutFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for putFile identification"); addStep("Sending a putFile identification request.", @@ -79,14 +80,15 @@ public void normalIdentificationTest() { "Received unexpected PillarChecksumSpec"); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID(), "Unexpected 'From' element in the received response:\n" + receivedIdentifyResponse + "\n"); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE, + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode(), "Received unexpected ResponseCode"); assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo(), "Received unexpected ReplyTo"); } - @Test @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void identificationTestForChecksumPillar() { addDescription("Verifies the normal behaviour for putFile identification for a checksum pillar"); addStep("Sending a putFile identification.", @@ -110,7 +112,8 @@ public void identificationTestForChecksumPillar() { assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void fileExistsTest() { addDescription("Verifies the exists of a file with the same ID is handled correctly. " + "This means that a checksum for the existing file is returned, enabling the client to continue with " + @@ -125,8 +128,8 @@ public void fileExistsTest() { IdentifyPillarsForPutFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForPutFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.DUPLICATE_FILE_FAILURE); + assertEquals(ResponseCode.DUPLICATE_FILE_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); } @Override 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 1d8340dfd..38adcfeb3 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 @@ -34,27 +34,31 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.lang.reflect.Method; import java.util.concurrent.TimeUnit; - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; public class PutFileRequestIT extends DefaultPillarOperationTest { protected PutFileMessageFactory msgFactory; private String pillarDestination; - @BeforeMethod(alwaysRun=true) - public void initialiseReferenceTest(Method method) throws Exception { + @BeforeEach + public void initialiseReferenceTest() throws Exception { pillarDestination = lookupPutFileDestination(); msgFactory = new PutFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), pillarDestination); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalPutFileTest() { addDescription("Tests a normal PutFile sequence"); addStep("Send a putFile request to " + testConfiguration.getPillarUnderTestID(), @@ -98,11 +102,12 @@ public void normalPutFileTest() { "Received unexpected 'FileAddress' element."); assertEquals(finalResponse.getPillarID(), getPillarID(), "Received unexpected 'PillarID' element."); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED, + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' element."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void putFileWithMD5ReturnChecksumTest() { addDescription("Tests that the pillar is able to return the default type checksum in the final response"); addStep("Send a putFile request to " + testConfiguration.getPillarUnderTestID() + " with the ", @@ -120,8 +125,10 @@ public void putFileWithMD5ReturnChecksumTest() { "Return MD5 checksum was not equals to checksum for default file."); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST, - PillarTestGroups.OPERATION_ACCEPTED_PROGRESS}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) + @Tag(PillarTestGroups.OPERATION_ACCEPTED_PROGRESS) public void putFileOperationAcceptedProgressTest() { addDescription("Tests a that a pillar sends progress response after receiving a putFile request."); @@ -159,8 +166,8 @@ public void putFileOperationAcceptedProgressTest() { "Received unexpected 'FileID' element."); assertEquals(progressResponse.getFileAddress(), putRequest.getFileAddress(), "Received unexpected 'FileAddress' element."); - assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS, + assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode(), "Received unexpected 'ResponseCode' element."); } 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 6249578bf..7ab67118d 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 @@ -31,19 +31,23 @@ import org.bitrepository.pillar.integration.func.Assert; import org.bitrepository.pillar.integration.func.DefaultPillarIdentificationTest; import org.bitrepository.pillar.messagefactories.ReplaceFileMessageFactory; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class IdentifyPillarsForReplaceFileIT extends DefaultPillarIdentificationTest { protected ReplaceFileMessageFactory msgFactory; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { msgFactory = new ReplaceFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), null); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for replaceFile identification"); addStep("Sending a replaceFile identification.", @@ -60,12 +64,13 @@ public void normalIdentificationTest() { Assertions.assertEquals(receivedIdentifyResponse.getFileID(), DEFAULT_FILE_ID); Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); Assertions.assertNull(receivedIdentifyResponse.getPillarChecksumSpec()); - Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void identificationTestForChecksumPillar() { addDescription("Verifies the normal behaviour for replaceFile identification for a checksum pillar"); addStep("Sending a replaceFile identification.", @@ -83,12 +88,13 @@ public void identificationTestForChecksumPillar() { Assertions.assertEquals(receivedIdentifyResponse.getPillarChecksumSpec().getChecksumType(), ChecksumUtils.getDefault(settingsForCUT).getChecksumType()); Assertions.assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); - Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + Assertions.assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag( PillarTestGroups.CHECKSUM_PILLAR_TEST) public void fileDoesNotExistsTest() { addDescription("Verifies that a request for a non-existing file is handled correctly"); addStep("Sending a replaceFile identification for a file not in the pillar.", @@ -99,8 +105,8 @@ public void fileDoesNotExistsTest() { IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - Assertions.assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + Assertions.assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); } @Override 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 24e4aa1cd..e46372262 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 @@ -33,8 +33,10 @@ import org.bitrepository.pillar.PillarTestGroups; import org.bitrepository.pillar.integration.func.DefaultPillarOperationTest; import org.bitrepository.pillar.messagefactories.ReplaceFileMessageFactory; - - +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.lang.reflect.Method; @@ -44,8 +46,8 @@ public class ReplaceFileRequestIT extends DefaultPillarOperationTest { protected ReplaceFileMessageFactory msgFactory; private String pillarDestination; - @BeforeMethod(alwaysRun=true) - public void initialiseReferenceTest(Method method) throws Exception { + @BeforeEach + public void initialiseReferenceTest() throws Exception { pillarDestination = lookupReplaceFileDestination(); msgFactory = new ReplaceFileMessageFactory(collectionID, settingsForTestClient, getPillarID(), pillarDestination); clientProvider.getPutClient().putFile( @@ -56,7 +58,9 @@ public void initialiseReferenceTest(Method method) throws Exception { null, null, null); } - @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST, PillarTestGroups.CHECKSUM_PILLAR_TEST}) + @Test + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalReplaceFileTest() { addDescription("Tests a normal ReplaceFile sequence"); addStep("Send a ReplaceFile request to " + testConfiguration.getPillarUnderTestID(), @@ -73,12 +77,12 @@ public void normalReplaceFileTest() { Assertions.assertEquals(progressResponse.getCorrelationID(), replaceRequest.getCorrelationID()); Assertions.assertEquals(progressResponse.getFrom(), getPillarID()); Assertions.assertEquals(progressResponse.getPillarID(), getPillarID()); - Assertions.assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS); + Assertions.assertEquals(ResponseCode.OPERATION_ACCEPTED_PROGRESS, + progressResponse.getResponseInfo().getResponseCode()); ReplaceFileFinalResponse finalResponse = (ReplaceFileFinalResponse) receiveResponse(); Assertions.assertNotNull(finalResponse); - Assertions.assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + Assertions.assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); Assertions.assertEquals(finalResponse.getCorrelationID(), replaceRequest.getCorrelationID()); Assertions.assertEquals(finalResponse.getFrom(), getPillarID()); Assertions.assertNull(finalResponse.getChecksumDataForExistingFile()); 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 d8fe4415c..ce998978d 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 @@ -25,25 +25,54 @@ import org.bitrepository.access.getaudittrails.AuditTrailClient; import org.bitrepository.access.getaudittrails.BlockingAuditTrailClient; import org.bitrepository.client.eventhandler.EventHandler; +import org.bitrepository.common.utils.TestFileHelper; +import org.bitrepository.modify.ModifyComponentFactory; +import org.bitrepository.modify.putfile.BlockingPutFileClient; +import org.bitrepository.modify.putfile.PutFileClient; import org.bitrepository.pillar.integration.perf.metrics.Metrics; import org.bitrepository.protocol.security.DummySecurityManager; - - +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class GetAuditTrailsFileStressIT extends PillarPerformanceTest { protected AuditTrailClient auditTrailClient; + PutFileClient putClient; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { + putClient = ModifyComponentFactory.getInstance().retrievePutClient( + settingsForTestClient, createSecurityManager(), settingsForTestClient.getComponentID() ); auditTrailClient = AccessComponentFactory.getInstance().createAuditTrailClient( - settingsForCUT, new DummySecurityManager(), settingsForCUT.getComponentID() - ); + settingsForCUT, new DummySecurityManager(), settingsForCUT.getComponentID()); + } + + private void singleTreadedPut() throws Exception { + final int NUMBER_OF_FILES = 10; + final int PART_STATISTIC_INTERVAL = 2; + addDescription("Attempt to put " + NUMBER_OF_FILES + " files into the pillar, one at a time."); + BlockingPutFileClient blockingPutFileClient = new BlockingPutFileClient(putClient); + String[] fileIDs = TestFileHelper.createFileIDs(NUMBER_OF_FILES, "singleTreadedPutTest"); + Metrics metrics = new Metrics("put", NUMBER_OF_FILES, PART_STATISTIC_INTERVAL); + metrics.addAppenders(metricAppenders); + metrics.start(); + addStep("Add " + NUMBER_OF_FILES + " files", "Not errors should occur"); + for (String fileID:fileIDs) { + blockingPutFileClient.putFile(collectionID, httpServerConfiguration.getURL(TestFileHelper.DEFAULT_FILE_ID), fileID, 10L, + TestFileHelper.getDefaultFileChecksum(), null, null, "singleTreadedPut stress test file"); + metrics.mark(fileID); + } + + addStep("Check that the files are now present on the pillar(s)", "No missing files should be found."); + //ToDo assert that the files are present } - @Test @Tag("pillar-stress-test"}, dependsOnGroups={"stress-test-pillar-population"}) + @Test + @Tag("pillar-stress-test") public void singleTreadedGetAuditTrails() throws Exception { final int NUMBER_OF_AUDITS = 100; final int PART_STATISTIC_INTERVAL = NUMBER_OF_AUDITS/5; + singleTreadedPut(); addDescription("Attempt to request " + NUMBER_OF_AUDITS + " full audit trails one at a time."); BlockingAuditTrailClient blockingAuditTrailFileClient = new BlockingAuditTrailClient(auditTrailClient); @@ -58,7 +87,8 @@ public void singleTreadedGetAuditTrails() throws Exception { } } - @Test @Tag("pillar-stress-test"}) + @Test + @Tag("pillar-stress-test") public void parallelGetAuditTrails() throws Exception { final int NUMBER_OF_AUDITS = 10; final int PART_STATISTIC_INTERVAL = NUMBER_OF_AUDITS/5; 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 18c96f77e..79def6179 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,20 +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.BeforeEach; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class GetFileStressIT extends PillarPerformanceTest { protected GetFileClient getFileClient; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { getFileClient = AccessComponentFactory.getInstance().createGetFileClient( settingsForTestClient, createSecurityManager(), settingsForTestClient.getComponentID() ); } - @Test @Tag("pillar-stress-test"}) + @Test + @Tag("pillar-stress-test") public void singleGetFilePerformanceTest() throws Exception { final int NUMBER_OF_FILES = 1000; final int PART_STATISTIC_INTERVAL = 100; @@ -64,7 +66,8 @@ public void singleGetFilePerformanceTest() throws Exception { } } - @Test @Tag("pillar-stress-test"}) + @Test + @Tag("pillar-stress-test") public void parallelGetFilePerformanceTest() throws Exception { final int numberOfFiles = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.numberOfFiles"); final int partStatisticsInterval = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.partStatisticsInterval"); @@ -89,7 +92,8 @@ public void parallelGetFilePerformanceTest() throws Exception { awaitAsynchronousCompletion(metrics, numberOfFiles); } - @Test @Tag("pillar-stress-test"}) + @Test + @Tag("pillar-stress-test") public void noIdentfyGetFilePerformanceTest() throws Exception { final int numberOfFiles = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.numberOfFiles"); final int partStatisticsInterval = testConfiguration.getInt("pillarintegrationtest.GetFileStressIT.parallelGet.partStatisticsInterval"); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java index 327afd03a..63e8cce84 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/integration/perf/PillarPerformanceTest.java @@ -47,13 +47,6 @@ public class PillarPerformanceTest extends PillarIntegrationTest { protected List metricAppenders = new LinkedList<>(); protected String[] existingFiles; - @BeforeSuite - @Override - public void initializeSuite(ITestContext testContext) { - super.initializeSuite(testContext); - defineMetricAppenders(); - } - private void defineMetricAppenders() { MetricAppender consoleAppender = new ConsoleMetricAppender(); consoleAppender.disableSingleMeasurement(true); 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 f7257e19e..b39972768 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 @@ -28,7 +28,9 @@ import org.bitrepository.modify.putfile.BlockingPutFileClient; 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.Tag; +import org.junit.jupiter.api.Test; import java.util.concurrent.BlockingQueue; @@ -37,14 +39,16 @@ public class PutFileStressIT extends PillarPerformanceTest { protected PutFileClient putClient; - @BeforeMethod(alwaysRun=true) + @BeforeEach public void initialiseReferenceTest() throws Exception { putClient = ModifyComponentFactory.getInstance().retrievePutClient( settingsForTestClient, createSecurityManager(), settingsForTestClient.getComponentID() ); } - @Test @Tag("pillar-stress-test", "stress-test-pillar-population"}) + @Test + @Tag("pillar-stress-test") + @Tag("stress-test-pillar-population") public void singleTreadedPut() throws Exception { final int NUMBER_OF_FILES = 10; final int PART_STATISTIC_INTERVAL = 2; @@ -65,7 +69,8 @@ public void singleTreadedPut() throws Exception { //ToDo assert that the files are present } - @Test @Tag("pillar-stress-test"}) + @Test + @Tag("pillar-stress-test") public void parallelPut() throws Exception { final int numberOfFiles = testConfiguration.getInt("pillarintegrationtest.PutFileStressIT.parallelPut.numberOfFiles"); final int partStatisticsInterval = testConfiguration.getInt("pillarintegrationtest.PutFileStressIT.parallelPut.partStatisticsInterval"); 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 b918490f4..98c24b785 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 @@ -35,10 +35,11 @@ import org.bitrepository.bitrepositorymessages.IdentifyPillarsForDeleteFileResponse; import org.bitrepository.pillar.MockedPillarTest; import org.bitrepository.pillar.messagefactories.DeleteFileMessageFactory; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; - - +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -58,7 +59,9 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseIdentification() throws Exception { 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!"); @@ -86,17 +89,19 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a DeleteFile operation on the checksum pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -124,17 +129,19 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForDeleteFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForDeleteFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationNoFile() throws Exception { addDescription("Tests the DeleteFile functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -162,16 +169,18 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationMissingVerification() throws Exception { addDescription("Tests the DeleteFile functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -199,7 +208,7 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE); + assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); @@ -207,9 +216,9 @@ public String answer(InvocationOnMock invocation) { AlarmMessage alarm = alarmReceiver.waitForMessage(AlarmMessage.class); assertEquals(alarm.getAlarm().getFileID(), FILE_ID); assertEquals(alarm.getAlarm().getAlarmRaiser(), getPillarID()); - assertEquals(alarm.getAlarm().getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + assertEquals(AlarmCode.CHECKSUM_ALARM, alarm.getAlarm().getAlarmCode()); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -252,11 +261,11 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 1, "Should create one audit trail for the DeleteFile operation"); + 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 64691e4d0..e1e317d8b 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 @@ -32,20 +32,24 @@ import org.bitrepository.pillar.store.StorageModel; import org.bitrepository.protocol.MessageContext; import org.bitrepository.service.exception.RequestHandlerException; +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 static org.junit.jupiter.api.Assertions.assertThrows; public class GeneralMessageHandlingTest extends MockedPillarTest { MockRequestHandler requestHandler; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setup() { this.requestHandler = new MockRequestHandler(context, model); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") @Tag("pillartest") public void testPillarMessageHandler() { addDescription("Test the handling of the PillarMessageHandler super-class."); addStep("Setup", "Should be OK."); @@ -60,56 +64,84 @@ public void testPillarMessageHandler() { } } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatDefaultFileId() throws Exception { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on the default file id"); requestHandler.validateFileIDFormat(DEFAULT_FILE_ID); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatFolderFileId() throws Exception { addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id with directory path"); requestHandler.validateFileIDFormat("path/" + DEFAULT_FILE_ID); } - @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatParentFolderFileId() throws Exception { - addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id containing path to a parent directory"); - requestHandler.validateFileIDFormat("../../OTHER_COLLECTION/folderDir/test.txt"); + 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"); + requestHandler.validateFileIDFormat("../../OTHER_COLLECTION/folderDir/test.txt"); + }); } - @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatRootPathFileId() throws Exception { - addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id containing path from the root folder"); - requestHandler.validateFileIDFormat("/usr/local/bin/execute.sh"); + assertThrows(RequestHandlerException.class, () -> { + addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id containing path from the root folder"); + requestHandler.validateFileIDFormat("/usr/local/bin/execute.sh"); + }); } - @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatSubFolderToParentFolderFileId() throws Exception { - 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"); - requestHandler.validateFileIDFormat("OTHER_COLLECTION/../../folderDir/test.txt"); + 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"); + requestHandler.validateFileIDFormat("OTHER_COLLECTION/../../folderDir/test.txt"); + }); } - @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatEnvHomePathFileId() throws Exception { - 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"); - requestHandler.validateFileIDFormat("$HOME/bin/execute.sh"); + 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"); + requestHandler.validateFileIDFormat("$HOME/bin/execute.sh"); + }); } - @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatTildeHomePathFileId() throws Exception { - 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"); - requestHandler.validateFileIDFormat("~/bin/execute.sh"); + 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"); + requestHandler.validateFileIDFormat("~/bin/execute.sh"); + }); } - @Test @Tag("regressiontest", "pillartest"}, expectedExceptions = RequestHandlerException.class) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarMessageHandlerValidateFileIDFormatTooLong() throws Exception { - addDescription("Test the validation of file id formats of the PillarMessageHandler super-class on a file id which has more characters than required"); - String fileId = ""; - for(int i = 0; i < 300; i++) { - fileId += Integer.toString(i); - } - requestHandler.validateFileIDFormat(fileId); + 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"); + String fileId = ""; + for (int i = 0; i < 300; i++) { + fileId += Integer.toString(i); + } + requestHandler.validateFileIDFormat(fileId); + }); } private class MockRequestHandler extends PillarMessageHandler { 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 3f5b01479..e4bcb2c2b 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 @@ -32,15 +32,15 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.pillar.MockedPillarTest; import org.bitrepository.pillar.messagefactories.GetAuditTrailsMessageFactory; - - +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import javax.xml.datatype.XMLGregorianCalendar; import java.math.BigInteger; import java.util.Date; - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; public class GetAuditTrailsTest extends MockedPillarTest { private GetAuditTrailsMessageFactory msgFactory; @@ -51,7 +51,9 @@ public void initializeCUT() { msgFactory = new GetAuditTrailsMessageFactory(collectionID, settingsForTestClient); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void checksumPillarGetAuditTrailsSuccessful() { addDescription("Tests the GetAuditTrails functionality of the pillar for the successful scenario, " + "where all audit trails are requested."); @@ -71,8 +73,8 @@ public void checksumPillarGetAuditTrailsSuccessful() { assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); assertEquals(receivedIdentifyResponse.getFrom(), settingsForCUT.getComponentID()); assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + 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."); @@ -87,8 +89,8 @@ public void checksumPillarGetAuditTrailsSuccessful() { assertEquals(progressResponse.getCorrelationID(), identifyRequest.getCorrelationID()); assertEquals(progressResponse.getFrom(), settingsForCUT.getComponentID()); assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); - assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS); + 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); @@ -96,11 +98,13 @@ public void checksumPillarGetAuditTrailsSuccessful() { assertEquals(receivedIdentifyResponse.getCorrelationID(), identifyRequest.getCorrelationID()); assertEquals(receivedIdentifyResponse.getFrom(), settingsForCUT.getComponentID()); assertEquals(receivedIdentifyResponse.getDestination(), identifyRequest.getReplyTo()); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - assertEquals(finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size(), 1); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); + assertEquals(1, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void checksumPillarGetAuditTrailsSpecificRequests() { addDescription("Tests the GetAuditTrails functionality of the pillar for the successful scenario, " + "where a specific audit trail are requested."); @@ -128,8 +132,8 @@ public void checksumPillarGetAuditTrailsSpecificRequests() { addStep("Retrieve and validate the response.", "Should be a positive response."); IdentifyContributorsForGetAuditTrailsResponse identifyResponse = clientReceiver.waitForMessage( IdentifyContributorsForGetAuditTrailsResponse.class); - assertEquals(identifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + 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."); @@ -140,19 +144,19 @@ public void checksumPillarGetAuditTrailsSpecificRequests() { addStep("Receive and validate the progress response.", "Should be sent by the pillar."); GetAuditTrailsProgressResponse progressResponse = clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); - assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS); + 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - assertEquals(finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size(), 1); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); + assertEquals(1, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); AuditTrailEvent event = finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().get(0); - assertEquals(event.getActorOnFile(), ACTOR); - assertEquals(event.getAuditTrailInformation(), AUDITTRAIL); + assertEquals(ACTOR, event.getActorOnFile()); + assertEquals(AUDITTRAIL, event.getAuditTrailInformation()); assertEquals(event.getFileID(), FILE_ID); - assertEquals(event.getInfo(), INFO); - assertEquals(event.getSequenceNumber(), BigInteger.ONE); + assertEquals(INFO, event.getInfo()); + assertEquals(BigInteger.ONE, event.getSequenceNumber()); addStep("Make another request, where both ingested audit trails is requested", "Should be handled by the pillar."); @@ -162,17 +166,19 @@ public void checksumPillarGetAuditTrailsSpecificRequests() { addStep("Receive and validate the progress response.", "Should be sent by the pillar."); progressResponse = clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); - assertEquals(progressResponse.getResponseInfo().getResponseCode(), - ResponseCode.OPERATION_ACCEPTED_PROGRESS); + 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - assertEquals(finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size(), 2); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); + assertEquals(2, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); assertFalse(finalResponse.isPartialResult()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void checksumPillarGetAuditTrailsMaximumNumberOfResults() { addDescription("Tests the GetAuditTrails functionality of the pillar for the successful scenario, " + "where a limited number of audit trails are requested."); @@ -219,13 +225,13 @@ public void checksumPillarGetAuditTrailsMaximumNumberOfResults() { GetAuditTrailsProgressResponse progressResponse = clientReceiver.waitForMessage(GetAuditTrailsProgressResponse.class); assertEquals(progressResponse.getCollectionID(), collectionID); - assertEquals(progressResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_ACCEPTED_PROGRESS); + 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); - assertEquals(finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size(), maxNumberOfResults); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); + assertEquals(maxNumberOfResults, finalResponse.getResultingAuditTrails().getAuditTrailEvents().getAuditTrailEvent().size()); 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 f03d3052e..1d541cdbc 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 @@ -39,20 +39,20 @@ import org.bitrepository.pillar.messagefactories.GetChecksumsMessageFactory; import org.bitrepository.pillar.store.checksumdatabase.ChecksumEntry; import org.bitrepository.pillar.store.checksumdatabase.ExtractedChecksumResultSet; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; - - import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; +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.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; - - /** * Tests the PutFile functionality on the ReferencePillar. */ @@ -67,7 +67,9 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseIdentification() throws Exception { addDescription("Tests the identification for a GetChecksums operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -96,17 +98,18 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetChecksumsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetChecksumsResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileIDs(), fileids); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") @Tag("pillartest") public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a GetChecksums operation on the pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -135,17 +138,19 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetChecksumsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetChecksumsResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileIDs(), fileids); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseOperationSingleFile() throws Exception { addDescription("Tests the GetChecksums operation on the pillar for the successful scenario when requesting one specific file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -186,14 +191,16 @@ public ExtractedChecksumResultSet answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetChecksums request", "The final response should say 'operation_complete', and give the requested data."); GetChecksumsFinalResponse finalResponse = clientReceiver.waitForMessage(GetChecksumsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); - assertEquals(finalResponse.getResultingChecksums().getChecksumDataItems().size(), 1); + assertEquals(1, finalResponse.getResultingChecksums().getChecksumDataItems().size()); assertEquals(finalResponse.getResultingChecksums().getChecksumDataItems().get(0).getFileID(), FILE_ID); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseOperationAllFiles() throws Exception { addDescription("Tests the GetChecksums operation on the pillar for the successful scenario, when requesting all files."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -229,13 +236,15 @@ public ExtractedChecksumResultSet answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetChecksums request", "The final response should say 'operation_complete', and give the requested data."); GetChecksumsFinalResponse finalResponse = clientReceiver.waitForMessage(GetChecksumsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); - assertEquals(finalResponse.getResultingChecksums().getChecksumDataItems().size(), 2); + assertEquals(2, finalResponse.getResultingChecksums().getChecksumDataItems().size()); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationNoFile() throws Exception { addDescription("Tests the GetChecksums functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -263,16 +272,18 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetChecksums request", "The final response should tell about the error, and not contain the file."); GetChecksumsFinalResponse finalResponse = clientReceiver.waitForMessage(GetChecksumsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertNull(finalResponse.getResultingChecksums()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testRestrictions() throws Exception { addDescription("Tests that the restrictions are correctly passed on to the cache."); @@ -312,9 +323,9 @@ public ExtractedChecksumResultSet answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetChecksums request", "The final response should say 'operation_complete', and give the requested data."); GetChecksumsFinalResponse finalResponse = clientReceiver.waitForMessage(GetChecksumsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); - assertEquals(finalResponse.getResultingChecksums().getChecksumDataItems().size(), 1); + assertEquals(1, finalResponse.getResultingChecksums().getChecksumDataItems().size()); assertEquals(finalResponse.getResultingChecksums().getChecksumDataItems().get(0).getFileID(), DEFAULT_FILE_ID); } } 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 cc678c486..6be11e1d9 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 @@ -37,13 +37,15 @@ import org.bitrepository.pillar.MockedPillarTest; import org.bitrepository.pillar.messagefactories.GetFileIDsMessageFactory; import org.bitrepository.pillar.store.checksumdatabase.ExtractedFileIDsResultSet; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; - - import javax.xml.datatype.XMLGregorianCalendar; import java.util.Date; +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.anyLong; import static org.mockito.ArgumentMatchers.anyString; @@ -67,7 +69,9 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseIdentification() throws Exception { 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!"); @@ -96,17 +100,19 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileIDsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileIDsResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileIDs(), fileids); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a GetFileIDs operation on the pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -135,13 +141,13 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileIDsResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileIDsResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileIDs(), fileids); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -186,10 +192,10 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetFileIDs request", "The final response should say 'operation_complete', and give the requested data."); GetFileIDsFinalResponse finalResponse = clientReceiver.waitForMessage(GetFileIDsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileIDs().getFileID(), FILE_ID); - assertEquals(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + assertEquals(1, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); assertEquals(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID); } @@ -237,14 +243,16 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetFileIDs request", "The final response should say 'operation_complete', and give the requested data."); GetFileIDsFinalResponse finalResponse = clientReceiver.waitForMessage(GetFileIDsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertNull(finalResponse.getFileIDs().getFileID()); - assertEquals(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size(), 2); + assertEquals(2, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationNoFile() throws Exception { addDescription("Tests the GetFileIDs functionality of the pillar for the failure scenario, where it does not have the file."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -272,13 +280,13 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetFileIDs request", "The final response should tell about the error, and not contain the file."); GetFileIDsFinalResponse finalResponse = clientReceiver.waitForMessage(GetFileIDsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileIDs().getFileID(), FILE_ID); assertNull(finalResponse.getResultingFileIDs()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -329,10 +337,10 @@ public ExtractedFileIDsResultSet answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetFileIDs request", "The final response should say 'operation_complete', and give the requested data."); GetFileIDsFinalResponse finalResponse = clientReceiver.waitForMessage(GetFileIDsFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertNull(finalResponse.getFileIDs().getFileID()); - assertEquals(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + assertEquals(1, finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().size()); assertEquals(finalResponse.getResultingFileIDs().getFileIDsData().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID); } } 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 1886be1d0..cde343b86 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 @@ -38,12 +38,13 @@ import org.bitrepository.service.exception.IdentifyContributorException; import org.bitrepository.service.exception.InvalidMessageException; import org.bitrepository.service.exception.RequestHandlerException; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; - - import java.io.ByteArrayInputStream; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doAnswer; @@ -62,7 +63,9 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseIdentification() throws Exception { addDescription("Tests the identification for a GetFile operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -85,17 +88,18 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a GetFile operation on the checksum pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -123,13 +127,13 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForGetFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForGetFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -162,12 +166,12 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the GetFile request", "The final response should tell about the error, and not contain the file."); GetFileFinalResponse finalResponse = clientReceiver.waitForMessage(GetFileFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") @@ -202,16 +206,16 @@ public String answer(InvocationOnMock invocation) { GetFileProgressResponse progressResponse = clientReceiver.waitForMessage(GetFileProgressResponse.class); assertEquals(progressResponse.getFileID(), FILE_ID); assertEquals(progressResponse.getPillarID(), getPillarID()); - assertEquals(progressResponse.getFileSize().longValue(), 0L); + assertEquals(0L, progressResponse.getFileSize().longValue()); addStep("Retrieve the FinalResponse for the GetFile request", "The final response should tell about the error, and not contain the file."); GetFileFinalResponse finalResponse = clientReceiver.waitForMessage(GetFileFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 1, "Should create one audit trail for the GetFile operation"); + assertEquals(1, audits.getCallsForAuditEvent(), "Should create one audit trail for the GetFile operation"); } } 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 cf029e64a..2578a43e8 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 @@ -38,10 +38,15 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.pillar.MockedPillarTest; import org.bitrepository.pillar.messagefactories.PutFileMessageFactory; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -66,7 +71,9 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseIdentification() throws Exception { addDescription("Tests the identification for a PutFile operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -96,17 +103,18 @@ public Object answer(InvocationOnMock invocation) throws Throwable { "The pillar should make a response."); IdentifyPillarsForPutFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForPutFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseIdentification() throws Exception { addDescription("Tests the identification for a PutFile operation on the pillar for the failure scenario, when the file already exists."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -134,17 +142,18 @@ public String answer(InvocationOnMock invocation) { "The pillar should make a response."); IdentifyPillarsForPutFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForPutFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.DUPLICATE_FILE_FAILURE); + assertEquals(ResponseCode.DUPLICATE_FILE_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationFileAlreadyExists() throws Exception { addDescription("Tests the PutFile operation on the pillar for the failure scenario, when the file already exists."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -173,16 +182,17 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.DUPLICATE_FILE_FAILURE); + assertEquals(ResponseCode.DUPLICATE_FILE_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCasePutOperationNoValidationChecksum() throws Exception { addDescription("Tests the PutFile operation on the pillar for the failure scenario, when no validation checksum is given but required."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -210,7 +220,7 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.NEW_FILE_CHECKSUM_FAILURE); + assertEquals(ResponseCode.NEW_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); @@ -256,19 +266,20 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); assertNull(finalResponse.getChecksumDataForNewFile()); assertNull(finalResponse.getChecksumDataForExistingFile()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 1, "Should make 1 put-file audit trail"); + assertEquals(1, audits.getCallsForAuditEvent(), "Should make 1 put-file audit trail"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void goodCaseOperationWithChecksumReturn() throws Exception { addDescription("Tests the PutFile operation on the pillar for the success scenario, when requesting the cheksum of the file returned."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -300,13 +311,13 @@ public void goodCaseOperationWithChecksumReturn() throws Exception { 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); assertNotNull(finalResponse.getChecksumDataForNewFile()); assertEquals(finalResponse.getChecksumDataForNewFile().getChecksumSpec(), csSpec); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 1, "Should make 1 put-file audit trail"); + assertEquals(1, audits.getCallsForAuditEvent(), "Should make 1 put-file audit trail"); } } 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 8abf11f31..911ce6bd4 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 @@ -39,10 +39,15 @@ import org.bitrepository.common.utils.CalendarUtils; import org.bitrepository.pillar.MockedPillarTest; import org.bitrepository.pillar.messagefactories.ReplaceFileMessageFactory; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; import org.mockito.stubbing.Answer; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; @@ -66,7 +71,9 @@ public void initializeCUT() { } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void goodCaseIdentification() { addDescription("Tests the identification for a ReplaceFile operation on the pillar for the successful scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -86,17 +93,18 @@ public void goodCaseIdentification() { "The pillar should make a response."); IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.IDENTIFICATION_POSITIVE); + assertEquals(ResponseCode.IDENTIFICATION_POSITIVE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseIdentification() { addDescription("Tests the identification for a ReplaceFile operation on the pillar for the failure scenario, when the file does not exist."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -116,17 +124,18 @@ public void badCaseIdentification() { "The pillar should make a response."); IdentifyPillarsForReplaceFileResponse receivedIdentifyResponse = clientReceiver.waitForMessage( IdentifyPillarsForReplaceFileResponse.class); - assertEquals(receivedIdentifyResponse.getResponseInfo().getResponseCode(), - ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, + receivedIdentifyResponse.getResponseInfo().getResponseCode()); assertEquals(receivedIdentifyResponse.getPillarID(), getPillarID()); assertEquals(receivedIdentifyResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationMissingFile() { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when the file is missing."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -149,16 +158,17 @@ public String answer(InvocationOnMock invocation) { addStep("Retrieve the FinalResponse for the ReplaceFile request", "The final response should give file not found failure."); ReplaceFileFinalResponse finalResponse = clientReceiver.waitForMessage(ReplaceFileFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.FILE_NOT_FOUND_FAILURE); + assertEquals(ResponseCode.FILE_NOT_FOUND_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 0, "Should not deliver audits"); + assertEquals(0, audits.getCallsForAuditEvent(), "Should not deliver audits"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationNoDestructiveChecksum() { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when no validation " + "checksum is given for the destructive action, but though is required."); @@ -179,7 +189,7 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE); + assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); @@ -187,11 +197,12 @@ public void badCaseOperationNoDestructiveChecksum() { AlarmMessage alarm = alarmReceiver.waitForMessage(AlarmMessage.class); assertEquals(alarm.getAlarm().getFileID(), FILE_ID); assertEquals(alarm.getAlarm().getAlarmRaiser(), getPillarID()); - assertEquals(alarm.getAlarm().getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + assertEquals(AlarmCode.CHECKSUM_ALARM, alarm.getAlarm().getAlarmCode()); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationNoValidationChecksum() { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when no validation " + "checksum is given for the new file, but though is required."); @@ -212,7 +223,7 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.NEW_FILE_CHECKSUM_FAILURE); + assertEquals(ResponseCode.NEW_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); @@ -220,11 +231,12 @@ public void badCaseOperationNoValidationChecksum() { AlarmMessage alarm = alarmReceiver.waitForMessage(AlarmMessage.class); assertEquals(alarm.getAlarm().getFileID(), FILE_ID); assertEquals(alarm.getAlarm().getAlarmRaiser(), getPillarID()); - assertEquals(alarm.getAlarm().getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + assertEquals(AlarmCode.CHECKSUM_ALARM, alarm.getAlarm().getAlarmCode()); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void badCaseOperationWrongDestructiveChecksum() throws Exception { addDescription("Tests the ReplaceFile operation on the pillar for the failure scenario, when the checksum for " +"the destructive action is different from the one in the cache."); @@ -245,7 +257,7 @@ 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); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE); + assertEquals(ResponseCode.EXISTING_FILE_CHECKSUM_FAILURE, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); @@ -253,11 +265,12 @@ public void badCaseOperationWrongDestructiveChecksum() throws Exception { AlarmMessage alarm = alarmReceiver.waitForMessage(AlarmMessage.class); assertEquals(alarm.getAlarm().getFileID(), FILE_ID); assertEquals(alarm.getAlarm().getAlarmRaiser(), getPillarID()); - assertEquals(alarm.getAlarm().getAlarmCode(), AlarmCode.CHECKSUM_ALARM); + assertEquals(AlarmCode.CHECKSUM_ALARM, alarm.getAlarm().getAlarmCode()); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void goodCaseOperation() throws Exception { addDescription("Tests the ReplaceFile operation on the pillar for the success scenario."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -290,11 +303,12 @@ public void goodCaseOperation() throws Exception { assertNull(finalResponse.getChecksumDataForExistingFile()); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 1, "Should make 1 put-file audit trail"); + assertEquals(1, audits.getCallsForAuditEvent(), "Should make 1 put-file audit trail"); } @SuppressWarnings("rawtypes") - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void goodCaseOperationWithChecksumsReturn() throws Exception { addDescription("Tests the ReplaceFile operation on the pillar for the success scenario, when requesting both the cheksums of the file returned."); addStep("Set up constants and variables.", "Should not fail here!"); @@ -341,7 +355,7 @@ public void goodCaseOperationWithChecksumsReturn() throws Exception { addStep("Retrieve the FinalResponse for the ReplaceFile request", "The final response should say 'operation_complete', and give the requested data."); ReplaceFileFinalResponse finalResponse = clientReceiver.waitForMessage(ReplaceFileFinalResponse.class); - assertEquals(finalResponse.getResponseInfo().getResponseCode(), ResponseCode.OPERATION_COMPLETED); + assertEquals(ResponseCode.OPERATION_COMPLETED, finalResponse.getResponseInfo().getResponseCode()); assertEquals(finalResponse.getPillarID(), getPillarID()); assertEquals(finalResponse.getFileID(), FILE_ID); assertNotNull(finalResponse.getChecksumDataForNewFile()); @@ -350,6 +364,6 @@ public void goodCaseOperationWithChecksumsReturn() throws Exception { assertEquals(finalResponse.getChecksumDataForExistingFile().getChecksumSpec(), existingRequestChecksumSpec); alarmReceiver.checkNoMessageIsReceived(AlarmMessage.class); - assertEquals(audits.getCallsForAuditEvent(), 1, "Should make 1 put-file audit trail"); + 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 18fb44aed..e46352996 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 @@ -23,8 +23,10 @@ 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 javax.xml.datatype.DatatypeConfigurationException; @@ -35,17 +37,19 @@ public class RecalculateChecksumWorkflowTest extends DefaultPillarTest { DatatypeFactory factory; - @BeforeMethod(alwaysRun = true) + @BeforeEach public void setUpFactory() throws DatatypeConfigurationException { factory = DatatypeFactory.newInstance(); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testWorkflowRecalculatesChecksum() throws Exception { addDescription("Test that the workflow recalculates the workflows, when the maximum age has been met."); Date beforeWorkflowDate = csCache.getCalculationDate(DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(csCache.getAllFileIDs(collectionID).size(), 1); - Assertions.assertEquals(archives.getAllFileIds(collectionID).size(), 1); + Assertions.assertEquals(1, csCache.getAllFileIDs(collectionID).size()); + Assertions.assertEquals(1, archives.getAllFileIds(collectionID).size()); settingsForCUT.getReferenceSettings().getPillarSettings().setMaxAgeForChecksums(factory.newDuration(0)); synchronized(this) { @@ -61,13 +65,14 @@ public void testWorkflowRecalculatesChecksum() throws Exception { beforeWorkflowDate.getTime() + " < "+ afterWorkflowDate.getTime()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test @Tag("regressiontest") + @Tag("pillartest") public void testWorkflowDoesNotRecalculateWhenNotNeeded() throws Exception { addDescription("Test that the workflow does not recalculates the workflows, when the maximum age has " + "not yet been met."); Date beforeWorkflowDate = csCache.getCalculationDate(DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(csCache.getAllFileIDs(collectionID).size(), 1); - Assertions.assertEquals(archives.getAllFileIds(collectionID).size(), 1); + Assertions.assertEquals(1, csCache.getAllFileIDs(collectionID).size()); + Assertions.assertEquals(1, archives.getAllFileIds(collectionID).size()); settingsForCUT.getReferenceSettings().getPillarSettings() .setMaxAgeForChecksums(factory.newDuration(Long.MAX_VALUE)); 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 398ec9feb..1c4735e49 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 @@ -29,14 +29,15 @@ import org.bitrepository.pillar.store.checksumdatabase.ChecksumStore; import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.settings.referencesettings.ChecksumPillarFileDownload; - - +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.util.Date; - - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class ChecksumPillarModelTest extends DefaultFixturePillarTest { @@ -61,7 +62,9 @@ protected void initializeCUT() { nonDefaultCsType.setChecksumSalt(new byte[]{'a', 'z'}); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarModelBasicFunctionality() { addDescription("Test the basic functions of the full reference pillar model."); addStep("Check the pillar id in the pillar model", "Identical to the one from the test."); @@ -83,19 +86,21 @@ public void testPillarModelBasicFunctionality() { "It should say as it is in settings, or return default"); settingsForCUT.getReferenceSettings().getPillarSettings().setChecksumPillarFileDownload( ChecksumPillarFileDownload.ALWAYS_DOWNLOAD); - assertEquals(pillarModel.getChecksumPillarFileDownload(), - ChecksumPillarFileDownload.ALWAYS_DOWNLOAD); + assertEquals(ChecksumPillarFileDownload.ALWAYS_DOWNLOAD, + pillarModel.getChecksumPillarFileDownload()); settingsForCUT.getReferenceSettings().getPillarSettings().setChecksumPillarFileDownload( ChecksumPillarFileDownload.NEVER_DOWNLOAD); - assertEquals(pillarModel.getChecksumPillarFileDownload(), - ChecksumPillarFileDownload.NEVER_DOWNLOAD); + assertEquals(ChecksumPillarFileDownload.NEVER_DOWNLOAD, + pillarModel.getChecksumPillarFileDownload()); settingsForCUT.getReferenceSettings().getPillarSettings().setChecksumPillarFileDownload(null); - assertEquals(pillarModel.getChecksumPillarFileDownload(), - ChecksumPillarFileDownload.DOWNLOAD_WHEN_MISSING_FROM_MESSAGE); + assertEquals(ChecksumPillarFileDownload.DOWNLOAD_WHEN_MISSING_FROM_MESSAGE, + pillarModel.getChecksumPillarFileDownload()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarModelHasFile() throws Exception { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -186,7 +191,9 @@ public void testPillarModelHasFile() throws Exception { } } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarModelNoFile() { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); 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 3149d525b..bc32709e2 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 @@ -32,16 +32,16 @@ import org.bitrepository.pillar.store.filearchive.CollectionArchiveManager; import org.bitrepository.service.AlarmDispatcher; import org.bitrepository.service.exception.RequestHandlerException; - - +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.ByteArrayInputStream; import java.io.IOException; - - - - - +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; public class FullPillarModelTest extends DefaultFixturePillarTest { FileStorageModel pillarModel; @@ -68,7 +68,9 @@ protected void initializeCUT() { nonDefaultCsType.setChecksumSalt(new byte[]{'a', 'z'}); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarModelBasicFunctionality() throws Exception { addDescription("Test the basic functions of the full reference pillar model."); addStep("Check the pillar id in the pillar model", "Identical to the one from the test."); @@ -92,7 +94,9 @@ public void testPillarModelBasicFunctionality() throws Exception { assertNull(pillarModel.getChecksumPillarSpec()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarModelHasFile() throws Exception { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -101,7 +105,7 @@ public void testPillarModelHasFile() throws Exception { addStep("Check whether file exists and retrieve it.", "Should be the empty file."); assertTrue(pillarModel.hasFileID(DEFAULT_FILE_ID, collectionID)); FileInfo fileInfo = pillarModel.getFileInfoForActualFile(DEFAULT_FILE_ID, collectionID); - assertEquals(fileInfo.getSize(), 0L); + assertEquals(0L, fileInfo.getSize()); assertEquals(fileInfo.getFileID(), DEFAULT_FILE_ID); addStep("Verify that no exceptions are thrown when verifying file existance.", "Should exist."); @@ -114,7 +118,9 @@ public void testPillarModelHasFile() throws Exception { assertEquals(EMPTY_HMAC_SHA385_CHECKSUM, otherChecksum); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testPillarModelNoFile() throws Exception { addDescription("Test that the file exists, when placed in the archive and cache"); addStep("Setup", "Should place the 'existing file' in the directory."); diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java index da703ba86..e540645d5 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/store/PillarSettingsProviderTest.java @@ -25,14 +25,17 @@ import org.bitrepository.common.settings.SettingsProvider; import org.bitrepository.common.settings.XMLFileSettingsLoader; import org.bitrepository.pillar.PillarSettingsProvider; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; public class PillarSettingsProviderTest { private static final String PATH_TO_TEST_SETTINGS = "settings/xml/bitrepository-devel"; - @Test @Tag("regressiontest"}) + @Test + @Tag("regressiontest") public void componentIDTest() { SettingsProvider settingsLoader = new PillarSettingsProvider(new XMLFileSettingsLoader(PATH_TO_TEST_SETTINGS), 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 6936f3ab5..f37ea988a 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 @@ -25,10 +25,10 @@ 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; +import org.junit.jupiter.api.Test; import java.io.File; import java.io.FileOutputStream; import java.io.OutputStreamWriter; @@ -45,7 +45,7 @@ public class ArchiveDirectoryTest extends ExtendedTestCase { private static String FILE_ID = "file1"; private static String FOLDER_FILE_ID = "folder1/folder2/file1"; - @AfterMethod (alwaysRun=true) + @AfterEach public void shutdownTests() throws Exception { File dir = new File(DIR_NAME); if(dir.exists()) { @@ -53,7 +53,9 @@ public void shutdownTests() throws Exception { } } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryExistingFile() throws Exception { addDescription("Test the ArchiveDirectory when the file exists"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -72,7 +74,9 @@ public void testArchiveDirectoryExistingFile() throws Exception { Assertions.assertNull(directory.retrieveFile(FILE_ID)); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryMissingFile() throws Exception { addDescription("Test the ArchiveDirectory when the file is missing."); addStep("Setup", "No file added to the directory."); @@ -93,7 +97,9 @@ public void testArchiveDirectoryMissingFile() throws Exception { } } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryNewFile() throws Exception { addDescription("Testing the ArchiveDirectory handling of a new file."); addStep("Setup", "No file added to the directory."); @@ -130,7 +136,9 @@ public void testArchiveDirectoryNewFile() throws Exception { Assertions.assertFalse(directory.hasFileInTempDir(FILE_ID)); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") 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."); @@ -168,7 +176,9 @@ public void testArchiveDirectoryMoveFileToArchive() throws Exception { Assertions.assertFalse(directory.hasFileInTempDir(FILE_ID)); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryRemoveFile() throws Exception { addDescription("Testing the error scenarios when removing files from the archive."); addStep("Setup", "No file added to the directory."); @@ -197,15 +207,17 @@ public void testArchiveDirectoryRemoveFile() throws Exception { Assertions.assertTrue(tmpFile.createNewFile()); File retainFile = new File(retainDir, FILE_ID); Assertions.assertTrue(retainFile.createNewFile()); - Assertions.assertEquals(retainDir.list().length, 1); + Assertions.assertEquals(1, retainDir.list().length); addStep("Remove the file from archive and tmp", "all 3 files in retain dir."); directory.removeFileFromArchive(FILE_ID); directory.removeFileFromTmp(FILE_ID); - Assertions.assertEquals(retainDir.list().length, 3); + Assertions.assertEquals(3, retainDir.list().length); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryExistingFolderFile() throws Exception { addDescription("Test the ArchiveDirectory when the file exists"); addStep("Setup", "Should place the 'existing file' in the directory."); @@ -224,7 +236,9 @@ public void testArchiveDirectoryExistingFolderFile() throws Exception { Assertions.assertNull(directory.retrieveFile(FOLDER_FILE_ID)); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryMissingFolderFile() throws Exception { addDescription("Test the ArchiveDirectory when the file is missing."); addStep("Setup", "No file added to the directory."); @@ -234,7 +248,7 @@ public void testArchiveDirectoryMissingFolderFile() throws Exception { addStep("Validate the existence of the file", "Should neither exist nor be retrievable."); Assertions.assertFalse(directory.hasFile(FOLDER_FILE_ID)); Assertions.assertNull(directory.retrieveFile(FOLDER_FILE_ID)); - Assertions.assertEquals(directory.getFileIds(), Collections.EMPTY_LIST); + Assertions.assertEquals(Collections.EMPTY_LIST, directory.getFileIds()); addStep("Delete the file.", "exception since the file does not exist."); try { @@ -245,7 +259,9 @@ public void testArchiveDirectoryMissingFolderFile() throws Exception { } } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryNewFolderFile() throws Exception { addDescription("Testing the ArchiveDirectory handling of a new file."); addStep("Setup", "No file added to the directory."); @@ -282,7 +298,9 @@ public void testArchiveDirectoryNewFolderFile() throws Exception { Assertions.assertFalse(directory.hasFileInTempDir(FOLDER_FILE_ID)); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") 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."); @@ -322,7 +340,9 @@ public void testArchiveDirectoryMoveFolderFileToArchive() throws Exception { Assertions.assertFalse(directory.hasFileInTempDir(FOLDER_FILE_ID)); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testArchiveDirectoryRemoveFolderFile() throws Exception { addDescription("Testing the error scenarios when removing files from the archive."); addStep("Setup", "No file added to the directory."); @@ -354,13 +374,13 @@ public void testArchiveDirectoryRemoveFolderFile() throws Exception { Assertions.assertTrue(retainFile.getParentFile().mkdirs()); } Assertions.assertTrue(retainFile.createNewFile()); - Assertions.assertEquals(retainDir.list().length, 1); + Assertions.assertEquals(1, retainDir.list().length); addStep("Remove the file from archive and tmp", "all 3 files in retain dir."); directory.removeFileFromArchive(FOLDER_FILE_ID); directory.removeFileFromTmp(FOLDER_FILE_ID); List retainFiles = TestFileHelper.getAllFilesFromSubDirs(retainDir); - Assertions.assertEquals(retainFiles.size(), 3); + Assertions.assertEquals(3, retainFiles.size()); } private void createExistingFile() throws Exception { 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 28eba2c1c..988e45440 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 @@ -31,7 +31,9 @@ import org.bitrepository.pillar.messagehandler.PillarMediator; import org.bitrepository.pillar.store.filearchive.ReferenceArchive; import org.bitrepository.service.audit.MockAuditManager; - +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; import java.io.File; @@ -62,7 +64,9 @@ protected void shutdownCUT() { super.shutdownCUT(); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testReferenceArchive() throws Exception { addDescription("Test the ReferenceArchive."); addStep("Setup", "Should be OK."); 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 2974398c9..4dc96dcc4 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,11 +30,11 @@ 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 java.io.File; import java.util.Calendar; import java.util.Date; @@ -59,7 +59,7 @@ public class ChecksumDatabaseMigrationTest extends ExtendedTestCase { static DBConnector connector = null; - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { settings = TestSettingsProvider.reloadSettings("ReferencePillarTest"); @@ -71,7 +71,7 @@ public void setup() throws Exception { DerbyDatabaseDestroyer.deleteDatabase(checksumDB); } - @AfterMethod (alwaysRun = true) + @AfterEach public void cleanup() throws Exception { FileUtils.deleteDirIfExists(new File(PATH_TO_DATABASE_UNPACKED)); if(connector != null && !connector.getConnection().isClosed()) { @@ -94,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, CHECKSUM_TABLE); - Assertions.assertEquals(versionBefore, 1, "Table version before migration"); + Assertions.assertEquals(1, versionBefore, "Table version before migration"); addStep("Ingest a entry to the database without the collection id", "works only in version 1."); String insertSql = "INSERT INTO " + CHECKSUM_TABLE + " ( " + CS_FILE_ID + " , " + CS_CHECKSUM + " , " + CS_DATE @@ -105,7 +105,7 @@ public void testMigratingChecksumDatabaseFromV1ToV2() throws Exception { ChecksumDBMigrator migrator = new ChecksumDBMigrator(connector, settings); migrator.migrate(); int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); - Assertions.assertEquals(versionAfter, 4, "Table version after migration"); + Assertions.assertEquals(4, versionAfter, "Table version after migration"); addStep("Validate the entry", "The collection id has been set to the default collection id"); String retrieveCollectionIdSql = "SELECT " + CS_COLLECTION_ID + " FROM " + CHECKSUM_TABLE + " WHERE " @@ -114,7 +114,9 @@ public void testMigratingChecksumDatabaseFromV1ToV2() throws Exception { Assertions.assertEquals(collectionID, settings.getCollections().get(0).getID()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { addDescription("Tests that the checksums table can be migrated from version 3 to 4, e.g. changing the column " + "calculatedchecksumdate from timestamp to bigint."); @@ -132,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, CHECKSUM_TABLE); - Assertions.assertEquals(versionBefore, 3, "Table version before migration"); + 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."); String insertSql = "INSERT INTO " + CHECKSUM_TABLE + " ( " + CS_FILE_ID + " , " + CS_CHECKSUM + " , " + CS_DATE @@ -143,7 +145,7 @@ public void testMigratingChecksumDatabaseFromV3ToV4() throws Exception { ChecksumDBMigrator migrator = new ChecksumDBMigrator(connector, settings); migrator.migrate(); int versionAfter = DatabaseUtils.selectIntValue(connector, extractVersionSql, CHECKSUM_TABLE); - Assertions.assertEquals(versionAfter, 4, "Table version after migration"); + Assertions.assertEquals(4, versionAfter, "Table version after migration"); addStep("Validate the migration", "The timestamp is now the millis from epoch"); String retrieveCollectionIdSql = "SELECT " + CS_DATE + " FROM " + CHECKSUM_TABLE + " WHERE " 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 8158a7b2f..b3d55c9c7 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 @@ -36,10 +36,10 @@ 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; +import org.junit.jupiter.api.Test; import java.time.Instant; import java.util.Date; import java.util.List; @@ -52,7 +52,7 @@ public class ChecksumDatabaseTest extends ExtendedTestCase { private static final String DEFAULT_CHECKSUM = "abcdef0110fedcba"; private static final Date DEFAULT_DATE = new Date(); - @BeforeMethod (alwaysRun = true) + @BeforeEach public void setup() throws Exception { loadSettings(); collectionID = settings.getCollections().get(0).getID(); @@ -65,7 +65,9 @@ public void setup() throws Exception { checksumDatabaseCreator.createChecksumDatabase(settings, null); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testChecksumDatabaseExtraction() { addDescription("Test the extraction of data from the checksum database."); ChecksumDAO cache = getCacheWithData(); @@ -74,28 +76,30 @@ public void testChecksumDatabaseExtraction() { Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); addStep("Extract calculation date", "Should be identical to the default date."); - Assertions.assertEquals(cache.getCalculationDate(DEFAULT_FILE_ID, collectionID), DEFAULT_DATE); + Assertions.assertEquals(DEFAULT_DATE, cache.getCalculationDate(DEFAULT_FILE_ID, collectionID)); addStep("Extract the checksum", "Should be identical to the default checksum"); - Assertions.assertEquals(cache.getChecksum(DEFAULT_FILE_ID, collectionID), DEFAULT_CHECKSUM); + Assertions.assertEquals(DEFAULT_CHECKSUM, cache.getChecksum(DEFAULT_FILE_ID, collectionID)); addStep("Extract the whole entry", "Should have the default values."); ChecksumEntry entry = cache.getEntry(DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(entry.getFileId(), DEFAULT_FILE_ID); - Assertions.assertEquals(entry.getChecksum(), DEFAULT_CHECKSUM); - Assertions.assertEquals(entry.getCalculationDate(), DEFAULT_DATE); + Assertions.assertEquals(DEFAULT_FILE_ID, entry.getFileId()); + Assertions.assertEquals(DEFAULT_CHECKSUM, entry.getChecksum()); + Assertions.assertEquals(DEFAULT_DATE, entry.getCalculationDate()); addStep("Extract all entries", "Should only be the one default."); List entries = cache.getChecksumResults(null, null, null, collectionID).getEntries(); - Assertions.assertEquals(entries.size(), 1); - Assertions.assertEquals(entries.get(0).getFileID(), DEFAULT_FILE_ID); - Assertions.assertEquals(Base16Utils.decodeBase16(entries.get(0).getChecksumValue()), DEFAULT_CHECKSUM); - Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(entries.get(0).getCalculationTimestamp()), - DEFAULT_DATE); + Assertions.assertEquals(1, entries.size()); + Assertions.assertEquals(DEFAULT_FILE_ID, entries.get(0).getFileID()); + Assertions.assertEquals(DEFAULT_CHECKSUM, Base16Utils.decodeBase16(entries.get(0).getChecksumValue())); + Assertions.assertEquals(DEFAULT_DATE, + CalendarUtils.convertFromXMLGregorianCalendar(entries.get(0).getCalculationTimestamp())); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testDeletion() { addDescription("Test that data can be deleted from the database."); ChecksumDAO cache = getCacheWithData(); @@ -103,18 +107,20 @@ public void testDeletion() { addStep("Check whether the default entry exists.", "It does!"); Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); ExtractedFileIDsResultSet res = cache.getFileIDs(null, null, null, null, collectionID); - Assertions.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assertions.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), - DEFAULT_FILE_ID); + Assertions.assertEquals(1, res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); + Assertions.assertEquals(DEFAULT_FILE_ID, + res.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID()); addStep("Remove the default entry", "Should no longer exist"); cache.deleteEntry(DEFAULT_FILE_ID, collectionID); Assertions.assertFalse(cache.hasFile(DEFAULT_FILE_ID, collectionID)); res = cache.getFileIDs(null, null, null, null, collectionID); - Assertions.assertEquals(res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(0, res.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testReplacingExistingEntry() { addDescription("Test that an entry can be replaced by another in the database."); ChecksumDAO cache = getCacheWithData(); @@ -125,21 +131,23 @@ public void testReplacingExistingEntry() { addStep("Check whether the default entry exists.", "It does!"); Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); ChecksumEntry oldEntry = cache.getEntry(DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(oldEntry.getFileId(), DEFAULT_FILE_ID); - Assertions.assertEquals(oldEntry.getChecksum(), DEFAULT_CHECKSUM); - Assertions.assertEquals(oldEntry.getCalculationDate(), DEFAULT_DATE); + Assertions.assertEquals(DEFAULT_FILE_ID, oldEntry.getFileId()); + Assertions.assertEquals(DEFAULT_CHECKSUM, oldEntry.getChecksum()); + Assertions.assertEquals(DEFAULT_DATE, oldEntry.getCalculationDate()); addStep("Replace the checksum and date", "Should still exist, but have different values."); cache.insertChecksumCalculation(DEFAULT_FILE_ID, collectionID, newChecksum, newDate); Assertions.assertTrue(cache.hasFile(DEFAULT_FILE_ID, collectionID)); ChecksumEntry newEntry = cache.getEntry(DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(newEntry.getFileId(), DEFAULT_FILE_ID); - Assertions.assertEquals(newEntry.getChecksum(), newChecksum); + Assertions.assertEquals(DEFAULT_FILE_ID, newEntry.getFileId()); + Assertions.assertEquals(newChecksum, newEntry.getChecksum()); Assertions.assertFalse(oldEntry.getChecksum().equals(newEntry.getChecksum())); Assertions.assertFalse(oldEntry.getCalculationDate().getTime() == newEntry.getCalculationDate().getTime()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testExtractionOfMissingData() { addDescription("Test the handling of bad arguments."); ChecksumDAO cache = getCacheWithData(); @@ -170,7 +178,9 @@ public void testExtractionOfMissingData() { } } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testSpecifiedEntryExtraction() { addDescription("Test that specific entries can be extracted. Has two entries in the database: " + "one for the current timestamp and one for the epoch."); @@ -182,40 +192,42 @@ public void testSpecifiedEntryExtraction() { addStep("Extract with out restrictions", "Both entries."); ExtractedChecksumResultSet extractedResults = cache.getChecksumResults(null, null, null, collectionID); - Assertions.assertEquals(extractedResults.getEntries().size(), 2); + Assertions.assertEquals(2, extractedResults.getEntries().size()); addStep("Extract with a maximum of 1 entry", "The oldest entry"); extractedResults = cache.getChecksumResults(null, null, 1L, collectionID); - Assertions.assertEquals(extractedResults.getEntries().size(), 1); + Assertions.assertEquals(1, extractedResults.getEntries().size()); ChecksumDataForChecksumSpecTYPE dataEntry = extractedResults.getEntries().get(0); - Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime(), 0); - Assertions.assertEquals(dataEntry.getFileID(), oldFile); + Assertions.assertEquals(0, CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime()); + Assertions.assertEquals(oldFile, dataEntry.getFileID()); addStep("Extract all dates older than this tests instantiation", "The oldest entry"); extractedResults = cache.getChecksumResults(null, CalendarUtils.getXmlGregorianCalendar(beforeTest), null, collectionID); - Assertions.assertEquals(extractedResults.getEntries().size(), 1); + Assertions.assertEquals(1, extractedResults.getEntries().size()); dataEntry = extractedResults.getEntries().get(0); - Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime(), 0); - Assertions.assertEquals(dataEntry.getFileID(), oldFile); + Assertions.assertEquals(0, CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()).getTime()); + Assertions.assertEquals(oldFile, dataEntry.getFileID()); addStep("Extract all dates newer than this tests instantiation", "The default entry"); extractedResults = cache.getChecksumResults(CalendarUtils.getXmlGregorianCalendar(beforeTest), null, null, collectionID); - Assertions.assertEquals(extractedResults.getEntries().size(), 1); + Assertions.assertEquals(1, extractedResults.getEntries().size()); dataEntry = extractedResults.getEntries().get(0); - Assertions.assertEquals(CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp()), - DEFAULT_DATE); - Assertions.assertEquals(dataEntry.getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(DEFAULT_DATE, + CalendarUtils.convertFromXMLGregorianCalendar(dataEntry.getCalculationTimestamp())); + Assertions.assertEquals(DEFAULT_FILE_ID, dataEntry.getFileID()); addStep("Extract all dates older than the newest instance", "Both entries"); extractedResults = cache.getChecksumResults(null, CalendarUtils.getXmlGregorianCalendar(DEFAULT_DATE), null, collectionID); - Assertions.assertEquals(extractedResults.getEntries().size(), 2); + Assertions.assertEquals(2, extractedResults.getEntries().size()); addStep("Extract all dates newer than the oldest instantiation", "Both entries"); extractedResults = cache.getChecksumResults(CalendarUtils.getEpoch(), null, null, collectionID); - Assertions.assertEquals(extractedResults.getEntries().size(), 2); + Assertions.assertEquals(2, extractedResults.getEntries().size()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testGetFileIDsRestrictions() { addDescription("Tests the restrictions on the GetFileIDs call to the database."); addStep("Instantiate database with appropriate data.", ""); @@ -230,54 +242,56 @@ public void testGetFileIDsRestrictions() { addStep("Test with no time restrictions and 10000 max_results", "Delivers both files."); ExtractedFileIDsResultSet efirs = cache.getFileIDs(null, null, 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); + Assertions.assertEquals(2, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); addStep("Test with minimum-date earlier than first file", "Delivers both files."); efirs = cache.getFileIDs(CalendarUtils.getFromMillis(0), null, 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); + Assertions.assertEquals(2, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); addStep("Test with maximum-date earlier than first file", "Delivers no files."); efirs = cache.getFileIDs(null, CalendarUtils.getFromMillis(0), 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(0, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); addStep("Test with minimum-date set to later than second file.", "Delivers no files."); efirs = cache.getFileIDs(CalendarUtils.getXmlGregorianCalendar(new Date()), null, 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(0, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); addStep("Test with maximum-date set to later than second file.", "Delivers both files."); efirs = cache.getFileIDs(null, CalendarUtils.getXmlGregorianCalendar(new Date()), 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 2); + Assertions.assertEquals(2, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); addStep("Test with minimum-date set to middle date.", "Delivers second file."); efirs = cache.getFileIDs(CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), null, 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); + Assertions.assertEquals(1, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_2); addStep("Test with maximum-date set to middle date.", "Delivers first file."); efirs = cache.getFileIDs(null, CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_1); + Assertions.assertEquals(1, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); + Assertions.assertEquals(FILE_ID_1, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID()); addStep("Test with both minimum-date and maximum-date set to middle date.", "Delivers no files."); efirs = cache.getFileIDs(CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), 100000L, null, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(0, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); addStep("Test the first file-id, with no other restrictions", "Only delivers the requested file-id"); efirs = cache.getFileIDs(null, null, 100000L, FILE_ID_1, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_1); + Assertions.assertEquals(1, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); + Assertions.assertEquals(FILE_ID_1, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID()); addStep("Test the second file-id, with no other restrictions", "Only delivers the requested file-id"); efirs = cache.getFileIDs(null, null, 100000L, FILE_ID_2, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 1); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID(), FILE_ID_2); + Assertions.assertEquals(1, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); + Assertions.assertEquals(FILE_ID_2, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().get(0).getFileID()); addStep("Test the date for the first file-id, while requesting the second file-id", "Should not deliver anything"); efirs = cache.getFileIDs(CalendarUtils.getFromMillis(0), CalendarUtils.getXmlGregorianCalendar(MIDDLE_DATE), 100000L, FILE_ID_2, collectionID); - Assertions.assertEquals(efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size(), 0); + Assertions.assertEquals(0, efirs.getEntries().getFileIDsDataItems().getFileIDsDataItem().size()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testGetChecksumResult() { addDescription("Tests the restrictions on the GetChecksumResult call to the database."); addStep("Instantiate database with appropriate data.", ""); @@ -285,39 +299,41 @@ public void testGetChecksumResult() { addStep("Test with no time restrictions", "Retrieves the file"); ExtractedChecksumResultSet extractedChecksums = cache.getChecksumResult(null, null, DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); - Assertions.assertEquals(extractedChecksums.getEntries().get(0).getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(1, extractedChecksums.getEntries().size()); + Assertions.assertEquals(DEFAULT_FILE_ID, extractedChecksums.getEntries().get(0).getFileID()); addStep("Test with time restrictions from epoc to now", "Retrieves the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getEpoch(), CalendarUtils.getNow(), DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); + Assertions.assertEquals(1, extractedChecksums.getEntries().size()); addStep("Test with very strict time restrictions around the default date", "Retrieves the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() - 1), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() + 1), DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); + Assertions.assertEquals(1, extractedChecksums.getEntries().size()); addStep("Test with too new a lower limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() + 1), CalendarUtils.getNow(), DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(0, extractedChecksums.getEntries().size()); addStep("Test with exact date as both upper and lower limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(0, extractedChecksums.getEntries().size()); addStep("Test with date limit from 1 millis before as lower and exact date a upper limit", "Does retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()-1), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 1); + Assertions.assertEquals(1, extractedChecksums.getEntries().size()); addStep("Test with date limit from exact date as lower and 1 millis after date a upper limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime()+1), DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(0, extractedChecksums.getEntries().size()); addStep("Test with too old an upper limit", "Does not retrieve the file"); extractedChecksums = cache.getChecksumResult(CalendarUtils.getEpoch(), CalendarUtils.getFromMillis(DEFAULT_DATE.getTime() - 1), DEFAULT_FILE_ID, collectionID); - Assertions.assertEquals(extractedChecksums.getEntries().size(), 0); + Assertions.assertEquals(0, extractedChecksums.getEntries().size()); } - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testGetFileIDsWithOldChecksums() { addDescription("Tests the restrictions on the GetFileIDsWithOldChecksums call to the database."); addStep("Instantiate database with appropriate data.", ""); @@ -332,17 +348,17 @@ public void testGetFileIDsWithOldChecksums() { addStep("Extract all entries with checksum date older than now", "Returns both file ids"); List extractedFileIDs = cache.getFileIDsWithOldChecksums(Instant.now(), collectionID); - Assertions.assertEquals(extractedFileIDs.size(), 2); + Assertions.assertEquals(2, extractedFileIDs.size()); Assertions.assertTrue(extractedFileIDs.contains(FILE_ID_1)); Assertions.assertTrue(extractedFileIDs.contains(FILE_ID_2)); addStep("Extract all entries with checksum date older than epoch", "Returns no file ids"); extractedFileIDs = cache.getFileIDsWithOldChecksums(Instant.EPOCH, collectionID); - Assertions.assertEquals(extractedFileIDs.size(), 0); + Assertions.assertEquals(0, extractedFileIDs.size()); addStep("Extract all entries with checksum date older than middle date", "Returns the first file id"); extractedFileIDs = cache.getFileIDsWithOldChecksums(MIDDLE_DATE.toInstant(), collectionID); - Assertions.assertEquals(extractedFileIDs.size(), 1); + Assertions.assertEquals(1, extractedFileIDs.size()); Assertions.assertTrue(extractedFileIDs.contains(FILE_ID_1)); } 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 f958b64db..bbed75b5e 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 @@ -23,8 +23,9 @@ 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; @@ -33,13 +34,15 @@ public class ChecksumEntryTest extends ExtendedTestCase { private static final String CE_CHECKSUM = "checksum"; private static final Date CE_DATE = new Date(1234567890); - @Test @Tag("regressiontest", "pillartest"}) + @Test + @Tag("regressiontest") + @Tag("pillartest") public void testExtendedTestCase() throws Exception { addDescription("Test the ChecksumEntry"); addStep("Create a ChecksumEntry", "The data should be extractable again."); ChecksumEntry ce = new ChecksumEntry(CE_FILE, CE_CHECKSUM, CE_DATE); - Assertions.assertEquals(ce.getFileId(), CE_FILE); - Assertions.assertEquals(ce.getChecksum(), CE_CHECKSUM); - Assertions.assertEquals(ce.getCalculationDate(), CE_DATE); + Assertions.assertEquals(CE_FILE, ce.getFileId()); + Assertions.assertEquals(CE_CHECKSUM, ce.getChecksum()); + Assertions.assertEquals(CE_DATE, ce.getCalculationDate()); } } From f96a705b6617b148ca5e54c8506cb93c0b994a55 Mon Sep 17 00:00:00 2001 From: kaah Date: Thu, 1 Jan 2026 22:08:40 +0100 Subject: [PATCH 10/14] Removed the TestNG dependency --- pom.xml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 63616a3bf..d57801d8d 100644 --- a/pom.xml +++ b/pom.xml @@ -186,12 +186,6 @@ test
- - - - - - org.junit.platform junit-platform-suite-engine @@ -459,7 +453,7 @@ org.apache.maven.plugins maven-pmd-plugin - 3.28.0 + 3.26.0 From 7553d8261f1ef734c7e6400cdbe536a3d0cf0ed1 Mon Sep 17 00:00:00 2001 From: kaah Date: Mon, 5 Jan 2026 17:09:30 +0100 Subject: [PATCH 11/14] The suite classes looks for tags instead of classes --- .../BitrepositoryChecksumPillarTestSuite.java | 64 +++++++++++++++++++ .../pillar/BitrepositoryPillarTestSuite.java | 8 ++- .../getaudittrails/GetAuditTrailsTest.java | 2 +- .../IdentifyPillarsForGetChecksumsIT.java | 3 +- 4 files changed, 73 insertions(+), 4 deletions(-) create mode 100644 bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryChecksumPillarTestSuite.java diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryChecksumPillarTestSuite.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryChecksumPillarTestSuite.java new file mode 100644 index 000000000..a3757b351 --- /dev/null +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryChecksumPillarTestSuite.java @@ -0,0 +1,64 @@ +package org.bitrepository.pillar; + +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.platform.suite.api.ExcludeTags; +import org.junit.platform.suite.api.IncludeTags; +import org.junit.platform.suite.api.SelectClasses; +import org.junit.platform.suite.api.SelectPackages; +import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SuiteDisplayName; + +/** + * BitrepositoryPillarTestSuite is a JUnit 5 suite class that groups and configures multiple test classes + * for the BitRepositoryPillar project. This suite uses JUnit 5 annotations to select test classes, packages, + * and tags, and extend the suite with custom extensions. + * + *

JUnit 5 Annotations Used:

+ *
    + *
  • {@link Suite}: Indicates that this class is a JUnit 5 suite. It groups multiple test classes + * into a single test suite.
  • + *
  • {@link SelectClasses}: Specifies the test classes to be included in the suite. The value is an array + * of class references to the test classes.
  • + *
  • {@link SelectPackages}: Specifies the test packages to be included in the suite. The value is an array + * of package names.
  • + *
  • {@link IncludeTags}: Specifies the tags to include in the suite. The value is an array of tag names.
  • + *
  • {@link ExcludeTags}: Specifies the tags to exclude from the suite. The value is an array of tag names.
  • + *
  • {@link ExtendWith}: Specifies the extensions to be applied to the suite. The value is an array of + * extension classes.
  • + *
+ * + *

Options in a JUnit 5 Suite:

+ *
    + *
  • Selecting Test Classes: Use the {@link SelectClasses} annotation to specify the test + * classes to be included in the suite. The value is an array of class references to the test classes.
  • + *
  • Selecting Test Packages: Use the {@link SelectPackages} annotation to specify the test + * packages to be included in the suite. The value is an array of package names.
  • + *
  • Selecting Tests by Tag: Use the {@link IncludeTags} and {@link ExcludeTags} annotations + * to specify the tags to include or exclude in the suite. The value is an array of tag names.
  • + *
  • Extending the Suite: Use the {@link ExtendWith} annotation to specify custom extensions + * to be applied to the suite. The value is an array of extension classes.
  • + *
+ * + *

Example Usage:

+ *
+ * {@code
+ * @Suite
+ * @SelectClasses({BitrepositoryPillarTest.class})  // List your test classes here
+ * @SelectPackages("org.bitrepository.pillar")  // List your test packages here
+ * @IncludeTags("integration")  // List your include tags here
+ * @ExcludeTags("slow")  // List your exclude tags here
+ * @ExtendWith(GlobalSuiteExtension.class)
+ * public class BitrepositoryTestSuite {
+ *     // No need for methods here; this just groups and extends
+ * }
+ * }
+ * 
+ */ +@Suite +@SuiteDisplayName("Checksum Pillar Acceptance Test") +// Select the package(s) where the tests are located +@SelectPackages("org.bitrepository.pillar.integration.func") +// Filter to only run methods that have the specific @Tag +@IncludeTags(PillarTestGroups.CHECKSUM_PILLAR_TEST) +public class BitrepositoryChecksumPillarTestSuite { +} diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java index a96d68393..f9943c50a 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java @@ -9,6 +9,7 @@ import org.junit.platform.suite.api.SelectClasses; import org.junit.platform.suite.api.SelectPackages; import org.junit.platform.suite.api.Suite; +import org.junit.platform.suite.api.SuiteDisplayName; /** * BitrepositoryPillarTestSuite is a JUnit 5 suite class that groups and configures multiple test classes @@ -57,7 +58,10 @@ * */ @Suite -@SelectClasses({IntegrationTest.class, ActiveMQMessageBusTest.class}) // List your test classes here -@ExtendWith(GlobalSuiteExtension.class) +@SuiteDisplayName("Full Pillar Acceptance Test") +// Select the package(s) where the tests are located +@SelectPackages("org.bitrepository.pillar.integration.func") +// Filter to only run methods that have the specific @Tag +@IncludeTags(PillarTestGroups.FULL_PILLAR_TEST) public class BitrepositoryPillarTestSuite { } 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 00e7ba460..64cc5b5ff 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 @@ -45,7 +45,7 @@ protected void initializeCUT() { @Test @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) - public void eventSortingTest() throws NegativeResponseException{ + public void eventSortingTest() throws NegativeResponseException{ addDescription("Test whether the audit trails are sorted based on sequence numbers, with the largest " + "sequence number last.."); addFixture("Ensure at least two files are present on the pillar."); 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 7a73fc171..616c85818 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 @@ -51,7 +51,8 @@ public void initialiseReferenceTest() throws Exception { } @Test - @Tag(PillarTestGroups.FULL_PILLAR_TEST) @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) + @Tag(PillarTestGroups.FULL_PILLAR_TEST) + @Tag(PillarTestGroups.CHECKSUM_PILLAR_TEST) public void normalIdentificationTest() { addDescription("Verifies the normal behaviour for getChecksums identification"); addStep("Setup for test", "2 files on the pillar"); From c565330fc8612c5a6547cdbacff0808a544d920f Mon Sep 17 00:00:00 2001 From: kaah Date: Mon, 5 Jan 2026 18:46:40 +0100 Subject: [PATCH 12/14] Modified setupPillarIntegrationTest method so it reflects junit 5 instead of TestNG --- .../pillar/integration/PillarIntegrationTest.java | 13 ++++++++++++- .../perf/GetAuditTrailsFileStressIT.java | 3 +++ .../pillar/integration/perf/PutFileStressIT.java | 3 +++ 3 files changed, 18 insertions(+), 1 deletion(-) 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 448071081..e3717745c 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 @@ -95,7 +95,17 @@ protected void initializeCUT() { clientEventHandler = new ClientEventLogger(testEventManager); } - @AfterAll + @BeforeAll + public void setupPillarIntegrationTest(TestInfo testInfo) { + if (testConfiguration == null) { + testConfiguration = new PillarIntegrationTestConfiguration(PATH_TO_TESTPROPS_DIR + "/" + TEST_CONFIGURATION_FILE_NAME); + } + + super.initMessagebus(); + startEmbeddedPillar(testInfo); + } + + // @AfterAll public void shutdownRealMessageBus() { if(!useEmbeddedMessageBus()) { MessageBusManager.clear(); @@ -127,6 +137,7 @@ protected void setupRealMessageBus() { protected void setupMessageBus() { //Shortcircuit this so the messagebus is NOT INITIALISED BEFORE THE CONFIGURATION //super.setupMessageBus(); + setupRealMessageBus(); } @Override 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 ce998978d..5b8325b29 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 @@ -32,6 +32,7 @@ import org.bitrepository.pillar.integration.perf.metrics.Metrics; import org.bitrepository.protocol.security.DummySecurityManager; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Tag; import org.junit.jupiter.api.Test; @@ -69,6 +70,7 @@ private void singleTreadedPut() throws Exception { @Test @Tag("pillar-stress-test") +// @Disabled public void singleTreadedGetAuditTrails() throws Exception { final int NUMBER_OF_AUDITS = 100; final int PART_STATISTIC_INTERVAL = NUMBER_OF_AUDITS/5; @@ -89,6 +91,7 @@ public void singleTreadedGetAuditTrails() throws Exception { @Test @Tag("pillar-stress-test") + @Disabled public void parallelGetAuditTrails() throws Exception { final int NUMBER_OF_AUDITS = 10; final int PART_STATISTIC_INTERVAL = NUMBER_OF_AUDITS/5; 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 b39972768..f78cbd8a9 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,6 +29,7 @@ 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; @@ -49,6 +50,7 @@ settingsForTestClient, createSecurityManager(), settingsForTestClient.getCompone @Test @Tag("pillar-stress-test") @Tag("stress-test-pillar-population") + @Disabled public void singleTreadedPut() throws Exception { final int NUMBER_OF_FILES = 10; final int PART_STATISTIC_INTERVAL = 2; @@ -71,6 +73,7 @@ public void singleTreadedPut() throws Exception { @Test @Tag("pillar-stress-test") +// @Disabled public void parallelPut() throws Exception { final int numberOfFiles = testConfiguration.getInt("pillarintegrationtest.PutFileStressIT.parallelPut.numberOfFiles"); final int partStatisticsInterval = testConfiguration.getInt("pillarintegrationtest.PutFileStressIT.parallelPut.partStatisticsInterval"); From bbeace6040e570fe57de5a02286d4db8d145ba0a Mon Sep 17 00:00:00 2001 From: kaah Date: Tue, 6 Jan 2026 13:04:24 +0100 Subject: [PATCH 13/14] Now closer to without testng --- bitrepository-reference-pillar/pom.xml | 23 ++ .../pillar/BitrepositoryPillarTestSuite.java | 6 +- .../protocol/GlobalSuiteExtension.java | 210 ++++++++++++++++++ 3 files changed, 236 insertions(+), 3 deletions(-) create mode 100644 bitrepository-reference-pillar/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java diff --git a/bitrepository-reference-pillar/pom.xml b/bitrepository-reference-pillar/pom.xml index 201fa8ebc..0fb56e63c 100644 --- a/bitrepository-reference-pillar/pom.xml +++ b/bitrepository-reference-pillar/pom.xml @@ -16,6 +16,12 @@ bitrepository-core ${project.version}
+ + org.testng + testng + 7.11.0 + test + org.bitrepository.reference bitrepository-service @@ -88,6 +94,23 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 3.5.4 + + + org.junit.jupiter + junit-jupiter-engine + 5.13.4 + + + org.junit.platform + junit-platform-suite-engine + 1.13.4 + + + maven-assembly-plugin diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java index f9943c50a..09831aabe 100644 --- a/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/pillar/BitrepositoryPillarTestSuite.java @@ -59,9 +59,9 @@ */ @Suite @SuiteDisplayName("Full Pillar Acceptance Test") -// Select the package(s) where the tests are located +// Use SelectPackages with the exact base package @SelectPackages("org.bitrepository.pillar.integration.func") -// Filter to only run methods that have the specific @Tag -@IncludeTags(PillarTestGroups.FULL_PILLAR_TEST) +// For debugging: Comment out the Tag filter to see if it finds ANY tests in that package +// @IncludeTags(PillarTestGroups.FULL_PILLAR_TEST) public class BitrepositoryPillarTestSuite { } diff --git a/bitrepository-reference-pillar/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java b/bitrepository-reference-pillar/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java new file mode 100644 index 000000000..58615077b --- /dev/null +++ b/bitrepository-reference-pillar/src/test/java/org/bitrepository/protocol/GlobalSuiteExtension.java @@ -0,0 +1,210 @@ +package org.bitrepository.protocol; + +import org.bitrepository.common.settings.Settings; +import org.bitrepository.common.settings.TestSettingsProvider; +import org.bitrepository.common.utils.SettingsUtils; +import org.bitrepository.common.utils.TestFileHelper; +import org.bitrepository.protocol.bus.LocalActiveMQBroker; +import org.bitrepository.protocol.bus.MessageReceiver; +import org.bitrepository.protocol.fileexchange.HttpServerConfiguration; +import org.bitrepository.protocol.http.EmbeddedHttpServer; +import org.bitrepository.protocol.messagebus.MessageBus; +import org.bitrepository.protocol.messagebus.MessageBusManager; +import org.bitrepository.protocol.messagebus.SimpleMessageBus; +import org.bitrepository.protocol.security.DummySecurityManager; +import org.bitrepository.protocol.security.SecurityManager; +import org.jaccept.TestEventManager; +import org.junit.jupiter.api.extension.AfterAllCallback; +import org.junit.jupiter.api.extension.BeforeAllCallback; +import org.junit.jupiter.api.extension.ExtensionContext; + +import javax.jms.JMSException; +import java.net.MalformedURLException; +import java.net.URL; + +public class GlobalSuiteExtension implements BeforeAllCallback, AfterAllCallback { + + private static boolean initialized = false; + protected static TestEventManager testEventManager = TestEventManager.getInstance(); + public static LocalActiveMQBroker broker; + public static EmbeddedHttpServer server; + public static HttpServerConfiguration httpServerConfiguration; + public static MessageBus messageBus; + private MessageReceiverManager receiverManager; + protected static String alarmDestinationID; + protected static MessageReceiver alarmReceiver; + protected static SecurityManager securityManager; + protected static Settings settingsForCUT; + protected static Settings settingsForTestClient; + protected static String collectionID; + protected String NON_DEFAULT_FILE_ID; + protected static String DEFAULT_FILE_ID; + protected static URL DEFAULT_FILE_URL; + protected static String DEFAULT_DOWNLOAD_FILE_ADDRESS; + protected static String DEFAULT_UPLOAD_FILE_ADDRESS; + protected String DEFAULT_AUDIT_INFORMATION; + protected String testMethodName; + + @Override + public void beforeAll(ExtensionContext context) { + if (!initialized) { + initialized = true; + settingsForCUT = loadSettings(getComponentID()); + settingsForTestClient = loadSettings("TestSuiteInitialiser"); + makeUserSpecificSettings(settingsForCUT); + makeUserSpecificSettings(settingsForTestClient); + httpServerConfiguration = new HttpServerConfiguration(settingsForTestClient.getReferenceSettings().getFileExchangeSettings()); + collectionID = settingsForTestClient.getCollections().get(0).getID(); + + securityManager = createSecurityManager(); + DEFAULT_FILE_ID = "DefaultFile"; + try { + DEFAULT_FILE_URL = httpServerConfiguration.getURL(TestFileHelper.DEFAULT_FILE_ID); + DEFAULT_DOWNLOAD_FILE_ADDRESS = DEFAULT_FILE_URL.toExternalForm(); + DEFAULT_UPLOAD_FILE_ADDRESS = DEFAULT_FILE_URL.toExternalForm() + "-" + DEFAULT_FILE_ID; + } catch (MalformedURLException e) { + throw new RuntimeException("Never happens", e); + } + } + } + + @Override + public void afterAll(ExtensionContext context) { + if (initialized) { + teardownMessageBus(); + teardownHttpServer(); + } + } + + /** + * May be extended by subclasses needing to have their receivers managed. Remember to still call + * super.registerReceivers() when overriding + */ + protected void registerMessageReceivers() { + alarmReceiver = new MessageReceiver(settingsForCUT.getAlarmDestination(), testEventManager); + addReceiver(alarmReceiver); + } + + protected void addReceiver(MessageReceiver receiver) { + receiverManager.addReceiver(receiver); + } + protected void initializeCUT() {} + + /** + * Purges all messages from the receivers. + */ + protected void clearReceivers() { + receiverManager.clearMessagesInReceivers(); + } + + /** + * May be overridden by specific tests wishing to do stuff. Remember to call super if this is overridden. + */ + protected void shutdownCUT() {} + + /** + * Initializes the settings. Will postfix the alarm and collection topics with '-${user.name} + */ + protected void setupSettings() { + settingsForCUT = loadSettings(getComponentID()); + makeUserSpecificSettings(settingsForCUT); + SettingsUtils.initialize(settingsForCUT); + + alarmDestinationID = settingsForCUT.getRepositorySettings().getProtocolSettings().getAlarmDestination(); + + settingsForTestClient = loadSettings(testMethodName); + makeUserSpecificSettings(settingsForTestClient); + } + + + protected Settings loadSettings(String componentID) { + return TestSettingsProvider.reloadSettings(componentID); + } + + private void makeUserSpecificSettings(Settings settings) { + settings.getRepositorySettings().getProtocolSettings() + .setCollectionDestination(settings.getCollectionDestination() + getTopicPostfix()); + settings.getRepositorySettings().getProtocolSettings().setAlarmDestination(settings.getAlarmDestination() + getTopicPostfix()); + } + + /** + * Indicated whether an embedded active MQ should be started and used + */ + public boolean useEmbeddedMessageBus() { + return System.getProperty("useEmbeddedMessageBus", "true").equals("true"); + } + + /** + * Indicated whether an embedded http server should be started and used + */ + public boolean useEmbeddedHttpServer() { + return System.getProperty("useEmbeddedHttpServer", "false").equals("true"); + } + + /** + * Hooks up the message bus. + */ + protected void setupMessageBus() { + if (useEmbeddedMessageBus()) { + if (messageBus == null) { + messageBus = new SimpleMessageBus(); + } + } + } + + /** + * Shutdown the message bus. + */ + private void teardownMessageBus() { + MessageBusManager.clear(); + if (messageBus != null) { + try { + messageBus.close(); + messageBus = null; + } catch (JMSException e) { + throw new RuntimeException(e); + } + } + + if (broker != null) { + try { + broker.stop(); + broker = null; + } catch (Exception e) { + // No reason to pollute the test output with this + } + } + } + + /** + * Shutdown the embedded http server if any. + */ + protected void teardownHttpServer() { + if (useEmbeddedHttpServer()) { + server.stop(); + } + } + + /** + * Returns the postfix string to use when accessing user specific topics, which is the mechanism we use in the + * bit repository tests. + * + * @return The string to postfix all topix names with. + */ + protected String getTopicPostfix() { + return "-" + System.getProperty("user.name"); + } + + protected String getComponentID() { + return getClass().getSimpleName(); + } + + protected String createDate() { + return Long.toString(System.currentTimeMillis()); + } + + protected SecurityManager createSecurityManager() { + return new DummySecurityManager(); + } + +} \ No newline at end of file From dc838ff522861abe1530af9cd253b4f30d727f53 Mon Sep 17 00:00:00 2001 From: kaah Date: Tue, 13 Jan 2026 21:03:10 +0100 Subject: [PATCH 14/14] Minor adjustments --- .../GetChecksumsClientComponentTest.java | 72 +++++++++---------- ...llectionBasedConversationMediatorTest.java | 3 - .../mediator/ConversationMediatorTest.java | 1 - .../common/utils/ResponseInfoUtilsTest.java | 2 +- .../protocol/IntegrationTest.java | 7 ++ .../bus/MultiThreadedMessageBusTest.java | 2 +- ...MessageBusNumberOfListenersStressTest.java | 2 +- .../integration/PillarIntegrationTest.java | 2 +- .../integration/perf/PutFileStressIT.java | 2 +- 9 files changed, 47 insertions(+), 46 deletions(-) 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 edbc04820..80fdc39cf 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 @@ -69,8 +69,6 @@ import java.util.Date; import java.util.LinkedList; -import static org.junit.jupiter.api.Assertions.assertEquals; - /** * Test class for the 'GetFileClient'. @@ -118,9 +116,9 @@ public void getChecksumsFromSinglePillar() throws Exception { IdentifyPillarsForGetChecksumsRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForGetChecksumsRequest.class); - assertEquals(receivedIdentifyRequestMessage.getFileIDs().getFileID(), DEFAULT_FILE_ID); - assertEquals(receivedIdentifyRequestMessage.getChecksumRequestForExistingFile(), DEFAULT_CHECKSUM_SPECS); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(receivedIdentifyRequestMessage.getFileIDs().getFileID(), DEFAULT_FILE_ID); + Assertions.assertEquals(receivedIdentifyRequestMessage.getChecksumRequestForExistingFile(), DEFAULT_CHECKSUM_SPECS); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("Sends a response from pillar2.", "This should be ignored."); @@ -138,9 +136,9 @@ public void getChecksumsFromSinglePillar() throws Exception { messageBus.sendMessage(identifyResponse); GetChecksumsRequest receivedGetChecksumsRequest = pillar1Receiver.waitForMessage(GetChecksumsRequest.class); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("Send a GetChecksumsFinalResponse to the client from pillar1", "A COMPONENT_COMPLETE event should be generated with the resulting checksum. Finally a COMPLETE event" + @@ -154,8 +152,8 @@ public void getChecksumsFromSinglePillar() throws Exception { messageBus.sendMessage(completeMsg); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } @Test @Tag("regressiontest") @@ -179,7 +177,7 @@ public void getChecksumsDeliveredAtUrl() throws Exception { IdentifyPillarsForGetChecksumsRequest receivedIdentifyRequestMessage = null; receivedIdentifyRequestMessage = collectionReceiver.waitForMessage( IdentifyPillarsForGetChecksumsRequest.class); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("The pillar sends a response to the identify message.", "The callback listener should notify of the response and the client should send a GetChecksumsRequest " @@ -194,10 +192,10 @@ public void getChecksumsDeliveredAtUrl() throws Exception { GetChecksumsRequest receivedGetChecksumsRequest1 = pillar1Receiver.waitForMessage(GetChecksumsRequest.class); for(int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("Sends a final response from each pillar", "The GetChecksumsClient notifies that the file is ready through the callback listener and the uploaded file is present."); @@ -207,14 +205,14 @@ public void getChecksumsDeliveredAtUrl() throws Exception { res.setResultAddress(receivedGetChecksumsRequest1.getResultAddress()); completeMsg1.setResultingChecksums(res); messageBus.sendMessage(completeMsg1); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); GetChecksumsFinalResponse completeMsg2 = messageFactory.createGetChecksumsFinalResponse( receivedGetChecksumsRequest1, PILLAR2_ID, pillar2DestinationId); completeMsg2.setResultingChecksums(res); messageBus.sendMessage(completeMsg2); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } @Test @Tag("regressiontest") @@ -235,7 +233,7 @@ public void testNoSuchFile() throws Exception { IdentifyPillarsForGetChecksumsRequest receivedIdentifyRequestMessage = null; receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetChecksumsRequest.class); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); addStep("The pillar sends a response to the identify message.", "The callback listener should notify of the response and the client should send a GetChecksumsRequest " @@ -249,10 +247,10 @@ public void testNoSuchFile() throws Exception { receivedGetChecksumsRequest = pillar1Receiver.waitForMessage(GetChecksumsRequest.class); for(int i = 0; i < settingsForCUT.getRepositorySettings().getCollections().getCollection().get(0).getPillarIDs().getPillarID().size(); i++) { - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); } - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); addStep("Send a error that the file cannot be found.", "Should trigger a 'event failed'."); GetChecksumsFinalResponse completeMsg = messageFactory.createGetChecksumsFinalResponse( @@ -266,8 +264,8 @@ public void testNoSuchFile() throws Exception { messageBus.sendMessage(completeMsg); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_FAILED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.FAILED); } @@ -299,24 +297,24 @@ public void testPaging() throws Exception { receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId)); GetChecksumsRequest receivedGetChecksumsRequest1 = pillar1Receiver.waitForMessage(GetChecksumsRequest.class); - assertEquals(receivedGetChecksumsRequest1.getMinTimestamp(), + Assertions.assertEquals(receivedGetChecksumsRequest1.getMinTimestamp(), CalendarUtils.getXmlGregorianCalendar(query1.getMinTimestamp()), "Unexpected MinTimestamp in GetChecksumsRequest to pillar1."); - assertEquals(receivedGetChecksumsRequest1.getMaxTimestamp(), + Assertions.assertEquals(receivedGetChecksumsRequest1.getMaxTimestamp(), CalendarUtils.getXmlGregorianCalendar(query1.getMaxTimestamp()), "Unexpected MaxTimestamp in GetChecksumsRequest to pillar1."); - assertEquals(receivedGetChecksumsRequest1.getMaxNumberOfResults(), + Assertions.assertEquals(receivedGetChecksumsRequest1.getMaxNumberOfResults(), BigInteger.valueOf(query1.getMaxNumberOfResults()), "Unexpected MaxNumberOfResults in GetChecksumsRequest to pillar1."); GetChecksumsRequest receivedGetChecksumsRequest2 = pillar2Receiver.waitForMessage(GetChecksumsRequest.class); - assertEquals(receivedGetChecksumsRequest2.getMinTimestamp(), + Assertions.assertEquals(receivedGetChecksumsRequest2.getMinTimestamp(), CalendarUtils.getXmlGregorianCalendar((query2.getMinTimestamp())), "Unexpected MinTimestamp in GetChecksumsRequest to pillar2."); - assertEquals(receivedGetChecksumsRequest2.getMaxTimestamp(), + Assertions.assertEquals(receivedGetChecksumsRequest2.getMaxTimestamp(), CalendarUtils.getXmlGregorianCalendar(query2.getMaxTimestamp()), "Unexpected MaxTimestamp in GetChecksumsRequest to pillar2."); - assertEquals(receivedGetChecksumsRequest2.getMaxNumberOfResults(), + Assertions.assertEquals(receivedGetChecksumsRequest2.getMaxNumberOfResults(), BigInteger.valueOf(query2.getMaxNumberOfResults()), "Unexpected MaxNumberOfResults in GetChecksumsRequest to pillar2."); } @@ -339,29 +337,29 @@ public void getChecksumsFromOtherCollection() throws Exception { "A identification request should be dispatched."); client.getChecksums(otherCollection, null, null, null, null, testEventHandler, null); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFY_REQUEST_SENT); IdentifyPillarsForGetChecksumsRequest receivedIdentifyRequestMessage = collectionReceiver.waitForMessage(IdentifyPillarsForGetChecksumsRequest.class); - assertEquals(receivedIdentifyRequestMessage.getCollectionID(), otherCollection); + Assertions.assertEquals(receivedIdentifyRequestMessage.getCollectionID(), otherCollection); addStep("Send an identification response from pillar2.", "An COMPONENT_IDENTIFIED event should be generate folled by a IDENTIFICATION_COMPLETE and a " + "REQUEST_SENT. A GetChecksumsFileRequest should be sent to pillar2"); messageBus.sendMessage(messageFactory.createIdentifyPillarsForGetChecksumsResponse( receivedIdentifyRequestMessage, PILLAR2_ID, pillar2DestinationId)); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_IDENTIFIED); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.IDENTIFICATION_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.REQUEST_SENT); GetChecksumsRequest receivedRequest = pillar2Receiver.waitForMessage(GetChecksumsRequest.class); - assertEquals(receivedRequest.getCollectionID(), otherCollection); + Assertions.assertEquals(receivedRequest.getCollectionID(), otherCollection); addStep("Send a complete event from the pillar", "The client generates " + "a COMPONENT_COMPLETE, followed by a COMPLETE event."); GetChecksumsFinalResponse putFileFinalResponse1 = messageFactory.createGetChecksumsFinalResponse( receivedRequest, PILLAR2_ID, pillar2DestinationId); messageBus.sendMessage(putFileFinalResponse1); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); - assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPONENT_COMPLETE); + Assertions.assertEquals(testEventHandler.waitForEvent().getEventType(), OperationEventType.COMPLETE); } diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java index 741bae3bb..19aae9332 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/CollectionBasedConversationMediatorTest.java @@ -25,10 +25,7 @@ package org.bitrepository.client.conversation.mediator; import org.bitrepository.common.settings.Settings; -import org.junit.jupiter.api.Test; - -//@Test public class CollectionBasedConversationMediatorTest extends ConversationMediatorTest { @Override diff --git a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java index b1f40db26..5a4428378 100644 --- a/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java +++ b/bitrepository-client/src/test/java/org/bitrepository/client/conversation/mediator/ConversationMediatorTest.java @@ -38,7 +38,6 @@ /** * Test the general ConversationMediator functionality. */ -//@Test public abstract class ConversationMediatorTest { protected Settings settings = TestSettingsProvider.getSettings(getClass().getSimpleName()); protected SecurityManager securityManager = new DummySecurityManager(); 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 cf7f13719..312cac645 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 @@ -31,7 +31,7 @@ public class ResponseInfoUtilsTest extends ExtendedTestCase { @Test - @Tag("regressiontest") + @Tag("regressiontest") public void responseInfoTester() throws Exception { addDescription("Test the response info."); addStep("Validate the positive identification response", "Should be 'IDENTIFICATION_POSITIVE'"); 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 00b63c846..e6f5bf797 100644 --- a/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java +++ b/bitrepository-core/src/test/java/org/bitrepository/protocol/IntegrationTest.java @@ -24,6 +24,8 @@ */ package org.bitrepository.protocol; +import ch.qos.logback.classic.LoggerContext; +import ch.qos.logback.core.util.StatusPrinter; import org.bitrepository.common.settings.Settings; import org.bitrepository.common.settings.TestSettingsProvider; import org.bitrepository.common.utils.SettingsUtils; @@ -48,6 +50,7 @@ import org.junit.jupiter.api.TestInstance; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.TestWatcher; +import org.slf4j.LoggerFactory; import javax.jms.JMSException; import java.net.MalformedURLException; @@ -114,6 +117,10 @@ protected void addReceiver(MessageReceiver receiver) { public void initMessagebus() { initializationMethod(); setupMessageBus(); + if (System.getProperty("enableLogStatus", "false").equals("true")) { + LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory(); + StatusPrinter.print(lc); + } } @AfterAll 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 b785f2cc3..714dfc854 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 @@ -65,7 +65,7 @@ protected void setupMessageBus() { } @Test - @Tag("regressiontest" ) + @Tag("regressiontest" ) public final void manyTheadsBeforeFinish() throws Exception { addDescription("Tests whether it is possible to start the handling of many threads simultaneously."); IdentifyPillarsForGetFileRequest content = 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 cff4e8c89..d69bad278 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 @@ -123,7 +123,7 @@ public void initializeSettings() { * @throws Exception Can possibly throw an exception. */ @Test - @Tag("StressTest") + @Tag("StressTest") 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."); 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 e3717745c..8ff7bd2cd 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 @@ -105,7 +105,7 @@ public void setupPillarIntegrationTest(TestInfo testInfo) { startEmbeddedPillar(testInfo); } - // @AfterAll + @AfterAll public void shutdownRealMessageBus() { if(!useEmbeddedMessageBus()) { MessageBusManager.clear(); 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 f78cbd8a9..d6974fceb 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 @@ -50,7 +50,7 @@ settingsForTestClient, createSecurityManager(), settingsForTestClient.getCompone @Test @Tag("pillar-stress-test") @Tag("stress-test-pillar-population") - @Disabled +// @Disabled public void singleTreadedPut() throws Exception { final int NUMBER_OF_FILES = 10; final int PART_STATISTIC_INTERVAL = 2;