Search in sources :

Example 1 with MQTeststepProperties

use of io.irontest.models.teststep.MQTeststepProperties in project irontest by zheng-wang.

the class MQTeststepRunner method run.

protected BasicTeststepRun run(Teststep teststep) throws Exception {
    String action = teststep.getAction();
    if (teststep.getAction() == null) {
        throw new Exception("Action not specified.");
    }
    MQTeststepProperties teststepProperties = (MQTeststepProperties) teststep.getOtherProperties();
    if (teststepProperties.getDestinationType() == null) {
        throw new Exception("Destination type not specified.");
    }
    BasicTeststepRun basicTeststepRun = new BasicTeststepRun();
    MQAPIResponse response = new MQAPIResponse();
    MQEndpointProperties endpointProperties = (MQEndpointProperties) teststep.getEndpoint().getOtherProperties();
    MQQueueManager queueManager = null;
    try {
        // connect to queue manager
        if (endpointProperties.getConnectionMode() == MQConnectionMode.BINDINGS) {
            queueManager = new MQQueueManager(endpointProperties.getQueueManagerName());
        } else {
            Hashtable qmConnProperties = new Hashtable();
            qmConnProperties.put(CMQC.HOST_NAME_PROPERTY, endpointProperties.getHost());
            qmConnProperties.put(CMQC.PORT_PROPERTY, endpointProperties.getPort());
            qmConnProperties.put(CMQC.CHANNEL_PROPERTY, endpointProperties.getSvrConnChannelName());
            queueManager = new MQQueueManager(endpointProperties.getQueueManagerName(), qmConnProperties);
        }
        if (MQDestinationType.QUEUE == teststepProperties.getDestinationType()) {
            Object responseValue = doQueueAction(queueManager, teststepProperties.getQueueName(), action, teststep.getRequest(), teststepProperties.getRfh2Header());
            response.setValue(responseValue);
        } else if (MQDestinationType.TOPIC == teststepProperties.getDestinationType()) {
            doTopicAction(queueManager, teststepProperties.getTopicString(), action, teststep.getRequest(), teststepProperties.getRfh2Header());
        }
    } finally {
        if (queueManager != null) {
            queueManager.disconnect();
        }
    }
    basicTeststepRun.setResponse(response);
    return basicTeststepRun;
}
Also used : MQEndpointProperties(io.irontest.models.endpoint.MQEndpointProperties) MQTeststepProperties(io.irontest.models.teststep.MQTeststepProperties) Hashtable(java.util.Hashtable) MQDataException(com.ibm.mq.headers.MQDataException) IOException(java.io.IOException)

Aggregations

MQDataException (com.ibm.mq.headers.MQDataException)1 MQEndpointProperties (io.irontest.models.endpoint.MQEndpointProperties)1 MQTeststepProperties (io.irontest.models.teststep.MQTeststepProperties)1 IOException (java.io.IOException)1 Hashtable (java.util.Hashtable)1