@@ -17,24 +17,10 @@ import (
17
17
"github.com/stretchr/testify/assert"
18
18
)
19
19
20
- /*
21
- * mq-golang: SetMP, DltMP, InqMP
22
- * https://github.com/ibm-messaging/mq-golang/blob/95e9b8b09a1fc167747de7d066c49adb86e14dda/ibmmq/mqi.go#L1080
23
- *
24
- * mq-golang sample application to set properties
25
- * https://github.com/ibm-messaging/mq-golang/blob/master/samples/amqsprop.go#L49
26
- *
27
- * JMS: SetStringProperty, GetStringProperty,
28
- * https://github.com/eclipse-ee4j/messaging/blob/master/api/src/main/java/jakarta/jms/Message.java#L1119
29
- *
30
- * Property conversion between types
31
- *
32
- */
33
-
34
20
/*
35
21
* Test the creation of a text message with a string property.
36
22
*/
37
- func TestStringPropertyTextMsg (t * testing.T ) {
23
+ func TestPropertyStringTextMsg (t * testing.T ) {
38
24
39
25
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
40
26
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -133,6 +119,13 @@ func TestStringPropertyTextMsg(t *testing.T) {
133
119
assert .Nil (t , propErr )
134
120
assert .Nil (t , gotPropValue )
135
121
122
+ // Error checking on property names
123
+ emptyNameValue , emptyNameErr := rcvMsg .GetStringProperty ("" )
124
+ assert .NotNil (t , emptyNameErr )
125
+ assert .Equal (t , "2513" , emptyNameErr .GetErrorCode ())
126
+ assert .Equal (t , "MQRC_PROPERTY_NAME_LENGTH_ERR" , emptyNameErr .GetReason ())
127
+ assert .Nil (t , emptyNameValue )
128
+
136
129
}
137
130
138
131
/*
@@ -475,7 +468,7 @@ func TestPropertyClearProperties(t *testing.T) {
475
468
/*
476
469
* Test send and receive of a text message with a string property and no content.
477
470
*/
478
- func TestStringPropertyTextMessageNilBody (t * testing.T ) {
471
+ func TestPropertyStringTextMessageNilBody (t * testing.T ) {
479
472
480
473
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
481
474
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -532,7 +525,7 @@ func TestStringPropertyTextMessageNilBody(t *testing.T) {
532
525
* body. It's difficult to distinguish nil and empty string so we are expecting
533
526
* that the received message will contain a nil body.
534
527
*/
535
- func TestStringPropertyTextMessageEmptyBody (t * testing.T ) {
528
+ func TestPropertyStringTextMessageEmptyBody (t * testing.T ) {
536
529
537
530
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
538
531
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -599,7 +592,7 @@ func TestStringPropertyTextMessageEmptyBody(t *testing.T) {
599
592
/*
600
593
* Test the creation of a text message with an int property.
601
594
*/
602
- func TestIntProperty (t * testing.T ) {
595
+ func TestPropertyInt (t * testing.T ) {
603
596
604
597
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
605
598
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -689,7 +682,7 @@ func TestIntProperty(t *testing.T) {
689
682
gotPropValue , propErr = rcvMsg .GetIntProperty (propName )
690
683
assert .Nil (t , propErr )
691
684
assert .Equal (t , propValue , gotPropValue )
692
- propExists , propErr = txtMsg .PropertyExists (propName )
685
+ propExists , propErr = rcvMsg .PropertyExists (propName )
693
686
assert .Nil (t , propErr )
694
687
assert .True (t , propExists ) // now exists
695
688
@@ -704,16 +697,23 @@ func TestIntProperty(t *testing.T) {
704
697
gotPropValue , propErr = rcvMsg .GetIntProperty (unsetPropName )
705
698
assert .Nil (t , propErr )
706
699
assert .Equal (t , 0 , gotPropValue )
707
- propExists , propErr = txtMsg .PropertyExists (unsetPropName )
700
+ propExists , propErr = rcvMsg .PropertyExists (unsetPropName )
708
701
assert .Nil (t , propErr )
709
702
assert .True (t , propExists ) // exists, even though it is set to zero
710
703
704
+ // Error checking on property names
705
+ emptyNameValue , emptyNameErr := rcvMsg .GetStringProperty ("" )
706
+ assert .NotNil (t , emptyNameErr )
707
+ assert .Equal (t , "2513" , emptyNameErr .GetErrorCode ())
708
+ assert .Equal (t , "MQRC_PROPERTY_NAME_LENGTH_ERR" , emptyNameErr .GetReason ())
709
+ assert .Nil (t , emptyNameValue )
710
+
711
711
}
712
712
713
713
/*
714
714
* Test the creation of a text message with a double property.
715
715
*/
716
- func TestDoubleProperty (t * testing.T ) {
716
+ func TestPropertyDouble (t * testing.T ) {
717
717
718
718
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
719
719
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -803,7 +803,7 @@ func TestDoubleProperty(t *testing.T) {
803
803
gotPropValue , propErr = rcvMsg .GetDoubleProperty (propName )
804
804
assert .Nil (t , propErr )
805
805
assert .Equal (t , propValue , gotPropValue )
806
- propExists , propErr = txtMsg .PropertyExists (propName )
806
+ propExists , propErr = rcvMsg .PropertyExists (propName )
807
807
assert .Nil (t , propErr )
808
808
assert .True (t , propExists ) // now exists
809
809
@@ -818,16 +818,23 @@ func TestDoubleProperty(t *testing.T) {
818
818
gotPropValue , propErr = rcvMsg .GetDoubleProperty (unsetPropName )
819
819
assert .Nil (t , propErr )
820
820
assert .Equal (t , float64 (0 ), gotPropValue )
821
- propExists , propErr = txtMsg .PropertyExists (unsetPropName )
821
+ propExists , propErr = rcvMsg .PropertyExists (unsetPropName )
822
822
assert .Nil (t , propErr )
823
823
assert .True (t , propExists ) // exists, even though it is set to zero
824
824
825
+ // Error checking on property names
826
+ emptyNameValue , emptyNameErr := rcvMsg .GetStringProperty ("" )
827
+ assert .NotNil (t , emptyNameErr )
828
+ assert .Equal (t , "2513" , emptyNameErr .GetErrorCode ())
829
+ assert .Equal (t , "MQRC_PROPERTY_NAME_LENGTH_ERR" , emptyNameErr .GetReason ())
830
+ assert .Nil (t , emptyNameValue )
831
+
825
832
}
826
833
827
834
/*
828
835
* Test the creation of a text message with a boolean property.
829
836
*/
830
- func TestBooleanProperty (t * testing.T ) {
837
+ func TestPropertyBoolean (t * testing.T ) {
831
838
832
839
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
833
840
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -917,7 +924,7 @@ func TestBooleanProperty(t *testing.T) {
917
924
gotPropValue , propErr = rcvMsg .GetBooleanProperty (propName )
918
925
assert .Nil (t , propErr )
919
926
assert .Equal (t , propValue , gotPropValue )
920
- propExists , propErr = txtMsg .PropertyExists (propName )
927
+ propExists , propErr = rcvMsg .PropertyExists (propName )
921
928
assert .Nil (t , propErr )
922
929
assert .True (t , propExists ) // now exists
923
930
@@ -932,10 +939,17 @@ func TestBooleanProperty(t *testing.T) {
932
939
gotPropValue , propErr = rcvMsg .GetBooleanProperty (unsetPropName )
933
940
assert .Nil (t , propErr )
934
941
assert .Equal (t , false , gotPropValue )
935
- propExists , propErr = txtMsg .PropertyExists (unsetPropName )
942
+ propExists , propErr = rcvMsg .PropertyExists (unsetPropName )
936
943
assert .Nil (t , propErr )
937
944
assert .True (t , propExists ) // exists, even though it is set to zero
938
945
946
+ // Error checking on property names
947
+ emptyNameValue , emptyNameErr := rcvMsg .GetStringProperty ("" )
948
+ assert .NotNil (t , emptyNameErr )
949
+ assert .Equal (t , "2513" , emptyNameErr .GetErrorCode ())
950
+ assert .Equal (t , "MQRC_PROPERTY_NAME_LENGTH_ERR" , emptyNameErr .GetReason ())
951
+ assert .Nil (t , emptyNameValue )
952
+
939
953
}
940
954
941
955
/*
@@ -1092,7 +1106,7 @@ func TestPropertyBytesMsg(t *testing.T) {
1092
1106
/*
1093
1107
* Test the conversion between string message properties and other data types.
1094
1108
*/
1095
- func TestPropertyTypesStringConversion (t * testing.T ) {
1109
+ func TestPropertyConversionString (t * testing.T ) {
1096
1110
1097
1111
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
1098
1112
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -1283,7 +1297,7 @@ func TestPropertyTypesStringConversion(t *testing.T) {
1283
1297
/*
1284
1298
* Test the conversion between different int message properties and other data types.
1285
1299
*/
1286
- func TestPropertyTypesIntConversion (t * testing.T ) {
1300
+ func TestPropertyConversionInt (t * testing.T ) {
1287
1301
1288
1302
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
1289
1303
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -1421,7 +1435,7 @@ func TestPropertyTypesIntConversion(t *testing.T) {
1421
1435
/*
1422
1436
* Test the conversion between different int message properties and other data types.
1423
1437
*/
1424
- func TestPropertyTypesBoolConversion (t * testing.T ) {
1438
+ func TestPropertyConversionBool (t * testing.T ) {
1425
1439
1426
1440
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
1427
1441
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -1499,7 +1513,7 @@ func TestPropertyTypesBoolConversion(t *testing.T) {
1499
1513
/*
1500
1514
* Test the conversion between different int message properties and other data types.
1501
1515
*/
1502
- func TestPropertyTypesDoubleConversion (t * testing.T ) {
1516
+ func TestPropertyConversionDouble (t * testing.T ) {
1503
1517
1504
1518
// Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
1505
1519
cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
0 commit comments