Skip to content

Commit

Permalink
Merge pull request #35 from ayeshLK/master
Browse files Browse the repository at this point in the history
Fix documentation issues
  • Loading branch information
ayeshLK authored Jan 29, 2024
2 parents c5ba608 + 2e3ed24 commit 96f8f28
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 37 deletions.
6 changes: 3 additions & 3 deletions ballerina/Ballerina.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
org = "ballerinax"
name = "ibm.ibmmq"
version = "0.1.3"
version = "0.1.4"
authors = ["Ballerina"]
keywords = ["ibm-mq"]
repository = "https://github.com/ballerina-platform/module-ballerinax-ibm.ibmmq"
Expand All @@ -12,8 +12,8 @@ distribution = "2201.8.0"
[[platform.java17.dependency]]
groupId = "io.ballerina.stdlib"
artifactId = "ibm.ibmmq-native"
version = "0.1.3"
path = "../native/build/libs/ibm.ibmmq-native-0.1.3.jar"
version = "0.1.4"
path = "../native/build/libs/ibm.ibmmq-native-0.1.4-SNAPSHOT.jar"

[[platform.java17.dependency]]
groupId = "org.json"
Expand Down
2 changes: 1 addition & 1 deletion ballerina/Dependencies.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ modules = [
[[package]]
org = "ballerinax"
name = "ibm.ibmmq"
version = "0.1.3"
version = "0.1.4"
dependencies = [
{org = "ballerina", name = "crypto"},
{org = "ballerina", name = "jballerina.java"},
Expand Down
18 changes: 18 additions & 0 deletions ballerina/destination.bal
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public isolated client class Queue {
*Destination;

# Puts a message to an IBM MQ queue.
# ```ballerina
# check queue->put({payload: "Hello World".toBytes()});
# ```
#
# + message - IBM MQ message
# + return - An `ibmmq:Error` if the operation fails or else `()`
Expand All @@ -39,6 +42,9 @@ public isolated client class Queue {
} external;

# Retrieves a message from an IBM MQ queue.
# ```ballerina
# ibmmq:Message? message = check queue->get();
# ```
#
# + getMessageOptions - Options to control message retrieval
# + return - An `ibmmq:Message` if there is a message in the queue, `()` if there
Expand All @@ -49,6 +55,9 @@ public isolated client class Queue {
} external;

# Closes the IBM MQ queue object. No further operations on this object are permitted after it is closed.
# ```ballerina
# check queue->close();
# ```
#
# + return - An `ibmmq:Error` if the operation fails or else `()`
isolated remote function close() returns Error? =
Expand All @@ -62,6 +71,9 @@ public isolated client class Topic {
*Destination;

# Puts a message to an IBM MQ topic.
#```ballerina
# check topic->put({payload: "Hello World".toBytes()});
#```
#
# + message - IBM MQ message
# + return - An `ibmmq:Error` if the operation fails or else `()`
Expand All @@ -71,6 +83,9 @@ public isolated client class Topic {
} external;

# Retrieves a message from an IBM MQ topic.
#```ballerina
# ibmmq:Message? message = check topic->get();
#```
#
# + getMessageOptions - Options to control message retrieval
# + return - An `ibmmq:Message` if there is a message in the topic, `()` if there
Expand All @@ -81,6 +96,9 @@ public isolated client class Topic {
} external;

# Closes the IBM MQ topic object. No further operations on this object are permitted after it is closed.
# ```ballerina
# check topic->close();
# ```
#
# + return - An `ibmmq:Error` if the operation fails or else `()`
isolated remote function close() returns Error? =
Expand Down
3 changes: 3 additions & 0 deletions ballerina/queue_manager.bal
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ public isolated class QueueManager {
'class: "io.ballerina.lib.ibm.ibmmq.QueueManager"
} external;

# Ends the connection to the IBM MQ queue manager.
#
# + return - An `ibmmq:Error` if the operation fails or else `()`
public isolated function disconnect() returns Error? =
@java:Method {
'class: "io.ballerina.lib.ibm.ibmmq.QueueManager"
Expand Down
52 changes: 39 additions & 13 deletions ballerina/tests/queue_producer_consumer_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import ballerina/time;
groups: ["ibmmqQueue"]
}
function basicQueueProducerConsumerTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
check producer->put({
Expand All @@ -42,7 +44,9 @@ function basicQueueProducerConsumerTest() returns error? {
groups: ["ibmmqQueue"]
}
function basicQueueProducerConsumerWithOneQueueObjectTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue queue = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT | MQOO_INPUT_AS_Q_DEF);
check queue->put({
payload: "Hello World with one queue".toBytes()
Expand All @@ -61,7 +65,9 @@ function basicQueueProducerConsumerWithOneQueueObjectTest() returns error? {
groups: ["ibmmqQueue"]
}
function basicQueueProducerConsumerWithJsonPayloadTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
json messageBody = {
Expand Down Expand Up @@ -116,7 +122,9 @@ function basicQueueProducerConsumerWithJsonPayloadTest() returns error? {
groups: ["ibmmqQueue"]
}
function pubSubMultipleMessagesQueueProducerConsumerTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
foreach int i in 0 ... 4 {
Expand All @@ -141,7 +149,9 @@ function pubSubMultipleMessagesQueueProducerConsumerTest() returns error? {
groups: ["ibmmqQueue"]
}
function consumerWithoutProducingMessageTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
Message|Error? result = consumer->get(options = MQGMO_WAIT, waitInterval = 5);
test:assertTrue(result is ());
Expand All @@ -153,7 +163,9 @@ function consumerWithoutProducingMessageTest() returns error? {
groups: ["ibmmqQueue"]
}
function produceToNonExistingQueueTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue|Error result = queueManager.accessQueue("NON.EXISTING.QUEUE", MQOO_OUTPUT);
if result is Error {
test:assertEquals(result.message(), "Error occurred while accessing queue: MQJE001: Completion Code '2', Reason '2085'.");
Expand All @@ -169,7 +181,9 @@ function produceToNonExistingQueueTest() returns error? {
groups: ["ibmmqQueue"]
}
function consumerConnectToNonExistingQueueTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue|Error result = queueManager.accessQueue("NON.EXISTING.QUEUE", MQOO_INPUT_AS_Q_DEF);
if result is Error {
test:assertEquals(result.message(), "Error occurred while accessing queue: MQJE001: Completion Code '2', Reason '2085'.");
Expand All @@ -185,7 +199,9 @@ function consumerConnectToNonExistingQueueTest() returns error? {
groups: ["ibmmqQueue"]
}
function produceWithInvalidQueueNameTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue|Error result = queueManager.accessQueue("INVALID QUEUE", MQOO_INPUT_AS_Q_DEF);
if result is Error {
test:assertEquals(result.message(), "Error occurred while accessing queue: MQJE001: Completion Code '2', Reason '2085'.");
Expand All @@ -201,7 +217,9 @@ function produceWithInvalidQueueNameTest() returns error? {
groups: ["ibmmqQueue"]
}
function consumeFromAnInvalidQueueNameTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue|Error result = queueManager.accessQueue("INVALID QUEUE", MQOO_INPUT_AS_Q_DEF);
if result is Error {
test:assertEquals(result.message(), "Error occurred while accessing queue: MQJE001: Completion Code '2', Reason '2085'.");
Expand All @@ -217,7 +235,9 @@ function consumeFromAnInvalidQueueNameTest() returns error? {
groups: ["ibmmqQueue"]
}
function produceAndConsumerMessageWithAdditionalPropertiesTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
time:Utc timeNow = time:utcNow();
Expand Down Expand Up @@ -257,7 +277,9 @@ function produceAndConsumerMessageWithAdditionalPropertiesTest() returns error?
groups: ["ibmmqQueue"]
}
function produceAndConsumerMessageWithAdditionalPropertiesWithJsonPayloadTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
time:Utc timeNow = time:utcNow();
Expand Down Expand Up @@ -332,7 +354,9 @@ function produceAndConsumerMessageWithAdditionalPropertiesWithJsonPayloadTest()
groups: ["ibmmqQueue"]
}
function produceAndConsumerMessageWithMultipleHeaderTypesTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
check producer->put({
Expand Down Expand Up @@ -397,7 +421,9 @@ function produceAndConsumerMessageWithMultipleHeaderTypesTest() returns error? {
groups: ["ibmmqQueue"]
}
function produceAndConsumerMessageWithMultipleHeaderTypesWithJsonPayloadTest() returns error? {
QueueManager queueManager = check new (name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN");
QueueManager queueManager = check new (
name = "QM1", host = "localhost", channel = "DEV.APP.SVRCONN",
userID = "app", password = "password");
Queue producer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_OUTPUT);
Queue consumer = check queueManager.accessQueue("DEV.QUEUE.1", MQOO_INPUT_AS_Q_DEF);
json messageBody = {
Expand Down
2 changes: 2 additions & 0 deletions ballerina/tests/resources/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
environment:
- LICENSE=accept
- MQ_QMGR_NAME=QM1
- MQ_APP_PASSWORD=password
healthcheck:
test: ["CMD-SHELL", "chkmqstarted"]
interval: 10s
Expand All @@ -26,6 +27,7 @@ services:
environment:
- LICENSE=accept
- MQ_QMGR_NAME=QM2
- MQ_APP_PASSWORD=password
volumes:
- ./secrets/server.crt:/etc/mqm/pki/keys/mykey/server.crt
- ./secrets/server.key:/etc/mqm/pki/keys/mykey/server.key
Expand Down
8 changes: 8 additions & 0 deletions ballerina/tests/secure_socket_tests.bal
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ function basicPublisherSubscriberSecureSocketTest() returns error? {
host = "localhost",
port = 1415,
channel = "DEV.APP.SVRCONN",
userID = "app",
password = "password",
sslCipherSuite = TLS12ORHIGHER,
secureSocket = {
cert: "./tests/resources/secrets/server.crt",
Expand Down Expand Up @@ -59,6 +61,8 @@ function basicQueueProducerConsumerSecureSocketTest() returns error? {
host = "localhost",
port = 1415,
channel = "DEV.APP.SVRCONN",
userID = "app",
password = "password",
sslCipherSuite = TLS12ORHIGHER,
secureSocket = {
cert: "./tests/resources/secrets/server.crt",
Expand Down Expand Up @@ -93,6 +97,8 @@ function basicPublisherSubscriberSecureSocketJksTest() returns error? {
host = "localhost",
port = 1415,
channel = "DEV.APP.SVRCONN",
userID = "app",
password = "password",
sslCipherSuite = TLS12ORHIGHER,
secureSocket = {
cert: {
Expand Down Expand Up @@ -130,6 +136,8 @@ function basicQueueProducerConsumerSecureSocketJksTest() returns error? {
host = "localhost",
port = 1415,
channel = "DEV.APP.SVRCONN",
userID = "app",
password = "password",
sslCipherSuite = TLS12ORHIGHER,
secureSocket = {
cert: {
Expand Down
Loading

0 comments on commit 96f8f28

Please sign in to comment.