From 1986baedaca728c19f60dd66e8883a0a0d21c7df Mon Sep 17 00:00:00 2001 From: Mikhail Laptev Date: Wed, 24 Apr 2024 18:34:26 +0100 Subject: [PATCH] Feat: updating junit from version 4.x to 5.x (#56) - updated version of junit 4.x -> 5.x - updated version of mockito - updated tests - result codes tests has been split on a several groups - marking commented out tests as @Disabled - fixed misprints Signed-off-by: Mikhail Laptev --- bmq-sdk/pom.xml | 17 +- bmq-sdk/src/test/bin/docker-build.sh | 2 +- .../com/bloomberg/bmq/MessageGUIDTest.java | 12 +- .../com/bloomberg/bmq/QueueFlagsTest.java | 12 +- .../com/bloomberg/bmq/QueueOptionsTest.java | 16 +- .../com/bloomberg/bmq/ResultCodesTest.java | 874 ------------------ .../com/bloomberg/bmq/SessionOptionsTest.java | 30 +- .../bmq/SubscriptionExpressionTest.java | 14 +- .../com/bloomberg/bmq/SubscriptionTest.java | 16 +- .../test/java/com/bloomberg/bmq/UriTest.java | 80 +- .../bloomberg/bmq/impl/BrokerSessionTest.java | 59 +- .../bmq/impl/InboundEventBufferTest.java | 18 +- .../impl/ProtocolEventImplTcpReaderTest.java | 14 +- .../com/bloomberg/bmq/impl/PutPosterTest.java | 30 +- .../bloomberg/bmq/impl/QueueManagerTest.java | 22 +- .../impl/infr/codec/JsonDecoderUtilTest.java | 28 +- .../infr/io/ByteBufferInputStreamTest.java | 20 +- .../impl/infr/io/LimitedInputStreamTest.java | 14 +- .../impl/infr/msg/OpenQueueResponseTest.java | 14 +- .../bmq/impl/infr/msg/OpenQueueTest.java | 10 +- .../bmq/impl/infr/net/NetResolverTest.java | 22 +- .../impl/infr/net/NettyTcpConnectionTest.java | 52 +- .../infr/proto/AckEventImplBuilderTest.java | 10 +- .../bmq/impl/infr/proto/AckHeaderTest.java | 12 +- .../infr/proto/AckMessageIteratorTest.java | 12 +- .../impl/infr/proto/ApplicationDataTest.java | 26 +- .../proto/CompressionAlgorithmTypeTest.java | 27 +- .../proto/ConfirmEventImplBuilderTest.java | 10 +- .../proto/ConfirmMessageIteratorTest.java | 10 +- .../impl/infr/proto/EventImplHeaderTest.java | 18 +- .../proto/MessagePropertiesHeaderTest.java | 10 +- .../infr/proto/MessagePropertiesTest.java | 22 +- .../infr/proto/MessagePropertyHeaderTest.java | 10 +- .../bmq/impl/infr/proto/OptionHeaderTest.java | 26 +- .../bmq/impl/infr/proto/OptionsTest.java | 18 +- .../bmq/impl/infr/proto/ProtocolUtilTest.java | 8 +- .../infr/proto/PushEventImplBuilderTest.java | 12 +- .../impl/infr/proto/PushEventImplTest.java | 12 +- .../impl/infr/proto/PushHeaderFlagsTest.java | 12 +- .../bmq/impl/infr/proto/PushHeaderTest.java | 24 +- .../impl/infr/proto/PushMessageImplTest.java | 32 +- .../infr/proto/PushMessageIteratorTest.java | 28 +- .../infr/proto/PutEventImplBuilderTest.java | 16 +- .../impl/infr/proto/PutHeaderFlagsTest.java | 12 +- .../bmq/impl/infr/proto/PutHeaderTest.java | 16 +- .../impl/infr/proto/PutMessageImplTest.java | 24 +- .../infr/proto/PutMessageIteratorTest.java | 18 +- .../impl/infr/proto/RequestManagerTest.java | 22 +- .../proto/SchemaEventImplBuilderTest.java | 16 +- .../infr/proto/SubQueueIdsOptionTest.java | 14 +- .../infr/proto/SubQueueInfosOptionTest.java | 14 +- .../bmq/impl/infr/scm/VersionUtilTest.java | 14 +- .../impl/infr/stat/EventQueueStatsTest.java | 14 +- .../bmq/impl/infr/stat/EventsStatsTest.java | 8 +- .../bmq/impl/infr/stat/QueuesStatsTest.java | 20 +- .../bmq/impl/infr/stat/StatsTest.java | 14 +- .../bmq/impl/infr/stat/StatsUtilTest.java | 20 +- .../bmq/impl/infr/util/ArgumentTest.java | 16 +- .../bmq/impl/infr/util/SystemUtilTest.java | 18 +- .../impl/infr/util/ZlibCompressionTest.java | 12 +- .../ExpressionValidatorTest.java | 26 +- .../impl/intf/BrokerConnectionFSMTest.java | 26 +- .../com/bloomberg/bmq/it/BrokerSessionIT.java | 111 +-- .../bmq/it/BrokerSessionStressIT.java | 26 +- .../com/bloomberg/bmq/it/NettyConsumerIT.java | 12 +- .../com/bloomberg/bmq/it/NettyProducerIT.java | 8 +- .../bmq/it/NettyTcpConnectionImplIT.java | 34 +- .../java/com/bloomberg/bmq/it/PayloadIT.java | 12 +- .../com/bloomberg/bmq/it/PlainConsumerIT.java | 17 +- .../com/bloomberg/bmq/it/PlainProducerIT.java | 17 +- .../java/com/bloomberg/bmq/it/SessionIT.java | 122 +-- .../com/bloomberg/bmq/it/SessionStressIT.java | 30 +- .../com/bloomberg/bmq/it/SubscriptionIT.java | 65 +- .../bmq/it/TcpBrokerConnectionIT.java | 52 +- .../bmq/it/impl/infr/proto/Crc32cTest.java | 20 +- .../bmq/it/util/BmqBrokerTestServer.java | 4 +- .../com/bloomberg/bmq/it/util/TestTools.java | 10 +- .../bmq/resultcodes/AckResultTest.java | 175 ++++ .../bmq/resultcodes/CloseQueueResultTest.java | 198 ++++ .../resultcodes/ConfigureQueueResultTest.java | 155 ++++ .../bmq/resultcodes/GenericResultChecks.java | 81 ++ .../bmq/resultcodes/GenericResultTest.java | 197 ++++ .../bmq/resultcodes/OpenQueueResultTest.java | 219 +++++ .../com/bloomberg/bmq/util/TestHelpers.java | 6 +- pom.xml | 19 +- 85 files changed, 1922 insertions(+), 1723 deletions(-) delete mode 100644 bmq-sdk/src/test/java/com/bloomberg/bmq/ResultCodesTest.java create mode 100644 bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/AckResultTest.java create mode 100644 bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/CloseQueueResultTest.java create mode 100644 bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/ConfigureQueueResultTest.java create mode 100644 bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultChecks.java create mode 100644 bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultTest.java create mode 100644 bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/OpenQueueResultTest.java diff --git a/bmq-sdk/pom.xml b/bmq-sdk/pom.xml index 078bf72..91b6b1f 100644 --- a/bmq-sdk/pom.xml +++ b/bmq-sdk/pom.xml @@ -66,9 +66,10 @@ limitations under the License. --> + - junit - junit + org.mockito + mockito-junit-jupiter test @@ -96,6 +97,18 @@ limitations under the License. --> test + + org.junit.jupiter + junit-jupiter-engine + test + + + + org.junit.jupiter + junit-jupiter-params + test + + commons-io commons-io diff --git a/bmq-sdk/src/test/bin/docker-build.sh b/bmq-sdk/src/test/bin/docker-build.sh index 0c35a5e..e201262 100755 --- a/bmq-sdk/src/test/bin/docker-build.sh +++ b/bmq-sdk/src/test/bin/docker-build.sh @@ -7,7 +7,7 @@ # USAGE # ===== # docker-build.sh image_name -# BMQ_DOCKER_IMAGE=image_name docker_build.sh +# BMQ_DOCKER_IMAGE=image_name docker-build.sh image="" diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/MessageGUIDTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/MessageGUIDTest.java index 18e6ff0..a01f501 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/MessageGUIDTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/MessageGUIDTest.java @@ -15,16 +15,16 @@ */ package com.bloomberg.bmq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.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; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class MessageGUIDTest { +class MessageGUIDTest { @Test - public void testGUID() { + void testGUID() { // Test some valid & invalid hex reps final String INVALID_HEX_REP = "abcdefghijklmnopqrstuvwxyz012345"; final String VALID_HEX_REP = "ABCDEF0123456789ABCDEF0123456789"; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueFlagsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueFlagsTest.java index 42b8631..a521016 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueFlagsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueFlagsTest.java @@ -15,16 +15,16 @@ */ package com.bloomberg.bmq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.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; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class QueueFlagsTest { +class QueueFlagsTest { @Test - public void testFlags() { + void testFlags() { long l = 0L; assertFalse(QueueFlags.isReader(l)); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueOptionsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueOptionsTest.java index fef4647..0dc6d00 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueOptionsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/QueueOptionsTest.java @@ -15,21 +15,21 @@ */ package com.bloomberg.bmq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QueueOptionsTest { +class QueueOptionsTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void breathingTest() { + void breathingTest() { // Create default options QueueOptions obj = QueueOptions.createDefault(); @@ -92,7 +92,7 @@ public void breathingTest() { } @Test - public void mergeTest() { + void mergeTest() { QueueOptions baseOptions = QueueOptions.builder() .setConsumerPriority(2) diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/ResultCodesTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/ResultCodesTest.java deleted file mode 100644 index 93ed2b8..0000000 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/ResultCodesTest.java +++ /dev/null @@ -1,874 +0,0 @@ -/* - * Copyright 2022 Bloomberg Finance L.P. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.bloomberg.bmq; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; - -import com.bloomberg.bmq.ResultCodes.AckCode; -import com.bloomberg.bmq.ResultCodes.AckResult; -import com.bloomberg.bmq.ResultCodes.CloseQueueCode; -import com.bloomberg.bmq.ResultCodes.CloseQueueResult; -import com.bloomberg.bmq.ResultCodes.ConfigureQueueCode; -import com.bloomberg.bmq.ResultCodes.ConfigureQueueResult; -import com.bloomberg.bmq.ResultCodes.GenericCode; -import com.bloomberg.bmq.ResultCodes.GenericResult; -import com.bloomberg.bmq.ResultCodes.OpenQueueCode; -import com.bloomberg.bmq.ResultCodes.OpenQueueResult; -import org.junit.Test; - -public class ResultCodesTest { - // ================================================================ - // GenericResult tests - // ================================================================ - public abstract static class BaseTest { - public void isSuccessTest(GenericCode obj) { - assertFalse(obj.isSuccess()); - } - - public void isFailureTest(GenericCode obj) { - assertFalse(obj.isFailure()); - } - - public void isCanceledTest(GenericCode obj) { - assertFalse(obj.isCanceled()); - } - - public void isInvalidArgumentTest(GenericCode obj) { - assertFalse(obj.isInvalidArgument()); - } - - public void isNotConnectedTest(GenericCode obj) { - assertFalse(obj.isNotConnected()); - } - - public void isNotReadyTest(GenericCode obj) { - assertFalse(obj.isNotReady()); - } - - public void isNotSupportedTest(GenericCode obj) { - assertFalse(obj.isNotSupproted()); - } - - public void isRefusedTest(GenericCode obj) { - assertFalse(obj.isRefused()); - } - - public void isTimeoutTest(GenericCode obj) { - assertFalse(obj.isTimeout()); - } - - public void isUnknownTest(GenericCode obj) { - assertFalse(obj.isUnknown()); - } - } - - public static class SuccessTest extends BaseTest { - @Override - public void isSuccessTest(GenericCode obj) { - assertTrue(obj.isSuccess()); - } - } - - public abstract static class FailureStatusTest extends BaseTest { - @Override - public void isFailureTest(GenericCode obj) { - assertTrue(obj.isFailure()); - } - } - - public static class CanceledTest extends FailureStatusTest { - @Override - public void isCanceledTest(GenericCode obj) { - assertTrue(obj.isCanceled()); - } - } - - public static class InvalidArgumentTest extends FailureStatusTest { - @Override - public void isInvalidArgumentTest(GenericCode obj) { - assertTrue(obj.isInvalidArgument()); - } - } - - public static class NotConnectedTest extends FailureStatusTest { - @Override - public void isNotConnectedTest(GenericCode obj) { - assertTrue(obj.isNotConnected()); - } - } - - public static class NotReadyTest extends FailureStatusTest { - @Override - public void isNotReadyTest(GenericCode obj) { - assertTrue(obj.isNotReady()); - } - } - - public static class NotSupportedTest extends FailureStatusTest { - @Override - public void isNotSupportedTest(GenericCode obj) { - assertTrue(obj.isNotSupproted()); - } - } - - public static class RefusedTest extends FailureStatusTest { - @Override - public void isRefusedTest(GenericCode obj) { - assertTrue(obj.isRefused()); - } - } - - public static class TimeoutTest extends FailureStatusTest { - @Override - public void isTimeoutTest(GenericCode obj) { - assertTrue(obj.isTimeout()); - } - } - - public static class UnknownTest extends FailureStatusTest { - @Override - public void isUnknownTest(GenericCode obj) { - assertTrue(obj.isUnknown()); - } - } - - public static class GenericResultTest { - public static void checkPredicates(BaseTest test, GenericCode obj) { - test.isSuccessTest(obj); - test.isFailureTest(obj); - test.isCanceledTest(obj); - test.isInvalidArgumentTest(obj); - test.isNotConnectedTest(obj); - test.isNotReadyTest(obj); - test.isNotSupportedTest(obj); - test.isRefusedTest(obj); - test.isTimeoutTest(obj); - test.isUnknownTest(obj); - } - - public static void checkIfGeneric(GenericCode obj) { - assertEquals(obj, obj.getGeneralResult()); - } - - public static void checkIfNotGeneric(GenericCode obj) { - assertNotEquals(obj, obj.getGeneralResult()); - } - - public static void checkSuccess(GenericCode obj) { - GenericResultTest.checkPredicates(new SuccessTest(), obj); - } - - public static void checkTimeout(GenericCode obj) { - GenericResultTest.checkPredicates(new TimeoutTest(), obj); - } - - public static void checkNotConnected(GenericCode obj) { - GenericResultTest.checkPredicates(new NotConnectedTest(), obj); - } - - public static void checkCanceled(GenericCode obj) { - GenericResultTest.checkPredicates(new CanceledTest(), obj); - } - - public static void checkNotSupported(GenericCode obj) { - GenericResultTest.checkPredicates(new NotSupportedTest(), obj); - } - - public static void checkRefused(GenericCode obj) { - GenericResultTest.checkPredicates(new RefusedTest(), obj); - } - - public static void checkInvalidArgument(GenericCode obj) { - GenericResultTest.checkPredicates(new InvalidArgumentTest(), obj); - } - - public static void checkNotReady(GenericCode obj) { - GenericResultTest.checkPredicates(new NotReadyTest(), obj); - } - - public static void checkUnknown(GenericCode obj) { - GenericResultTest.checkPredicates(new UnknownTest(), obj); - } - - @Test - public void timeOutTest() { - GenericResultTest.checkIfGeneric(GenericResult.TIMEOUT); - GenericResultTest.checkTimeout(GenericResult.TIMEOUT); - } - - @Test - public void notConnectedTest() { - GenericResultTest.checkIfGeneric(GenericResult.NOT_CONNECTED); - GenericResultTest.checkNotConnected(GenericResult.NOT_CONNECTED); - } - - @Test - public void canceledTest() { - GenericResultTest.checkIfGeneric(GenericResult.CANCELED); - GenericResultTest.checkCanceled(GenericResult.CANCELED); - } - - @Test - public void notSupportedTest() { - GenericResultTest.checkIfGeneric(GenericResult.NOT_SUPPORTED); - GenericResultTest.checkNotSupported(GenericResult.NOT_SUPPORTED); - } - - @Test - public void refusedTest() { - GenericResultTest.checkIfGeneric(GenericResult.REFUSED); - GenericResultTest.checkRefused(GenericResult.REFUSED); - } - - @Test - public void invalidArgumentTest() { - GenericResultTest.checkIfGeneric(GenericResult.INVALID_ARGUMENT); - GenericResultTest.checkInvalidArgument(GenericResult.INVALID_ARGUMENT); - } - - @Test - public void notReadyTest() { - GenericResultTest.checkIfGeneric(GenericResult.NOT_READY); - GenericResultTest.checkNotReady(GenericResult.NOT_READY); - } - - @Test - public void unknownTest() { - GenericResultTest.checkIfGeneric(GenericResult.UNKNOWN); - GenericResultTest.checkUnknown(GenericResult.UNKNOWN); - } - } - - // ================================================================ - // OpenQueueResult tests - // ================================================================ - - public static class OpenQueueResultTest { - public static class OpenQueueGenericTest { - public void isAlreadyOpenedTest(OpenQueueCode obj) { - assertFalse(obj.isAlreadyOpened()); - } - - public void isAlreadyInProgressTest(OpenQueueCode obj) { - assertFalse(obj.isAlreadyInProgress()); - } - - public void isInvalidUriTest(OpenQueueCode obj) { - assertFalse(obj.isInvalidUri()); - } - - public void isInvalidFlagsTest(OpenQueueCode obj) { - assertFalse(obj.isInvalidFlags()); - } - - public void isQueueIdNotUniqueTest(OpenQueueCode obj) { - assertFalse(obj.isQueueIdNotUnique()); - } - } - - public static class AlreadyOpenedTest extends OpenQueueGenericTest { - @Override - public void isAlreadyOpenedTest(OpenQueueCode obj) { - assertTrue(obj.isAlreadyOpened()); - } - } - - public static class AlreadyInProgressTest extends OpenQueueGenericTest { - public void isAlreadyInProgressTest(OpenQueueCode obj) { - assertTrue(obj.isAlreadyInProgress()); - } - } - - public static class InvalidUriTest extends OpenQueueGenericTest { - @Override - public void isInvalidUriTest(OpenQueueCode obj) { - assertTrue(obj.isInvalidUri()); - } - } - - public static class InvalidFlagsTest extends OpenQueueGenericTest { - @Override - public void isInvalidFlagsTest(OpenQueueCode obj) { - assertTrue(obj.isInvalidFlags()); - } - } - - public static class QueueIdNotUniqueTest extends OpenQueueGenericTest { - @Override - public void isQueueIdNotUniqueTest(OpenQueueCode obj) { - assertTrue(obj.isQueueIdNotUnique()); - } - } - - public static void checkExtraPredicates(OpenQueueGenericTest test, OpenQueueCode obj) { - test.isAlreadyInProgressTest(obj); - test.isAlreadyOpenedTest(obj); - test.isInvalidFlagsTest(obj); - test.isInvalidUriTest(obj); - test.isQueueIdNotUniqueTest(obj); - } - - public static void checkGeneric(OpenQueueCode obj) { - OpenQueueResultTest.checkExtraPredicates(new OpenQueueGenericTest(), obj); - } - - public static void checkAlreadyInProgress(OpenQueueCode obj) { - OpenQueueResultTest.checkExtraPredicates(new AlreadyInProgressTest(), obj); - } - - public static void checkAlreadyOpened(OpenQueueCode obj) { - OpenQueueResultTest.checkExtraPredicates(new AlreadyOpenedTest(), obj); - } - - public static void checkInvalidFlags(OpenQueueCode obj) { - OpenQueueResultTest.checkExtraPredicates(new InvalidFlagsTest(), obj); - } - - public static void checkInvalidUri(OpenQueueCode obj) { - OpenQueueResultTest.checkExtraPredicates(new InvalidUriTest(), obj); - } - - public static void checkQueueIdNotUnique(OpenQueueCode obj) { - OpenQueueResultTest.checkExtraPredicates(new QueueIdNotUniqueTest(), obj); - } - - @Test - public void successTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.SUCCESS); - GenericResultTest.checkSuccess(OpenQueueResult.SUCCESS); - OpenQueueResultTest.checkGeneric(OpenQueueResult.SUCCESS); - } - - @Test - public void timeOutTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.TIMEOUT); - GenericResultTest.checkTimeout(OpenQueueResult.TIMEOUT); - OpenQueueResultTest.checkGeneric(OpenQueueResult.TIMEOUT); - } - - @Test - public void notConnectedTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.NOT_CONNECTED); - GenericResultTest.checkNotConnected(OpenQueueResult.NOT_CONNECTED); - OpenQueueResultTest.checkGeneric(OpenQueueResult.NOT_CONNECTED); - } - - @Test - public void canceledTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.CANCELED); - GenericResultTest.checkCanceled(OpenQueueResult.CANCELED); - OpenQueueResultTest.checkGeneric(OpenQueueResult.CANCELED); - } - - @Test - public void notSupportedTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.NOT_SUPPORTED); - GenericResultTest.checkNotSupported(OpenQueueResult.NOT_SUPPORTED); - OpenQueueResultTest.checkGeneric(OpenQueueResult.NOT_SUPPORTED); - } - - @Test - public void refusedTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.REFUSED); - GenericResultTest.checkRefused(OpenQueueResult.REFUSED); - OpenQueueResultTest.checkGeneric(OpenQueueResult.REFUSED); - } - - @Test - public void invalidArgumentTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.INVALID_ARGUMENT); - GenericResultTest.checkInvalidArgument(OpenQueueResult.INVALID_ARGUMENT); - OpenQueueResultTest.checkGeneric(OpenQueueResult.INVALID_ARGUMENT); - } - - @Test - public void notReadyTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.NOT_READY); - GenericResultTest.checkNotReady(OpenQueueResult.NOT_READY); - OpenQueueResultTest.checkGeneric(OpenQueueResult.NOT_READY); - } - - @Test - public void unknownTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.UNKNOWN); - GenericResultTest.checkUnknown(OpenQueueResult.UNKNOWN); - OpenQueueResultTest.checkGeneric(OpenQueueResult.UNKNOWN); - } - - @Test - public void alreadyInProgressTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.ALREADY_IN_PROGRESS); - OpenQueueResultTest.checkAlreadyInProgress(OpenQueueResult.ALREADY_IN_PROGRESS); - } - - @Test - public void alreadyOpenedTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.ALREADY_OPENED); - OpenQueueResultTest.checkAlreadyOpened(OpenQueueResult.ALREADY_OPENED); - } - - @Test - public void invalidFlagsTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.INVALID_FLAGS); - OpenQueueResultTest.checkInvalidFlags(OpenQueueResult.INVALID_FLAGS); - } - - @Test - public void invalidUriTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.INVALID_URI); - OpenQueueResultTest.checkInvalidUri(OpenQueueResult.INVALID_URI); - } - - @Test - public void queueIdNotUniqueTest() { - GenericResultTest.checkIfNotGeneric(OpenQueueResult.QUEUE_ID_NOT_UNIQUE); - OpenQueueResultTest.checkQueueIdNotUnique(OpenQueueResult.QUEUE_ID_NOT_UNIQUE); - } - } - - // ================================================================ - // ConfigureQueueResult tests - // ================================================================ - public static class ConfigureQueueResultTest { - public static class ConfigureQueueGenericTest { - public void isAlreadyInProgressTest(ConfigureQueueCode obj) { - assertFalse(obj.isAlreadyInProgress()); - } - - public void isInvalidQueueTest(ConfigureQueueCode obj) { - assertFalse(obj.isInvalidQueue()); - } - } - - public static class AlreadyInProgressTest extends ConfigureQueueGenericTest { - @Override - public void isAlreadyInProgressTest(ConfigureQueueCode obj) { - assertTrue(obj.isAlreadyInProgress()); - } - } - - public static class InvalidQueueTest extends ConfigureQueueGenericTest { - @Override - public void isInvalidQueueTest(ConfigureQueueCode obj) { - assertTrue(obj.isInvalidQueue()); - } - } - - public static void checkPredicates(ConfigureQueueGenericTest test, ConfigureQueueCode obj) { - test.isAlreadyInProgressTest(obj); - test.isInvalidQueueTest(obj); - } - - public static void checkGeneric(ConfigureQueueCode obj) { - ConfigureQueueResultTest.checkPredicates(new ConfigureQueueGenericTest(), obj); - } - - public static void checkAlreadyInProgress(ConfigureQueueCode obj) { - ConfigureQueueResultTest.checkPredicates(new AlreadyInProgressTest(), obj); - } - - public static void checkAlreadyOpenedTest(ConfigureQueueCode obj) { - ConfigureQueueResultTest.checkPredicates(new InvalidQueueTest(), obj); - } - - @Test - public void successTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.SUCCESS); - GenericResultTest.checkSuccess(ConfigureQueueResult.SUCCESS); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.SUCCESS); - } - - @Test - public void timeOutTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.TIMEOUT); - GenericResultTest.checkTimeout(ConfigureQueueResult.TIMEOUT); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.TIMEOUT); - } - - @Test - public void notConnectedTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.NOT_CONNECTED); - GenericResultTest.checkNotConnected(ConfigureQueueResult.NOT_CONNECTED); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.NOT_CONNECTED); - } - - @Test - public void canceledTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.CANCELED); - GenericResultTest.checkCanceled(ConfigureQueueResult.CANCELED); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.CANCELED); - } - - @Test - public void notSupportedTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.NOT_SUPPORTED); - GenericResultTest.checkNotSupported(ConfigureQueueResult.NOT_SUPPORTED); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.NOT_SUPPORTED); - } - - @Test - public void refusedTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.REFUSED); - GenericResultTest.checkRefused(ConfigureQueueResult.REFUSED); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.REFUSED); - } - - @Test - public void invalidArgumentTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.INVALID_ARGUMENT); - GenericResultTest.checkInvalidArgument(ConfigureQueueResult.INVALID_ARGUMENT); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.INVALID_ARGUMENT); - } - - @Test - public void notReadyTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.NOT_READY); - GenericResultTest.checkNotReady(ConfigureQueueResult.NOT_READY); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.NOT_READY); - } - - @Test - public void unknownTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.UNKNOWN); - GenericResultTest.checkUnknown(ConfigureQueueResult.UNKNOWN); - ConfigureQueueResultTest.checkGeneric(ConfigureQueueResult.UNKNOWN); - } - - @Test - public void alreadyInProgressTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.ALREADY_IN_PROGRESS); - ConfigureQueueResultTest.checkAlreadyInProgress( - ConfigureQueueResult.ALREADY_IN_PROGRESS); - } - - @Test - public void alreadyOpenedTest() { - GenericResultTest.checkIfNotGeneric(ConfigureQueueResult.INVALID_QUEUE); - ConfigureQueueResultTest.checkAlreadyOpenedTest(ConfigureQueueResult.INVALID_QUEUE); - } - } - - // ================================================================ - // CloseQueueResult tests - // ================================================================ - public static class CloseQueueResultTest { - public static class CloseQueueGenericTest { - public void isAlreadyClosed(CloseQueueCode obj) { - assertFalse(obj.isAlreadyClosed()); - } - - public void isAlreadyInProgressTest(CloseQueueCode obj) { - assertFalse(obj.isAlreadyInProgress()); - } - - public void isUnknownQueueTest(CloseQueueCode obj) { - assertFalse(obj.isUnknownQueue()); - } - - public void isInvalidQueueTest(CloseQueueCode obj) { - assertFalse(obj.isInvalidQueue()); - } - } - - public static class AlreadyClosedTest extends CloseQueueGenericTest { - @Override - public void isAlreadyClosed(CloseQueueCode obj) { - assertTrue(obj.isAlreadyClosed()); - } - } - - public static class AlreadyInProgressTest extends CloseQueueGenericTest { - @Override - public void isAlreadyInProgressTest(CloseQueueCode obj) { - assertTrue(obj.isAlreadyInProgress()); - } - } - - public static class UnknownQueueTest extends CloseQueueGenericTest { - @Override - public void isUnknownQueueTest(CloseQueueCode obj) { - assertTrue(obj.isUnknownQueue()); - } - } - - public static class InvalidQueueTest extends CloseQueueGenericTest { - @Override - public void isInvalidQueueTest(CloseQueueCode obj) { - assertTrue(obj.isInvalidQueue()); - } - } - - public static void checkPredicates(CloseQueueGenericTest test, CloseQueueResult obj) { - test.isAlreadyClosed(obj); - test.isAlreadyInProgressTest(obj); - test.isUnknownQueueTest(obj); - test.isInvalidQueueTest(obj); - } - - public static void checkGeneric(CloseQueueResult obj) { - CloseQueueResultTest.checkPredicates(new CloseQueueGenericTest(), obj); - } - - public static void checkAlreadyClosed(CloseQueueResult obj) { - CloseQueueResultTest.checkPredicates(new AlreadyClosedTest(), obj); - } - - public static void checkAlreadyInProgress(CloseQueueResult obj) { - CloseQueueResultTest.checkPredicates(new AlreadyInProgressTest(), obj); - } - - public static void checkUnknownQueue(CloseQueueResult obj) { - CloseQueueResultTest.checkPredicates(new UnknownQueueTest(), obj); - } - - public static void checkInvalidQueue(CloseQueueResult obj) { - CloseQueueResultTest.checkPredicates(new InvalidQueueTest(), obj); - } - - @Test - public void successTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.SUCCESS); - GenericResultTest.checkSuccess(CloseQueueResult.SUCCESS); - CloseQueueResultTest.checkGeneric(CloseQueueResult.SUCCESS); - } - - @Test - public void timeOutTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.TIMEOUT); - GenericResultTest.checkTimeout(CloseQueueResult.TIMEOUT); - CloseQueueResultTest.checkGeneric(CloseQueueResult.TIMEOUT); - } - - @Test - public void notConnectedTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.NOT_CONNECTED); - GenericResultTest.checkNotConnected(CloseQueueResult.NOT_CONNECTED); - CloseQueueResultTest.checkGeneric(CloseQueueResult.NOT_CONNECTED); - } - - @Test - public void canceledTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.CANCELED); - GenericResultTest.checkCanceled(CloseQueueResult.CANCELED); - CloseQueueResultTest.checkGeneric(CloseQueueResult.CANCELED); - } - - @Test - public void notSupportedTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.NOT_SUPPORTED); - GenericResultTest.checkNotSupported(CloseQueueResult.NOT_SUPPORTED); - CloseQueueResultTest.checkGeneric(CloseQueueResult.NOT_SUPPORTED); - } - - @Test - public void refusedTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.REFUSED); - GenericResultTest.checkRefused(CloseQueueResult.REFUSED); - CloseQueueResultTest.checkGeneric(CloseQueueResult.REFUSED); - } - - @Test - public void invalidArgumentTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.INVALID_ARGUMENT); - GenericResultTest.checkInvalidArgument(CloseQueueResult.INVALID_ARGUMENT); - CloseQueueResultTest.checkGeneric(CloseQueueResult.INVALID_ARGUMENT); - } - - @Test - public void notReadyTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.NOT_READY); - GenericResultTest.checkNotReady(CloseQueueResult.NOT_READY); - CloseQueueResultTest.checkGeneric(CloseQueueResult.NOT_READY); - } - - @Test - public void unknownTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.UNKNOWN); - GenericResultTest.checkUnknown(CloseQueueResult.UNKNOWN); - CloseQueueResultTest.checkGeneric(CloseQueueResult.UNKNOWN); - } - - @Test - public void alreadyClosedTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.ALREADY_CLOSED); - CloseQueueResultTest.checkAlreadyClosed(CloseQueueResult.ALREADY_CLOSED); - } - - @Test - public void alreadyInProgressTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.ALREADY_IN_PROGRESS); - CloseQueueResultTest.checkAlreadyInProgress(CloseQueueResult.ALREADY_IN_PROGRESS); - } - - @Test - public void unknownQueueTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.UNKNOWN_QUEUE); - CloseQueueResultTest.checkUnknownQueue(CloseQueueResult.UNKNOWN_QUEUE); - } - - @Test - public void invalidQueueTest() { - GenericResultTest.checkIfNotGeneric(CloseQueueResult.INVALID_QUEUE); - CloseQueueResultTest.checkInvalidQueue(CloseQueueResult.INVALID_QUEUE); - } - } - - // ================================================================ - // AckResult tests - // ================================================================ - public static class AckResultTest { - public static class AckGenericTest { - public void isLimitMessages(AckCode obj) { - assertFalse(obj.isLimitMessages()); - } - - public void isLimitBytes(AckCode obj) { - assertFalse(obj.isLimitBytes()); - } - - public void isStorageFailure(AckCode obj) { - assertFalse(obj.isStorageFailure()); - } - } - - public static class LimitMessagesTest extends AckGenericTest { - @Override - public void isLimitMessages(AckCode obj) { - assertTrue(obj.isLimitMessages()); - } - } - - public static class LimitBytesTest extends AckGenericTest { - @Override - public void isLimitBytes(AckCode obj) { - assertTrue(obj.isLimitBytes()); - } - } - - public static class StorageFailureTest extends AckGenericTest { - @Override - public void isStorageFailure(AckCode obj) { - assertTrue(obj.isStorageFailure()); - } - } - - public static void checkExtraPredicates(AckGenericTest test, AckResult obj) { - test.isLimitMessages(obj); - test.isLimitBytes(obj); - test.isStorageFailure(obj); - } - - public static void checkGeneric(AckResult obj) { - AckResultTest.checkExtraPredicates(new AckGenericTest(), obj); - } - - public static void checkLimitMessages(AckResult obj) { - AckResultTest.checkExtraPredicates(new LimitMessagesTest(), obj); - } - - public static void checkLimitBytes(AckResult obj) { - AckResultTest.checkExtraPredicates(new LimitBytesTest(), obj); - } - - public static void checkStorageFailure(AckResult obj) { - AckResultTest.checkExtraPredicates(new StorageFailureTest(), obj); - } - - @Test - public void successTest() { - GenericResultTest.checkIfNotGeneric(AckResult.SUCCESS); - GenericResultTest.checkSuccess(AckResult.SUCCESS); - AckResultTest.checkGeneric(AckResult.SUCCESS); - } - - @Test - public void timeOutTest() { - GenericResultTest.checkIfNotGeneric(AckResult.TIMEOUT); - GenericResultTest.checkTimeout(AckResult.TIMEOUT); - AckResultTest.checkGeneric(AckResult.TIMEOUT); - } - - @Test - public void notConnectedTest() { - GenericResultTest.checkIfNotGeneric(AckResult.NOT_CONNECTED); - GenericResultTest.checkNotConnected(AckResult.NOT_CONNECTED); - AckResultTest.checkGeneric(AckResult.NOT_CONNECTED); - } - - @Test - public void canceledTest() { - GenericResultTest.checkIfNotGeneric(AckResult.CANCELED); - GenericResultTest.checkCanceled(AckResult.CANCELED); - AckResultTest.checkGeneric(AckResult.CANCELED); - } - - @Test - public void notSupportedTest() { - GenericResultTest.checkIfNotGeneric(AckResult.NOT_SUPPORTED); - GenericResultTest.checkNotSupported(AckResult.NOT_SUPPORTED); - AckResultTest.checkGeneric(AckResult.NOT_SUPPORTED); - } - - @Test - public void refusedTest() { - GenericResultTest.checkIfNotGeneric(AckResult.REFUSED); - GenericResultTest.checkRefused(AckResult.REFUSED); - AckResultTest.checkGeneric(AckResult.REFUSED); - } - - @Test - public void invalidArgumentTest() { - GenericResultTest.checkIfNotGeneric(AckResult.INVALID_ARGUMENT); - GenericResultTest.checkInvalidArgument(AckResult.INVALID_ARGUMENT); - AckResultTest.checkGeneric(AckResult.INVALID_ARGUMENT); - } - - @Test - public void notReadyTest() { - GenericResultTest.checkIfNotGeneric(AckResult.NOT_READY); - GenericResultTest.checkNotReady(AckResult.NOT_READY); - AckResultTest.checkGeneric(AckResult.NOT_READY); - } - - @Test - public void unknownTest() { - GenericResultTest.checkIfNotGeneric(AckResult.UNKNOWN); - GenericResultTest.checkUnknown(AckResult.UNKNOWN); - AckResultTest.checkGeneric(AckResult.UNKNOWN); - } - - @Test - public void limitMessagesTest() { - GenericResultTest.checkIfNotGeneric(AckResult.LIMIT_MESSAGES); - AckResultTest.checkLimitMessages(AckResult.LIMIT_MESSAGES); - } - - @Test - public void limitBytesTest() { - GenericResultTest.checkIfNotGeneric(AckResult.LIMIT_BYTES); - AckResultTest.checkLimitBytes(AckResult.LIMIT_BYTES); - } - - @Test - public void storageFailureTest() { - GenericResultTest.checkIfNotGeneric(AckResult.STORAGE_FAILURE); - AckResultTest.checkStorageFailure(AckResult.STORAGE_FAILURE); - } - } -} diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/SessionOptionsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/SessionOptionsTest.java index d3c5e4d..230fe35 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/SessionOptionsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/SessionOptionsTest.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import com.google.gson.Gson; @@ -29,12 +29,12 @@ import com.google.gson.JsonSerializer; import java.lang.reflect.Type; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class SessionOptionsTest { +class SessionOptionsTest { @Test - public void testWaterMarks() { + void testWaterMarks() { // Negative LWM try { SessionOptions.builder() @@ -104,7 +104,7 @@ public void testWaterMarks() { } @Test - public void testStatsDumpInterval() { + void testStatsDumpInterval() { // Negative SDI try { SessionOptions.builder().setStatsDumpInterval(Duration.ofNanos(-1)); @@ -122,7 +122,7 @@ public void testStatsDumpInterval() { } @Test - public void testHostHealthMonitor() { + void testHostHealthMonitor() { // Default value is null assertNull(SessionOptions.createDefault().hostHealthMonitor()); @@ -146,7 +146,7 @@ public void testHostHealthMonitor() { } @Test - public void testBuilderWithOptions() { + void testBuilderWithOptions() { // GSON cannot serialize Duration type, so add simple adapter to convert Duration to string GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.registerTypeAdapter( @@ -160,12 +160,12 @@ public JsonElement serialize( }); Gson gson = gsonBuilder.create(); - SessionOptions defaulOptions = SessionOptions.createDefault(); - assertEquals(gson.toJson(defaulOptions), gson.toJson(SessionOptions.builder().build())); + SessionOptions defaultOptions = SessionOptions.createDefault(); + assertEquals(gson.toJson(defaultOptions), gson.toJson(SessionOptions.builder().build())); assertEquals( - gson.toJson(defaulOptions), - gson.toJson(SessionOptions.builder(defaulOptions).build())); + gson.toJson(defaultOptions), + gson.toJson(SessionOptions.builder(defaultOptions).build())); Duration startTimeout = Duration.ofSeconds(1); Duration stopTimeout = Duration.ofMinutes(1); @@ -176,7 +176,7 @@ public JsonElement serialize( .setStopTimeout(stopTimeout) .build(); - assertNotEquals(gson.toJson(defaulOptions), gson.toJson(newOptions)); + assertNotEquals(gson.toJson(defaultOptions), gson.toJson(newOptions)); assertEquals( gson.toJson(newOptions), gson.toJson(SessionOptions.builder(newOptions).build())); } diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionExpressionTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionExpressionTest.java index 55523a4..66e88c7 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionExpressionTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionExpressionTest.java @@ -15,21 +15,21 @@ */ package com.bloomberg.bmq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SubscriptionExpressionTest { +class SubscriptionExpressionTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void breathingTest() { + void breathingTest() { // Create subscription expression with an empty constructor SubscriptionExpression obj = new SubscriptionExpression(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionTest.java index 01b0968..ed58d14 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/SubscriptionTest.java @@ -15,21 +15,21 @@ */ package com.bloomberg.bmq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SubscriptionTest { +class SubscriptionTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void breathingTest() { + void breathingTest() { // Create default subscription parameters Subscription obj = Subscription.createDefault(); @@ -79,7 +79,7 @@ public void breathingTest() { } @Test - public void mergeTest() { + void mergeTest() { Subscription baseSubscription = Subscription.builder() .setConsumerPriority(2) diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/UriTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/UriTest.java index 93fba22..01d97a8 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/UriTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/UriTest.java @@ -15,16 +15,18 @@ */ package com.bloomberg.bmq; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.fail; -import org.junit.Test; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.ValueSource; -public class UriTest { +class UriTest { @Test - public void testBasic() { + void testBasic() { String uriStr = "bmq://my.domain/queue-foo-bar?id=my.app"; @@ -41,7 +43,7 @@ public void testBasic() { } @Test - public void testValidParsing() { + void testValidParsing() { { String uriStr = "bmq://ts.trades.myapp/my.queue"; Uri obj = new Uri(uriStr); @@ -91,43 +93,41 @@ public void testValidParsing() { } } - @Test - public void testInvalidParsing() { - String[] URIs = { - "", - "foobar", - "bb://", - "bmq://", - "bmq://a/", - "bmq://$%@/ts.trades.myapp/queue@sss", - "bb:///ts.trades.myapp/myqueue", - "bmq://ts.trades.myapp/", - "bmq://ts.trades.myapp/queue?id=", - "bmq://ts.trades.myapp/queue?bs=a", - "bmq://ts.trades.myapp/queue?", - "bmq://ts.trades.myapp/queue?id=", - "bmq://ts.trades.myapp/queue&id==", - "bmq://ts.trades.myapp/queue&id=foo", - "bmq://ts.trades.myapp/queue?id=foo&", - "bmq://ts.trades.myapp/queue?pid=foo", - "bmq://ts.trades.myapp.~/queue", - "bmq://ts.trades~myapp/queue", - "bmq://ts.trades.myapp.~a_b/queue" - }; - - for (String uriStr : URIs) { - try { - new Uri(uriStr); - // Shouldn't be here - fail(); - } catch (RuntimeException e) { - // OK - } + @ParameterizedTest + @ValueSource( + strings = { + "", + "foobar", + "bb://", + "bmq://", + "bmq://a/", + "bmq://$%@/ts.trades.myapp/queue@sss", + "bb:///ts.trades.myapp/myqueue", + "bmq://ts.trades.myapp/", + "bmq://ts.trades.myapp/queue?id=", + "bmq://ts.trades.myapp/queue?bs=a", + "bmq://ts.trades.myapp/queue?", + "bmq://ts.trades.myapp/queue?id=", + "bmq://ts.trades.myapp/queue&id==", + "bmq://ts.trades.myapp/queue&id=foo", + "bmq://ts.trades.myapp/queue?id=foo&", + "bmq://ts.trades.myapp/queue?pid=foo", + "bmq://ts.trades.myapp.~/queue", + "bmq://ts.trades~myapp/queue", + "bmq://ts.trades.myapp.~a_b/queue" + }) + void testInvalidParsing(String uri) { + try { + new Uri(uri); + // Shouldn't be here + fail(); + } catch (RuntimeException e) { + // OK } } @Test - public void testEquals() { + void testEquals() { // Equals with the same string URI { String uriStr = "bmq://my.domain/queue-foo-bar?id=my.app"; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/BrokerSessionTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/BrokerSessionTest.java index ea665c6..e6af8d1 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/BrokerSessionTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/BrokerSessionTest.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +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.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -71,11 +71,11 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeoutException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class BrokerSessionTest { +class BrokerSessionTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -158,7 +158,7 @@ public void start() { public void start(Duration timeout) { session.startAsync(Argument.expectNonNull(timeout, "timeout")); - sendNegotiationRespose(verifyNegotiationRequest(), StatusCategory.E_SUCCESS); + sendNegotiationResponse(verifyNegotiationRequest(), StatusCategory.E_SUCCESS); verifySessionEvent(BrokerSessionEvent.Type.e_CONNECTED); } @@ -219,7 +219,8 @@ public ClientIdentity verifyNegotiationRequest() { return negotiationMessageChoice.clientIdentity(); } - public void sendNegotiationRespose(ClientIdentity clientIdentity, StatusCategory category) { + public void sendNegotiationResponse( + ClientIdentity clientIdentity, StatusCategory category) { Argument.expectNonNull(clientIdentity, "clientIdentity"); Argument.expectNonNull(category, "category"); @@ -519,7 +520,7 @@ public void arriveAtStep(QueueImpl queue, QueueOptions queueOptions, QueueTestSt connection.setChannelStatus(ChannelStatus.CHANNEL_UP); // Negotiate - sendNegotiationRespose( + sendNegotiationResponse( verifyNegotiationRequest(), StatusCategory.E_SUCCESS); // Wait RECONNECTED event @@ -589,8 +590,8 @@ public void arriveAtStep(QueueImpl queue, QueueOptions queueOptions, QueueTestSt Argument.expectNonNull(curRequest, "curRequest") .configureStream() .streamParameters(); - assertEquals(params.subscriptions().length, 1); - assertEquals(params.subscriptions()[0].consumers().length, 1); + assertEquals(1, params.subscriptions().length); + assertEquals(1, params.subscriptions()[0].consumers().length); ConsumerInfo info = params.subscriptions()[0].consumers()[0]; info.setMaxUnconfirmedBytes(info.maxUnconfirmedBytes() - 1); @@ -709,7 +710,7 @@ private static Uri createUri() { /** Basic test that creates BrokerSession with a test channel */ @Test - public void breathingTest() { + void breathingTest() { TcpConnectionFactory connectionFactory = new TestTcpConnectionFactory(); ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); @@ -731,7 +732,7 @@ public void breathingTest() { /** Check that BrokerSession with a test channel can be started and stopped asynchronously */ @Test - public void checkStartStopAsyncTest() { + void checkStartStopAsyncTest() { TestSession obj = new TestSession(); try { @@ -750,7 +751,7 @@ public void checkStartStopAsyncTest() { // Check startAsync OK obj.session().startAsync(Duration.ofSeconds(1)); - obj.sendNegotiationRespose(obj.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); + obj.sendNegotiationResponse(obj.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); obj.verifySessionEvent(BrokerSessionEvent.Type.e_CONNECTED); @@ -777,7 +778,7 @@ public void checkStartStopAsyncTest() { * stopped asynchronously */ @Test - public void checkStartStopAsyncWithMonitorTest() { + void checkStartStopAsyncWithMonitorTest() { HostHealthMonitor monitor = mock(HostHealthMonitor.class); SessionOptions options = SessionOptions.builder().setHostHealthMonitor(monitor).build(); @@ -804,7 +805,7 @@ public void checkStartStopAsyncWithMonitorTest() { // Call startAsync first time obj.session().startAsync(Duration.ofSeconds(1)); - obj.sendNegotiationRespose(obj.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); + obj.sendNegotiationResponse(obj.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); // Since monitor returns Unknown state, HOST_UNHEALTHY event // should be issued @@ -850,7 +851,7 @@ public void checkStartStopAsyncWithMonitorTest() { * stopped synchronously */ @Test - public void checkStartStopSyncWithMonitorTest() { + void checkStartStopSyncWithMonitorTest() { HostHealthMonitor monitor = mock(HostHealthMonitor.class); SessionOptions options = SessionOptions.builder().setHostHealthMonitor(monitor).build(); @@ -877,7 +878,7 @@ public void checkStartStopSyncWithMonitorTest() { // Call start first time CompletableFuture.runAsync( () -> { - obj.sendNegotiationRespose( + obj.sendNegotiationResponse( obj.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); }); obj.session().start(Duration.ofSeconds(1)); @@ -925,7 +926,7 @@ public void checkStartStopSyncWithMonitorTest() { * drop */ @Test - public void checkRestartTest() { + void checkRestartTest() { TestSession obj = new TestSession(); try { @@ -945,7 +946,7 @@ public void checkRestartTest() { obj.connection().setChannelStatus(ChannelStatus.CHANNEL_UP); // Negotiate - obj.sendNegotiationRespose( + obj.sendNegotiationResponse( obj.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); obj.verifySessionEvent(BrokerSessionEvent.Type.e_RECONNECTED); @@ -968,7 +969,7 @@ public void checkRestartTest() { /** Check substreamcount when broker session fails to send open queue request */ @Test - public void openQueueRequestFailsTest() { + void openQueueRequestFailsTest() { TestSession obj = new TestSession(); try { @@ -1048,7 +1049,7 @@ public void openQueueRequestFailsTest() { /** Check substreamcount when broker session fails to send open configure queue request */ @Test - public void openConfigureQueueRequestFailsTest() { + void openConfigureQueueRequestFailsTest() { TestSession obj = new TestSession(); try { @@ -1140,7 +1141,7 @@ public void openConfigureQueueRequestFailsTest() { /** Check substreamcount when broker session fails to send close configure queue request */ @Test - public void closeConfigureQueueRequestFailsTest() { + void closeConfigureQueueRequestFailsTest() { TestSession obj = new TestSession(); try { @@ -1225,7 +1226,7 @@ public void closeConfigureQueueRequestFailsTest() { * response */ @Test - public void closeQueueRequestFailsTest() { + void closeQueueRequestFailsTest() { TestSession obj = new TestSession(); try { @@ -1328,7 +1329,7 @@ public void closeQueueRequestFailsTest() { } @Test - public void cancelRequestTest() { + void cancelRequestTest() { class Test { TestSession.QueueTestStep queueTestStep; @@ -1439,7 +1440,7 @@ class Test { obj.connection().setChannelStatus(ChannelStatus.CHANNEL_UP); // Negotiate - obj.sendNegotiationRespose( + obj.sendNegotiationResponse( obj.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); obj.verifySessionEvent(BrokerSessionEvent.Type.e_RECONNECTED); @@ -1492,12 +1493,12 @@ class Test { } @Test - public void testMultipleStartAsync() { + void multipleStartAsync() { final Duration TIMEOUT = Duration.ofSeconds(1); final TestSession testSession = new TestSession(); testSession.session().startAsync(TIMEOUT); - testSession.sendNegotiationRespose( + testSession.sendNegotiationResponse( testSession.verifyNegotiationRequest(), StatusCategory.E_SUCCESS); testSession.verifySessionEvent(BrokerSessionEvent.Type.e_CONNECTED); @@ -1513,7 +1514,7 @@ public void testMultipleStartAsync() { } @Test - public void testMultipleStopAsync() { + void multipleStopAsync() { final Duration TIMEOUT = Duration.ofSeconds(1); final TestSession testSession = new TestSession(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/InboundEventBufferTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/InboundEventBufferTest.java index 0f3e1a9..79e654d 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/InboundEventBufferTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/InboundEventBufferTest.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.SessionOptions; import com.bloomberg.bmq.impl.events.BrokerSessionEvent; @@ -26,11 +26,11 @@ import com.bloomberg.bmq.impl.infr.stat.EventQueueStats; import com.bloomberg.bmq.impl.infr.util.Argument; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class InboundEventBufferTest { +class InboundEventBufferTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -58,7 +58,7 @@ private boolean isSessionEvent(Event ev, BrokerSessionEvent.Type type) { } @Test - public void testErrors() throws InterruptedException { + void testErrors() throws InterruptedException { // Null watermarks object try { new InboundEventBuffer(null, new EventQueueStats()); @@ -115,7 +115,7 @@ public void testErrors() throws InterruptedException { } @Test - public void testWatermarkEvents() throws InterruptedException { + void testWatermarkEvents() throws InterruptedException { InboundEventBuffer b = new InboundEventBuffer( new SessionOptions.InboundEventBufferWaterMark(0, 1), @@ -160,7 +160,7 @@ public void testWatermarkEvents() throws InterruptedException { } @Test - public void testPollAfterDumpFinalStats() throws InterruptedException { + void testPollAfterDumpFinalStats() throws InterruptedException { EventQueueStats stats = new EventQueueStats(); InboundEventBuffer b = diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/ProtocolEventImplTcpReaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/ProtocolEventImplTcpReaderTest.java index f6a3bb2..7801c23 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/ProtocolEventImplTcpReaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/ProtocolEventImplTcpReaderTest.java @@ -15,9 +15,9 @@ */ package com.bloomberg.bmq.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; @@ -45,11 +45,11 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ProtocolEventImplTcpReaderTest { +class ProtocolEventImplTcpReaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -71,7 +71,7 @@ private ByteBuffer[] buildPushMessage(boolean isOldStyleProperties) throws IOExc } @Test - public void testIODump() throws IOException, InterruptedException { + void testIODump() throws IOException, InterruptedException { logger.info("========================================================"); logger.info("BEGIN Testing ProtocolEventImplTcpReaderTest testIODump."); logger.info("========================================================"); @@ -193,7 +193,7 @@ public void testIODump() throws IOException, InterruptedException { } @Test - public void testPartialReading() throws IOException { + void testPartialReading() throws IOException { // Check that ProtocolEventTcpReader correctly reads BlazingMQ events // even if incoming buffer contains partial EventImpl header or body. diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/PutPosterTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/PutPosterTest.java index 363102b..918eb11 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/PutPosterTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/PutPosterTest.java @@ -15,10 +15,11 @@ */ package com.bloomberg.bmq.impl; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyBoolean; import static org.mockito.Mockito.mock; @@ -50,16 +51,16 @@ import java.util.concurrent.Future; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PutPosterTest { +class PutPosterTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testConstructor() { + void testConstructor() { try { new PutPoster(null, null); fail(); // Should not get here @@ -86,7 +87,7 @@ public void testConstructor() { } @Test - public void testPostEmptyArray() { + void testPostEmptyArray() { BrokerConnection mockedConnection = mock(BrokerConnection.class); PutPoster poster = new PutPoster(mockedConnection, new EventsStats()); @@ -118,7 +119,7 @@ public void testPostEmptyArray() { } @Test - public void testPostFailed() throws IOException { + void testPostFailed() throws IOException { BrokerConnection mockedConnection = mock(BrokerConnection.class); PutPoster poster = new PutPoster(mockedConnection, new EventsStats()); @@ -159,7 +160,7 @@ public void testPostFailed() throws IOException { } @Test - public void testPostValidMessages() throws IOException { + void testPostValidMessages() throws IOException { for (boolean isOldStyleProperties : new boolean[] {false, true}) { BrokerConnection mockedConnection = mock(BrokerConnection.class); when(mockedConnection.isOldStyleMessageProperties()).thenReturn(isOldStyleProperties); @@ -248,8 +249,8 @@ public void testPostValidMessages() throws IOException { assertArrayEquals(data2, allData.get(1)); // Verify second argument - assertEquals(true, allBooleans.get(0)); - assertEquals(true, allBooleans.get(1)); + assertTrue(allBooleans.get(0)); + assertTrue(allBooleans.get(1)); StringBuilder expectedBuilder = new StringBuilder(); EventsStatsTest.dump(expectedStats, expectedBuilder, false); @@ -266,8 +267,7 @@ public void testPostValidMessages() throws IOException { } @Test - public void testPostNoInfiniteLoop() - throws IOException, TimeoutException, InterruptedException { + void testPostNoInfiniteLoop() throws IOException, TimeoutException, InterruptedException { for (boolean isOldStyleProperties : new boolean[] {false, true}) { BrokerConnection connection = mock(BrokerConnection.class); @@ -312,7 +312,7 @@ public void testPostNoInfiniteLoop() } @Test - public void testRegisterAck() throws Exception { + void testRegisterAck() throws Exception { for (boolean isOldStyleProperties : new boolean[] {false, true}) { BrokerConnection connection = mock(BrokerConnection.class); when(connection.isOldStyleMessageProperties()).thenReturn(isOldStyleProperties); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/QueueManagerTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/QueueManagerTest.java index 1ffc7b3..4506efd 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/QueueManagerTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/QueueManagerTest.java @@ -15,16 +15,16 @@ */ package com.bloomberg.bmq.impl; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +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; import static org.mockito.Mockito.mock; import com.bloomberg.bmq.Uri; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -71,7 +71,7 @@ static QueueImpl createQueue(BrokerSession session, Uri uri, long flags) { * */ @Test - public void insertActiveQueueTest() { + void insertActiveQueueTest() { logger.info("=================================================================="); logger.info("BEGIN Testing QueueManager insertActiveQueueTest."); logger.info("=================================================================="); @@ -124,7 +124,7 @@ public void insertActiveQueueTest() { * */ @Test - public void removeActiveQueueTest() { + void removeActiveQueueTest() { logger.info("=================================================================="); logger.info("BEGIN Testing QueueManager removeActiveQueueTest."); logger.info("=================================================================="); @@ -187,7 +187,7 @@ public void removeActiveQueueTest() { * */ @Test - public void insertExpiredQueueTest() { + void insertExpiredQueueTest() { logger.info("=================================================================="); logger.info("BEGIN Testing QueueManager insertExpiredQueueTest."); logger.info("=================================================================="); @@ -236,7 +236,7 @@ public void insertExpiredQueueTest() { * */ @Test - public void removeExpiredQueueTest() { + void removeExpiredQueueTest() { logger.info("=================================================================="); logger.info("BEGIN Testing QueueManager removeExpiredQueueTest."); logger.info("=================================================================="); @@ -295,7 +295,7 @@ public void removeExpiredQueueTest() { * */ @Test - public void subStreamCountTest() { + void subStreamCountTest() { logger.info("=============================================="); logger.info("BEGIN Testing QueueManager subStreamCountTest."); logger.info("=============================================="); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/codec/JsonDecoderUtilTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/codec/JsonDecoderUtilTest.java index 5a57a65..ba21746 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/codec/JsonDecoderUtilTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/codec/JsonDecoderUtilTest.java @@ -15,12 +15,12 @@ */ package com.bloomberg.bmq.impl.infr.codec; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +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; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.msg.BrokerResponse; @@ -41,16 +41,16 @@ import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class JsonDecoderUtilTest { +class JsonDecoderUtilTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testDecodeClientIdentity() throws IOException { + void testDecodeClientIdentity() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.CLIENT_IDENTITY_JSON.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -87,7 +87,7 @@ public void testDecodeClientIdentity() throws IOException { } @Test - public void testDecodeBrokerResponse() throws IOException { + void testDecodeBrokerResponse() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.BROKER_RESPONSE_JSON.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -131,7 +131,7 @@ public void testDecodeBrokerResponse() throws IOException { } @Test - public void testDecodeOpenQueue() throws IOException { + void testDecodeOpenQueue() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.OPEN_QUEUE_JSON.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -166,7 +166,7 @@ public void testDecodeOpenQueue() throws IOException { } @Test - public void testDecodeOpenQueueResponse() throws IOException { + void testDecodeOpenQueueResponse() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.OPEN_QUEUE_RESPONSE_JSON.filePath()); @@ -206,7 +206,7 @@ public void testDecodeOpenQueueResponse() throws IOException { } @Test - public void testDecodeStatus() throws IOException { + void testDecodeStatus() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.STATUS_MSG_JSON.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -232,7 +232,7 @@ public void testDecodeStatus() throws IOException { } @Test - public void testDecodeFromJsonFail() { + void testDecodeFromJsonFail() { JsonDecoderUtil.decodeFromJson("\"test_string\"", String.class); try { JsonDecoderUtil.decodeFromJson("\"test_string", String.class); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/ByteBufferInputStreamTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/ByteBufferInputStreamTest.java index 1b2bddf..386ac96 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/ByteBufferInputStreamTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/ByteBufferInputStreamTest.java @@ -15,22 +15,22 @@ */ package com.bloomberg.bmq.impl.infr.io; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ByteBufferInputStreamTest { +class ByteBufferInputStreamTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testEmpty() { + void testEmpty() { ByteBuffer buf = ByteBuffer.allocate(0); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); assertEquals(0, bbis.available()); @@ -50,7 +50,7 @@ public void testEmpty() { } @Test - public void testReadByte() throws IOException { + void testReadByte() throws IOException { ByteBuffer buf = ByteBuffer.allocate(1); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); assertEquals(1, bbis.available()); @@ -68,7 +68,7 @@ public void testReadByte() throws IOException { } @Test - public void testReadBytes() throws IOException { + void testReadBytes() throws IOException { ByteBuffer buf1 = ByteBuffer.allocate(1); ByteBuffer buf2 = ByteBuffer.allocate(1); buf1.put((byte) 'A').rewind(); @@ -94,7 +94,7 @@ public void testReadBytes() throws IOException { } @Test - public void testSkipBytes() throws IOException { + void testSkipBytes() throws IOException { ByteBuffer buf1 = ByteBuffer.allocate(1); ByteBuffer buf2 = ByteBuffer.allocate(1); buf1.put((byte) 'A').rewind(); @@ -127,7 +127,7 @@ public void testSkipBytes() throws IOException { } @Test - public void testReadType() throws IOException { + void testReadType() throws IOException { ByteBuffer buf1 = ByteBuffer.allocate(1); ByteBuffer buf2 = ByteBuffer.allocate(1); buf1.put((byte) 1).rewind(); @@ -152,7 +152,7 @@ public void testReadType() throws IOException { } @Test - public void testRead() throws IOException { + void testRead() throws IOException { ByteBuffer buf1 = ByteBuffer.allocate(1); ByteBuffer buf2 = ByteBuffer.allocate(1); buf1.put((byte) 1).rewind(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/LimitedInputStreamTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/LimitedInputStreamTest.java index 4fe752e..e87dd58 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/LimitedInputStreamTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/io/LimitedInputStreamTest.java @@ -15,22 +15,22 @@ */ package com.bloomberg.bmq.impl.infr.io; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import java.io.IOException; import java.io.InputStream; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class LimitedInputStreamTest { +class LimitedInputStreamTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testConstructor() throws IOException { + void testConstructor() throws IOException { InputStream source = null; try { @@ -67,7 +67,7 @@ public void testConstructor() throws IOException { } @Test - public void testReadEmptyStream() throws IOException { + void testReadEmptyStream() throws IOException { InputStream source = new ByteBufferInputStream(ByteBuffer.allocate(0)); LimitedInputStream stream = new LimitedInputStream(source, 0); @@ -81,7 +81,7 @@ public void testReadEmptyStream() throws IOException { } @Test - public void testReadLimitedStream() throws IOException { + void testReadLimitedStream() throws IOException { byte[] content = new byte[] {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; InputStream source = new ByteBufferInputStream(ByteBuffer.wrap(content)); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueResponseTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueResponseTest.java index 4f0f2bd..6b8d154 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueResponseTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueResponseTest.java @@ -15,16 +15,16 @@ */ package com.bloomberg.bmq.impl.infr.msg; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class OpenQueueResponseTest { +class OpenQueueResponseTest { @Test - public void testReset() { + void testReset() { OpenQueueResponse openQueueResponse = new OpenQueueResponse(); assertNull(openQueueResponse.getOriginalRequest()); assertNull(openQueueResponse.getRoutingConfiguration()); @@ -38,7 +38,7 @@ public void testReset() { } @Test - public void testCreateNewInstance() { + void testCreateNewInstance() { OpenQueueResponse openQueueResponse = new OpenQueueResponse(); OpenQueueResponse responseBefore = openQueueResponse; openQueueResponse = (OpenQueueResponse) openQueueResponse.createNewInstance(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueTest.java index 528301d..20b30e1 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/msg/OpenQueueTest.java @@ -15,14 +15,14 @@ */ package com.bloomberg.bmq.impl.infr.msg; -import static org.junit.Assert.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class OpenQueueTest { +class OpenQueueTest { @Test - public void testReset() { + void testReset() { OpenQueue openQueue = new OpenQueue(); QueueHandleParameters parametersBefore = openQueue.getHandleParameters(); openQueue.reset(); @@ -31,7 +31,7 @@ public void testReset() { } @Test - public void testCreateNewInstance() { + void testCreateNewInstance() { OpenQueue openQueue = new OpenQueue(); OpenQueue queueBefore = openQueue; openQueue = (OpenQueue) openQueue.createNewInstance(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NetResolverTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NetResolverTest.java index aa95543..df5b644 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NetResolverTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NetResolverTest.java @@ -15,26 +15,26 @@ */ package com.bloomberg.bmq.impl.infr.net; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +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; +import static org.junit.jupiter.api.Assertions.fail; import java.lang.invoke.MethodHandles; import java.net.URI; import java.net.URISyntaxException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class NetResolverTest { +class NetResolverTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testValidHosts() { + void testValidHosts() { NetResolver nr = new NetResolver(); URI uri = nr.getNextUri(); @@ -70,7 +70,7 @@ public void testValidHosts() { } @Test - public void testInvalidHosts() { + void testInvalidHosts() { NetResolver nr = new NetResolver(); @@ -93,7 +93,7 @@ public void testInvalidHosts() { } @Test - public void testUnknownHost() throws URISyntaxException, InterruptedException { + void testUnknownHost() throws URISyntaxException { NetResolver nr = new NetResolver(); assertFalse(nr.isUnknownHost()); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NettyTcpConnectionTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NettyTcpConnectionTest.java index d8e1341..8faf216 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NettyTcpConnectionTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/net/NettyTcpConnectionTest.java @@ -15,13 +15,13 @@ */ package com.bloomberg.bmq.impl.infr.net; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.SessionOptions; import com.bloomberg.bmq.impl.infr.net.intf.ChannelStatusHandler; @@ -52,7 +52,8 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -383,7 +384,7 @@ public void readWriteTest(Boolean isAsync) { } @Test - public void testReadWriteSync() { + void testReadWriteSync() { logger.info("======================================================="); logger.info("Testing NettyTcpConnection read/write in sync mode."); logger.info("======================================================="); @@ -391,7 +392,7 @@ public void testReadWriteSync() { } @Test - public void testReadWriteAsync() { + void testReadWriteAsync() { logger.info("======================================================="); logger.info("Testing NettyTcpConnection read/write in async mode."); logger.info("======================================================="); @@ -449,7 +450,7 @@ public void testConnectDisconnectNoServer(Boolean isAsync) { } @Test - public void testConnectDisconnectNoServerAsync() { + void testConnectDisconnectNoServerAsync() { logger.info("============================================================"); logger.info("Testing NettyTcpConnection without server in async mode."); logger.info("============================================================"); @@ -457,7 +458,7 @@ public void testConnectDisconnectNoServerAsync() { } @Test - public void testConnectDisconnectNoServerSync() { + void testConnectDisconnectNoServerSync() { logger.info("==========================================================="); logger.info("Testing NettyTcpConnection without server in sync mode."); logger.info("==========================================================="); @@ -509,7 +510,7 @@ public void testConnectDisconnectWithServer(Boolean isAsync) { } @Test - public void testConnectDisconnectWithServerAsync() { + void testConnectDisconnectWithServerAsync() { logger.info("========================================================="); logger.info("Testing NettyTcpConnection with server in async mode."); logger.info("========================================================="); @@ -517,7 +518,7 @@ public void testConnectDisconnectWithServerAsync() { } @Test - public void testConnectDisconnectWithServerSync() { + void testConnectDisconnectWithServerSync() { logger.info("========================================================"); logger.info("Testing NettyTcpConnection with server in sync mode."); logger.info("========================================================"); @@ -525,7 +526,7 @@ public void testConnectDisconnectWithServerSync() { } @Test - public void testConnectDisconnectWithIntermittentServer() { + void testConnectDisconnectWithIntermittentServer() { logger.info("======================================================="); logger.info("Testing NettyTcpConnection with intermittent server."); logger.info("======================================================="); @@ -578,7 +579,7 @@ public void testConnectDisconnectWithIntermittentServer() { } @Test - public void testDisconnectWhileConnectionInProgress() { + void testDisconnectWhileConnectionInProgress() { logger.info("=========================================="); logger.info("Testing NettyTcpConnection disconnect."); @@ -631,7 +632,8 @@ public void testDisconnectWhileConnectionInProgress() { assertEquals(0, obj.linger()); } - // @Test + @Test + @Disabled public void testChannelWaterMark() { // ==================================================================== @@ -737,8 +739,9 @@ public void testChannelWaterMark() { assertEquals(0, obj.linger()); } - // @Test - public void testChannelWritable() { + @Test + @Disabled + void testChannelWritable() { // ==================================================================== // DISABLED_TEST @@ -826,8 +829,9 @@ public void testChannelWritable() { assertEquals(0, obj.linger()); } - // @Test - public void testChannelWaterMarkSlowServer() { + @Test + @Disabled + void testChannelWaterMarkSlowServer() { // ==================================================================== // DISABLED_TEST @@ -930,10 +934,10 @@ public void testChannelWaterMarkSlowServer() { } @Test - public void testCompositeBuffer() { - // 1) In a child thread put 4 strigns into netty ByteBufs and add them into + void testCompositeBuffer() { + // 1) In a child thread put 4 strings into netty ByteBufs and add them into // CompositeByteBuf. - // 2) Store interal NIO buffers, clean related ByteBufs + // 2) Store internal NIO buffers, clean related ByteBufs // 3) In a main thread check content of the NIO buffers. logger.info("============================================="); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckEventImplBuilderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckEventImplBuilderTest.java index ba7f350..422eddb 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckEventImplBuilderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckEventImplBuilderTest.java @@ -15,7 +15,7 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.impl.CorrelationIdImpl; @@ -25,16 +25,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AckEventImplBuilderTest { +class AckEventImplBuilderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testErrorMessages() throws IOException { + void testErrorMessages() throws IOException { EventBuilderResult res; AckEventBuilder builder = new AckEventBuilder(); AckMessageImpl message = new AckMessageImpl(); @@ -53,7 +53,7 @@ public void testErrorMessages() throws IOException { } @Test - public void testBuildAckMessage() throws IOException { + void testBuildAckMessage() throws IOException { String GUID = "0000000000003039CD8101000000270F"; // Above hex string represents a valid guid with these values: // TS = 12345 diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckHeaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckHeaderTest.java index b857455..c6e65cb 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckHeaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckHeaderTest.java @@ -15,9 +15,9 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.msg.MessagesTestSamples; @@ -25,16 +25,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AckHeaderTest { +class AckHeaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testStreamIn() { + void testStreamIn() { try { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.ACK_MSG.filePath()); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckMessageIteratorTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckMessageIteratorTest.java index 817ddf8..a832c18 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckMessageIteratorTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/AckMessageIteratorTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.impl.CorrelationIdImpl; @@ -27,16 +27,16 @@ import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; import java.util.Iterator; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class AckMessageIteratorTest { +class AckMessageIteratorTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testWithPattern() throws IOException { + void testWithPattern() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.ACK_MSG.filePath()); AckEventImpl ackEvent = new AckEventImpl(new ByteBuffer[] {buf}); @@ -70,7 +70,7 @@ public void testWithPattern() throws IOException { } @Test - public void testWithBuilder() throws IOException { + void testWithBuilder() throws IOException { String GUID = "0000000000003039CD8101000000270F"; final int NUM_MSGS = 1000; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ApplicationDataTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ApplicationDataTest.java index e40aa1f..b713eee 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ApplicationDataTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ApplicationDataTest.java @@ -15,14 +15,14 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +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.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; @@ -34,7 +34,7 @@ import java.util.Iterator; import java.util.Map; import java.util.zip.ZipException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,7 +44,7 @@ public class ApplicationDataTest { static final double THRESHOLD = 0.0001; @Test - public void testEmpty() throws IOException { + void testEmpty() throws IOException { ApplicationData appData = new ApplicationData(); assertEquals(0, appData.payloadSize()); @@ -61,7 +61,7 @@ public void testEmpty() throws IOException { } @Test - public void testStreamOut() throws IOException { + void testStreamOut() throws IOException { for (ByteBuffer[] payload : new ByteBuffer[][] {null, generatePayload(0), generatePayload(1024)}) for (MessagePropertiesImpl props : @@ -82,7 +82,7 @@ null, new MessagePropertiesImpl(), generateProps() } @Test - public void testStreamIn() throws IOException { + void testStreamIn() throws IOException { for (ByteBuffer[] payload : new ByteBuffer[][] {null, generatePayload(0), generatePayload(1024)}) for (MessagePropertiesImpl props : @@ -103,7 +103,7 @@ null, new MessagePropertiesImpl(), generateProps() } @Test - public void testStreamInInvalidCompression() throws IOException { + void testStreamInInvalidCompression() throws IOException { ByteBufferOutputStream bbos = new ByteBufferOutputStream(); ByteBuffer[] payload = generatePayload(1024); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/CompressionAlgorithmTypeTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/CompressionAlgorithmTypeTest.java index 6e81dba..be8b037 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/CompressionAlgorithmTypeTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/CompressionAlgorithmTypeTest.java @@ -15,35 +15,33 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.hamcrest.CoreMatchers.instanceOf; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.BMQException; import com.bloomberg.bmq.CompressionAlgorithm; import com.bloomberg.bmq.impl.infr.util.ZlibCompression; import java.util.EnumSet; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class CompressionAlgorithmTypeTest { +class CompressionAlgorithmTypeTest { @Test - public void testToInt() { + void testToInt() { assertEquals(0, CompressionAlgorithmType.E_NONE.toInt()); assertEquals(1, CompressionAlgorithmType.E_ZLIB.toInt()); } @Test - public void testToAlgorithm() { + void testToAlgorithm() { assertEquals(CompressionAlgorithm.None, CompressionAlgorithmType.E_NONE.toAlgorithm()); assertEquals(CompressionAlgorithm.Zlib, CompressionAlgorithmType.E_ZLIB.toAlgorithm()); } @Test - public void testFromInt() { + void testFromInt() { for (CompressionAlgorithmType t : CompressionAlgorithmType.values()) { int i = t.toInt(); assertEquals(t, CompressionAlgorithmType.fromInt(i)); @@ -85,7 +83,7 @@ public void testFromInt() { } @Test - public void testFromAlgorithm() { + void testFromAlgorithm() { Set toCover = EnumSet.allOf(CompressionAlgorithm.class); for (CompressionAlgorithmType t : CompressionAlgorithmType.values()) { @@ -99,7 +97,7 @@ public void testFromAlgorithm() { } @Test - public void testGetCompression() { + void testGetCompression() { try { CompressionAlgorithmType.E_NONE.getCompression(); fail(); // should not get here @@ -107,8 +105,7 @@ public void testGetCompression() { assertEquals("No compression for type 'E_NONE'", e.getMessage()); } - assertThat( - CompressionAlgorithmType.E_ZLIB.getCompression(), - instanceOf(ZlibCompression.class)); + assertEquals( + ZlibCompression.class, CompressionAlgorithmType.E_ZLIB.getCompression().getClass()); } } diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmEventImplBuilderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmEventImplBuilderTest.java index bb8695b..937651b 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmEventImplBuilderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmEventImplBuilderTest.java @@ -15,7 +15,7 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.impl.infr.msg.MessagesTestSamples; @@ -23,16 +23,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ConfirmEventImplBuilderTest { +class ConfirmEventImplBuilderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testErrorMessages() throws IOException { + void testErrorMessages() throws IOException { EventBuilderResult res; ConfirmEventBuilder builder = new ConfirmEventBuilder(); ConfirmMessage message = new ConfirmMessage(); @@ -51,7 +51,7 @@ public void testErrorMessages() throws IOException { } @Test - public void testBuildConfirmMessage() throws IOException { + void testBuildConfirmMessage() throws IOException { String GUID = "0000000000003039CD8101000000270F"; // Above hex string represents a valid guid with these values: // TS = 12345 diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmMessageIteratorTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmMessageIteratorTest.java index ea49c82..ec67cac 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmMessageIteratorTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ConfirmMessageIteratorTest.java @@ -15,22 +15,22 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.bloomberg.bmq.MessageGUID; import java.io.IOException; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ConfirmMessageIteratorTest { +class ConfirmMessageIteratorTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testWithBuilder() throws IOException { + void testWithBuilder() throws IOException { String GUID = "0000000000003039CD8101000000270F"; final int NUM_MSGS = 1000; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/EventImplHeaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/EventImplHeaderTest.java index dfa6584..760554b 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/EventImplHeaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/EventImplHeaderTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; @@ -26,16 +26,16 @@ import java.io.InputStream; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class EventImplHeaderTest { +class EventImplHeaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testStreamIn() throws IOException { + void testStreamIn() throws IOException { try (InputStream is = this.getClass() .getResourceAsStream(MessagesTestSamples.STATUS_MSG_27032018.filePath())) { @@ -69,7 +69,7 @@ public void testStreamIn() throws IOException { } @Test - public void testStreamInFragmented() throws IOException { + void testStreamInFragmented() throws IOException { try (InputStream is = this.getClass() .getResourceAsStream(MessagesTestSamples.STATUS_MSG_FRAGMENT.filePath())) { @@ -103,7 +103,7 @@ public void testStreamInFragmented() throws IOException { } @Test - public void testStreamOut() throws IOException { + void testStreamOut() throws IOException { // Plan: // - Create an EventHeader instance, populate it and stream it out. // - Compare the streamed out representation with the one stored in the @@ -129,7 +129,7 @@ public void testStreamOut() throws IOException { } @Test - public void testGetters() { + void testGetters() { // Ensure that getters on a default constructed EventHeader return // correct values. @@ -143,7 +143,7 @@ public void testGetters() { } @Test - public void testSetters() { + void testSetters() { // Set the maximum values for various fields as allowed by the // EventHeader struct, and ensure that getters return the same values. diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesHeaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesHeaderTest.java index 43ed80b..36e3060 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesHeaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesHeaderTest.java @@ -15,7 +15,7 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.msg.MessagesTestSamples; @@ -23,16 +23,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class MessagePropertiesHeaderTest { +class MessagePropertiesHeaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testWithPattern() throws IOException { + void testWithPattern() throws IOException { class TestData { final String fileName; final int headerSize; @@ -112,7 +112,7 @@ class TestData { } @Test - public void testGettersSetters() { + void testGettersSetters() { MessagePropertiesHeader mph = new MessagePropertiesHeader(); assertEquals(MessagePropertiesHeader.HEADER_SIZE, mph.headerSize()); assertEquals(MessagePropertyHeader.HEADER_SIZE, mph.messagePropertyHeaderSize()); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesTest.java index 53dab82..8194388 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertiesTest.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; @@ -29,16 +29,16 @@ import java.nio.ByteBuffer; import java.util.Iterator; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class MessagePropertiesTest { +class MessagePropertiesTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testWithPattern() throws IOException { + void testWithPattern() throws IOException { class TestData { final MessagesTestSamples.SampleFileMetadata sampleFile; final boolean streamInOld; @@ -172,7 +172,7 @@ class TestData { } @Test - public void testStreamOut() throws IOException { + void testStreamOut() throws IOException { for (boolean isOldStyleProperties : new boolean[] {false, true}) { final boolean BOOL_VAL = true; final byte BYTE_VAL = 2; @@ -295,7 +295,7 @@ public void testStreamOut() throws IOException { } @Test - public void testRemove() { + void testRemove() { MessagePropertiesImpl props = new MessagePropertiesImpl(); props.setPropertyAsInt32("myProp", 123); @@ -311,7 +311,7 @@ public void testRemove() { } @Test - public void testUpdate() { + void testUpdate() { final boolean BOOL_VAL = true; final byte BYTE_VAL = 2; final short SHORT_VAL = 12; @@ -441,7 +441,7 @@ private String constructOutput(PropertyType t, Object v) { } @Test - public void testToString() throws IOException { + void testToString() throws IOException { final boolean BOOL_VAL = true; final byte BYTE_VAL = 2; final short SHORT_VAL = 12; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertyHeaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertyHeaderTest.java index 2681a7c..40bf71c 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertyHeaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/MessagePropertyHeaderTest.java @@ -15,22 +15,22 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; import java.io.IOException; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class MessagePropertyHeaderTest { +class MessagePropertyHeaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testGettersSetters() { + void testGettersSetters() { MessagePropertyHeader mph = new MessagePropertyHeader(); assertEquals(0, mph.propertyType()); assertEquals(0, mph.propertyValueLength()); @@ -56,7 +56,7 @@ public void testGettersSetters() { } @Test - public void testStreamInStreamOut() throws IOException { + void testStreamInStreamOut() throws IOException { final int valueLength = (1 << 26) - 1; // max per protocol final int nameLength = (1 << 12) - 1; // max per protocol diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionHeaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionHeaderTest.java index 1f9a017..7735da9 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionHeaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionHeaderTest.java @@ -15,32 +15,32 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OptionHeaderTest { +class OptionHeaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testPreconditions() { + void testPreconditions() { assertTrue(OptionHeader.HEADER_SIZE > 0); assertTrue(Protocol.WORD_SIZE > 0); assertEquals(0, OptionHeader.HEADER_SIZE % Protocol.WORD_SIZE); } @Test - public void testConstructor() { + void testConstructor() { OptionHeader optionHeader = new OptionHeader(); assertEquals(OptionType.UNDEFINED, optionHeader.type()); @@ -50,7 +50,7 @@ public void testConstructor() { } @Test - public void testGetterSetterType() { + void testGetterSetterType() { OptionHeader optionHeader = new OptionHeader(); for (OptionType t : OptionType.values()) { @@ -64,7 +64,7 @@ public void testGetterSetterType() { } @Test - public void testGetterSetterPacked() { + void testGetterSetterPacked() { OptionHeader optionHeader = new OptionHeader(); optionHeader.setPacked(true); @@ -83,7 +83,7 @@ public void testGetterSetterPacked() { } @Test - public void testGetterSetterTypeSpecific() { + void testGetterSetterTypeSpecific() { OptionHeader optionHeader = new OptionHeader(); // ts < 0 @@ -120,7 +120,7 @@ public void testGetterSetterTypeSpecific() { } @Test - public void testGetterSetterWords() { + void testGetterSetterWords() { OptionHeader optionHeader = new OptionHeader(); // words < 0 @@ -157,7 +157,7 @@ public void testGetterSetterWords() { } @Test - public void testStreamIn() throws IOException { + void testStreamIn() throws IOException { // packed option ByteBuffer bb = ByteBuffer.wrap(new byte[] {0b00001110, 0b00000000, 0b00000000, 0b00000101}); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionsTest.java index 9720367..c0cacef 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/OptionsTest.java @@ -15,25 +15,25 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +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 com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class OptionsTest { +class OptionsTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testStreamInIds() throws IOException { + void testStreamInIds() throws IOException { ByteBuffer bb = ByteBuffer.wrap( new byte[] { @@ -62,7 +62,7 @@ public void testStreamInIds() throws IOException { } @Test - public void testStreamInInfos() throws IOException { + void testStreamInInfos() throws IOException { ByteBuffer bb = ByteBuffer.wrap( new byte[] { @@ -97,7 +97,7 @@ public void testStreamInInfos() throws IOException { } @Test - public void testStreamInInfosIds() throws IOException { + void testStreamInInfosIds() throws IOException { ByteBuffer bb = ByteBuffer.wrap( new byte[] { diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ProtocolUtilTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ProtocolUtilTest.java index 5bcadde..b2997be 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ProtocolUtilTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/ProtocolUtilTest.java @@ -15,14 +15,14 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ProtocolUtilTest { +class ProtocolUtilTest { @Test - public void testPadding() { + void testPadding() { for (int i = 1; i < 5; i++) { byte[] p = ProtocolUtil.getPaddingBytes(i); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplBuilderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplBuilderTest.java index 2bdc517..75d8f90 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplBuilderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplBuilderTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.impl.infr.msg.MessagesTestSamples; @@ -24,16 +24,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PushEventImplBuilderTest { +class PushEventImplBuilderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testPackPushMessage() throws IOException { + void testPackPushMessage() throws IOException { for (boolean isOldStyleProperties : new boolean[] {true, false}) { PushMessageImpl pushMsg = new PushMessageImpl(); PushEventBuilder builder = new PushEventBuilder(); @@ -86,7 +86,7 @@ public void testPackPushMessage() throws IOException { } @Test - public void testBuildPushMessage() throws IOException { + void testBuildPushMessage() throws IOException { final String PAYLOAD = "abcdefghijklmnopqrstuvwxyz"; final String GUID = "ABCDEF0123456789ABCDEF0123456789"; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplTest.java index 549044a..b9a3510 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushEventImplTest.java @@ -15,9 +15,9 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; import com.bloomberg.bmq.impl.intf.SessionEventHandler; @@ -25,16 +25,16 @@ import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; import java.util.EnumSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PushEventImplTest { +class PushEventImplTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testDispatchUnknownCompression() throws IOException { + void testDispatchUnknownCompression() throws IOException { for (boolean isOldStyleProperties : new boolean[] {true, false}) { final byte[] bytes = new byte[Protocol.COMPRESSION_MIN_APPDATA_SIZE + 1]; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderFlagsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderFlagsTest.java index 64925a2..a22d898 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderFlagsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderFlagsTest.java @@ -15,16 +15,16 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.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; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PushHeaderFlagsTest { +class PushHeaderFlagsTest { @Test - public void testFlags() { + void testFlags() { int i = 0; assertFalse(PushHeaderFlags.isSet(i, PushHeaderFlags.IMPLICIT_PAYLOAD)); assertFalse(PushHeaderFlags.isSet(i, PushHeaderFlags.MESSAGE_PROPERTIES)); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderTest.java index 59f1aaf..e4fd570 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushHeaderTest.java @@ -15,7 +15,7 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; @@ -26,11 +26,11 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PushHeaderTest { +class PushHeaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -57,7 +57,7 @@ public class PushHeaderTest { BitUtil.oneMask(HEADER_WORDS_START_IDX, HEADER_WORDS_NUM_BITS); @Test - public void testStreamIn() throws IOException { + void testStreamIn() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.PUSH_MULTI_MSG.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -98,7 +98,7 @@ public void testStreamIn() throws IOException { } @Test - public void testStreamInZlib() throws IOException { + void testStreamInZlib() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.PUSH_MSG_ZLIB.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -127,7 +127,7 @@ public void testStreamInZlib() throws IOException { } @Test - public void testGetterSetterFlags() { + void testGetterSetterFlags() { PushHeader pushHeader = new PushHeader(); int value = Integer.MAX_VALUE; int flagVal = ((value << FLAGS_START_IDX) & FLAGS_MASK) >>> FLAGS_START_IDX; @@ -141,7 +141,7 @@ public void testGetterSetterFlags() { } @Test - public void testGetterSetterHeaderWords() { + void testGetterSetterHeaderWords() { PushHeader pushHeader = new PushHeader(); int value = Integer.MAX_VALUE; int headerWords = value & HEADER_WORDS_MASK; @@ -155,7 +155,7 @@ public void testGetterSetterHeaderWords() { } @Test - public void testGetterSetterMessageWords() { + void testGetterSetterMessageWords() { PushHeader pushHeader = new PushHeader(); int value = Integer.MAX_VALUE; int messageWords = value & MSG_WORDS_MASK; @@ -169,7 +169,7 @@ public void testGetterSetterMessageWords() { } @Test - public void testGetterSetterCompressionType() { + void testGetterSetterCompressionType() { PushHeader pushHeader = new PushHeader(); assertEquals(0, pushHeader.compressionType()); @@ -187,7 +187,7 @@ public void testGetterSetterCompressionType() { } @Test - public void testGetterSetterOptionWords() { + void testGetterSetterOptionWords() { PushHeader pushHeader = new PushHeader(); int value = Integer.MAX_VALUE; int optionsWords = @@ -205,7 +205,7 @@ public void testGetterSetterOptionWords() { } @Test - public void testStreamOut() throws IOException { + void testStreamOut() throws IOException { PushHeader pushHeader = new PushHeader(); pushHeader.setMessageWords(14); @@ -243,7 +243,7 @@ public void testStreamOut() throws IOException { } @Test - public void testStreamOutZlib() throws IOException { + void testStreamOutZlib() throws IOException { PushHeader pushHeader = new PushHeader(); pushHeader.setMessageWords(14); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageImplTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageImplTest.java index 53b403e..17354a6 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageImplTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageImplTest.java @@ -15,14 +15,14 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +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.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.BMQException; import com.bloomberg.bmq.impl.QueueId; @@ -35,16 +35,16 @@ import java.util.EnumSet; import java.util.Iterator; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PushMessageImplTest { +class PushMessageImplTest { static final int HEADER_WORDS = PushHeader.HEADER_SIZE_FOR_SCHEMA_ID / Protocol.WORD_SIZE; static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testStreamIn() throws Exception { + void testStreamIn() throws Exception { final MessagePropertiesImpl validProps = generateProps(); final ByteBuffer[][] payloads = @@ -79,7 +79,7 @@ public void testStreamIn() throws Exception { } @Test - public void testStreamOut() throws Exception { + void testStreamOut() throws Exception { final MessagePropertiesImpl validProps = generateProps(); final ByteBuffer[][] payloads = @@ -116,7 +116,7 @@ public void testStreamOut() throws Exception { } @Test - public void testSubQueueIds() throws IOException { + void testSubQueueIds() throws IOException { byte[] options = new byte[] { 0b00001100, 0b01000000, 0b00000000, 0b00000101, // header @@ -137,7 +137,7 @@ public void testSubQueueIds() throws IOException { } @Test - public void testSubQueueIdsOld() throws IOException { + void testSubQueueIdsOld() throws IOException { byte[] options = new byte[] { 0b00000100, 0b00000000, 0b00000000, 0b00000011, // header @@ -156,7 +156,7 @@ public void testSubQueueIdsOld() throws IOException { } @Test - public void testSubQueueIdsBoth() throws IOException { + void testSubQueueIdsBoth() throws IOException { byte[] options = new byte[] { // New option @@ -182,7 +182,7 @@ public void testSubQueueIdsBoth() throws IOException { } @Test - public void testStreamInUnknownCompression() throws IOException { + void testStreamInUnknownCompression() throws IOException { ByteBufferOutputStream bbos = new ByteBufferOutputStream(); ByteBuffer[] payload = generatePayload(1024); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageIteratorTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageIteratorTest.java index 56de6a3..c27830e 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageIteratorTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PushMessageIteratorTest.java @@ -15,12 +15,12 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +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; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; @@ -33,16 +33,16 @@ import java.util.Iterator; import java.util.Map; import java.util.NoSuchElementException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PushMessageIteratorTest { +class PushMessageIteratorTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testPatternWithOptions() throws IOException { + void testPatternWithOptions() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.PUSH_WITH_SUBQUEUE_IDS_MSG.filePath()); @@ -99,7 +99,7 @@ public void testPatternWithOptions() throws IOException { } @Test - public void testWithPattern() throws IOException { + void testWithPattern() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.PUSH_MULTI_MSG.filePath()); PushEventImpl pushEvent = new PushEventImpl(new ByteBuffer[] {buf}); @@ -181,7 +181,7 @@ public void testWithPattern() throws IOException { } @Test - public void testWithBuilder() throws IOException { + void testWithBuilder() throws IOException { final String PAYLOAD = "abcdefghijklmnopqrstuvwxyz"; final int NUM_MSGS = 1000; final int FLAGS = PushHeaderFlags.setFlag(0, PushHeaderFlags.MESSAGE_PROPERTIES); @@ -277,7 +277,7 @@ public void testWithBuilder() throws IOException { } @Test - public void testMultipleIterators() throws IOException { + void testMultipleIterators() throws IOException { // Verify that two message iterators in single thread mode don't affect each other. // 1. Using a pattern create PUSH event that contains 2 PUSH messages // 2. Create one message iterator and advance it with next() @@ -302,7 +302,7 @@ public void testMultipleIterators() throws IOException { } @Test - public void testMultipleCompressedMessages() throws IOException { + void testMultipleCompressedMessages() throws IOException { final PushEventBuilder builder = new PushEventBuilder(); final byte[] bytes = new byte[Protocol.COMPRESSION_MIN_APPDATA_SIZE + 1]; @@ -363,7 +363,7 @@ public void testMultipleCompressedMessages() throws IOException { } @Test - public void testUnknownCompression() throws IOException { + void testUnknownCompression() throws IOException { for (boolean isOldStyleProperties : new boolean[] {true, false}) { final byte[] bytes = new byte[Protocol.COMPRESSION_MIN_APPDATA_SIZE + 1]; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutEventImplBuilderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutEventImplBuilderTest.java index a423056..288b0d4 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutEventImplBuilderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutEventImplBuilderTest.java @@ -15,9 +15,9 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.bloomberg.bmq.CorrelationId; import com.bloomberg.bmq.impl.CorrelationIdImpl; @@ -26,16 +26,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PutEventImplBuilderTest { +class PutEventImplBuilderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testErrorPutMessage() throws IOException { + void testErrorPutMessage() throws IOException { for (boolean isOldStyleProperties : new boolean[] {false, true}) { PutMessageImpl putMsg = new PutMessageImpl(); PutEventBuilder builder = new PutEventBuilder(); @@ -96,7 +96,7 @@ public void testErrorPutMessage() throws IOException { } @Test - public void testBigPutEvent() throws IOException { + void testBigPutEvent() throws IOException { // Check that ByteBuffer limit is honored when Put event is being built for (boolean isOldStyleProperties : new boolean[] {false, true}) { @@ -132,7 +132,7 @@ public void testBigPutEvent() throws IOException { } @Test - public void testBuildPutMessageWithProperties() throws IOException { + void testBuildPutMessageWithProperties() throws IOException { final String k = "abcdefghijklmnopqrstuvwxyz"; final ByteBuffer b = ByteBuffer.wrap(k.getBytes()); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderFlagsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderFlagsTest.java index 7011b65..a6783bb 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderFlagsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderFlagsTest.java @@ -15,16 +15,16 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.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; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class PutHeaderFlagsTest { +class PutHeaderFlagsTest { @Test - public void testFlags() { + void testFlags() { int i = 0; assertFalse(PutHeaderFlags.isSet(i, PutHeaderFlags.ACK_REQUESTED)); assertFalse(PutHeaderFlags.isSet(i, PutHeaderFlags.MESSAGE_PROPERTIES)); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderTest.java index 78fa836..635da82 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutHeaderTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import com.bloomberg.bmq.CorrelationId; import com.bloomberg.bmq.impl.CorrelationIdImpl; @@ -27,16 +27,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PutHeaderTest { +class PutHeaderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testStreamIn() throws IOException { + void testStreamIn() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.PUT_MULTI_MSG.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -83,7 +83,7 @@ public void testStreamIn() throws IOException { } @Test - public void testStreamInZlib() throws IOException { + void testStreamInZlib() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.PUT_MSG_ZLIB.filePath()); ByteBufferInputStream bbis = new ByteBufferInputStream(buf); @@ -116,7 +116,7 @@ public void testStreamInZlib() throws IOException { } @Test - public void testStreamOut() throws IOException { + void testStreamOut() throws IOException { // Stream out PutHeader putHeader = new PutHeader(); @@ -158,7 +158,7 @@ public void testStreamOut() throws IOException { } @Test - public void testStreamOutZlib() throws IOException { + void testStreamOutZlib() throws IOException { // Stream out PutHeader putHeader = new PutHeader(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageImplTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageImplTest.java index 25e1824..38e89d2 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageImplTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageImplTest.java @@ -15,14 +15,14 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +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.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.BMQException; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; @@ -32,16 +32,16 @@ import java.nio.ByteBuffer; import java.util.Iterator; import java.util.Map; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PutMessageImplTest { +class PutMessageImplTest { static final int HEADER_WORDS = PutHeader.HEADER_SIZE / Protocol.WORD_SIZE; static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testStreamOut() throws Exception { + void testStreamOut() throws Exception { final MessagePropertiesImpl validProps = generateProps(); final ByteBuffer[][] payloads = @@ -78,7 +78,7 @@ public void testStreamOut() throws Exception { } @Test - public void testStreamIn() throws Exception { + void testStreamIn() throws Exception { final MessagePropertiesImpl validProps = generateProps(); final ByteBuffer[][] payloads = diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageIteratorTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageIteratorTest.java index 61f29b0..fc0ff84 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageIteratorTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/PutMessageIteratorTest.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.CorrelationId; import com.bloomberg.bmq.MessageProperties; @@ -30,16 +30,16 @@ import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; import java.util.NoSuchElementException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PutMessageIteratorTest { +class PutMessageIteratorTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testWithPattern() throws IOException { + void testWithPattern() throws IOException { ByteBuffer buf = TestHelpers.readFile(MessagesTestSamples.PUT_MULTI_MSG.filePath()); PutEventImpl putEvent = new PutEventImpl(new ByteBuffer[] {buf}); @@ -127,7 +127,7 @@ public void testWithPattern() throws IOException { } @Test - public void testWithBuilder() throws IOException { + void testWithBuilder() throws IOException { final String PAYLOAD = "abcdefghijklmnopqrstuvwxyz"; final int NUM_MSGS = 1000; final int FLAGS = PutHeaderFlags.setFlag(0, PutHeaderFlags.ACK_REQUESTED); @@ -194,7 +194,7 @@ public void testWithBuilder() throws IOException { } @Test - public void testMultipleIterators() throws IOException { + void testMultipleIterators() throws IOException { // Verify that two message iterators in single thread mode don't affect each other. // 1. Using a pattern create PUT event that contains 2 PUT messages // 2. Create one message iterator and advance it with next() diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/RequestManagerTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/RequestManagerTest.java index 646b555..75303b4 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/RequestManagerTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/RequestManagerTest.java @@ -15,11 +15,11 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.ResultCodes.GenericResult; import com.bloomberg.bmq.impl.infr.msg.ControlMessageChoice; @@ -41,11 +41,11 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class RequestManagerTest { +class RequestManagerTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -173,7 +173,7 @@ public GenericResult write(ByteBuffer[] buffers, boolean waitUntilWritable) { } @Test - public void testCallbackReentrance() { + void testCallbackReentrance() { /* * 1. Send one Request using RequestManager and a test Channel. @@ -209,7 +209,7 @@ public void testCallbackReentrance() { } @Test - public void testRequestTimeout() { + void testRequestTimeout() { /* * 1. Set request timeout duration. * 2. Connect via channel and disable pseudo-server. @@ -245,7 +245,7 @@ public void testRequestTimeout() { } @Test - public void testCancelAllEvents() { + void testCancelAllEvents() { /* * 1. Set request timeout duration. * 2. Connect via channel and disable pseudo-server. @@ -294,7 +294,7 @@ public void testCancelAllEvents() { } @Test - public void testAsyncNotifier() { + void testAsyncNotifier() { channel = new Channel(); eventHandler = new EventHandler(); scheduler = Executors.newSingleThreadScheduledExecutor(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SchemaEventImplBuilderTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SchemaEventImplBuilderTest.java index 72057f1..44f879d 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SchemaEventImplBuilderTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SchemaEventImplBuilderTest.java @@ -15,7 +15,7 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNotNull; import com.bloomberg.bmq.Uri; import com.bloomberg.bmq.impl.infr.msg.BrokerResponse; @@ -35,16 +35,16 @@ import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SchemaEventImplBuilderTest { +class SchemaEventImplBuilderTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testBuildClientIdentityJson() throws IOException { + void testBuildClientIdentityJson() throws IOException { NegotiationMessageChoice negoMsgChoice = new NegotiationMessageChoice(); negoMsgChoice.makeClientIdentity(); @@ -71,7 +71,7 @@ public void testBuildClientIdentityJson() throws IOException { } @Test - public void testBuildBrokerResponseJson() throws IOException { + void testBuildBrokerResponseJson() throws IOException { NegotiationMessageChoice negoMsgChoice = new NegotiationMessageChoice(); negoMsgChoice.makeBrokerResponse(); BrokerResponse br = negoMsgChoice.brokerResponse(); @@ -103,7 +103,7 @@ public void testBuildBrokerResponseJson() throws IOException { } @Test - public void testBuildStatusJson() throws IOException { + void testBuildStatusJson() throws IOException { ControlMessageChoice msgChoice = new ControlMessageChoice(); msgChoice.makeStatus(); @@ -126,7 +126,7 @@ public void testBuildStatusJson() throws IOException { } @Test - public void testBuildOpenQueueJson() throws IOException { + void testBuildOpenQueueJson() throws IOException { ControlMessageChoice msgChoice = new ControlMessageChoice(); msgChoice.makeOpenQueue(); @@ -158,7 +158,7 @@ public void testBuildOpenQueueJson() throws IOException { } @Test - public void testBuildOpenQueueResponseJson() throws IOException { + void testBuildOpenQueueResponseJson() throws IOException { ControlMessageChoice msgChoice = new ControlMessageChoice(); msgChoice.makeOpenQueueResponse(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueIdsOptionTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueIdsOptionTest.java index 8e419d1..c214dc4 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueIdsOptionTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueIdsOptionTest.java @@ -15,24 +15,24 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SubQueueIdsOptionTest { +class SubQueueIdsOptionTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testConstructor() { + void testConstructor() { // Null header try { new SubQueueIdsOption(null); @@ -61,7 +61,7 @@ public void testConstructor() { } @Test - public void testStreamIn() throws IOException { + void testStreamIn() throws IOException { ByteBuffer bb = ByteBuffer.wrap( new byte[] { diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueInfosOptionTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueInfosOptionTest.java index 7dc67e5..05bf73e 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueInfosOptionTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/proto/SubQueueInfosOptionTest.java @@ -15,25 +15,25 @@ */ package com.bloomberg.bmq.impl.infr.proto; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.QueueId; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import java.io.IOException; import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SubQueueInfosOptionTest { +class SubQueueInfosOptionTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testConstructor() { + void testConstructor() { // Null header try { new SubQueueInfosOption(null); @@ -76,7 +76,7 @@ public void testConstructor() { } @Test - public void testStreamIn() throws IOException { + void testStreamIn() throws IOException { ByteBuffer bb = ByteBuffer.wrap( new byte[] { diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/scm/VersionUtilTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/scm/VersionUtilTest.java index bfe73d9..b7c7a9b 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/scm/VersionUtilTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/scm/VersionUtilTest.java @@ -15,32 +15,32 @@ */ package com.bloomberg.bmq.impl.infr.scm; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class VersionUtilTest { +class VersionUtilTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testJarVersion() { + void testJarVersion() { String ver = VersionUtil.getJarVersion(); assertNull(ver); } @Test - public void testSdkVersion() { + void testSdkVersion() { int ver = VersionUtil.getSdkVersion(); assertEquals(999999, ver); // the default version } @Test - public void testVersionStringToInt() { + void testVersionStringToInt() { assertEquals(999999, VersionUtil.versionStringToInt("0.0")); assertEquals(999999, VersionUtil.versionStringToInt("0")); assertEquals(999999, VersionUtil.versionStringToInt("0")); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventQueueStatsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventQueueStatsTest.java index 0c63558..6d8ed01 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventQueueStatsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventQueueStatsTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.stat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.msg.MessagesTestSamples; import com.bloomberg.bmq.util.TestHelpers; @@ -25,16 +25,16 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.time.Duration; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class EventQueueStatsTest { +class EventQueueStatsTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testOnDequeue() { + void testOnDequeue() { EventQueueStats stats = new EventQueueStats(); // Invalid arguments @@ -72,7 +72,7 @@ public void testOnDequeue() { } @Test - public void testEmptyOutput() throws IOException { + void testEmptyOutput() throws IOException { EventQueueStats stats = new EventQueueStats(); StringBuilder builder = new StringBuilder(); @@ -98,7 +98,7 @@ public void testEmptyOutput() throws IOException { } @Test - public void testSampleOutput() throws Exception { + void testSampleOutput() throws Exception { EventQueueStats stats = new EventQueueStats(); // First group of activities diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventsStatsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventsStatsTest.java index 05b8571..c34c0dc 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventsStatsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/EventsStatsTest.java @@ -15,7 +15,7 @@ */ package com.bloomberg.bmq.impl.infr.stat; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.bloomberg.bmq.impl.infr.msg.MessagesTestSamples; import com.bloomberg.bmq.impl.infr.proto.EventType; @@ -27,7 +27,7 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -111,7 +111,7 @@ public static void dump(EventsStats eventsStats, StringBuilder builder, boolean } @Test - public void testEmptyOutput() throws IOException { + void testEmptyOutput() throws IOException { EventsStats stats = new EventsStats(); StringBuilder builder = new StringBuilder(); @@ -137,7 +137,7 @@ public void testEmptyOutput() throws IOException { } @Test - public void testSampleOutput() throws Exception { + void testSampleOutput() throws Exception { EventsStats stats = new EventsStats(); Simulator simulator = new Simulator(stats); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/QueuesStatsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/QueuesStatsTest.java index f21af1d..eef5714 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/QueuesStatsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/QueuesStatsTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.stat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.Uri; import com.bloomberg.bmq.impl.QueueId; @@ -29,11 +29,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class QueuesStatsTest { +class QueuesStatsTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -94,7 +94,7 @@ private void sleep(int ms) { } @Test - public void testOnQueueOpen() { + void testOnQueueOpen() { QueuesStats stats = new QueuesStats(); Uri uri = new Uri("bmq://test/queue"); @@ -133,7 +133,7 @@ public void testOnQueueOpen() { } @Test - public void testOnQueueClose() { + void testOnQueueClose() { QueuesStats stats = new QueuesStats(); // Open queues @@ -167,7 +167,7 @@ public void testOnQueueClose() { } @Test - public void testOnPushMessage() { + void testOnPushMessage() { QueuesStats stats = new QueuesStats(); QueueId queueId1 = QueueId.createInstance(1, 0); @@ -228,7 +228,7 @@ public void testOnPushMessage() { } @Test - public void testOnPutEvent() { + void testOnPutEvent() { QueuesStats stats = new QueuesStats(); QueueId queueId1 = QueueId.createInstance(1, 0); @@ -295,7 +295,7 @@ public void testOnPutEvent() { } @Test - public void testEmptyOutput() throws IOException { + void testEmptyOutput() throws IOException { QueuesStats stats = new QueuesStats(); StringBuilder builder = new StringBuilder(); @@ -321,7 +321,7 @@ public void testEmptyOutput() throws IOException { } @Test - public void testSampleOutput() throws Exception { + void testSampleOutput() throws Exception { QueuesStats stats = new QueuesStats(); Simulator simulator = new Simulator(stats); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsTest.java index 6d0512e..15a1387 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.stat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.any; import static org.mockito.Mockito.anyInt; import static org.mockito.Mockito.eq; @@ -35,18 +35,18 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.mockito.ArgumentCaptor; import org.mockito.InOrder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class StatsTest { +class StatsTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testConstructor() { + void testConstructor() { Consumer emptyConsumer = s -> {}; try { @@ -81,11 +81,11 @@ public void testConstructor() { any(Runnable.class), anyInt(), anyInt(), any(TimeUnit.class)); } - // Non-generic interface to avoid compilator warnings + // Non-generic interface to avoid compilation warnings private interface StringConsumer extends Consumer {} @Test - public void testDump() { + void testDump() { ScheduledExecutorService scheduler = mock(ScheduledExecutorService.class); ArgumentCaptor captor = ArgumentCaptor.forClass(Runnable.class); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsUtilTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsUtilTest.java index 957f7ec..2ad5800 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsUtilTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/stat/StatsUtilTest.java @@ -20,23 +20,23 @@ import static com.bloomberg.bmq.impl.infr.stat.StatsUtil.formatNum; import static com.bloomberg.bmq.impl.infr.stat.StatsUtil.numWidth; import static com.bloomberg.bmq.impl.infr.stat.StatsUtil.repeatCharacter; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.infr.stat.StatsUtil.Format; import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.Collection; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class StatsUtilTest { +class StatsUtilTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testColumnWidth() { + void testColumnWidth() { // Null table try { columnWidth(null, -1, -1, Format.NUM); @@ -83,7 +83,7 @@ public void testColumnWidth() { } @Test - public void testColumnWidthWithSummary() { + void testColumnWidthWithSummary() { // Null summary try { columnWidth(new ArrayList<>(), null, -1, -1, Format.NUM); @@ -123,7 +123,7 @@ public void testColumnWidthWithSummary() { } @Test - public void testFormatCenter() { + void testFormatCenter() { // Null string try { formatCenter(null, 0); @@ -156,7 +156,7 @@ public void testFormatCenter() { } @Test - public void testFormatNum() { + void testFormatNum() { // Negative number try { formatNum(-1, Format.NUM, false); @@ -218,7 +218,7 @@ public void testFormatNum() { } @Test - public void testNumWidth() { + void testNumWidth() { // Negative number try { numWidth(-1, Format.NUM, false); @@ -280,7 +280,7 @@ public void testNumWidth() { } @Test - public void testRepeatCharacter() { + void testRepeatCharacter() { // Null builder try { repeatCharacter(null, 'c', -1); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ArgumentTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ArgumentTest.java index 3b0dcc7..d36372f 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ArgumentTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ArgumentTest.java @@ -15,14 +15,14 @@ */ package com.bloomberg.bmq.impl.infr.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; -import org.junit.Test; +import org.junit.jupiter.api.Test; -public class ArgumentTest { +class ArgumentTest { @Test - public void testExpectPrimitiveInteger() { + void testExpectPrimitiveInteger() { int val1 = 10; assertEquals(10, Argument.expectPositive(val1, "val1")); assertEquals(10, Argument.expectNonNegative(val1, "val1")); @@ -60,7 +60,7 @@ public void testExpectPrimitiveInteger() { } @Test - public void testExpectPrimitiveLong() { + void testExpectPrimitiveLong() { long val1 = 10; assertEquals(10, Argument.expectNonNegative(val1, "val1")); @@ -77,7 +77,7 @@ public void testExpectPrimitiveLong() { } @Test - public void testExpectNonNull() { + void testExpectNonNull() { // empty string is not a null string so the check must be fine assertEquals("", Argument.expectNonNull("", "empty string")); try { @@ -103,7 +103,7 @@ public void testExpectNonNull() { } @Test - public void testExpectCondition() { + void testExpectCondition() { // basic condition checks without extra message components Argument.expectCondition(true); try { diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/SystemUtilTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/SystemUtilTest.java index cac3344..4d2600b 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/SystemUtilTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/SystemUtilTest.java @@ -15,20 +15,20 @@ */ package com.bloomberg.bmq.impl.infr.util; -import static org.junit.Assert.assertNotSame; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertNotSame; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.lang.invoke.MethodHandles; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SystemUtilTest { +class SystemUtilTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testJavaVersions() { + void testJavaVersions() { assertTrue( SystemUtil.JavaVersion.JAVA_UNSUPPORTED.compareTo(SystemUtil.JavaVersion.JAVA_8) < 0); @@ -37,7 +37,7 @@ public void testJavaVersions() { } @Test - public void testVersion() { + void testVersion() { SystemUtil.JavaVersion v = SystemUtil.getJavaVersion(); logger.info("JAVA ver.: {}", v); @@ -46,7 +46,7 @@ public void testVersion() { } @Test - public void testPid() { + void testPid() { int p = SystemUtil.getProcessId(); logger.info("PID: {}", p); @@ -55,12 +55,12 @@ public void testPid() { } @Test - public void testProcName() { + void testProcName() { assertTrue(SystemUtil.getProcessName().length() > 0); } @Test - public void testOsName() { + void testOsName() { logger.info("OS: [{}]", SystemUtil.getOsName()); assertTrue(SystemUtil.getOsName().length() > 0); } diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ZlibCompressionTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ZlibCompressionTest.java index 3d37e8b..7e62f6f 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ZlibCompressionTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/ZlibCompressionTest.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.impl.infr.util; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import com.bloomberg.bmq.impl.infr.io.ByteBufferInputStream; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; @@ -30,11 +30,11 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Base64; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ZlibCompressionTest { +class ZlibCompressionTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); private final String TEXT = @@ -43,7 +43,7 @@ public class ZlibCompressionTest { "eJwLzs9NVSguKcrMS1cozyzJUCgGCZSkVpQoJCbll5aA+SUZIOnEvBQgzi/JSC1C0QETw6opN78oFQBxgiXz"; @Test - public void testCompress() throws IOException { + void testCompress() throws IOException { // Prepare expected data ByteBufferOutputStream bbos = new ByteBufferOutputStream(); @@ -91,7 +91,7 @@ public void testCompress() throws IOException { } @Test - public void testDecompress() throws IOException { + void testDecompress() throws IOException { ZlibCompression compression = new ZlibCompression(); byte[] zipped = Base64.getDecoder().decode(ZIPPED64); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/expressionvalidator/ExpressionValidatorTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/expressionvalidator/ExpressionValidatorTest.java index eab8756..83ae187 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/expressionvalidator/ExpressionValidatorTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/infr/util/expressionvalidator/ExpressionValidatorTest.java @@ -15,26 +15,14 @@ */ package com.bloomberg.bmq.impl.infr.util.expressionvalidator; -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import java.util.Arrays; import java.util.Collection; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; -@RunWith(Parameterized.class) public class ExpressionValidatorTest { - private String inputExpression; - private Boolean expectedResult; - private String expectedErrorMessage; - - public ExpressionValidatorTest( - String inputExpression, Boolean expectedResult, String expectedErrorMessage) { - this.inputExpression = inputExpression; - this.expectedResult = expectedResult; - this.expectedErrorMessage = expectedErrorMessage; - } private static String makeTooManyOperators() { int numOperators = ExpressionValidator.MAX_OPERATORS + 1; @@ -44,7 +32,6 @@ private static String makeTooManyOperators() { return builder.toString(); } - @Parameterized.Parameters public static Collection testArguments() { return Arrays.asList( new Object[][] { @@ -345,8 +332,11 @@ public static Collection testArguments() { }); } - @Test - public void testExpressionValidator() throws java.io.IOException { + @MethodSource("testArguments") + @ParameterizedTest + public void testExpressionValidator( + String inputExpression, Boolean expectedResult, String expectedErrorMessage) + throws java.io.IOException { try (java.io.Reader expression = new java.io.StringReader(inputExpression)) { ValidationResult result = ExpressionValidator.validate(expression); assertEquals(result.isSuccess(), expectedResult); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/intf/BrokerConnectionFSMTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/intf/BrokerConnectionFSMTest.java index 16465a0..53e4008 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/intf/BrokerConnectionFSMTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/impl/intf/BrokerConnectionFSMTest.java @@ -15,16 +15,16 @@ */ package com.bloomberg.bmq.impl.intf; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.impl.BrokerConnectionFSMImpl; import com.bloomberg.bmq.impl.intf.BrokerConnectionFSM.Inputs; import com.bloomberg.bmq.impl.intf.BrokerConnectionFSM.States; import java.lang.invoke.MethodHandles; import java.util.TreeSet; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +35,7 @@ public class BrokerConnectionFSMTest { static final int[][] transitions = BrokerConnectionFSMImpl.transitionTable(); @Test - public void testTransitions() { + void testTransitions() { // Check that transition table contains only existed states and each // state is reachable. @@ -68,7 +68,7 @@ States getState(States initState, Inputs signal) { return States.fromInt(idx); } - public void testStopped() { + private void testStopped() { // Check transitions fom the STOPPED state States initState = States.STOPPED; int[] transitions = BrokerConnectionFSMTest.transitions[initState.ordinal()]; @@ -88,7 +88,7 @@ public void testStopped() { } } - public void testDisconnectingBroker() { + private void testDisconnectingBroker() { // Check transitions fom the DISCONNECTING_BROKER state States initState = States.DISCONNECTING_BROKER; int[] transitions = BrokerConnectionFSMTest.transitions[initState.ordinal()]; @@ -113,7 +113,7 @@ public void testDisconnectingBroker() { } } - public void testDisconnectingChannel() { + private void testDisconnectingChannel() { // Check transitions fom the DISCONNECTING_CHANNEL state States initState = States.DISCONNECTING_CHANNEL; int[] transitions = BrokerConnectionFSMTest.transitions[initState.ordinal()]; @@ -137,7 +137,7 @@ public void testDisconnectingChannel() { } } - public void testConnectionLost() { + private void testConnectionLost() { // Check transitions fom the CONNECTION_LOST state States initState = States.CONNECTION_LOST; int[] transitions = BrokerConnectionFSMTest.transitions[initState.ordinal()]; @@ -164,7 +164,7 @@ public void testConnectionLost() { } } - public void testConnecting() { + private void testConnecting() { // Check transitions fom the CONNECTING state States initState = States.CONNECTING; int[] transitions = BrokerConnectionFSMTest.transitions[initState.ordinal()]; @@ -194,7 +194,7 @@ public void testConnecting() { } } - public void testNegotiating() { + private void testNegotiating() { // Check transitions fom the NEGOTIATING state States initState = States.NEGOTIATING; int[] transitions = BrokerConnectionFSMTest.transitions[initState.ordinal()]; @@ -222,7 +222,7 @@ public void testNegotiating() { } } - public void testConnected() { + private void testConnected() { // Check transitions fom the CONNECTED state States initState = States.CONNECTED; int[] transitions = BrokerConnectionFSMTest.transitions[initState.ordinal()]; @@ -246,7 +246,7 @@ public void testConnected() { } @Test - public void testStates() { + void testStates() { for (States s : States.values()) { switch (s) { case CONNECTION_LOST: diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionIT.java index 5491968..84f19e1 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionIT.java @@ -15,12 +15,12 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +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; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -86,7 +86,8 @@ import java.util.concurrent.SynchronousQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -189,11 +190,11 @@ private static void verifyQueueControlEvent( QueueHandle queue) { assertNotNull(event); assertTrue( + event instanceof QueueControlEvent, "Expected 'QueueControlEvent', received '" + event.getClass().getName() + "': " - + event, - event instanceof QueueControlEvent); + + event); QueueControlEvent queueControlEvent = (QueueControlEvent) event; assertEquals(eventType, queueControlEvent.getEventType()); @@ -204,11 +205,11 @@ private static void verifyQueueControlEvent( private static void verifyBrokerSessionEvent(Event event, BrokerSessionEvent.Type eventType) { assertNotNull(event); assertTrue( + event instanceof BrokerSessionEvent, "Expected 'BrokerSessionEvent', received '" + event.getClass().getName() + "': " - + event, - event instanceof BrokerSessionEvent); + + event); BrokerSessionEvent brokerSessionEvent = (BrokerSessionEvent) event; assertEquals(eventType, brokerSessionEvent.getEventType()); @@ -239,7 +240,7 @@ private static QueueOptions mergeOptions(QueueOptions... optionsArray) { * */ @Test - public void openConfigureCloseQueueAsyncTest() { + void openConfigureCloseQueueAsyncTest() { logger.info("================================================================="); logger.info("BEGIN Testing BrokerSessionIT openConfigureCloseQueueAsyncTest."); logger.info("================================================================="); @@ -290,7 +291,7 @@ public void openConfigureCloseQueueAsyncTest() { assertEquals(1, events.size()); Event event = events.pollLast(); assertNotNull(event); - assertEquals(event.getClass(), QueueControlEvent.class); + assertEquals(QueueControlEvent.class, event.getClass()); QueueControlEvent queueControlEvent = (QueueControlEvent) event; assertEquals( QueueControlEvent.Type.e_QUEUE_OPEN_RESULT, queueControlEvent.getEventType()); @@ -307,7 +308,7 @@ public void openConfigureCloseQueueAsyncTest() { assertEquals(1, events.size()); event = events.pollLast(); assertNotNull(event); - assertEquals(event.getClass(), QueueControlEvent.class); + assertEquals(QueueControlEvent.class, event.getClass()); queueControlEvent = (QueueControlEvent) event; assertEquals( QueueControlEvent.Type.e_QUEUE_CONFIGURE_RESULT, @@ -325,7 +326,7 @@ public void openConfigureCloseQueueAsyncTest() { assertEquals(1, events.size()); event = events.pollLast(); assertNotNull(event); - assertEquals(event.getClass(), QueueControlEvent.class); + assertEquals(QueueControlEvent.class, event.getClass()); queueControlEvent = (QueueControlEvent) event; assertEquals( QueueControlEvent.Type.e_QUEUE_CLOSE_RESULT, queueControlEvent.getEventType()); @@ -370,7 +371,7 @@ public void openConfigureCloseQueueAsyncTest() { * */ @Test - public void openConfigureCloseQueueTest() { + void openConfigureCloseQueueTest() { logger.info("============================================================"); logger.info("BEGIN Testing BrokerSessionIT openConfigureCloseQueueTest."); logger.info("============================================================"); @@ -471,7 +472,7 @@ public void openConfigureCloseQueueTest() { * */ @Test - public void pushMessageTest() throws IOException { + void pushMessageTest() throws IOException { logger.info("============================================================"); logger.info("BEGIN Testing BrokerSessionIT openConfigureCloseQueueTest."); logger.info("============================================================"); @@ -547,7 +548,7 @@ public void pushMessageTest() throws IOException { * */ @Test - public void queueConfigureNotSupported() { + void queueConfigureNotSupported() { logger.info("==========================================================="); logger.info("BEGIN Testing BrokerSessionIT queueConfigureNotSupported."); logger.info("==========================================================="); @@ -613,7 +614,7 @@ public void queueConfigureNotSupported() { * */ @Test - public void queueOpenAlreadyInProgress() { + void queueOpenAlreadyInProgress() { logger.info("==========================================================="); logger.info("BEGIN Testing BrokerSessionIT queueOpenAlreadyInProgress."); logger.info("==========================================================="); @@ -672,7 +673,7 @@ public void queueOpenAlreadyInProgress() { * */ @Test - public void startSessionTimeoutTest() { + void startSessionTimeoutTest() { logger.info("========================================================"); logger.info("BEGIN Testing BrokerSessionIT startSessionTimeoutTest."); @@ -718,7 +719,7 @@ public void startSessionTimeoutTest() { * */ @Test - public void openQueueTimeoutTest() { + void openQueueTimeoutTest() { logger.info("==================================================="); logger.info("BEGIN Testing BrokerSessionIT openQueueTimeoutTest."); @@ -814,7 +815,7 @@ public void openQueueTimeoutTest() { * */ @Test - public void openQueueConfigureTimeoutTest() { + void openQueueConfigureTimeoutTest() { logger.info("============================================================"); logger.info("BEGIN Testing BrokerSessionIT openQueueConfigureTimeoutTest."); @@ -920,7 +921,7 @@ public void openQueueConfigureTimeoutTest() { * */ @Test - public void openQueueConfigureCanceledTest() { + void openQueueConfigureCanceledTest() { logger.info("============================================================="); logger.info("BEGIN Testing BrokerSessionIT openQueueConfigureCanceledTest."); @@ -1044,7 +1045,7 @@ public void openQueueConfigureCanceledTest() { * */ @Test - public void closeQueueConfigurationFailedTest() { + void closeQueueConfigurationFailedTest() { logger.info("=================================================================="); logger.info("BEGIN Testing BrokerSessionIT closeQueueConfigurationFailedTest."); logger.info("=================================================================="); @@ -1154,7 +1155,7 @@ public void closeQueueConfigurationFailedTest() { * */ @Test - public void closeQueueConfigurationTimeoutTest() { + void closeQueueConfigurationTimeoutTest() { logger.info("================================================================="); logger.info("BEGIN Testing BrokerSessionIT closeQueueConfigurationTimeoutTest."); logger.info("================================================================="); @@ -1276,7 +1277,7 @@ public void closeQueueConfigurationTimeoutTest() { * */ @Test - public void closeQueueConfigurationCanceledTest() { + void closeQueueConfigurationCanceledTest() { logger.info("=================================================================="); logger.info("BEGIN Testing BrokerSessionIT closeQueueConfigurationCanceledTest."); logger.info("=================================================================="); @@ -1408,7 +1409,7 @@ public void closeQueueConfigurationCanceledTest() { * */ @Test - public void sequenceTimeoutTest() { + void sequenceTimeoutTest() { logger.info("============================================================"); logger.info("BEGIN Testing BrokerSessionIT sequenceTimeoutTest."); logger.info("============================================================"); @@ -1516,7 +1517,7 @@ public void sequenceTimeoutTest() { * */ @Test - public void lateOpenQueueResponseTest() { + void lateOpenQueueResponseTest() { logger.info("============================================================"); logger.info("BEGIN Testing BrokerSessionIT lateOpenQueueResponseTest."); logger.info("============================================================"); @@ -1683,7 +1684,7 @@ public void lateOpenQueueResponseTest() { * */ @Test - public void lateConfigureOpenQueueResponseTest() { + void lateConfigureOpenQueueResponseTest() { logger.info("==================================================================="); logger.info("BEGIN Testing BrokerSessionIT lateConfigureOpenQueueResponseTest."); logger.info("==================================================================="); @@ -1846,7 +1847,7 @@ public void lateConfigureOpenQueueResponseTest() { * */ @Test - public void lateStandaloneConfigureResponseTest() { + void lateStandaloneConfigureResponseTest() { logger.info("==================================================================="); logger.info("BEGIN Testing BrokerSessionIT lateStandaloneConfigureResponseTest."); logger.info("==================================================================="); @@ -1990,7 +1991,7 @@ public void lateStandaloneConfigureResponseTest() { * */ @Test - public void lateCloseQueueConfigureResponseTest() { + void lateCloseQueueConfigureResponseTest() { logger.info("==================================================================="); logger.info("BEGIN Testing BrokerSessionIT lateCloseQueueConfigureResponseTest."); logger.info("==================================================================="); @@ -2409,7 +2410,7 @@ private void reOpenQueueTest(int numberOfQueuesOpened) { } @Test - public void stateRestoredWithoutQueuesTest() { + void stateRestoredWithoutQueuesTest() { logger.info("==============================================================="); logger.info("BEGIN Testing BrokerSessionIT stateRestoredWithoutQueuesTest."); logger.info("==============================================================="); @@ -2420,7 +2421,7 @@ public void stateRestoredWithoutQueuesTest() { } @Test - public void multipleQueuesReopenTest() { + void multipleQueuesReopenTest() { logger.info("========================================================="); logger.info("BEGIN Testing BrokerSessionIT multipleQueuesReopenTest."); logger.info("========================================================="); @@ -2447,7 +2448,7 @@ public void multipleQueuesReopenTest() { * */ @Test - public void closeQueueOnStoppedSession() { + void closeQueueOnStoppedSession() { logger.info("==========================================================="); logger.info("BEGIN Testing BrokerSessionIT closeQueueOnStoppedSession."); logger.info("==========================================================="); @@ -2538,7 +2539,7 @@ public void closeQueueOnStoppedSession() { * */ @Test - public void closeQueuePreconditionFailures() { + void closeQueuePreconditionFailures() { logger.info("==============================================================="); logger.info("BEGIN Testing BrokerSessionIT closeQueuePreconditionFailures."); logger.info("==============================================================="); @@ -2688,9 +2689,9 @@ public void closeQueuePreconditionFailures() { *
  • stop and linger broker session and stop server * */ - // Temporarily disable this test - // Until achieved more stable repeatability on slow hosts - // @Test + @Test + @Disabled( + "Temporarily disable this test until achieved more stable repeatability on slow hosts") public void closeQueueOnPendingConfigureRequest() { logger.info("=================================================================="); logger.info("BEGIN Testing BrokerSessionIT closeQueueOnPendingConfigureRequest."); @@ -2893,7 +2894,7 @@ public void closeQueueOnPendingConfigureRequest() { * */ @Test - public void closeQueueOnDeferredResumeRequest() { + void closeQueueOnDeferredResumeRequest() { logger.info("================================================================"); logger.info("BEGIN Testing BrokerSessionIT closeQueueOnDeferredResumeRequest."); logger.info("================================================================"); @@ -3011,7 +3012,7 @@ public void closeQueueOnDeferredResumeRequest() { * */ @Test - public void configureQueuePreconditionFailures() { + void configureQueuePreconditionFailures() { logger.info("==================================================================="); logger.info("BEGIN Testing BrokerSessionIT configureQueuePreconditionFailures."); logger.info("==================================================================="); @@ -3153,7 +3154,7 @@ public void configureQueuePreconditionFailures() { * */ @Test - public void configureSuspendedQueue() throws ExecutionException, InterruptedException { + void configureSuspendedQueue() throws ExecutionException, InterruptedException { logger.info("======================================================"); logger.info("BEGIN Testing BrokerSessionIT configureSuspendedQueue."); logger.info("======================================================"); @@ -3506,7 +3507,7 @@ private void addEvent(Event event) { * */ @Test - public void configureOptionsAndParameters() throws ExecutionException, InterruptedException { + void configureOptionsAndParameters() throws ExecutionException, InterruptedException { logger.info("======================================================"); logger.info("BEGIN Testing BrokerSessionIT configureOptionsAndParameters."); logger.info("======================================================"); @@ -3899,7 +3900,7 @@ public void handleQueueEvent(QueueControlEvent event) { * */ @Test - public void queueOpenErrorTest() throws BMQException { + void queueOpenErrorTest() throws BMQException { logger.info("================================================"); logger.info("BEGIN Testing BrokerSessionIT queueOpenErrorTest"); logger.info("================================================"); @@ -3973,7 +3974,7 @@ public void queueOpenErrorTest() throws BMQException { assertEquals(1, events.size()); Event event = events.pollLast(); assertNotNull(event); - assertEquals(event.getClass(), QueueControlEvent.class); + assertEquals(QueueControlEvent.class, event.getClass()); QueueControlEvent queueControlEvent = (QueueControlEvent) event; @@ -4005,7 +4006,7 @@ public void queueOpenErrorTest() throws BMQException { assertEquals(1, events.size()); event = events.pollLast(); assertNotNull(event); - assertEquals(event.getClass(), QueueControlEvent.class); + assertEquals(QueueControlEvent.class, event.getClass()); queueControlEvent = (QueueControlEvent) event; @@ -4051,7 +4052,7 @@ public void queueOpenErrorTest() throws BMQException { * */ @Test - public void openCloseMultipleSubqueuesTest() { + void openCloseMultipleSubqueuesTest() { logger.info("============================================================"); logger.info("BEGIN Testing BrokerSessionIT openCloseMultipleSubqueuesTest"); logger.info("============================================================"); @@ -4581,7 +4582,7 @@ public void openCloseMultipleSubqueuesTest() { * */ @Test - public void sessionStopTest() throws ExecutionException, InterruptedException { + void sessionStopTest() throws ExecutionException, InterruptedException { logger.info("=============================================="); logger.info("BEGIN Testing BrokerSessionIT sessionStopTest."); logger.info("=============================================="); @@ -4784,7 +4785,7 @@ public void sessionStopTest() throws ExecutionException, InterruptedException { * */ @Test - public void sessionStopNullTimeoutTest() { + void sessionStopNullTimeoutTest() { logger.info("========================================================="); logger.info("BEGIN Testing BrokerSessionIT sessionStopNullTimeoutTest."); logger.info("========================================================="); @@ -4864,7 +4865,7 @@ public void sessionStopNullTimeoutTest() { * */ @Test - public void sessionStopAsyncTest() throws IOException { + void sessionStopAsyncTest() throws IOException { logger.info("==================================================="); logger.info("BEGIN Testing BrokerSessionIT sessionStopAsyncTest."); logger.info("==================================================="); @@ -5054,7 +5055,7 @@ public void sessionStopAsyncTest() throws IOException { * */ @Test - public void sessionStopAsyncNullTimeoutTest() { + void sessionStopAsyncNullTimeoutTest() { logger.info("=============================================================="); logger.info("BEGIN Testing BrokerSessionIT sessionStopAsyncNullTimeoutTest."); logger.info("=============================================================="); @@ -5138,7 +5139,7 @@ public void sessionStopAsyncNullTimeoutTest() { * */ @Test - public void sessionStopTimeoutTest() { + void sessionStopTimeoutTest() { logger.info("====================================================="); logger.info("BEGIN Testing BrokerSessionIT sessionStopTimeoutTest."); logger.info("====================================================="); @@ -5221,7 +5222,7 @@ public void sessionStopTimeoutTest() { * */ @Test - public void sessionStopAsyncTimeoutTest() { + void sessionStopAsyncTimeoutTest() { logger.info("=========================================================="); logger.info("BEGIN Testing BrokerSessionIT sessionStopAsyncTimeoutTest."); logger.info("=========================================================="); @@ -5320,7 +5321,7 @@ public void sessionStopAsyncTimeoutTest() { * */ @Test - public void sessionStopInProgressTest() { + void sessionStopInProgressTest() { logger.info("========================================================"); logger.info("BEGIN Testing BrokerSessionIT sessionStopInProgressTest."); logger.info("========================================================"); @@ -5409,7 +5410,7 @@ public void sessionStopInProgressTest() { * */ @Test - public void sessionStopAsyncInProgressTest() { + void sessionStopAsyncInProgressTest() { logger.info("============================================================="); logger.info("BEGIN Testing BrokerSessionIT sessionStopAsyncInProgressTest."); logger.info("============================================================="); @@ -5511,7 +5512,7 @@ public void sessionStopAsyncInProgressTest() { * */ @Test - public void inboundWatermarksTest() throws TimeoutException, InterruptedException { + void inboundWatermarksTest() throws TimeoutException, InterruptedException { logger.info("===================================================="); logger.info("BEGIN Testing BrokerSessionIT inboundWatermarksTest."); logger.info("===================================================="); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionStressIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionStressIT.java index 3666b24..ab59b7e 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionStressIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/BrokerSessionStressIT.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.BMQException; import com.bloomberg.bmq.QueueFlags; @@ -58,11 +58,11 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class BrokerSessionStressIT { +class BrokerSessionStressIT { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -265,7 +265,7 @@ public void validate() { assertNotNull(data); // Check ACK status - assertEquals(ackMsg.status(), ResultCodes.AckResult.SUCCESS); + assertEquals(ResultCodes.AckResult.SUCCESS, ackMsg.status()); // Check Correlation IDs assertEquals(putMsg.correlationId(), ackMsg.correlationId()); @@ -277,7 +277,7 @@ public void validate() { if (reader.getSubQueueId() != SubQueueIdInfo.DEFAULT_SUB_ID) { Integer[] subQueueIds = pshMsg.subQueueIds(); assertNotNull(subQueueIds); - assertEquals(subQueueIds.length, 1); + assertEquals(1, subQueueIds.length); assertTrue(reader.getSubscriptionIdMap().containsKey(subQueueIds[0])); } @@ -391,7 +391,7 @@ void testThroughput(int payloadSize, int numMsgs, int numPutsPerEvent, boolean w } @Test - public void testMultipleEvents() throws IOException { + void testMultipleEvents() throws IOException { // Send multiple PUT messages each with unique payload via native Broker, // receive related PUSH messages from the queue, verify the payload. @@ -413,7 +413,7 @@ public void testMultipleEvents() throws IOException { } @Test - public void testMultipleEventsNoPushWait() throws IOException { + void testMultipleEventsNoPushWait() throws IOException { // Send multiple PUT messages each with unique payload via native Broker, // waiting only for related ACK messages. // Receive related PUSH messages from the queue, verify the payload. @@ -466,7 +466,7 @@ void startStopSession(SessionOptions so) { } @Test - public void testMultipleSessionStartStop() throws IOException { + void testMultipleSessionStartStop() throws IOException { logger.info("==========================================="); logger.info("BEGIN Testing testMultipleSessionStartStop."); @@ -516,7 +516,7 @@ public void testMultipleSessionStartStop() throws IOException { } @Test - public void testBigEvent() throws IOException { + void testBigEvent() throws IOException { // Send a single PUT messages with a big payload via native Broker, // receive related PUSH message from the queue, verify the payload. @@ -538,7 +538,7 @@ public void testBigEvent() throws IOException { } @Test - public void testFanoutThroughput() throws IOException { + void testFanoutThroughput() throws IOException { // Send multiple PUT messages each with unique payload via native Broker, // receive related PUSH messages from the queue, verify the payload. diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyConsumerIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyConsumerIT.java index 6c4a696..7937b79 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyConsumerIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyConsumerIT.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.QueueFlags; import com.bloomberg.bmq.QueueOptions; @@ -48,7 +48,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.Semaphore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -140,7 +140,7 @@ public static ByteBuffer[] getLastMessage(SessionOptions sesOpts, Uri uri, boole } @Test - public void testConsumer() throws IOException { + void testConsumer() throws IOException { logger.info("===================================================================="); logger.info("BEGIN Testing NettyConsumerIT getting message from the BlazingMQ Broker."); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyProducerIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyProducerIT.java index debc6f9..557fd9d 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyProducerIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyProducerIT.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.QueueFlags; import com.bloomberg.bmq.QueueOptions; @@ -42,7 +42,7 @@ import java.util.LinkedList; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -117,7 +117,7 @@ public static void sendMessage( } @Test - public void testProducer() throws IOException { + void testProducer() throws IOException { logger.info("=================================================="); logger.info("BEGIN Testing NettyProducerIT sending a message."); logger.info("=================================================="); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyTcpConnectionImplIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyTcpConnectionImplIT.java index fa06104..cc124e4 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyTcpConnectionImplIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/NettyTcpConnectionImplIT.java @@ -15,12 +15,12 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.SessionOptions; import com.bloomberg.bmq.SessionOptions.WriteBufferWaterMark; @@ -49,7 +49,7 @@ import java.time.Duration; import java.util.ArrayList; import java.util.concurrent.Semaphore; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -168,7 +168,7 @@ TestTcpServer getServer(int port, boolean echoMode) { } @Test - public void testConnectDisconnectNoServer() { + void testConnectDisconnectNoServer() { logger.info("================================================"); logger.info("BEGIN Testing NettyTcpConnection without server."); @@ -224,7 +224,7 @@ public void testConnectDisconnectNoServer() { } @Test - public void testConnectDisconnectWithServer() { + void testConnectDisconnectWithServer() { logger.info("============================================="); logger.info("BEGIN Testing NettyTcpConnection with server."); @@ -297,7 +297,7 @@ public void testConnectDisconnectWithServer() { } @Test - public void testConnectDropReconnect() { + void testConnectDropReconnect() { logger.info("========================================================"); logger.info("BEGIN Testing NettyTcpConnection Connect-Drop-Reconnect."); @@ -396,7 +396,7 @@ public void testConnectDropReconnect() { } @Test - public void testConnectDisconnectWithIntermittentServer() { + void testConnectDisconnectWithIntermittentServer() { logger.info("=========================================================="); logger.info("BEGIN Testing NettyTcpConnection with intermittent server."); @@ -482,7 +482,7 @@ public void testConnectDisconnectWithIntermittentServer() { } @Test - public void testDisconnectWhileConnectionInProgress() { + void testDisconnectWhileConnectionInProgress() { logger.info("============================================"); logger.info("BEGIN Testing NettyTcpConnection disconnect."); @@ -544,7 +544,7 @@ public void testDisconnectWhileConnectionInProgress() { } @Test - public void testReadWrite() { + void testReadWrite() { logger.info("============================================"); logger.info("BEGIN Testing NettyTcpConnection read/write."); @@ -645,7 +645,7 @@ public void testReadWrite() { } @Test - public void testChannelWaterMark() { + void testChannelWaterMark() { logger.info("===================================================="); logger.info("BEGIN Testing NettyTcpConnection channel water mark."); @@ -765,7 +765,7 @@ public void testChannelWaterMark() { } @Test - public void testChannelWritable() { + void testChannelWritable() { logger.info("========================================================="); logger.info("BEGIN Testing NettyTcpConnection channel writable status."); @@ -866,7 +866,7 @@ public void testChannelWritable() { } @Test - public void testChannelWaterMarkSlowServer() { + void testChannelWaterMarkSlowServer() { logger.info("================================================================"); logger.info("BEGIN Testing NettyTcpConnection channel water mark slow server."); @@ -980,7 +980,7 @@ public void testChannelWaterMarkSlowServer() { } @Test - public void testBmqServer() throws IOException { + void testBmqServer() throws IOException { logger.info("======================================================================"); logger.info("BEGIN Testing NettyTcpConnection channel and connection to BlazingMQ Broker."); logger.info("======================================================================"); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PayloadIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PayloadIT.java index 7a67660..d74521e 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PayloadIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PayloadIT.java @@ -15,9 +15,9 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +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 com.bloomberg.bmq.SessionOptions; import com.bloomberg.bmq.Uri; @@ -28,16 +28,16 @@ import java.lang.invoke.MethodHandles; import java.nio.ByteBuffer; import java.util.Arrays; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class PayloadIT { +class PayloadIT { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @Test - public void testPayloadNetty() throws IOException { + void testPayloadNetty() throws IOException { // This is a complex test where a test payload is sent via Producer and // is received via Consumer. It is expected that the incoming payload // should contain the initial message together with two message diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainConsumerIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainConsumerIT.java index 15e6676..820d064 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainConsumerIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainConsumerIT.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; +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 com.bloomberg.bmq.QueueFlags; import com.bloomberg.bmq.Uri; @@ -55,6 +55,8 @@ import java.nio.channels.SocketChannel; import java.util.Iterator; import java.util.Map; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -311,7 +313,7 @@ public static ByteBuffer[] getLastMessage(int port, Uri uri) MessagePropertiesImpl props = pushMsg.appData().properties(); if (props != null) { // We expect 2 properties in the message. - assertEquals(props.numProperties(), 2); + assertEquals(2, props.numProperties()); // Note that per contract, order of message properties is // undefined. @@ -528,9 +530,8 @@ public static ByteBuffer[] getLastMessage(int port, Uri uri) return msg; } - // Disable this test because it uses plain sockets and read BMQ - // events unreliably - // @Test + @Test + @Disabled("Disable this test because it uses plain sockets and read BMQ events unreliably") public void testConsumer() throws IOException, InterruptedException { logger.info("===================================================================="); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainProducerIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainProducerIT.java index cdaeef8..09024f5 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainProducerIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/PlainProducerIT.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.QueueFlags; import com.bloomberg.bmq.Uri; @@ -56,6 +56,8 @@ import java.nio.ByteBuffer; import java.nio.channels.SocketChannel; import java.util.Iterator; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -271,7 +273,7 @@ public static void sendMessage( PutEventBuilder putBuilder = new PutEventBuilder(); EventBuilderResult res = putBuilder.packMessage(putMsg, isOldStyleProperties); - assertSame(res, EventBuilderResult.SUCCESS); + assertSame(EventBuilderResult.SUCCESS, res); message = putBuilder.build(); @@ -423,9 +425,8 @@ public static void sendMessage( schannel.close(); } - // Disable this test because it uses plain sockets and read BMQ - // events unreliably - // @Test + @Test + @Disabled("Disable this test because it uses plain sockets and read BMQ events unreliably") public void testProducer() throws IOException, InterruptedException { logger.info("=================================================="); logger.info("BEGIN Testing PlainProducerIT sending a message."); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionIT.java index 6274301..ed092f3 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionIT.java @@ -15,13 +15,13 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +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; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.AbstractSession; import com.bloomberg.bmq.AckMessage; @@ -81,7 +81,8 @@ import java.util.concurrent.Semaphore; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -502,7 +503,7 @@ private static void verifyQueueControlEvent( } @Test - public void testConnectionDown() throws BMQException, IOException { + void testConnectionDown() throws BMQException, IOException { logger.info("==========================================================="); logger.info("BEGIN Testing SessionIT connection down."); @@ -565,7 +566,7 @@ public void testConnectionDown() throws BMQException, IOException { } @Test - public void testAsyncConnection() throws BMQException, IOException { + void testAsyncConnection() throws BMQException, IOException { logger.info("================================================"); logger.info("BEGIN Testing SessionIT async connection."); @@ -628,7 +629,7 @@ public void testAsyncConnection() throws BMQException, IOException { } @Test - public void testQueueRestored() throws BMQException, IOException { + void testQueueRestored() throws BMQException, IOException { logger.info("=============================================="); logger.info("BEGIN Testing SessionIT queue restored."); @@ -730,7 +731,7 @@ public void testQueueRestored() throws BMQException, IOException { } @Test - public void testQueueReadAndConfirm() throws BMQException, IOException { + void testQueueReadAndConfirm() throws BMQException, IOException { logger.info("======================================================="); logger.info("BEGIN Testing SessionIT testQueueReadAndConfirm."); @@ -837,7 +838,7 @@ public void testQueueReadAndConfirm() throws BMQException, IOException { * */ @Test - public void openConfigureCloseQueueAsyncTest() throws BMQException { + void openConfigureCloseQueueAsyncTest() throws BMQException { logger.info("================================================================="); logger.info("BEGIN Testing SessionIT openConfigureCloseQueueAsyncTest."); logger.info("================================================================="); @@ -1215,7 +1216,7 @@ private void openQueueHostHeathChangesTest( /** Tests for opening insensitive queue when host health changes */ @Test - public void openInsensitiveQueueHostHeathChangesTest() throws BMQException { + void openInsensitiveQueueHostHeathChangesTest() throws BMQException { // For insensitive queues, there should be no suspend/resume requests // and QUEUE_SUSPENDED/QUEUE_RESUMED events. @@ -1231,7 +1232,7 @@ public void openInsensitiveQueueHostHeathChangesTest() throws BMQException { /** Tests for opening sensitive queue when host health changes */ @Test - public void openSensitiveQueueHostHeathChangesTest() throws BMQException { + void openSensitiveQueueHostHeathChangesTest() throws BMQException { // Sensitive queue, open before changing host health. // When opening queue in healthy state, open and open configure // requests should be sent. @@ -1287,7 +1288,7 @@ public void openSensitiveQueueHostHeathChangesTest() throws BMQException { * */ @Test - public void openConfigureCloseQueueAsyncNullHandlerTest() { + void openConfigureCloseQueueAsyncNullHandlerTest() { logger.info("===================================================================="); logger.info("BEGIN Testing SessionIT openConfigureCloseQueueAsyncNullHandlerTest."); logger.info("===================================================================="); @@ -1402,7 +1403,7 @@ public void openConfigureCloseQueueAsyncNullHandlerTest() { * */ @Test - public void openConfigureCloseQueueTest() throws BMQException { + void openConfigureCloseQueueTest() throws BMQException { logger.info("============================================================"); logger.info("BEGIN Testing SessionIT openConfigureCloseQueueTest."); logger.info("============================================================"); @@ -1467,7 +1468,7 @@ public void openConfigureCloseQueueTest() throws BMQException { * */ @Test - public void openHealthSensitiveQueueNullHandlerTest() { + void openHealthSensitiveQueueNullHandlerTest() { logger.info("===================================================================="); logger.info("BEGIN Testing SessionIT openConfigureCloseQueueAsyncNullHandlerTest."); logger.info("===================================================================="); @@ -1562,7 +1563,7 @@ public void openHealthSensitiveQueueNullHandlerTest() { * */ @Test - public void queueOpenErrorTest() throws BMQException { + void queueOpenErrorTest() throws BMQException { logger.info("=========================================="); logger.info("BEGIN Testing SessionIT queueOpenErrorTest"); logger.info("=========================================="); @@ -1656,12 +1657,13 @@ public void queueOpenErrorTest() throws BMQException { *
  • stop session * */ - // Disable this test for 2 reasons: - // - API misses convenient setters for Options, and it's not possible to override - // the default subQueueId of the mocked PushMessageImpl - // - we don't expose subscription id in Queue, and we need it to mock PushMessageImpl - // @Test - public void pushMessageTest() throws BMQException, IOException { + @Test + @Disabled( + "Disable this test for 2 reasons:\n" + + "- API misses convenient setters for Options, and it's not possible to override " + + " the default subQueueId of the mocked PushMessageImpl\n" + + "- we don't expose subscription id in Queue, and we need it to mock PushMessageImpl") + void pushMessageTest() throws BMQException, IOException { logger.info("==============================================="); logger.info("BEGIN Testing SessionIT pushMessageTest."); logger.info("==============================================="); @@ -1731,7 +1733,7 @@ public void pushMessageTest() throws BMQException, IOException { * */ @Test - public void queueConfigureNotSupported() throws BMQException { + void queueConfigureNotSupported() throws BMQException { logger.info("==========================================================="); logger.info("BEGIN Testing SessionIT queueConfigureNotSupported."); logger.info("==========================================================="); @@ -1789,7 +1791,7 @@ public void queueConfigureNotSupported() throws BMQException { * */ @Test - public void queueOpenAlreadyInProgress() throws BMQException { + void queueOpenAlreadyInProgress() throws BMQException { logger.info("==========================================================="); logger.info("BEGIN Testing SessionIT queueOpenAlreadyInProgress."); logger.info("==========================================================="); @@ -1841,7 +1843,7 @@ public void queueOpenAlreadyInProgress() throws BMQException { * */ @Test - public void startSessionTimeoutTest() throws BMQException { + void startSessionTimeoutTest() throws BMQException { logger.info("========================================================"); logger.info("BEGIN Testing SessionIT startSessionTimeoutTest."); @@ -1886,7 +1888,7 @@ public void startSessionTimeoutTest() throws BMQException { * */ @Test - public void openQueueTimeoutTest() throws BMQException { + void openQueueTimeoutTest() throws BMQException { logger.info("====================================================="); logger.info("BEGIN Testing SessionIT openQueueTimeoutTest."); @@ -1953,7 +1955,7 @@ public void openQueueTimeoutTest() throws BMQException { * */ @Test - public void openWriteQueueAppIdTest() throws BMQException { + void openWriteQueueAppIdTest() throws BMQException { logger.info("================================================"); logger.info("BEGIN Testing SessionIT openWriteQueueAppIdTest."); @@ -2032,7 +2034,7 @@ public void openWriteQueueAppIdTest() throws BMQException { * */ @Test - public void openQueueConfigureTimeoutTest() throws BMQException { + void openQueueConfigureTimeoutTest() throws BMQException { logger.info("======================================================"); logger.info("BEGIN Testing SessionIT openQueueConfigureTimeoutTest."); @@ -2110,7 +2112,7 @@ public void openQueueConfigureTimeoutTest() throws BMQException { * */ @Test - public void closeQueueConfigurationFailedTest() throws BMQException { + void closeQueueConfigurationFailedTest() throws BMQException { logger.info("=================================================================="); logger.info("BEGIN Testing SessionIT closeQueueConfigurationFailedTest."); logger.info("=================================================================="); @@ -2192,7 +2194,7 @@ public void closeQueueConfigurationFailedTest() throws BMQException { * */ @Test - public void closeQueueConfigurationTimeoutTest() { + void closeQueueConfigurationTimeoutTest() { logger.info("==========================================================="); logger.info("BEGIN Testing SessionIT closeQueueConfigurationTimeoutTest."); logger.info("==========================================================="); @@ -2299,10 +2301,10 @@ public void closeQueueConfigurationTimeoutTest() { *
  • stop and linger broker session and stop server * */ - // Temporarily disable this test - // Until achieved more stable repeatability on slow hosts - // @Test - public void closeQueueOnPendingConfigureRequest() { + @Test + @Disabled( + "Temporarily disable this test until achieved more stable repeatability on slow hosts") + void closeQueueOnPendingConfigureRequest() { logger.info("============================================================"); logger.info("BEGIN Testing SessionIT closeQueueOnPendingConfigureRequest."); logger.info("============================================================"); @@ -2499,7 +2501,7 @@ public void closeQueueOnPendingConfigureRequest() { * */ @Test - public void closeQueueOnDeferredResumeRequest() { + void closeQueueOnDeferredResumeRequest() { logger.info("=========================================================="); logger.info("BEGIN Testing SessionIT closeQueueOnDeferredResumeRequest."); logger.info("=========================================================="); @@ -2593,7 +2595,7 @@ public void closeQueueOnDeferredResumeRequest() { * */ @Test - public void sequenceTimeoutTest() throws BMQException { + void sequenceTimeoutTest() throws BMQException { logger.info("============================================================"); logger.info("BEGIN Testing SessionIT sequenceTimeoutTest."); logger.info("============================================================"); @@ -2655,7 +2657,7 @@ public void sequenceTimeoutTest() throws BMQException { } @Test - public void testQueueFlush() throws BMQException, IOException { + void testQueueFlush() throws BMQException, IOException { logger.info("=============================================="); logger.info("BEGIN Testing SessionIT testQueueFlush."); @@ -2746,7 +2748,7 @@ void getPushAndConfirm(TestSession session, Uri uri) { } @Test - public void testQueueAck() throws BMQException, IOException { + void testQueueAck() throws BMQException, IOException { logger.info("====================================="); logger.info("BEGIN Testing SessionIT testQueueAck."); @@ -2843,7 +2845,7 @@ public void testQueueAck() throws BMQException, IOException { } @Test - public void testPushProperties() throws BMQException, IOException { + void testPushProperties() throws BMQException, IOException { logger.info("==========================================="); logger.info("BEGIN Testing SessionIT testPushProperties."); @@ -2997,7 +2999,7 @@ public void testPushProperties() throws BMQException, IOException { boolFound = true; assertEquals(MessageProperty.Type.BOOL, type); - assertEquals(true, value); + assertTrue((Boolean) value); assertEquals(String.format(strPattern, true), str); break; case "byte": @@ -3077,7 +3079,7 @@ public void testPushProperties() throws BMQException, IOException { } @Test - public void testQueueCompression() throws BMQException, IOException { + void testQueueCompression() throws BMQException, IOException { logger.info("============================================="); logger.info("BEGIN Testing SessionIT testQueueCompression."); @@ -3233,7 +3235,7 @@ private static SessionEvent getEvent(LinkedBlockingQueue queue) { } @Test - public void testBadSessionEventHandler() throws Exception { + void testBadSessionEventHandler() throws Exception { // 1) Bring up the broker. // 2) Create a Session with a special SessionEventHandler that throws // 3) Invoke session 'startAsync' and verify incoming StartStatus event @@ -3308,7 +3310,7 @@ public void testBadSessionEventHandler() throws Exception { } @Test - public void testQueueFlushRestored() throws BMQException, IOException { + void testQueueFlushRestored() throws BMQException, IOException { logger.info("=============================================="); logger.info("BEGIN Testing SessionIT queue flush restored."); @@ -3440,7 +3442,7 @@ public void testQueueFlushRestored() throws BMQException, IOException { } @Test - public void testQueueFlushDown() throws Exception { + void testQueueFlushDown() throws Exception { logger.info("=============================================="); logger.info("BEGIN Testing SessionIT queue flush down."); @@ -3665,7 +3667,7 @@ private void verifyNakMessages( } @Test - public void testQueueClose() throws BMQException, IOException { + void queueClose() throws BMQException, IOException { logger.info("======================================="); logger.info("BEGIN Testing SessionIT testQueueClose."); @@ -3750,17 +3752,17 @@ public void testQueueClose() throws BMQException, IOException { *
  • start broker simulator in auto mode *
  • create session *
  • start session - *
  • create and open subqueues asyncronously + *
  • create and open subqueues asynchronously *
  • check that proper events were handled by user-defined user handler *
  • check that proper requests were sent - *
  • close subqueues asyncronously + *
  • close subqueues asynchronously *
  • check that proper events were handled by user-defined user handler *
  • check that proper requests were sent *
  • stop session * */ @Test - public void openCloseMultipleSubqueuesTest() throws BMQException { + void openCloseMultipleSubqueuesTest() throws BMQException { logger.info("======================================================="); logger.info("BEGIN Testing SessionIT openCloseMultipleSubqueuesTest."); logger.info("======================================================="); @@ -4088,7 +4090,7 @@ private void testCompleteHealthTransitions(HostHealthState initState) throws IOE } @Test - public void testCompleteHealthTransitions() throws IOException { + void testCompleteHealthTransitions() throws IOException { // Test complete health transitions when monitor provides null state // during first session start. Since null values are ignored, default // health state (Healthy) should be used instead. @@ -4148,7 +4150,7 @@ public void testCompleteHealthTransitions() throws IOException { * */ @Test - public void testIncompleteHealthTransitions() { + void testIncompleteHealthTransitions() { logger.info("========================================================"); logger.info("BEGIN Testing SessionIT testIncompleteHealthTransitions."); logger.info("========================================================"); @@ -4390,7 +4392,7 @@ public void testIncompleteHealthTransitions() { * */ @Test - public void testHealthChangesOnConnectionLost() { + void testHealthChangesOnConnectionLost() { logger.info("========================================================="); logger.info("BEGIN Testing SessionIT testHealthChangesOnConnectionLost"); logger.info("========================================================="); @@ -4553,7 +4555,7 @@ public void testHealthChangesOnConnectionLost() { * */ @Test - public void configureSuspendedQueue() { + void configureSuspendedQueue() { logger.info("================================================"); logger.info("BEGIN Testing SessionIT configureSuspendedQueue."); logger.info("================================================"); @@ -4736,7 +4738,7 @@ public void configureSuspendedQueue() { * */ @Test - public void reconfigureHostHealthSensitivity() { + void reconfigureHostHealthSensitivity() { logger.info("========================================================="); logger.info("BEGIN Testing SessionIT reconfigureHostHealthSensitivity."); logger.info("========================================================="); @@ -4971,7 +4973,7 @@ public void reconfigureHostHealthSensitivity() { * */ @Test - public void reconfigureHostHealthSensitivityErrors() { + void reconfigureHostHealthSensitivityErrors() { logger.info("==============================================================="); logger.info("BEGIN Testing SessionIT reconfigureHostHealthSensitivityErrors."); logger.info("==============================================================="); @@ -5284,7 +5286,7 @@ private void verifyPutsAreBlocked(TestSession session, Queue queue) { * */ @Test - public void putBlockUnblock() throws IOException { + void putBlockUnblock() throws IOException { logger.info("========================================"); logger.info("BEGIN Testing SessionIT putBlockUnblock."); logger.info("========================================"); @@ -5483,7 +5485,7 @@ public void putBlockUnblock() throws IOException { * */ @Test - public void errorHealthResponse() { + void errorHealthResponse() { logger.info("============================================"); logger.info("BEGIN Testing SessionIT errorHealthResponse."); logger.info("============================================"); @@ -5795,7 +5797,7 @@ public void errorHealthResponse() { * */ @Test - public void deferHealthRequestOnPendingStandalone() { + void deferHealthRequestOnPendingStandalone() { logger.info("=============================================================="); logger.info("BEGIN Testing SessionIT deferHealthRequestOnPendingStandalone."); logger.info("=============================================================="); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionStressIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionStressIT.java index 35e60ba..eb516ba 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionStressIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SessionStressIT.java @@ -15,10 +15,10 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.AbstractSession; import com.bloomberg.bmq.AckMessage; @@ -56,11 +56,11 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SessionStressIT { +class SessionStressIT { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -716,7 +716,7 @@ void restartBroker( } throw new IllegalStateException("Unknown queue: " + queueEv.queue()); } - assertEquals(queueEventFIFO.size(), 0); + assertEquals(0, queueEventFIFO.size()); } void testConnectionLost(int numQueues, int numMsgs) throws BMQException, IOException { @@ -977,7 +977,7 @@ void testFanoutMode(int numReaderQueues, int numMsgs) throws BMQException, IOExc } @Test - public void testZlibIncompressableSize() throws BMQException, IOException { + void testZlibIncompressableSize() throws BMQException, IOException { // Send multiple PUT messages each with unique payload via native Broker, // receive related PUSH messages from the queue, verify the payload. // For each PUT message Zlib compression is set, but payload( + props) is not compressed due @@ -1007,7 +1007,7 @@ public void testZlibIncompressableSize() throws BMQException, IOException { } @Test - public void testZlibCompressableSize() throws BMQException, IOException { + void testZlibCompressableSize() throws BMQException, IOException { // Send multiple PUT messages each with unique payload via native Broker, // receive related PUSH messages from the queue, verify the payload. // For each PUT message Zlib compression is set @@ -1035,7 +1035,7 @@ public void testZlibCompressableSize() throws BMQException, IOException { } @Test - public void testZlibBigSize() throws BMQException, IOException { + void testZlibBigSize() throws BMQException, IOException { // Send multiple PUT messages each with unique payload via native Broker, // receive related PUSH messages from the queue, verify the payload. // For each PUT message Zlib compression is set @@ -1063,7 +1063,7 @@ public void testZlibBigSize() throws BMQException, IOException { } @Test - public void testMultipleEvents() throws BMQException, IOException { + void testMultipleEvents() throws BMQException, IOException { // Send multiple PUT messages each with unique payload via native Broker, // receive related PUSH messages from the queue, verify the payload. @@ -1085,7 +1085,7 @@ public void testMultipleEvents() throws BMQException, IOException { } @Test - public void testMultipleEventsNoPushWait() throws BMQException, IOException { + void testMultipleEventsNoPushWait() throws BMQException, IOException { // Send multiple PUT messages each with unique payload via native Broker, // waiting only for related ACK messages. // Receive related PUSH messages from the queue, verify the payload. @@ -1108,7 +1108,7 @@ public void testMultipleEventsNoPushWait() throws BMQException, IOException { } @Test - public void testMultipleQueuesConnectionLost() throws BMQException, IOException { + void testMultipleQueuesConnectionLost() throws BMQException, IOException { // Create and open multiple read/write queues. // For each queue: // - send multiple PUT messages via native Broker; @@ -1131,7 +1131,7 @@ public void testMultipleQueuesConnectionLost() throws BMQException, IOException } @Test - public void testFanoutThroughput() throws IOException { + void testFanoutThroughput() throws IOException { // Send multiple PUT messages each with unique payload via native Broker, // receive related PUSH messages from the queues, verify the payload. @@ -1150,7 +1150,7 @@ public void testFanoutThroughput() throws IOException { } @Test - public void testMultithreadedWriters() throws IOException { + void testMultithreadedWriters() throws IOException { // Using one Session and multiple writer queues each posting from its // own thread send multiple PUT messages with unique payload via native Broker, // receive related PUSH messages from the queues, verify the payload. diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SubscriptionIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SubscriptionIT.java index 21d7053..7eafe6b 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SubscriptionIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/SubscriptionIT.java @@ -15,10 +15,33 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.*; - -import com.bloomberg.bmq.*; +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; + +import com.bloomberg.bmq.AbstractSession; +import com.bloomberg.bmq.AckMessage; +import com.bloomberg.bmq.AckMessageHandler; +import com.bloomberg.bmq.BMQException; +import com.bloomberg.bmq.CompressionAlgorithm; +import com.bloomberg.bmq.CorrelationId; +import com.bloomberg.bmq.MessageProperties; +import com.bloomberg.bmq.PushMessage; +import com.bloomberg.bmq.PushMessageHandler; +import com.bloomberg.bmq.PutMessage; import com.bloomberg.bmq.Queue; +import com.bloomberg.bmq.QueueControlEvent; +import com.bloomberg.bmq.QueueEventHandler; +import com.bloomberg.bmq.QueueFlags; +import com.bloomberg.bmq.QueueOptions; +import com.bloomberg.bmq.Session; +import com.bloomberg.bmq.SessionEvent; +import com.bloomberg.bmq.SessionEventHandler; +import com.bloomberg.bmq.SessionOptions; +import com.bloomberg.bmq.Subscription; +import com.bloomberg.bmq.Uri; import com.bloomberg.bmq.it.util.BmqBroker; import com.bloomberg.bmq.it.util.TestTools; import java.io.IOException; @@ -27,15 +50,19 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; import java.time.Duration; -import java.util.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.TimeUnit; -import org.junit.Assert; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class SubscriptionIT { +class SubscriptionIT { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -70,7 +97,7 @@ public void close() { } public void configure(QueueOptions options) { - assertTrue("Trying to configure not-opened queue", queue.isOpen()); + assertTrue(queue.isOpen(), "Trying to configure not-opened queue"); this.options = options; @@ -280,7 +307,7 @@ public void start(String brokerUri) { } public void openQueue(Uri uri) { - assertNull("Expect 'queue' to be null", queue); + assertNull(queue, "Expect 'queue' to be null"); queue = session.getQueue( @@ -349,7 +376,7 @@ public void close() { } @Test - public void testBreathing() throws BMQException, IOException { + void testBreathing() throws BMQException, IOException { logger.info("============================================="); logger.info("BEGIN Testing SubscriptionIT testBreathing."); logger.info("============================================="); @@ -357,7 +384,7 @@ public void testBreathing() throws BMQException, IOException { try (BmqBroker broker = BmqBroker.createStoppedBroker()) { logger.info("Step 1: Bring up the broker"); - Assert.assertFalse(broker.isOldStyleMessageProperties()); + assertFalse(broker.isOldStyleMessageProperties()); broker.start(); @@ -413,7 +440,7 @@ public void testBreathing() throws BMQException, IOException { } @Test - public void testFanout() throws BMQException, IOException { + void testFanout() throws BMQException, IOException { logger.info("============================================="); logger.info("BEGIN Testing SubscriptionIT testFanout."); logger.info("============================================="); @@ -423,7 +450,7 @@ public void testFanout() throws BMQException, IOException { try (BmqBroker broker = BmqBroker.createStoppedBroker()) { logger.info("Step 1: Bring up the broker"); - Assert.assertFalse(broker.isOldStyleMessageProperties()); + assertFalse(broker.isOldStyleMessageProperties()); broker.start(); @@ -482,7 +509,7 @@ public void testFanout() throws BMQException, IOException { } @Test - public void testReuseQueueOptions() throws BMQException, IOException { + void testReuseQueueOptions() throws BMQException, IOException { logger.info("============================================="); logger.info("BEGIN Testing SubscriptionIT testReuseQueueOptions."); logger.info("============================================="); @@ -492,7 +519,7 @@ public void testReuseQueueOptions() throws BMQException, IOException { try (BmqBroker broker = BmqBroker.createStoppedBroker()) { logger.info("Step 1: Bring up the broker"); - Assert.assertFalse(broker.isOldStyleMessageProperties()); + assertFalse(broker.isOldStyleMessageProperties()); broker.start(); @@ -552,7 +579,7 @@ public void testReuseQueueOptions() throws BMQException, IOException { } @Test - public void testUpdateSubscription() throws BMQException, IOException { + void testUpdateSubscription() throws BMQException, IOException { logger.info("============================================="); logger.info("BEGIN Testing SubscriptionIT testUpdateSubscription."); logger.info("============================================="); @@ -562,7 +589,7 @@ public void testUpdateSubscription() throws BMQException, IOException { try (BmqBroker broker = BmqBroker.createStoppedBroker()) { logger.info("Step 1: Bring up the broker"); - Assert.assertFalse(broker.isOldStyleMessageProperties()); + assertFalse(broker.isOldStyleMessageProperties()); broker.start(); @@ -641,7 +668,7 @@ public void testUpdateSubscription() throws BMQException, IOException { } @Test - public void testStress() throws BMQException, IOException { + void testStress() throws BMQException, IOException { logger.info("============================================="); logger.info("BEGIN Testing SubscriptionIT testStress."); logger.info("============================================="); @@ -654,7 +681,7 @@ public void testStress() throws BMQException, IOException { try (BmqBroker broker = BmqBroker.createStoppedBroker()) { logger.info("Step 1: Bring up the broker"); - Assert.assertFalse(broker.isOldStyleMessageProperties()); + assertFalse(broker.isOldStyleMessageProperties()); broker.start(); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/TcpBrokerConnectionIT.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/TcpBrokerConnectionIT.java index 24e8ede..920aa01 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/TcpBrokerConnectionIT.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/TcpBrokerConnectionIT.java @@ -15,12 +15,12 @@ */ package com.bloomberg.bmq.it; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +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.fail; import com.bloomberg.bmq.ResultCodes.GenericResult; import com.bloomberg.bmq.SessionOptions; @@ -68,11 +68,11 @@ import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class TcpBrokerConnectionIT { +class TcpBrokerConnectionIT { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -313,7 +313,7 @@ private Object exchangeObject(Object ev, int sec) { } @Test - public void testConnectionDown() throws Exception { + void testConnectionDown() throws Exception { logger.info("==========================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT connection down."); @@ -367,7 +367,7 @@ public void testConnectionDown() throws Exception { } @Test - public void testReconnection() throws Exception { + void testReconnection() throws Exception { logger.info("========================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT re-connection."); @@ -442,7 +442,7 @@ public void testReconnection() throws Exception { } @Test - public void testDropAndReconnection() throws Exception { + void testDropAndReconnection() throws Exception { logger.info("==========================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT drop and re-connection."); @@ -512,7 +512,7 @@ public void testDropAndReconnection() throws Exception { } @Test - public void testRestart() throws Exception { + void testRestart() throws Exception { logger.info("==================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT restart."); @@ -599,7 +599,7 @@ public void testRestart() throws Exception { } @Test - public void testNegotiationMpsEx() throws IOException { + void testNegotiationMpsEx() throws IOException { final ConnectionOptions opts = new ConnectionOptions(); opts.setBrokerUri(getServerUri()); @@ -705,7 +705,7 @@ private void testNegotiationFailed(StatusCategory status) { .getSeconds(); // 3) Wait for start status callback and ensure it reports error status. - assertEquals(session.startStatus((int) timeout + 1), StartStatus.NEGOTIATION_FAILURE); + assertEquals(StartStatus.NEGOTIATION_FAILURE, session.startStatus((int) timeout + 1)); } finally { // 4) Stop the server. server.stop(); @@ -718,7 +718,7 @@ private void testNegotiationFailed(StatusCategory status) { } @Test - public void testNegotiationTimeout() { + void testNegotiationTimeout() { logger.info("==============================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT negotiation timeout."); logger.info("==============================================================="); @@ -732,7 +732,7 @@ public void testNegotiationTimeout() { } @Test - public void testNegotiationError() { + void testNegotiationError() { logger.info("============================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT negotiation error."); logger.info("============================================================="); @@ -746,7 +746,7 @@ public void testNegotiationError() { } @Test - public void testNegotiationInterrupted() { + void testNegotiationInterrupted() { logger.info("==================================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT negotiation interrupted."); logger.info("==================================================================="); @@ -761,7 +761,7 @@ public void testNegotiationInterrupted() { } @Test - public void testConnectionTimeout() { + void testConnectionTimeout() { logger.info("=============================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT connection timeout."); logger.info("=============================================================="); @@ -802,7 +802,7 @@ public void testConnectionTimeout() { } @Test - public void testConnectionDelay() throws IOException { + void testConnectionDelay() throws IOException { logger.info("============================================================"); logger.info("BEGIN Testing TcpBrokerConnectionIT connection delay."); logger.info("============================================================"); @@ -859,7 +859,7 @@ public void testConnectionDelay() throws IOException { } @Test - public void testMultipleStarts() throws IOException { + void testMultipleStarts() throws IOException { logger.info("==========================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT multiple starts."); logger.info("==========================================================="); @@ -921,7 +921,7 @@ public void testMultipleStarts() throws IOException { } @Test - public void testMultipleRestarts() throws IOException { + void testMultipleRestarts() throws IOException { logger.info("============================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT multiple restarts."); logger.info("============================================================="); @@ -990,7 +990,7 @@ public void testMultipleRestarts() throws IOException { } @Test - public void testLinger() { + void testLinger() { logger.info("============================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT multiple restarts."); logger.info("============================================================="); @@ -1023,7 +1023,7 @@ public void testLinger() { } @Test - public void testPartialPayload() throws IOException { + void testPartialPayload() throws IOException { logger.info("==========================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT partial payload."); logger.info("==========================================================="); @@ -1105,7 +1105,7 @@ public void testPartialPayload() throws IOException { } @Test - public void testUnresolvedUri() throws Exception { + void testUnresolvedUri() throws Exception { logger.info("======================================================"); logger.info("BEGIN Testing TcpBrokerConnectionIT testUnresolvedUri."); logger.info("======================================================"); @@ -1145,7 +1145,7 @@ public void testUnresolvedUri() throws Exception { } @Test - public void testUnknownCompressionType() throws IOException { + void testUnknownCompressionType() throws IOException { logger.info("============================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT unknown compression type."); logger.info("============================================================="); @@ -1286,7 +1286,7 @@ public void testUnknownCompressionType() throws IOException { } @Test - public void testStopConnection() { + void testStopConnection() { logger.info("==========================================================="); logger.info("BEGIN Testing TcpBrokerConnectionIT stop connection."); logger.info("==========================================================="); diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/impl/infr/proto/Crc32cTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/impl/infr/proto/Crc32cTest.java index 30a1803..d23303b 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/impl/infr/proto/Crc32cTest.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/impl/infr/proto/Crc32cTest.java @@ -15,9 +15,9 @@ */ package com.bloomberg.bmq.it.impl.infr.proto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.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; import com.bloomberg.bmq.impl.infr.io.ByteBufferOutputStream; import com.bloomberg.bmq.impl.infr.proto.Crc32c; @@ -30,11 +30,11 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; -import org.junit.Test; +import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class Crc32cTest { +class Crc32cTest { static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); @@ -63,10 +63,10 @@ public class Crc32cTest { } @Test - public void testImplementation() { + void testImplementation() { // Ensure we are running with supported version of JVM SystemUtil.JavaVersion javaVersion = SystemUtil.getJavaVersion(); - assertTrue("Unsupported JDK", javaVersion.isSupported()); + assertTrue(javaVersion.isSupported(), "Unsupported JDK"); boolean isPartOfJar = VersionUtil.getJarVersion() != null; @@ -88,7 +88,7 @@ public void testImplementation() { } @Test - public void testCrc32c() throws IOException { + void testCrc32c() throws IOException { Set> set = DATA.entrySet(); for (Map.Entry me : set) { ByteBufferOutputStream bbos = new ByteBufferOutputStream(); @@ -98,7 +98,7 @@ public void testCrc32c() throws IOException { } @Test - public void testCrc32cUnsigned() throws IOException { + void testCrc32cUnsigned() throws IOException { final String PAYLOAD = "3jf-_3"; final long CRC32C_VALUE = 0xE186B745L; ByteBuffer bb = ByteBuffer.allocate(Integer.BYTES); @@ -114,7 +114,7 @@ public void testCrc32cUnsigned() throws IOException { } @Test - public void testCrc32cMultithreaded() throws InterruptedException { + void testCrc32cMultithreaded() throws InterruptedException { class TestThread implements Runnable { final Thread thread; boolean hasError; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/BmqBrokerTestServer.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/BmqBrokerTestServer.java index 6e93514..9b8b8e3 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/BmqBrokerTestServer.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/BmqBrokerTestServer.java @@ -15,8 +15,8 @@ */ package com.bloomberg.bmq.it.util; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import com.bloomberg.bmq.SessionOptions; import com.bloomberg.bmq.impl.infr.util.Argument; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/TestTools.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/TestTools.java index 7d1118d..48852a8 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/TestTools.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/it/util/TestTools.java @@ -15,11 +15,11 @@ */ package com.bloomberg.bmq.it.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +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.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.MessageGUID; import com.bloomberg.bmq.ResultCodes; diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/AckResultTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/AckResultTest.java new file mode 100644 index 0000000..335aa59 --- /dev/null +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/AckResultTest.java @@ -0,0 +1,175 @@ +/* + * Copyright 2024 Bloomberg Finance L.P. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.bloomberg.bmq.resultcodes; + +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkCanceled; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkIfNotGeneric; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkInvalidArgument; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotConnected; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotReady; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotSupported; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkRefused; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkSuccess; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkTimeout; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkUnknown; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.bloomberg.bmq.ResultCodes; +import org.junit.jupiter.api.Test; + +// ================================================================ +// AckResult tests +// ================================================================ +class AckResultTest { + static class AckGenericTest { + void isLimitMessages(ResultCodes.AckCode obj) { + assertFalse(obj.isLimitMessages()); + } + + void isLimitBytes(ResultCodes.AckCode obj) { + assertFalse(obj.isLimitBytes()); + } + + void isStorageFailure(ResultCodes.AckCode obj) { + assertFalse(obj.isStorageFailure()); + } + } + + static class LimitMessagesTest extends AckGenericTest { + @Override + public void isLimitMessages(ResultCodes.AckCode obj) { + assertTrue(obj.isLimitMessages()); + } + } + + static class LimitBytesTest extends AckGenericTest { + @Override + public void isLimitBytes(ResultCodes.AckCode obj) { + assertTrue(obj.isLimitBytes()); + } + } + + static class StorageFailureTest extends AckGenericTest { + @Override + public void isStorageFailure(ResultCodes.AckCode obj) { + assertTrue(obj.isStorageFailure()); + } + } + + static void checkExtraPredicates(AckResultTest.AckGenericTest test, ResultCodes.AckResult obj) { + test.isLimitMessages(obj); + test.isLimitBytes(obj); + test.isStorageFailure(obj); + } + + static void checkGeneric(ResultCodes.AckResult obj) { + checkExtraPredicates(new AckResultTest.AckGenericTest(), obj); + } + + static void checkLimitMessages(ResultCodes.AckResult obj) { + checkExtraPredicates(new AckResultTest.LimitMessagesTest(), obj); + } + + static void checkLimitBytes(ResultCodes.AckResult obj) { + checkExtraPredicates(new AckResultTest.LimitBytesTest(), obj); + } + + static void checkStorageFailure(ResultCodes.AckResult obj) { + checkExtraPredicates(new AckResultTest.StorageFailureTest(), obj); + } + + @Test + void successTest() { + checkIfNotGeneric(ResultCodes.AckResult.SUCCESS); + checkSuccess(ResultCodes.AckResult.SUCCESS); + checkGeneric(ResultCodes.AckResult.SUCCESS); + } + + @Test + void timeOutTest() { + checkIfNotGeneric(ResultCodes.AckResult.TIMEOUT); + checkTimeout(ResultCodes.AckResult.TIMEOUT); + checkGeneric(ResultCodes.AckResult.TIMEOUT); + } + + @Test + void notConnectedTest() { + checkIfNotGeneric(ResultCodes.AckResult.NOT_CONNECTED); + checkNotConnected(ResultCodes.AckResult.NOT_CONNECTED); + checkGeneric(ResultCodes.AckResult.NOT_CONNECTED); + } + + @Test + void canceledTest() { + checkIfNotGeneric(ResultCodes.AckResult.CANCELED); + checkCanceled(ResultCodes.AckResult.CANCELED); + checkGeneric(ResultCodes.AckResult.CANCELED); + } + + @Test + void notSupportedTest() { + checkIfNotGeneric(ResultCodes.AckResult.NOT_SUPPORTED); + checkNotSupported(ResultCodes.AckResult.NOT_SUPPORTED); + checkGeneric(ResultCodes.AckResult.NOT_SUPPORTED); + } + + @Test + void refusedTest() { + checkIfNotGeneric(ResultCodes.AckResult.REFUSED); + checkRefused(ResultCodes.AckResult.REFUSED); + checkGeneric(ResultCodes.AckResult.REFUSED); + } + + @Test + void invalidArgumentTest() { + checkIfNotGeneric(ResultCodes.AckResult.INVALID_ARGUMENT); + checkInvalidArgument(ResultCodes.AckResult.INVALID_ARGUMENT); + checkGeneric(ResultCodes.AckResult.INVALID_ARGUMENT); + } + + @Test + void notReadyTest() { + checkIfNotGeneric(ResultCodes.AckResult.NOT_READY); + checkNotReady(ResultCodes.AckResult.NOT_READY); + checkGeneric(ResultCodes.AckResult.NOT_READY); + } + + @Test + void unknownTest() { + checkIfNotGeneric(ResultCodes.AckResult.UNKNOWN); + checkUnknown(ResultCodes.AckResult.UNKNOWN); + checkGeneric(ResultCodes.AckResult.UNKNOWN); + } + + @Test + void limitMessagesTest() { + checkIfNotGeneric(ResultCodes.AckResult.LIMIT_MESSAGES); + checkLimitMessages(ResultCodes.AckResult.LIMIT_MESSAGES); + } + + @Test + void limitBytesTest() { + checkIfNotGeneric(ResultCodes.AckResult.LIMIT_BYTES); + checkLimitBytes(ResultCodes.AckResult.LIMIT_BYTES); + } + + @Test + void storageFailureTest() { + checkIfNotGeneric(ResultCodes.AckResult.STORAGE_FAILURE); + checkStorageFailure(ResultCodes.AckResult.STORAGE_FAILURE); + } +} diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/CloseQueueResultTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/CloseQueueResultTest.java new file mode 100644 index 0000000..7c84fc0 --- /dev/null +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/CloseQueueResultTest.java @@ -0,0 +1,198 @@ +/* + * Copyright 2024 Bloomberg Finance L.P. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.bloomberg.bmq.resultcodes; + +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkCanceled; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkIfNotGeneric; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkInvalidArgument; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotConnected; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotReady; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotSupported; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkRefused; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkSuccess; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkTimeout; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkUnknown; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.bloomberg.bmq.ResultCodes; +import org.junit.jupiter.api.Test; + +// ================================================================ +// CloseQueueResult tests +// ================================================================ +class CloseQueueResultTest { + static class CloseQueueGenericTest { + void isAlreadyClosed(ResultCodes.CloseQueueCode obj) { + assertFalse(obj.isAlreadyClosed()); + } + + void isAlreadyInProgressTest(ResultCodes.CloseQueueCode obj) { + assertFalse(obj.isAlreadyInProgress()); + } + + void isUnknownQueueTest(ResultCodes.CloseQueueCode obj) { + assertFalse(obj.isUnknownQueue()); + } + + void isInvalidQueueTest(ResultCodes.CloseQueueCode obj) { + assertFalse(obj.isInvalidQueue()); + } + } + + static class AlreadyClosedTest extends CloseQueueGenericTest { + @Override + public void isAlreadyClosed(ResultCodes.CloseQueueCode obj) { + assertTrue(obj.isAlreadyClosed()); + } + } + + static class AlreadyInProgressTest extends CloseQueueGenericTest { + @Override + public void isAlreadyInProgressTest(ResultCodes.CloseQueueCode obj) { + assertTrue(obj.isAlreadyInProgress()); + } + } + + static class UnknownQueueTest extends CloseQueueGenericTest { + @Override + public void isUnknownQueueTest(ResultCodes.CloseQueueCode obj) { + assertTrue(obj.isUnknownQueue()); + } + } + + static class InvalidQueueTest extends CloseQueueGenericTest { + @Override + public void isInvalidQueueTest(ResultCodes.CloseQueueCode obj) { + assertTrue(obj.isInvalidQueue()); + } + } + + static void checkPredicates( + CloseQueueResultTest.CloseQueueGenericTest test, ResultCodes.CloseQueueResult obj) { + test.isAlreadyClosed(obj); + test.isAlreadyInProgressTest(obj); + test.isUnknownQueueTest(obj); + test.isInvalidQueueTest(obj); + } + + static void checkGeneric(ResultCodes.CloseQueueResult obj) { + checkPredicates(new CloseQueueResultTest.CloseQueueGenericTest(), obj); + } + + static void checkAlreadyClosed(ResultCodes.CloseQueueResult obj) { + checkPredicates(new CloseQueueResultTest.AlreadyClosedTest(), obj); + } + + static void checkAlreadyInProgress(ResultCodes.CloseQueueResult obj) { + checkPredicates(new CloseQueueResultTest.AlreadyInProgressTest(), obj); + } + + static void checkUnknownQueue(ResultCodes.CloseQueueResult obj) { + checkPredicates(new CloseQueueResultTest.UnknownQueueTest(), obj); + } + + static void checkInvalidQueue(ResultCodes.CloseQueueResult obj) { + checkPredicates(new CloseQueueResultTest.InvalidQueueTest(), obj); + } + + @Test + void successTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.SUCCESS); + checkSuccess(ResultCodes.CloseQueueResult.SUCCESS); + checkGeneric(ResultCodes.CloseQueueResult.SUCCESS); + } + + @Test + void timeOutTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.TIMEOUT); + checkTimeout(ResultCodes.CloseQueueResult.TIMEOUT); + checkGeneric(ResultCodes.CloseQueueResult.TIMEOUT); + } + + @Test + void notConnectedTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.NOT_CONNECTED); + checkNotConnected(ResultCodes.CloseQueueResult.NOT_CONNECTED); + checkGeneric(ResultCodes.CloseQueueResult.NOT_CONNECTED); + } + + @Test + void canceledTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.CANCELED); + checkCanceled(ResultCodes.CloseQueueResult.CANCELED); + checkGeneric(ResultCodes.CloseQueueResult.CANCELED); + } + + @Test + void notSupportedTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.NOT_SUPPORTED); + checkNotSupported(ResultCodes.CloseQueueResult.NOT_SUPPORTED); + checkGeneric(ResultCodes.CloseQueueResult.NOT_SUPPORTED); + } + + @Test + void refusedTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.REFUSED); + checkRefused(ResultCodes.CloseQueueResult.REFUSED); + checkGeneric(ResultCodes.CloseQueueResult.REFUSED); + } + + @Test + void invalidArgumentTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.INVALID_ARGUMENT); + checkInvalidArgument(ResultCodes.CloseQueueResult.INVALID_ARGUMENT); + checkGeneric(ResultCodes.CloseQueueResult.INVALID_ARGUMENT); + } + + @Test + void notReadyTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.NOT_READY); + checkNotReady(ResultCodes.CloseQueueResult.NOT_READY); + checkGeneric(ResultCodes.CloseQueueResult.NOT_READY); + } + + @Test + void unknownTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.UNKNOWN); + checkUnknown(ResultCodes.CloseQueueResult.UNKNOWN); + checkGeneric(ResultCodes.CloseQueueResult.UNKNOWN); + } + + @Test + void alreadyClosedTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.ALREADY_CLOSED); + checkAlreadyClosed(ResultCodes.CloseQueueResult.ALREADY_CLOSED); + } + + @Test + void alreadyInProgressTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.ALREADY_IN_PROGRESS); + checkAlreadyInProgress(ResultCodes.CloseQueueResult.ALREADY_IN_PROGRESS); + } + + @Test + void unknownQueueTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.UNKNOWN_QUEUE); + checkUnknownQueue(ResultCodes.CloseQueueResult.UNKNOWN_QUEUE); + } + + @Test + void invalidQueueTest() { + checkIfNotGeneric(ResultCodes.CloseQueueResult.INVALID_QUEUE); + checkInvalidQueue(ResultCodes.CloseQueueResult.INVALID_QUEUE); + } +} diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/ConfigureQueueResultTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/ConfigureQueueResultTest.java new file mode 100644 index 0000000..da8efbc --- /dev/null +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/ConfigureQueueResultTest.java @@ -0,0 +1,155 @@ +/* + * Copyright 2024 Bloomberg Finance L.P. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.bloomberg.bmq.resultcodes; + +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkCanceled; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkIfNotGeneric; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkInvalidArgument; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotConnected; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotReady; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotSupported; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkRefused; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkSuccess; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkTimeout; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkUnknown; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.bloomberg.bmq.ResultCodes; +import org.junit.jupiter.api.Test; + +// ================================================================ +// ConfigureQueueResult tests +// ================================================================ +class ConfigureQueueResultTest { + static class ConfigureQueueGenericTest { + void isAlreadyInProgressTest(ResultCodes.ConfigureQueueCode obj) { + assertFalse(obj.isAlreadyInProgress()); + } + + void isInvalidQueueTest(ResultCodes.ConfigureQueueCode obj) { + assertFalse(obj.isInvalidQueue()); + } + } + + static class AlreadyInProgressTest extends ConfigureQueueGenericTest { + @Override + public void isAlreadyInProgressTest(ResultCodes.ConfigureQueueCode obj) { + assertTrue(obj.isAlreadyInProgress()); + } + } + + static class InvalidQueueTest extends ConfigureQueueGenericTest { + @Override + public void isInvalidQueueTest(ResultCodes.ConfigureQueueCode obj) { + assertTrue(obj.isInvalidQueue()); + } + } + + static void checkPredicates( + ConfigureQueueResultTest.ConfigureQueueGenericTest test, + ResultCodes.ConfigureQueueCode obj) { + test.isAlreadyInProgressTest(obj); + test.isInvalidQueueTest(obj); + } + + static void checkGeneric(ResultCodes.ConfigureQueueCode obj) { + checkPredicates(new ConfigureQueueResultTest.ConfigureQueueGenericTest(), obj); + } + + static void checkAlreadyInProgress(ResultCodes.ConfigureQueueCode obj) { + checkPredicates(new ConfigureQueueResultTest.AlreadyInProgressTest(), obj); + } + + static void checkAlreadyOpenedTest(ResultCodes.ConfigureQueueCode obj) { + checkPredicates(new ConfigureQueueResultTest.InvalidQueueTest(), obj); + } + + @Test + void successTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.SUCCESS); + checkSuccess(ResultCodes.ConfigureQueueResult.SUCCESS); + checkGeneric(ResultCodes.ConfigureQueueResult.SUCCESS); + } + + @Test + void timeOutTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.TIMEOUT); + checkTimeout(ResultCodes.ConfigureQueueResult.TIMEOUT); + checkGeneric(ResultCodes.ConfigureQueueResult.TIMEOUT); + } + + @Test + void notConnectedTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.NOT_CONNECTED); + checkNotConnected(ResultCodes.ConfigureQueueResult.NOT_CONNECTED); + checkGeneric(ResultCodes.ConfigureQueueResult.NOT_CONNECTED); + } + + @Test + void canceledTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.CANCELED); + checkCanceled(ResultCodes.ConfigureQueueResult.CANCELED); + checkGeneric(ResultCodes.ConfigureQueueResult.CANCELED); + } + + @Test + void notSupportedTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.NOT_SUPPORTED); + checkNotSupported(ResultCodes.ConfigureQueueResult.NOT_SUPPORTED); + checkGeneric(ResultCodes.ConfigureQueueResult.NOT_SUPPORTED); + } + + @Test + void refusedTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.REFUSED); + checkRefused(ResultCodes.ConfigureQueueResult.REFUSED); + checkGeneric(ResultCodes.ConfigureQueueResult.REFUSED); + } + + @Test + void invalidArgumentTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.INVALID_ARGUMENT); + checkInvalidArgument(ResultCodes.ConfigureQueueResult.INVALID_ARGUMENT); + checkGeneric(ResultCodes.ConfigureQueueResult.INVALID_ARGUMENT); + } + + @Test + void notReadyTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.NOT_READY); + checkNotReady(ResultCodes.ConfigureQueueResult.NOT_READY); + checkGeneric(ResultCodes.ConfigureQueueResult.NOT_READY); + } + + @Test + void unknownTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.UNKNOWN); + checkUnknown(ResultCodes.ConfigureQueueResult.UNKNOWN); + checkGeneric(ResultCodes.ConfigureQueueResult.UNKNOWN); + } + + @Test + void alreadyInProgressTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.ALREADY_IN_PROGRESS); + checkAlreadyInProgress(ResultCodes.ConfigureQueueResult.ALREADY_IN_PROGRESS); + } + + @Test + void alreadyOpenedTest() { + checkIfNotGeneric(ResultCodes.ConfigureQueueResult.INVALID_QUEUE); + checkAlreadyOpenedTest(ResultCodes.ConfigureQueueResult.INVALID_QUEUE); + } +} diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultChecks.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultChecks.java new file mode 100644 index 0000000..dbe3146 --- /dev/null +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultChecks.java @@ -0,0 +1,81 @@ +/* + * Copyright 2024 Bloomberg Finance L.P. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.bloomberg.bmq.resultcodes; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import com.bloomberg.bmq.ResultCodes; + +class GenericResultChecks { + + static void checkPredicates(GenericResultTest.BaseTest test, ResultCodes.GenericCode obj) { + test.isSuccessTest(obj); + test.isFailureTest(obj); + test.isCanceledTest(obj); + test.isInvalidArgumentTest(obj); + test.isNotConnectedTest(obj); + test.isNotReadyTest(obj); + test.isNotSupportedTest(obj); + test.isRefusedTest(obj); + test.isTimeoutTest(obj); + test.isUnknownTest(obj); + } + + static void checkIfGeneric(ResultCodes.GenericCode obj) { + assertEquals(obj, obj.getGeneralResult()); + } + + static void checkIfNotGeneric(ResultCodes.GenericCode obj) { + assertNotEquals(obj, obj.getGeneralResult()); + } + + static void checkSuccess(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.SuccessTest(), obj); + } + + static void checkTimeout(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.TimeoutTest(), obj); + } + + static void checkNotConnected(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.NotConnectedTest(), obj); + } + + static void checkCanceled(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.CanceledTest(), obj); + } + + static void checkNotSupported(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.NotSupportedTest(), obj); + } + + static void checkRefused(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.RefusedTest(), obj); + } + + static void checkInvalidArgument(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.InvalidArgumentTest(), obj); + } + + static void checkNotReady(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.NotReadyTest(), obj); + } + + static void checkUnknown(ResultCodes.GenericCode obj) { + checkPredicates(new GenericResultTest.UnknownTest(), obj); + } +} diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultTest.java new file mode 100644 index 0000000..a250667 --- /dev/null +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/GenericResultTest.java @@ -0,0 +1,197 @@ +/* + * Copyright 2024 Bloomberg Finance L.P. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.bloomberg.bmq.resultcodes; + +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkCanceled; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkIfGeneric; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkInvalidArgument; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotConnected; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotReady; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotSupported; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkRefused; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkTimeout; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkUnknown; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.bloomberg.bmq.ResultCodes; +import org.junit.jupiter.api.Test; + +// ================================================================ +// GenericResult tests +// ================================================================ +class GenericResultTest { + + abstract static class BaseTest { + void isSuccessTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isSuccess()); + } + + void isFailureTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isFailure()); + } + + void isCanceledTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isCanceled()); + } + + void isInvalidArgumentTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isInvalidArgument()); + } + + void isNotConnectedTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isNotConnected()); + } + + void isNotReadyTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isNotReady()); + } + + void isNotSupportedTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isNotSupproted()); + } + + void isRefusedTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isRefused()); + } + + void isTimeoutTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isTimeout()); + } + + void isUnknownTest(ResultCodes.GenericCode obj) { + assertFalse(obj.isUnknown()); + } + } + + static class SuccessTest extends BaseTest { + @Override + public void isSuccessTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isSuccess()); + } + } + + abstract static class FailureStatusTest extends BaseTest { + @Override + public void isFailureTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isFailure()); + } + } + + static class CanceledTest extends FailureStatusTest { + @Override + public void isCanceledTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isCanceled()); + } + } + + static class InvalidArgumentTest extends FailureStatusTest { + @Override + public void isInvalidArgumentTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isInvalidArgument()); + } + } + + static class NotConnectedTest extends FailureStatusTest { + @Override + public void isNotConnectedTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isNotConnected()); + } + } + + static class NotReadyTest extends FailureStatusTest { + @Override + public void isNotReadyTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isNotReady()); + } + } + + static class NotSupportedTest extends FailureStatusTest { + @Override + public void isNotSupportedTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isNotSupproted()); + } + } + + static class RefusedTest extends FailureStatusTest { + @Override + public void isRefusedTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isRefused()); + } + } + + static class TimeoutTest extends FailureStatusTest { + @Override + public void isTimeoutTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isTimeout()); + } + } + + static class UnknownTest extends FailureStatusTest { + @Override + public void isUnknownTest(ResultCodes.GenericCode obj) { + assertTrue(obj.isUnknown()); + } + } + + @Test + void timeOutTest() { + checkIfGeneric(ResultCodes.GenericResult.TIMEOUT); + checkTimeout(ResultCodes.GenericResult.TIMEOUT); + } + + @Test + void notConnectedTest() { + checkIfGeneric(ResultCodes.GenericResult.NOT_CONNECTED); + checkNotConnected(ResultCodes.GenericResult.NOT_CONNECTED); + } + + @Test + void canceledTest() { + checkIfGeneric(ResultCodes.GenericResult.CANCELED); + checkCanceled(ResultCodes.GenericResult.CANCELED); + } + + @Test + void notSupportedTest() { + checkIfGeneric(ResultCodes.GenericResult.NOT_SUPPORTED); + checkNotSupported(ResultCodes.GenericResult.NOT_SUPPORTED); + } + + @Test + void refusedTest() { + checkIfGeneric(ResultCodes.GenericResult.REFUSED); + checkRefused(ResultCodes.GenericResult.REFUSED); + } + + @Test + void invalidArgumentTest() { + checkIfGeneric(ResultCodes.GenericResult.INVALID_ARGUMENT); + checkInvalidArgument(ResultCodes.GenericResult.INVALID_ARGUMENT); + } + + @Test + void notReadyTest() { + checkIfGeneric(ResultCodes.GenericResult.NOT_READY); + checkNotReady(ResultCodes.GenericResult.NOT_READY); + } + + @Test + void unknownTest() { + checkIfGeneric(ResultCodes.GenericResult.UNKNOWN); + checkUnknown(ResultCodes.GenericResult.UNKNOWN); + } +} diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/OpenQueueResultTest.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/OpenQueueResultTest.java new file mode 100644 index 0000000..6cc6482 --- /dev/null +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/resultcodes/OpenQueueResultTest.java @@ -0,0 +1,219 @@ +/* + * Copyright 2024 Bloomberg Finance L.P. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.bloomberg.bmq.resultcodes; + +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkCanceled; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkIfNotGeneric; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkInvalidArgument; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotConnected; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotReady; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkNotSupported; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkRefused; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkSuccess; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkTimeout; +import static com.bloomberg.bmq.resultcodes.GenericResultChecks.checkUnknown; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import com.bloomberg.bmq.ResultCodes; +import org.junit.jupiter.api.Test; + +// ================================================================ +// OpenQueueResult tests +// ================================================================ +class OpenQueueResultTest { + static class OpenQueueGenericTest { + void isAlreadyOpenedTest(ResultCodes.OpenQueueCode obj) { + assertFalse(obj.isAlreadyOpened()); + } + + void isAlreadyInProgressTest(ResultCodes.OpenQueueCode obj) { + assertFalse(obj.isAlreadyInProgress()); + } + + void isInvalidUriTest(ResultCodes.OpenQueueCode obj) { + assertFalse(obj.isInvalidUri()); + } + + void isInvalidFlagsTest(ResultCodes.OpenQueueCode obj) { + assertFalse(obj.isInvalidFlags()); + } + + void isQueueIdNotUniqueTest(ResultCodes.OpenQueueCode obj) { + assertFalse(obj.isQueueIdNotUnique()); + } + } + + static class AlreadyOpenedTest extends OpenQueueGenericTest { + @Override + void isAlreadyOpenedTest(ResultCodes.OpenQueueCode obj) { + assertTrue(obj.isAlreadyOpened()); + } + } + + static class AlreadyInProgressTest extends OpenQueueGenericTest { + void isAlreadyInProgressTest(ResultCodes.OpenQueueCode obj) { + assertTrue(obj.isAlreadyInProgress()); + } + } + + static class InvalidUriTest extends OpenQueueGenericTest { + @Override + void isInvalidUriTest(ResultCodes.OpenQueueCode obj) { + assertTrue(obj.isInvalidUri()); + } + } + + static class InvalidFlagsTest extends OpenQueueGenericTest { + @Override + void isInvalidFlagsTest(ResultCodes.OpenQueueCode obj) { + assertTrue(obj.isInvalidFlags()); + } + } + + static class QueueIdNotUniqueTest extends OpenQueueGenericTest { + @Override + void isQueueIdNotUniqueTest(ResultCodes.OpenQueueCode obj) { + assertTrue(obj.isQueueIdNotUnique()); + } + } + + static void checkExtraPredicates( + OpenQueueResultTest.OpenQueueGenericTest test, ResultCodes.OpenQueueCode obj) { + test.isAlreadyInProgressTest(obj); + test.isAlreadyOpenedTest(obj); + test.isInvalidFlagsTest(obj); + test.isInvalidUriTest(obj); + test.isQueueIdNotUniqueTest(obj); + } + + static void checkGeneric(ResultCodes.OpenQueueCode obj) { + checkExtraPredicates(new OpenQueueResultTest.OpenQueueGenericTest(), obj); + } + + static void checkAlreadyInProgress(ResultCodes.OpenQueueCode obj) { + checkExtraPredicates(new OpenQueueResultTest.AlreadyInProgressTest(), obj); + } + + static void checkAlreadyOpened(ResultCodes.OpenQueueCode obj) { + checkExtraPredicates(new OpenQueueResultTest.AlreadyOpenedTest(), obj); + } + + static void checkInvalidFlags(ResultCodes.OpenQueueCode obj) { + checkExtraPredicates(new OpenQueueResultTest.InvalidFlagsTest(), obj); + } + + static void checkInvalidUri(ResultCodes.OpenQueueCode obj) { + checkExtraPredicates(new OpenQueueResultTest.InvalidUriTest(), obj); + } + + static void checkQueueIdNotUnique(ResultCodes.OpenQueueCode obj) { + checkExtraPredicates(new OpenQueueResultTest.QueueIdNotUniqueTest(), obj); + } + + @Test + void successTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.SUCCESS); + checkSuccess(ResultCodes.OpenQueueResult.SUCCESS); + checkGeneric(ResultCodes.OpenQueueResult.SUCCESS); + } + + @Test + void timeOutTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.TIMEOUT); + checkTimeout(ResultCodes.OpenQueueResult.TIMEOUT); + checkGeneric(ResultCodes.OpenQueueResult.TIMEOUT); + } + + @Test + void notConnectedTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.NOT_CONNECTED); + checkNotConnected(ResultCodes.OpenQueueResult.NOT_CONNECTED); + checkGeneric(ResultCodes.OpenQueueResult.NOT_CONNECTED); + } + + @Test + void canceledTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.CANCELED); + checkCanceled(ResultCodes.OpenQueueResult.CANCELED); + checkGeneric(ResultCodes.OpenQueueResult.CANCELED); + } + + @Test + void notSupportedTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.NOT_SUPPORTED); + checkNotSupported(ResultCodes.OpenQueueResult.NOT_SUPPORTED); + checkGeneric(ResultCodes.OpenQueueResult.NOT_SUPPORTED); + } + + @Test + void refusedTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.REFUSED); + checkRefused(ResultCodes.OpenQueueResult.REFUSED); + checkGeneric(ResultCodes.OpenQueueResult.REFUSED); + } + + @Test + void invalidArgumentTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.INVALID_ARGUMENT); + checkInvalidArgument(ResultCodes.OpenQueueResult.INVALID_ARGUMENT); + checkGeneric(ResultCodes.OpenQueueResult.INVALID_ARGUMENT); + } + + @Test + void notReadyTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.NOT_READY); + checkNotReady(ResultCodes.OpenQueueResult.NOT_READY); + checkGeneric(ResultCodes.OpenQueueResult.NOT_READY); + } + + @Test + void unknownTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.UNKNOWN); + checkUnknown(ResultCodes.OpenQueueResult.UNKNOWN); + checkGeneric(ResultCodes.OpenQueueResult.UNKNOWN); + } + + @Test + void alreadyInProgressTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.ALREADY_IN_PROGRESS); + checkAlreadyInProgress(ResultCodes.OpenQueueResult.ALREADY_IN_PROGRESS); + } + + @Test + void alreadyOpenedTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.ALREADY_OPENED); + checkAlreadyOpened(ResultCodes.OpenQueueResult.ALREADY_OPENED); + } + + @Test + void invalidFlagsTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.INVALID_FLAGS); + checkInvalidFlags(ResultCodes.OpenQueueResult.INVALID_FLAGS); + } + + @Test + void invalidUriTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.INVALID_URI); + checkInvalidUri(ResultCodes.OpenQueueResult.INVALID_URI); + } + + @Test + void queueIdNotUniqueTest() { + checkIfNotGeneric(ResultCodes.OpenQueueResult.QUEUE_ID_NOT_UNIQUE); + checkQueueIdNotUnique(ResultCodes.OpenQueueResult.QUEUE_ID_NOT_UNIQUE); + } +} diff --git a/bmq-sdk/src/test/java/com/bloomberg/bmq/util/TestHelpers.java b/bmq-sdk/src/test/java/com/bloomberg/bmq/util/TestHelpers.java index 3653c84..2a74eee 100644 --- a/bmq-sdk/src/test/java/com/bloomberg/bmq/util/TestHelpers.java +++ b/bmq-sdk/src/test/java/com/bloomberg/bmq/util/TestHelpers.java @@ -15,9 +15,9 @@ */ package com.bloomberg.bmq.util; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; import com.bloomberg.bmq.BMQException; import com.bloomberg.bmq.impl.infr.msg.MessagesTestSamples.SampleFileMetadata; diff --git a/pom.xml b/pom.xml index ad3446c..085e113 100644 --- a/pom.xml +++ b/pom.xml @@ -161,15 +161,26 @@ limitations under the License. --> - junit - junit - 4.13.2 + org.junit + junit-bom + 5.10.2 + pom + import + + + + + org.mockito + mockito-junit-jupiter + 4.11.0 + test org.mockito mockito-inline - 4.6.1 + 4.11.0 + test