add auto test for channel close
improve code coverage for tests by including a test for Channel::closeChannel to both Exchange and Queue test suites
This commit is contained in:
parent
9fbd0a852f
commit
6291bb7f42
|
|
@ -152,17 +152,22 @@ void ChannelPrivate::flowOk(const Frame::Method &frame)
|
|||
|
||||
void ChannelPrivate::close(int code, const QString &text, int classId, int methodId)
|
||||
{
|
||||
Frame::Method frame(Frame::fcChannel, miClose);
|
||||
QByteArray arguments;
|
||||
QDataStream stream(&arguments, QIODevice::WriteOnly);
|
||||
|
||||
Frame::writeAmqpField(stream, ShortString, client->virtualHost());
|
||||
if (!code) code = 200;
|
||||
Frame::writeAmqpField(stream, ShortUint, code);
|
||||
if (!text.isEmpty()) {
|
||||
Frame::writeAmqpField(stream, ShortString, text);
|
||||
} else {
|
||||
Frame::writeAmqpField(stream, ShortString, QLatin1String("OK"));
|
||||
}
|
||||
|
||||
stream << qint16(code);
|
||||
Frame::writeAmqpField(stream, ShortString, text);
|
||||
stream << qint16(classId);
|
||||
stream << qint16(methodId);
|
||||
Frame::writeAmqpField(stream, ShortUint, classId);
|
||||
Frame::writeAmqpField(stream, ShortUint, methodId);
|
||||
|
||||
Frame::Method frame(Frame::fcChannel, miClose);
|
||||
frame.setChannel(channelNumber);
|
||||
frame.setArguments(arguments);
|
||||
sendFrame(frame);
|
||||
}
|
||||
|
|
@ -268,7 +273,8 @@ void Channel::closeChannel()
|
|||
void Channel::reopen()
|
||||
{
|
||||
Q_D(Channel);
|
||||
closeChannel();
|
||||
if (d->opened)
|
||||
closeChannel();
|
||||
d->open();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -505,15 +505,14 @@ void ClientPrivate::open()
|
|||
|
||||
void ClientPrivate::close(int code, const QString &text, int classId, int methodId)
|
||||
{
|
||||
Frame::Method frame(Frame::fcConnection, ClientPrivate::miClose);
|
||||
QByteArray arguments;
|
||||
QDataStream stream(&arguments, QIODevice::WriteOnly);
|
||||
|
||||
stream << qint16(code);
|
||||
Frame::writeAmqpField(stream, ShortString, text);
|
||||
stream << qint16(classId);
|
||||
stream << qint16(methodId);
|
||||
|
||||
Frame::Method frame(Frame::fcConnection, ClientPrivate::miClose);
|
||||
frame.setArguments(arguments);
|
||||
sendFrame(frame);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ private Q_SLOTS:
|
|||
void removeIfUnused();
|
||||
void invalidMandatoryRouting();
|
||||
void invalidImmediateRouting();
|
||||
void closeChannel();
|
||||
|
||||
private:
|
||||
QScopedPointer<Client> client;
|
||||
|
|
@ -168,5 +169,15 @@ void tst_QAMQPExchange::invalidImmediateRouting()
|
|||
QCOMPARE(client->error(), QAMQP::NotImplementedError);
|
||||
}
|
||||
|
||||
void tst_QAMQPExchange::closeChannel()
|
||||
{
|
||||
Exchange *exchange = client->createExchange("test-close-channel");
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(opened())));
|
||||
exchange->declare(Exchange::Direct);
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(declared())));
|
||||
exchange->closeChannel();
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(closed())));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAMQPExchange)
|
||||
#include "tst_qamqpexchange.moc"
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ private Q_SLOTS:
|
|||
void invalidRoutingKey();
|
||||
void tableFieldDataTypes();
|
||||
void messageProperties();
|
||||
void closeChannel();
|
||||
|
||||
private:
|
||||
void declareQueueAndVerifyConsuming(Queue *queue);
|
||||
|
|
@ -664,6 +665,15 @@ void tst_QAMQPQueue::messageProperties()
|
|||
QCOMPARE(message.property(Message::ClusterID).toString(), QLatin1String("some-cluster-id"));
|
||||
}
|
||||
|
||||
void tst_QAMQPQueue::closeChannel()
|
||||
{
|
||||
Queue *queue = client->createQueue("test-close-channel");
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(opened())));
|
||||
declareQueueAndVerifyConsuming(queue);
|
||||
|
||||
queue->closeChannel();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(closed())));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAMQPQueue)
|
||||
#include "tst_qamqpqueue.moc"
|
||||
|
|
|
|||
Loading…
Reference in New Issue