added autotests for exclusive queues
This commit is contained in:
parent
613bd5ba96
commit
aff5fb70b7
|
|
@ -19,7 +19,9 @@ private Q_SLOTS:
|
||||||
void standardExchanges_data();
|
void standardExchanges_data();
|
||||||
void standardExchanges();
|
void standardExchanges();
|
||||||
|
|
||||||
void unnamedQueue();
|
void unnamed();
|
||||||
|
void exclusiveAccess();
|
||||||
|
void exclusiveRemoval();
|
||||||
|
|
||||||
void remove();
|
void remove();
|
||||||
void removeIfUnused();
|
void removeIfUnused();
|
||||||
|
|
@ -42,8 +44,10 @@ void tst_QAMQPQueue::init()
|
||||||
|
|
||||||
void tst_QAMQPQueue::cleanup()
|
void tst_QAMQPQueue::cleanup()
|
||||||
{
|
{
|
||||||
client->disconnectFromHost();
|
if (client->isConnected()) {
|
||||||
QVERIFY(waitForSignal(client.data(), SIGNAL(disconnected())));
|
client->disconnectFromHost();
|
||||||
|
QVERIFY(waitForSignal(client.data(), SIGNAL(disconnected())));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAMQPQueue::defaultExchange()
|
void tst_QAMQPQueue::defaultExchange()
|
||||||
|
|
@ -92,7 +96,7 @@ void tst_QAMQPQueue::standardExchanges()
|
||||||
QCOMPARE(queue->getMessage().payload(), QByteArray("test message"));
|
QCOMPARE(queue->getMessage().payload(), QByteArray("test message"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QAMQPQueue::unnamedQueue()
|
void tst_QAMQPQueue::unnamed()
|
||||||
{
|
{
|
||||||
Queue *queue = client->createQueue();
|
Queue *queue = client->createQueue();
|
||||||
queue->declare();
|
queue->declare();
|
||||||
|
|
@ -102,6 +106,45 @@ void tst_QAMQPQueue::unnamedQueue()
|
||||||
QVERIFY(!queue->name().isEmpty());
|
QVERIFY(!queue->name().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QAMQPQueue::exclusiveAccess()
|
||||||
|
{
|
||||||
|
Queue *queue = client->createQueue("test-exclusive-queue");
|
||||||
|
queue->declare(Queue::Exclusive);
|
||||||
|
QVERIFY(waitForSignal(queue, SIGNAL(declared())));
|
||||||
|
|
||||||
|
Client secondClient;
|
||||||
|
secondClient.connectToHost();
|
||||||
|
QVERIFY(waitForSignal(&secondClient, SIGNAL(connected())));
|
||||||
|
Queue *passiveQueue = secondClient.createQueue("test-exclusive-queue");
|
||||||
|
passiveQueue->declare(Queue::Passive);
|
||||||
|
QVERIFY(waitForSignal(passiveQueue, SIGNAL(error(ChannelError))));
|
||||||
|
QCOMPARE(passiveQueue->error(), Channel::ResourceLockedError);
|
||||||
|
|
||||||
|
secondClient.disconnectFromHost();
|
||||||
|
QVERIFY(waitForSignal(&secondClient, SIGNAL(disconnected())));
|
||||||
|
}
|
||||||
|
|
||||||
|
void tst_QAMQPQueue::exclusiveRemoval()
|
||||||
|
{
|
||||||
|
Queue *queue = client->createQueue("test-exclusive-queue");
|
||||||
|
queue->declare(Queue::Exclusive);
|
||||||
|
QVERIFY(waitForSignal(queue, SIGNAL(declared())));
|
||||||
|
client.data()->disconnectFromHost();
|
||||||
|
QVERIFY(waitForSignal(client.data(), SIGNAL(disconnected())));
|
||||||
|
|
||||||
|
// create a new client and try to access the queue that should
|
||||||
|
// no longer exist
|
||||||
|
Client secondClient;
|
||||||
|
secondClient.connectToHost();
|
||||||
|
QVERIFY(waitForSignal(&secondClient, SIGNAL(connected())));
|
||||||
|
Queue *passiveQueue = secondClient.createQueue("test-exclusive-queue");
|
||||||
|
passiveQueue->declare(Queue::Passive);
|
||||||
|
QVERIFY(waitForSignal(passiveQueue, SIGNAL(error(ChannelError))));
|
||||||
|
QCOMPARE(passiveQueue->error(), Channel::NotFoundError);
|
||||||
|
secondClient.disconnectFromHost();
|
||||||
|
QVERIFY(waitForSignal(&secondClient, SIGNAL(disconnected())));
|
||||||
|
}
|
||||||
|
|
||||||
void tst_QAMQPQueue::remove()
|
void tst_QAMQPQueue::remove()
|
||||||
{
|
{
|
||||||
Queue *queue = client->createQueue("test-remove");
|
Queue *queue = client->createQueue("test-remove");
|
||||||
|
|
@ -120,7 +163,7 @@ void tst_QAMQPQueue::removeIfUnused()
|
||||||
|
|
||||||
queue->remove(Queue::roIfUnused);
|
queue->remove(Queue::roIfUnused);
|
||||||
QVERIFY(waitForSignal(queue, SIGNAL(error(ChannelError))));
|
QVERIFY(waitForSignal(queue, SIGNAL(error(ChannelError))));
|
||||||
QCOMPARE(queue->error(), Channel::PreconditionFailed);
|
QCOMPARE(queue->error(), Channel::PreconditionFailedError);
|
||||||
QVERIFY(!queue->errorString().isEmpty());
|
QVERIFY(!queue->errorString().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,7 +183,7 @@ void tst_QAMQPQueue::removeIfEmpty()
|
||||||
|
|
||||||
queue->remove(Queue::roIfEmpty);
|
queue->remove(Queue::roIfEmpty);
|
||||||
QVERIFY(waitForSignal(queue, SIGNAL(error(ChannelError))));
|
QVERIFY(waitForSignal(queue, SIGNAL(error(ChannelError))));
|
||||||
QCOMPARE(queue->error(), Channel::PreconditionFailed);
|
QCOMPARE(queue->error(), Channel::PreconditionFailedError);
|
||||||
QVERIFY(!queue->errorString().isEmpty());
|
QVERIFY(!queue->errorString().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue