@@ -17,24 +17,10 @@ import (
1717 "github.com/stretchr/testify/assert"
1818)
1919
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-
3420/*
3521 * Test the creation of a text message with a string property.
3622 */
37- func TestStringPropertyTextMsg (t * testing.T ) {
23+ func TestPropertyStringTextMsg (t * testing.T ) {
3824
3925 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
4026 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -133,6 +119,13 @@ func TestStringPropertyTextMsg(t *testing.T) {
133119 assert .Nil (t , propErr )
134120 assert .Nil (t , gotPropValue )
135121
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+
136129}
137130
138131/*
@@ -475,7 +468,7 @@ func TestPropertyClearProperties(t *testing.T) {
475468/*
476469 * Test send and receive of a text message with a string property and no content.
477470 */
478- func TestStringPropertyTextMessageNilBody (t * testing.T ) {
471+ func TestPropertyStringTextMessageNilBody (t * testing.T ) {
479472
480473 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
481474 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -532,7 +525,7 @@ func TestStringPropertyTextMessageNilBody(t *testing.T) {
532525 * body. It's difficult to distinguish nil and empty string so we are expecting
533526 * that the received message will contain a nil body.
534527 */
535- func TestStringPropertyTextMessageEmptyBody (t * testing.T ) {
528+ func TestPropertyStringTextMessageEmptyBody (t * testing.T ) {
536529
537530 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
538531 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -599,7 +592,7 @@ func TestStringPropertyTextMessageEmptyBody(t *testing.T) {
599592/*
600593 * Test the creation of a text message with an int property.
601594 */
602- func TestIntProperty (t * testing.T ) {
595+ func TestPropertyInt (t * testing.T ) {
603596
604597 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
605598 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -689,7 +682,7 @@ func TestIntProperty(t *testing.T) {
689682 gotPropValue , propErr = rcvMsg .GetIntProperty (propName )
690683 assert .Nil (t , propErr )
691684 assert .Equal (t , propValue , gotPropValue )
692- propExists , propErr = txtMsg .PropertyExists (propName )
685+ propExists , propErr = rcvMsg .PropertyExists (propName )
693686 assert .Nil (t , propErr )
694687 assert .True (t , propExists ) // now exists
695688
@@ -704,16 +697,23 @@ func TestIntProperty(t *testing.T) {
704697 gotPropValue , propErr = rcvMsg .GetIntProperty (unsetPropName )
705698 assert .Nil (t , propErr )
706699 assert .Equal (t , 0 , gotPropValue )
707- propExists , propErr = txtMsg .PropertyExists (unsetPropName )
700+ propExists , propErr = rcvMsg .PropertyExists (unsetPropName )
708701 assert .Nil (t , propErr )
709702 assert .True (t , propExists ) // exists, even though it is set to zero
710703
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+
711711}
712712
713713/*
714714 * Test the creation of a text message with a double property.
715715 */
716- func TestDoubleProperty (t * testing.T ) {
716+ func TestPropertyDouble (t * testing.T ) {
717717
718718 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
719719 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -803,7 +803,7 @@ func TestDoubleProperty(t *testing.T) {
803803 gotPropValue , propErr = rcvMsg .GetDoubleProperty (propName )
804804 assert .Nil (t , propErr )
805805 assert .Equal (t , propValue , gotPropValue )
806- propExists , propErr = txtMsg .PropertyExists (propName )
806+ propExists , propErr = rcvMsg .PropertyExists (propName )
807807 assert .Nil (t , propErr )
808808 assert .True (t , propExists ) // now exists
809809
@@ -818,16 +818,23 @@ func TestDoubleProperty(t *testing.T) {
818818 gotPropValue , propErr = rcvMsg .GetDoubleProperty (unsetPropName )
819819 assert .Nil (t , propErr )
820820 assert .Equal (t , float64 (0 ), gotPropValue )
821- propExists , propErr = txtMsg .PropertyExists (unsetPropName )
821+ propExists , propErr = rcvMsg .PropertyExists (unsetPropName )
822822 assert .Nil (t , propErr )
823823 assert .True (t , propExists ) // exists, even though it is set to zero
824824
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+
825832}
826833
827834/*
828835 * Test the creation of a text message with a boolean property.
829836 */
830- func TestBooleanProperty (t * testing.T ) {
837+ func TestPropertyBoolean (t * testing.T ) {
831838
832839 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
833840 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -917,7 +924,7 @@ func TestBooleanProperty(t *testing.T) {
917924 gotPropValue , propErr = rcvMsg .GetBooleanProperty (propName )
918925 assert .Nil (t , propErr )
919926 assert .Equal (t , propValue , gotPropValue )
920- propExists , propErr = txtMsg .PropertyExists (propName )
927+ propExists , propErr = rcvMsg .PropertyExists (propName )
921928 assert .Nil (t , propErr )
922929 assert .True (t , propExists ) // now exists
923930
@@ -932,10 +939,17 @@ func TestBooleanProperty(t *testing.T) {
932939 gotPropValue , propErr = rcvMsg .GetBooleanProperty (unsetPropName )
933940 assert .Nil (t , propErr )
934941 assert .Equal (t , false , gotPropValue )
935- propExists , propErr = txtMsg .PropertyExists (unsetPropName )
942+ propExists , propErr = rcvMsg .PropertyExists (unsetPropName )
936943 assert .Nil (t , propErr )
937944 assert .True (t , propExists ) // exists, even though it is set to zero
938945
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+
939953}
940954
941955/*
@@ -1092,7 +1106,7 @@ func TestPropertyBytesMsg(t *testing.T) {
10921106/*
10931107 * Test the conversion between string message properties and other data types.
10941108 */
1095- func TestPropertyTypesStringConversion (t * testing.T ) {
1109+ func TestPropertyConversionString (t * testing.T ) {
10961110
10971111 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
10981112 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -1283,7 +1297,7 @@ func TestPropertyTypesStringConversion(t *testing.T) {
12831297/*
12841298 * Test the conversion between different int message properties and other data types.
12851299 */
1286- func TestPropertyTypesIntConversion (t * testing.T ) {
1300+ func TestPropertyConversionInt (t * testing.T ) {
12871301
12881302 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
12891303 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -1421,7 +1435,7 @@ func TestPropertyTypesIntConversion(t *testing.T) {
14211435/*
14221436 * Test the conversion between different int message properties and other data types.
14231437 */
1424- func TestPropertyTypesBoolConversion (t * testing.T ) {
1438+ func TestPropertyConversionBool (t * testing.T ) {
14251439
14261440 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
14271441 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
@@ -1499,7 +1513,7 @@ func TestPropertyTypesBoolConversion(t *testing.T) {
14991513/*
15001514 * Test the conversion between different int message properties and other data types.
15011515 */
1502- func TestPropertyTypesDoubleConversion (t * testing.T ) {
1516+ func TestPropertyConversionDouble (t * testing.T ) {
15031517
15041518 // Loads CF parameters from connection_info.json and applicationApiKey.json in the Downloads directory
15051519 cf , cfErr := mqjms .CreateConnectionFactoryFromDefaultJSONFiles ()
0 commit comments