From 84afb421f3bc0c60a9db90ed56a890ff0f580fd5 Mon Sep 17 00:00:00 2001 From: Ayesh Almeida Date: Thu, 21 Nov 2024 16:02:50 +0530 Subject: [PATCH 1/7] [Automated] Update the native jar versions --- ballerina/Dependencies.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/Dependencies.toml b/ballerina/Dependencies.toml index f3894d7..b0110f1 100644 --- a/ballerina/Dependencies.toml +++ b/ballerina/Dependencies.toml @@ -72,7 +72,7 @@ modules = [ [[package]] org = "ballerinax" name = "activemq.driver" -version = "1.0.1" +version = "1.0.2" scope = "testOnly" modules = [ {org = "ballerinax", packageName = "activemq.driver", moduleName = "activemq.driver"} From 5cb665de7b6e932d5663b6f050372471b9a5587d Mon Sep 17 00:00:00 2001 From: Ayesh Almeida Date: Thu, 21 Nov 2024 16:06:07 +0530 Subject: [PATCH 2/7] Add test case for failover scenario with ActiveMQ --- ballerina/tests/failover_connection_tests.bal | 86 +++++++++++++++++++ gradle.properties | 2 +- 2 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 ballerina/tests/failover_connection_tests.bal diff --git a/ballerina/tests/failover_connection_tests.bal b/ballerina/tests/failover_connection_tests.bal new file mode 100644 index 0000000..be0ff49 --- /dev/null +++ b/ballerina/tests/failover_connection_tests.bal @@ -0,0 +1,86 @@ +// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. +// +// WSO2 LLC. licenses this file to you 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. + +import ballerina/test; +import ballerinax/activemq.driver as _; + +final Connection TEST_FAILOVER_CONNECTION = check new ( + initialContextFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory", + providerUrl = "failover:(tcp://localhost:61616)" +); + +final Session FAILOVER_AUTO_ACK_SESSION = check createSession(AUTO_ACKNOWLEDGE); + +isolated function createFailoverSession(AcknowledgementMode acknowledgementMode) returns Session|error { + return TEST_FAILOVER_CONNECTION->createSession(acknowledgementMode); +} + +@test:Config { + groups: ["failover"] +} +isolated function testQueueWithTextMessageWithFailover() returns error? { + MessageProducer failoverQueueProducer = check createProducer(FAILOVER_AUTO_ACK_SESSION, { + 'type: QUEUE, + name: "test-failover-queue" + }); + final MessageConsumer failoverQueueConsumer = check createConsumer(FAILOVER_AUTO_ACK_SESSION, destination = { + 'type: QUEUE, + name: "test-failover-queue" + }); + + string content = "This is a sample message"; + TextMessage message = { + content: content + }; + check failoverQueueProducer->send(message); + Message? response = check failoverQueueConsumer->receive(5000); + test:assertTrue(response is TextMessage, "Invalid message type received"); + if response is TextMessage { + test:assertEquals(response.content, content, "Invalid payload"); + } + + check failoverQueueProducer->close(); + check failoverQueueConsumer->close(); +} + +@test:Config { + groups: ["failover"] +} +isolated function testTopicWithTextMessageWithFailover() returns error? { + MessageProducer failoverTopicProducer = check createProducer(AUTO_ACK_SESSION, { + 'type: TOPIC, + name: "test-failover-topic" + }); + MessageConsumer failoverTopicConsumer = check createConsumer(AUTO_ACK_SESSION, destination = { + 'type: TOPIC, + name: "test-failover-topic" + }); + + string content = "This is a sample message"; + TextMessage message = { + content: content + }; + check failoverTopicProducer->send(message); + Message? response = check failoverTopicConsumer->receive(5000); + test:assertTrue(response is TextMessage, "Invalid message type received"); + if response is TextMessage { + test:assertEquals(response.content, content, "Invalid payload"); + } + + check failoverTopicProducer->close(); + check failoverTopicConsumer->close(); +} + diff --git a/gradle.properties b/gradle.properties index 9f83dbf..40fbe4b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,7 +15,7 @@ javaxJmsVersion=2.0.1 slf4jVersion=2.0.7 # Test dependenices -activeMQDriverVersion=1.0.1 +activeMQDriverVersion=1.0.2-20241121-153900-bfb39bd #stdlib dependencies From fc8c03a20e6170540e9ccc81ef28371b95017f64 Mon Sep 17 00:00:00 2001 From: Ayesh Almeida Date: Thu, 21 Nov 2024 16:12:35 +0530 Subject: [PATCH 3/7] Point workflows to the 10.x branch --- .github/workflows/build-timestamped-master.yml | 2 +- .github/workflows/build-with-bal-test-graalvm.yml | 2 +- .github/workflows/central-publish.yml | 2 +- .github/workflows/publish-release.yml | 2 +- .github/workflows/pull-request.yml | 2 +- .github/workflows/trigger-load-tests.yml | 2 +- .github/workflows/trivy-scan.yml | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-timestamped-master.yml b/.github/workflows/build-timestamped-master.yml index 2d154ff..1417640 100644 --- a/.github/workflows/build-timestamped-master.yml +++ b/.github/workflows/build-timestamped-master.yml @@ -14,5 +14,5 @@ jobs: call_workflow: name: Run Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-timestamp-master-template.yml@2201.10.x secrets: inherit diff --git a/.github/workflows/build-with-bal-test-graalvm.yml b/.github/workflows/build-with-bal-test-graalvm.yml index 9c4fd6e..d792103 100644 --- a/.github/workflows/build-with-bal-test-graalvm.yml +++ b/.github/workflows/build-with-bal-test-graalvm.yml @@ -30,7 +30,7 @@ jobs: call_stdlib_workflow: name: Run StdLib Workflow if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} - uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/build-with-bal-test-graalvm-template.yml@2201.10.x with: lang_tag: ${{ inputs.lang_tag }} lang_version: ${{ inputs.lang_version }} diff --git a/.github/workflows/central-publish.yml b/.github/workflows/central-publish.yml index 11922b5..74c4855 100644 --- a/.github/workflows/central-publish.yml +++ b/.github/workflows/central-publish.yml @@ -15,7 +15,7 @@ jobs: call_workflow: name: Run Central Publish Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/central-publish-template.yml@2201.10.x secrets: inherit with: environment: ${{ github.event.inputs.environment }} diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 69914a5..a25501f 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -9,7 +9,7 @@ jobs: call_workflow: name: Run Release Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/release-package-template.yml@2201.10.x secrets: inherit with: package-name: java.jms diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 68b9979..25e8e17 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -10,7 +10,7 @@ jobs: call_workflow: name: Run PR Build Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/pull-request-build-template.yml@2201.10.x with: additional-windows-test-flags: "-x test" secrets: inherit diff --git a/.github/workflows/trigger-load-tests.yml b/.github/workflows/trigger-load-tests.yml index fc0b41e..da4b0e5 100644 --- a/.github/workflows/trigger-load-tests.yml +++ b/.github/workflows/trigger-load-tests.yml @@ -22,7 +22,7 @@ jobs: call_stdlib_trigger_load_test_workflow: name: Run StdLib Load Test Workflow if: ${{ github.event_name != 'schedule' || (github.event_name == 'schedule' && github.repository_owner == 'ballerina-platform') }} - uses: ballerina-platform/ballerina-library/.github/workflows/trigger-load-tests-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/trigger-load-tests-template.yml@2201.10.x with: repo_name: 'module-ballerina-java.jms' runtime_artifacts_url: 'https://api.github.com/repos/ballerina-platform/module-ballerina-java.jms/actions/artifacts' diff --git a/.github/workflows/trivy-scan.yml b/.github/workflows/trivy-scan.yml index 458aab5..b4cfe21 100644 --- a/.github/workflows/trivy-scan.yml +++ b/.github/workflows/trivy-scan.yml @@ -9,5 +9,5 @@ jobs: call_workflow: name: Run Trivy Scan Workflow if: ${{ github.repository_owner == 'ballerina-platform' }} - uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@main + uses: ballerina-platform/ballerina-library/.github/workflows/trivy-scan-template.yml@2201.10.x secrets: inherit From 2a010e710200d3f041b1457325c4ba0a4154c107 Mon Sep 17 00:00:00 2001 From: Ayesh Almeida Date: Thu, 21 Nov 2024 16:13:54 +0530 Subject: [PATCH 4/7] Update licensing header --- ballerina/tests/failover_connection_tests.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/tests/failover_connection_tests.bal b/ballerina/tests/failover_connection_tests.bal index be0ff49..b97b07f 100644 --- a/ballerina/tests/failover_connection_tests.bal +++ b/ballerina/tests/failover_connection_tests.bal @@ -1,4 +1,4 @@ -// Copyright (c) 2023, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except From 640fbffca2f58677e352363a2f3defa0e3ba9582 Mon Sep 17 00:00:00 2001 From: Ayesh Almeida <77491511+ayeshLK@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:19:15 +0530 Subject: [PATCH 5/7] Update ballerina/tests/failover_connection_tests.bal Co-authored-by: Nipuna Ransinghe --- ballerina/tests/failover_connection_tests.bal | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ballerina/tests/failover_connection_tests.bal b/ballerina/tests/failover_connection_tests.bal index b97b07f..45cc283 100644 --- a/ballerina/tests/failover_connection_tests.bal +++ b/ballerina/tests/failover_connection_tests.bal @@ -1,4 +1,4 @@ -// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org) All Rights Reserved. +// Copyright (c) 2024, WSO2 LLC. (http://www.wso2.org). // // WSO2 LLC. licenses this file to you under the Apache License, // Version 2.0 (the "License"); you may not use this file except From b3b9a72757de6a0a2068ca2a073d40e1cb46eb1b Mon Sep 17 00:00:00 2001 From: Ayesh Almeida Date: Thu, 21 Nov 2024 16:32:08 +0530 Subject: [PATCH 6/7] Refactor the code to use camal-case variable names --- ballerina/tests/failover_connection_tests.bal | 23 +++++++++++++------ ballerina/tests/jms_consumer_tests.bal | 12 +++++----- .../tests/jms_message_listener_tests.bal | 10 ++++---- ballerina/tests/jms_producer_tests.bal | 8 +++---- ballerina/tests/jms_queue_tests.bal | 12 +++++----- ballerina/tests/jms_topic_tests.bal | 12 +++++----- ballerina/tests/test_commons.bal | 10 ++++---- 7 files changed, 48 insertions(+), 39 deletions(-) diff --git a/ballerina/tests/failover_connection_tests.bal b/ballerina/tests/failover_connection_tests.bal index 45cc283..155803b 100644 --- a/ballerina/tests/failover_connection_tests.bal +++ b/ballerina/tests/failover_connection_tests.bal @@ -17,26 +17,26 @@ import ballerina/test; import ballerinax/activemq.driver as _; -final Connection TEST_FAILOVER_CONNECTION = check new ( +final Connection testFailoverConnection = check new ( initialContextFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory", providerUrl = "failover:(tcp://localhost:61616)" ); -final Session FAILOVER_AUTO_ACK_SESSION = check createSession(AUTO_ACKNOWLEDGE); +final Session failoverAutoAckSession = check createSession(AUTO_ACKNOWLEDGE); isolated function createFailoverSession(AcknowledgementMode acknowledgementMode) returns Session|error { - return TEST_FAILOVER_CONNECTION->createSession(acknowledgementMode); + return testFailoverConnection->createSession(acknowledgementMode); } @test:Config { groups: ["failover"] } isolated function testQueueWithTextMessageWithFailover() returns error? { - MessageProducer failoverQueueProducer = check createProducer(FAILOVER_AUTO_ACK_SESSION, { + MessageProducer failoverQueueProducer = check createProducer(failoverAutoAckSession, { 'type: QUEUE, name: "test-failover-queue" }); - final MessageConsumer failoverQueueConsumer = check createConsumer(FAILOVER_AUTO_ACK_SESSION, destination = { + final MessageConsumer failoverQueueConsumer = check createConsumer(failoverAutoAckSession, destination = { 'type: QUEUE, name: "test-failover-queue" }); @@ -60,11 +60,11 @@ isolated function testQueueWithTextMessageWithFailover() returns error? { groups: ["failover"] } isolated function testTopicWithTextMessageWithFailover() returns error? { - MessageProducer failoverTopicProducer = check createProducer(AUTO_ACK_SESSION, { + MessageProducer failoverTopicProducer = check createProducer(autoAckSession, { 'type: TOPIC, name: "test-failover-topic" }); - MessageConsumer failoverTopicConsumer = check createConsumer(AUTO_ACK_SESSION, destination = { + MessageConsumer failoverTopicConsumer = check createConsumer(autoAckSession, destination = { 'type: TOPIC, name: "test-failover-topic" }); @@ -84,3 +84,12 @@ isolated function testTopicWithTextMessageWithFailover() returns error? { check failoverTopicConsumer->close(); } +@test:AfterGroups { + groups: ["failover"] +} +isolated function afterSuite() returns error? { + check failoverAutoAckSession->close(); + check testFailoverConnection->close(); +} + + diff --git a/ballerina/tests/jms_consumer_tests.bal b/ballerina/tests/jms_consumer_tests.bal index ed35d9f..1f25866 100644 --- a/ballerina/tests/jms_consumer_tests.bal +++ b/ballerina/tests/jms_consumer_tests.bal @@ -17,11 +17,11 @@ import ballerina/lang.runtime; import ballerina/test; -final MessageProducer queue7Producer = check createProducer(AUTO_ACK_SESSION, { +final MessageProducer queue7Producer = check createProducer(autoAckSession, { 'type: QUEUE, name: "test-queue-7" }); -final MessageConsumer queue7Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { +final MessageConsumer queue7Consumer = check createConsumer(autoAckSession, destination = { 'type: QUEUE, name: "test-queue-7" }); @@ -61,7 +61,7 @@ isolated function testRequestReplyWithQueue() returns error? { Message? request = check queue7Consumer->receive(5000); test:assertTrue(request is TextMessage, "Invalid message received"); if request is TextMessage { - MessageProducer replyProducer = check createProducer(AUTO_ACK_SESSION, { + MessageProducer replyProducer = check createProducer(autoAckSession, { 'type: QUEUE, name: "reply-queue" }); @@ -94,7 +94,7 @@ isolated function testRequestReplyWithTempQueue() returns error? { if request is TextMessage { test:assertTrue(request.replyTo is Destination, "Could not find the replyTo destination in a request-message"); Destination replyTo = check request.replyTo.ensureType(); - MessageProducer replyProducer = check createProducer(AUTO_ACK_SESSION, replyTo); + MessageProducer replyProducer = check createProducer(autoAckSession, replyTo); test:assertTrue(request.correlationId is string, "Could not find the correlation Id"); TextMessage replyMessage = { content: "This is a reply message" @@ -130,11 +130,11 @@ isolated function testReceiveMapMessageWithMultipleTypes() returns error? { } } -final MessageProducer topic7Producer = check createProducer(AUTO_ACK_SESSION, { +final MessageProducer topic7Producer = check createProducer(autoAckSession, { 'type: TOPIC, name: "test-topic-7" }); -final MessageConsumer topic7Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { +final MessageConsumer topic7Consumer = check createConsumer(autoAckSession, destination = { 'type: TOPIC, name: "test-topic-7" }); diff --git a/ballerina/tests/jms_message_listener_tests.bal b/ballerina/tests/jms_message_listener_tests.bal index 42f0835..767b3bb 100644 --- a/ballerina/tests/jms_message_listener_tests.bal +++ b/ballerina/tests/jms_message_listener_tests.bal @@ -17,7 +17,7 @@ import ballerina/lang.runtime; import ballerina/test; -final MessageProducer queue3Producer = check createProducer(AUTO_ACK_SESSION, { +final MessageProducer queue3Producer = check createProducer(autoAckSession, { 'type: QUEUE, name: "test-queue-3" }); @@ -38,7 +38,7 @@ isolated boolean queue3ServiceReceivedTextMsg = false; isolated boolean queue3ServiceReceivedMapMsg = false; isolated boolean queue3ServiceReceivedBytesMsg = false; -final MessageProducer topic3Producer = check createProducer(AUTO_ACK_SESSION, { +final MessageProducer topic3Producer = check createProducer(autoAckSession, { 'type: TOPIC, name: "test-topic-3" }); @@ -238,7 +238,7 @@ function testNonIsolatedMessageListener() returns error? { check nonIsolatedMsgListener.attach(nonIsolatedSvc, "non-isolated-service"); check nonIsolatedMsgListener.'start(); - MessageProducer producer = check createProducer(AUTO_ACK_SESSION, { + MessageProducer producer = check createProducer(autoAckSession, { 'type: QUEUE, name: "test-isolation" }); @@ -323,7 +323,7 @@ isolated function testMessageListenerWithCaller() returns error? { check msgListener.attach(consumerSvc, "test-caller-service"); check msgListener.'start(); - MessageProducer producer = check createProducer(AUTO_ACK_SESSION, { + MessageProducer producer = check createProducer(autoAckSession, { 'type: QUEUE, name: "test-caller" }); @@ -393,7 +393,7 @@ isolated function testMessageListenerReturningError() returns error? { check msgListener.attach(consumerSvc, "test-onMessage-error-service"); check msgListener.'start(); - MessageProducer producer = check createProducer(AUTO_ACK_SESSION, { + MessageProducer producer = check createProducer(autoAckSession, { 'type: QUEUE, name: "test-onMessage-error" }); diff --git a/ballerina/tests/jms_producer_tests.bal b/ballerina/tests/jms_producer_tests.bal index 15d4590..1aa04ce 100644 --- a/ballerina/tests/jms_producer_tests.bal +++ b/ballerina/tests/jms_producer_tests.bal @@ -20,7 +20,7 @@ import ballerina/test; groups: ["producer"] } isolated function testCreateProducerWithoutQueueName() returns error? { - MessageProducer|Error producer = AUTO_ACK_SESSION.createProducer({ + MessageProducer|Error producer = autoAckSession.createProducer({ 'type: QUEUE }); test:assertTrue(producer is Error, "Allowing creating a queue-producer without queue-name"); @@ -35,7 +35,7 @@ isolated function testCreateProducerWithoutQueueName() returns error? { groups: ["producer"] } isolated function testProducerSendToWithoutQueueName() returns error? { - MessageProducer producer = check AUTO_ACK_SESSION.createProducer(); + MessageProducer producer = check autoAckSession.createProducer(); TextMessage message = { content: "This is a sample message" }; @@ -52,7 +52,7 @@ isolated function testProducerSendToWithoutQueueName() returns error? { groups: ["producer"] } isolated function testReplyToErrorForQueue() returns error? { - MessageProducer producer = check AUTO_ACK_SESSION.createProducer(); + MessageProducer producer = check autoAckSession.createProducer(); TextMessage message = { content: "This is a request message", correlationId: "cid-123", @@ -76,7 +76,7 @@ isolated function testReplyToErrorForQueue() returns error? { groups: ["producer"] } isolated function testReplyToErrorForTopic() returns error? { - MessageProducer producer = check AUTO_ACK_SESSION.createProducer(); + MessageProducer producer = check autoAckSession.createProducer(); TextMessage message = { content: "This is a request message", correlationId: "cid-123", diff --git a/ballerina/tests/jms_queue_tests.bal b/ballerina/tests/jms_queue_tests.bal index c05a89a..2711f61 100644 --- a/ballerina/tests/jms_queue_tests.bal +++ b/ballerina/tests/jms_queue_tests.bal @@ -16,11 +16,11 @@ import ballerina/test; -final MessageProducer queue1Producer = check createProducer(AUTO_ACK_SESSION, { +final MessageProducer queue1Producer = check createProducer(autoAckSession, { 'type: QUEUE, name: "test-queue-1" }); -final MessageConsumer queue1Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { +final MessageConsumer queue1Consumer = check createConsumer(autoAckSession, destination = { 'type: QUEUE, name: "test-queue-1" }); @@ -80,7 +80,7 @@ isolated function testQueueWithBytesMessage() returns error? { groups: ["queue"] } isolated function testTempQueue() returns error? { - MessageProducer tempQueueProducer = check createProducer(AUTO_ACK_SESSION, { + MessageProducer tempQueueProducer = check createProducer(autoAckSession, { 'type: TEMPORARY_QUEUE }); string content = "This is a sample message"; @@ -106,8 +106,8 @@ isolated function testQueueProducerSendToError() returns error? { "Allowing to send messages to other destination rather than the configured destination"); } -final MessageProducer queueProducerWithoutDestination = check createProducerWithoutDestination(AUTO_ACK_SESSION); -final MessageConsumer queue2Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { +final MessageProducer queueProducerWithoutDestination = check createProducerWithoutDestination(autoAckSession); +final MessageConsumer queue2Consumer = check createConsumer(autoAckSession, destination = { 'type: QUEUE, name: "test-queue-2" }); @@ -176,7 +176,7 @@ isolated function testQueueWithBytesMessageUsingSendTo() returns error? { groups: ["queue"] } isolated function testTempQueueUsingSendTo() returns error? { - MessageProducer tempQueueProducer = check createProducerWithoutDestination(AUTO_ACK_SESSION); + MessageProducer tempQueueProducer = check createProducerWithoutDestination(autoAckSession); string content = "This is a sample message"; TextMessage message = { content: content diff --git a/ballerina/tests/jms_topic_tests.bal b/ballerina/tests/jms_topic_tests.bal index e7c1d77..11d2223 100644 --- a/ballerina/tests/jms_topic_tests.bal +++ b/ballerina/tests/jms_topic_tests.bal @@ -16,11 +16,11 @@ import ballerina/test; -final MessageProducer topic1Producer = check createProducer(AUTO_ACK_SESSION, { +final MessageProducer topic1Producer = check createProducer(autoAckSession, { 'type: TOPIC, name: "test-topic-1" }); -final MessageConsumer topic1Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { +final MessageConsumer topic1Consumer = check createConsumer(autoAckSession, destination = { 'type: TOPIC, name: "test-topic-1" }); @@ -80,7 +80,7 @@ isolated function testTopicWithBytesMessage() returns error? { groups: ["topic"] } isolated function testTempTopic() returns error? { - MessageProducer tempTopicProducer = check createProducer(AUTO_ACK_SESSION, { + MessageProducer tempTopicProducer = check createProducer(autoAckSession, { 'type: TEMPORARY_TOPIC }); string content = "This is a sample message"; @@ -91,8 +91,8 @@ isolated function testTempTopic() returns error? { check tempTopicProducer->close(); } -final MessageProducer topicProducerWithoutDestination = check createProducerWithoutDestination(AUTO_ACK_SESSION); -final MessageConsumer topic2Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { +final MessageProducer topicProducerWithoutDestination = check createProducerWithoutDestination(autoAckSession); +final MessageConsumer topic2Consumer = check createConsumer(autoAckSession, destination = { 'type: TOPIC, name: "test-topic-2" }); @@ -161,7 +161,7 @@ isolated function testTopicProducerSendToBytesMessage() returns error? { groups: ["queue"] } isolated function testTempTopicUsingSendTo() returns error? { - MessageProducer tempTopicProducer = check createProducerWithoutDestination(AUTO_ACK_SESSION); + MessageProducer tempTopicProducer = check createProducerWithoutDestination(autoAckSession); string content = "This is a sample message"; TextMessage message = { content: content diff --git a/ballerina/tests/test_commons.bal b/ballerina/tests/test_commons.bal index 4fdbe52..d97ca6a 100644 --- a/ballerina/tests/test_commons.bal +++ b/ballerina/tests/test_commons.bal @@ -17,15 +17,15 @@ import ballerina/test; import ballerinax/activemq.driver as _; -final Connection TEST_CONNECTION = check new ( +final Connection testConnection = check new ( initialContextFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory", providerUrl = "tcp://localhost:61616" ); -final Session AUTO_ACK_SESSION = check createSession(AUTO_ACKNOWLEDGE); +final Session autoAckSession = check createSession(AUTO_ACKNOWLEDGE); isolated function createSession(AcknowledgementMode acknowledgementMode) returns Session|error { - return TEST_CONNECTION->createSession(acknowledgementMode); + return testConnection->createSession(acknowledgementMode); } isolated function createProducer(Session session, Destination destination) returns MessageProducer|error { @@ -44,6 +44,6 @@ isolated function createConsumer(Session session, *ConsumerOptions options) retu alwaysRun: true } isolated function afterSuite() returns error? { - check AUTO_ACK_SESSION->close(); - check TEST_CONNECTION->close(); + check autoAckSession->close(); + check testConnection->close(); } From 362a29e52605cdfbab616807644ea2e0083fed61 Mon Sep 17 00:00:00 2001 From: Ayesh Almeida Date: Thu, 21 Nov 2024 16:44:45 +0530 Subject: [PATCH 7/7] Revert "Refactor the code to use camal-case variable names" This reverts commit b3b9a72757de6a0a2068ca2a073d40e1cb46eb1b. --- ballerina/tests/failover_connection_tests.bal | 23 ++++++------------- ballerina/tests/jms_consumer_tests.bal | 12 +++++----- .../tests/jms_message_listener_tests.bal | 10 ++++---- ballerina/tests/jms_producer_tests.bal | 8 +++---- ballerina/tests/jms_queue_tests.bal | 12 +++++----- ballerina/tests/jms_topic_tests.bal | 12 +++++----- ballerina/tests/test_commons.bal | 10 ++++---- 7 files changed, 39 insertions(+), 48 deletions(-) diff --git a/ballerina/tests/failover_connection_tests.bal b/ballerina/tests/failover_connection_tests.bal index 155803b..45cc283 100644 --- a/ballerina/tests/failover_connection_tests.bal +++ b/ballerina/tests/failover_connection_tests.bal @@ -17,26 +17,26 @@ import ballerina/test; import ballerinax/activemq.driver as _; -final Connection testFailoverConnection = check new ( +final Connection TEST_FAILOVER_CONNECTION = check new ( initialContextFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory", providerUrl = "failover:(tcp://localhost:61616)" ); -final Session failoverAutoAckSession = check createSession(AUTO_ACKNOWLEDGE); +final Session FAILOVER_AUTO_ACK_SESSION = check createSession(AUTO_ACKNOWLEDGE); isolated function createFailoverSession(AcknowledgementMode acknowledgementMode) returns Session|error { - return testFailoverConnection->createSession(acknowledgementMode); + return TEST_FAILOVER_CONNECTION->createSession(acknowledgementMode); } @test:Config { groups: ["failover"] } isolated function testQueueWithTextMessageWithFailover() returns error? { - MessageProducer failoverQueueProducer = check createProducer(failoverAutoAckSession, { + MessageProducer failoverQueueProducer = check createProducer(FAILOVER_AUTO_ACK_SESSION, { 'type: QUEUE, name: "test-failover-queue" }); - final MessageConsumer failoverQueueConsumer = check createConsumer(failoverAutoAckSession, destination = { + final MessageConsumer failoverQueueConsumer = check createConsumer(FAILOVER_AUTO_ACK_SESSION, destination = { 'type: QUEUE, name: "test-failover-queue" }); @@ -60,11 +60,11 @@ isolated function testQueueWithTextMessageWithFailover() returns error? { groups: ["failover"] } isolated function testTopicWithTextMessageWithFailover() returns error? { - MessageProducer failoverTopicProducer = check createProducer(autoAckSession, { + MessageProducer failoverTopicProducer = check createProducer(AUTO_ACK_SESSION, { 'type: TOPIC, name: "test-failover-topic" }); - MessageConsumer failoverTopicConsumer = check createConsumer(autoAckSession, destination = { + MessageConsumer failoverTopicConsumer = check createConsumer(AUTO_ACK_SESSION, destination = { 'type: TOPIC, name: "test-failover-topic" }); @@ -84,12 +84,3 @@ isolated function testTopicWithTextMessageWithFailover() returns error? { check failoverTopicConsumer->close(); } -@test:AfterGroups { - groups: ["failover"] -} -isolated function afterSuite() returns error? { - check failoverAutoAckSession->close(); - check testFailoverConnection->close(); -} - - diff --git a/ballerina/tests/jms_consumer_tests.bal b/ballerina/tests/jms_consumer_tests.bal index 1f25866..ed35d9f 100644 --- a/ballerina/tests/jms_consumer_tests.bal +++ b/ballerina/tests/jms_consumer_tests.bal @@ -17,11 +17,11 @@ import ballerina/lang.runtime; import ballerina/test; -final MessageProducer queue7Producer = check createProducer(autoAckSession, { +final MessageProducer queue7Producer = check createProducer(AUTO_ACK_SESSION, { 'type: QUEUE, name: "test-queue-7" }); -final MessageConsumer queue7Consumer = check createConsumer(autoAckSession, destination = { +final MessageConsumer queue7Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { 'type: QUEUE, name: "test-queue-7" }); @@ -61,7 +61,7 @@ isolated function testRequestReplyWithQueue() returns error? { Message? request = check queue7Consumer->receive(5000); test:assertTrue(request is TextMessage, "Invalid message received"); if request is TextMessage { - MessageProducer replyProducer = check createProducer(autoAckSession, { + MessageProducer replyProducer = check createProducer(AUTO_ACK_SESSION, { 'type: QUEUE, name: "reply-queue" }); @@ -94,7 +94,7 @@ isolated function testRequestReplyWithTempQueue() returns error? { if request is TextMessage { test:assertTrue(request.replyTo is Destination, "Could not find the replyTo destination in a request-message"); Destination replyTo = check request.replyTo.ensureType(); - MessageProducer replyProducer = check createProducer(autoAckSession, replyTo); + MessageProducer replyProducer = check createProducer(AUTO_ACK_SESSION, replyTo); test:assertTrue(request.correlationId is string, "Could not find the correlation Id"); TextMessage replyMessage = { content: "This is a reply message" @@ -130,11 +130,11 @@ isolated function testReceiveMapMessageWithMultipleTypes() returns error? { } } -final MessageProducer topic7Producer = check createProducer(autoAckSession, { +final MessageProducer topic7Producer = check createProducer(AUTO_ACK_SESSION, { 'type: TOPIC, name: "test-topic-7" }); -final MessageConsumer topic7Consumer = check createConsumer(autoAckSession, destination = { +final MessageConsumer topic7Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { 'type: TOPIC, name: "test-topic-7" }); diff --git a/ballerina/tests/jms_message_listener_tests.bal b/ballerina/tests/jms_message_listener_tests.bal index 767b3bb..42f0835 100644 --- a/ballerina/tests/jms_message_listener_tests.bal +++ b/ballerina/tests/jms_message_listener_tests.bal @@ -17,7 +17,7 @@ import ballerina/lang.runtime; import ballerina/test; -final MessageProducer queue3Producer = check createProducer(autoAckSession, { +final MessageProducer queue3Producer = check createProducer(AUTO_ACK_SESSION, { 'type: QUEUE, name: "test-queue-3" }); @@ -38,7 +38,7 @@ isolated boolean queue3ServiceReceivedTextMsg = false; isolated boolean queue3ServiceReceivedMapMsg = false; isolated boolean queue3ServiceReceivedBytesMsg = false; -final MessageProducer topic3Producer = check createProducer(autoAckSession, { +final MessageProducer topic3Producer = check createProducer(AUTO_ACK_SESSION, { 'type: TOPIC, name: "test-topic-3" }); @@ -238,7 +238,7 @@ function testNonIsolatedMessageListener() returns error? { check nonIsolatedMsgListener.attach(nonIsolatedSvc, "non-isolated-service"); check nonIsolatedMsgListener.'start(); - MessageProducer producer = check createProducer(autoAckSession, { + MessageProducer producer = check createProducer(AUTO_ACK_SESSION, { 'type: QUEUE, name: "test-isolation" }); @@ -323,7 +323,7 @@ isolated function testMessageListenerWithCaller() returns error? { check msgListener.attach(consumerSvc, "test-caller-service"); check msgListener.'start(); - MessageProducer producer = check createProducer(autoAckSession, { + MessageProducer producer = check createProducer(AUTO_ACK_SESSION, { 'type: QUEUE, name: "test-caller" }); @@ -393,7 +393,7 @@ isolated function testMessageListenerReturningError() returns error? { check msgListener.attach(consumerSvc, "test-onMessage-error-service"); check msgListener.'start(); - MessageProducer producer = check createProducer(autoAckSession, { + MessageProducer producer = check createProducer(AUTO_ACK_SESSION, { 'type: QUEUE, name: "test-onMessage-error" }); diff --git a/ballerina/tests/jms_producer_tests.bal b/ballerina/tests/jms_producer_tests.bal index 1aa04ce..15d4590 100644 --- a/ballerina/tests/jms_producer_tests.bal +++ b/ballerina/tests/jms_producer_tests.bal @@ -20,7 +20,7 @@ import ballerina/test; groups: ["producer"] } isolated function testCreateProducerWithoutQueueName() returns error? { - MessageProducer|Error producer = autoAckSession.createProducer({ + MessageProducer|Error producer = AUTO_ACK_SESSION.createProducer({ 'type: QUEUE }); test:assertTrue(producer is Error, "Allowing creating a queue-producer without queue-name"); @@ -35,7 +35,7 @@ isolated function testCreateProducerWithoutQueueName() returns error? { groups: ["producer"] } isolated function testProducerSendToWithoutQueueName() returns error? { - MessageProducer producer = check autoAckSession.createProducer(); + MessageProducer producer = check AUTO_ACK_SESSION.createProducer(); TextMessage message = { content: "This is a sample message" }; @@ -52,7 +52,7 @@ isolated function testProducerSendToWithoutQueueName() returns error? { groups: ["producer"] } isolated function testReplyToErrorForQueue() returns error? { - MessageProducer producer = check autoAckSession.createProducer(); + MessageProducer producer = check AUTO_ACK_SESSION.createProducer(); TextMessage message = { content: "This is a request message", correlationId: "cid-123", @@ -76,7 +76,7 @@ isolated function testReplyToErrorForQueue() returns error? { groups: ["producer"] } isolated function testReplyToErrorForTopic() returns error? { - MessageProducer producer = check autoAckSession.createProducer(); + MessageProducer producer = check AUTO_ACK_SESSION.createProducer(); TextMessage message = { content: "This is a request message", correlationId: "cid-123", diff --git a/ballerina/tests/jms_queue_tests.bal b/ballerina/tests/jms_queue_tests.bal index 2711f61..c05a89a 100644 --- a/ballerina/tests/jms_queue_tests.bal +++ b/ballerina/tests/jms_queue_tests.bal @@ -16,11 +16,11 @@ import ballerina/test; -final MessageProducer queue1Producer = check createProducer(autoAckSession, { +final MessageProducer queue1Producer = check createProducer(AUTO_ACK_SESSION, { 'type: QUEUE, name: "test-queue-1" }); -final MessageConsumer queue1Consumer = check createConsumer(autoAckSession, destination = { +final MessageConsumer queue1Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { 'type: QUEUE, name: "test-queue-1" }); @@ -80,7 +80,7 @@ isolated function testQueueWithBytesMessage() returns error? { groups: ["queue"] } isolated function testTempQueue() returns error? { - MessageProducer tempQueueProducer = check createProducer(autoAckSession, { + MessageProducer tempQueueProducer = check createProducer(AUTO_ACK_SESSION, { 'type: TEMPORARY_QUEUE }); string content = "This is a sample message"; @@ -106,8 +106,8 @@ isolated function testQueueProducerSendToError() returns error? { "Allowing to send messages to other destination rather than the configured destination"); } -final MessageProducer queueProducerWithoutDestination = check createProducerWithoutDestination(autoAckSession); -final MessageConsumer queue2Consumer = check createConsumer(autoAckSession, destination = { +final MessageProducer queueProducerWithoutDestination = check createProducerWithoutDestination(AUTO_ACK_SESSION); +final MessageConsumer queue2Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { 'type: QUEUE, name: "test-queue-2" }); @@ -176,7 +176,7 @@ isolated function testQueueWithBytesMessageUsingSendTo() returns error? { groups: ["queue"] } isolated function testTempQueueUsingSendTo() returns error? { - MessageProducer tempQueueProducer = check createProducerWithoutDestination(autoAckSession); + MessageProducer tempQueueProducer = check createProducerWithoutDestination(AUTO_ACK_SESSION); string content = "This is a sample message"; TextMessage message = { content: content diff --git a/ballerina/tests/jms_topic_tests.bal b/ballerina/tests/jms_topic_tests.bal index 11d2223..e7c1d77 100644 --- a/ballerina/tests/jms_topic_tests.bal +++ b/ballerina/tests/jms_topic_tests.bal @@ -16,11 +16,11 @@ import ballerina/test; -final MessageProducer topic1Producer = check createProducer(autoAckSession, { +final MessageProducer topic1Producer = check createProducer(AUTO_ACK_SESSION, { 'type: TOPIC, name: "test-topic-1" }); -final MessageConsumer topic1Consumer = check createConsumer(autoAckSession, destination = { +final MessageConsumer topic1Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { 'type: TOPIC, name: "test-topic-1" }); @@ -80,7 +80,7 @@ isolated function testTopicWithBytesMessage() returns error? { groups: ["topic"] } isolated function testTempTopic() returns error? { - MessageProducer tempTopicProducer = check createProducer(autoAckSession, { + MessageProducer tempTopicProducer = check createProducer(AUTO_ACK_SESSION, { 'type: TEMPORARY_TOPIC }); string content = "This is a sample message"; @@ -91,8 +91,8 @@ isolated function testTempTopic() returns error? { check tempTopicProducer->close(); } -final MessageProducer topicProducerWithoutDestination = check createProducerWithoutDestination(autoAckSession); -final MessageConsumer topic2Consumer = check createConsumer(autoAckSession, destination = { +final MessageProducer topicProducerWithoutDestination = check createProducerWithoutDestination(AUTO_ACK_SESSION); +final MessageConsumer topic2Consumer = check createConsumer(AUTO_ACK_SESSION, destination = { 'type: TOPIC, name: "test-topic-2" }); @@ -161,7 +161,7 @@ isolated function testTopicProducerSendToBytesMessage() returns error? { groups: ["queue"] } isolated function testTempTopicUsingSendTo() returns error? { - MessageProducer tempTopicProducer = check createProducerWithoutDestination(autoAckSession); + MessageProducer tempTopicProducer = check createProducerWithoutDestination(AUTO_ACK_SESSION); string content = "This is a sample message"; TextMessage message = { content: content diff --git a/ballerina/tests/test_commons.bal b/ballerina/tests/test_commons.bal index d97ca6a..4fdbe52 100644 --- a/ballerina/tests/test_commons.bal +++ b/ballerina/tests/test_commons.bal @@ -17,15 +17,15 @@ import ballerina/test; import ballerinax/activemq.driver as _; -final Connection testConnection = check new ( +final Connection TEST_CONNECTION = check new ( initialContextFactory = "org.apache.activemq.jndi.ActiveMQInitialContextFactory", providerUrl = "tcp://localhost:61616" ); -final Session autoAckSession = check createSession(AUTO_ACKNOWLEDGE); +final Session AUTO_ACK_SESSION = check createSession(AUTO_ACKNOWLEDGE); isolated function createSession(AcknowledgementMode acknowledgementMode) returns Session|error { - return testConnection->createSession(acknowledgementMode); + return TEST_CONNECTION->createSession(acknowledgementMode); } isolated function createProducer(Session session, Destination destination) returns MessageProducer|error { @@ -44,6 +44,6 @@ isolated function createConsumer(Session session, *ConsumerOptions options) retu alwaysRun: true } isolated function afterSuite() returns error? { - check autoAckSession->close(); - check testConnection->close(); + check AUTO_ACK_SESSION->close(); + check TEST_CONNECTION->close(); }