split channel tests into their own executable
Refactored tests specific to QAMQP::Channel into its own full test case, as there are more on the way
This commit is contained in:
parent
baa5c1de3e
commit
870af7b5d4
|
|
@ -237,14 +237,6 @@ void ChannelPrivate::qosOk(const Frame::Method &frame)
|
|||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Channel::Channel(int channelNumber, Client *client)
|
||||
: QObject(client),
|
||||
d_ptr(new ChannelPrivate(this))
|
||||
{
|
||||
Q_D(Channel);
|
||||
d->init(channelNumber, client);
|
||||
}
|
||||
|
||||
Channel::Channel(ChannelPrivate *dd, Client *parent)
|
||||
: QObject(parent),
|
||||
d_ptr(dd)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ protected:
|
|||
virtual void channelClosed() = 0;
|
||||
|
||||
protected:
|
||||
explicit Channel(int channelNumber = -1, Client *client = 0);
|
||||
explicit Channel(ChannelPrivate *dd, Client *client);
|
||||
|
||||
Q_DISABLE_COPY(Channel)
|
||||
|
|
|
|||
|
|
@ -737,7 +737,6 @@ void Client::setHeartbeatDelay(qint16 delay)
|
|||
d->heartbeatDelay = delay;
|
||||
}
|
||||
|
||||
|
||||
void Client::addCustomProperty(const QString &name, const QString &value)
|
||||
{
|
||||
Q_D(Client);
|
||||
|
|
|
|||
|
|
@ -2,4 +2,5 @@ TEMPLATE = subdirs
|
|||
SUBDIRS = \
|
||||
qamqpclient \
|
||||
qamqpexchange \
|
||||
qamqpqueue
|
||||
qamqpqueue \
|
||||
qamqpchannel
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
include($${DEPTH}/tests/tests.pri)
|
||||
|
||||
TARGET = tst_qamqpchannel
|
||||
SOURCES = tst_qamqpchannel.cpp
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
#include <QtTest/QtTest>
|
||||
|
||||
#include "signalspy.h"
|
||||
#include "amqp_testcase.h"
|
||||
|
||||
#include "amqp_client.h"
|
||||
#include "amqp_exchange.h"
|
||||
#include "amqp_queue.h"
|
||||
using namespace QAMQP;
|
||||
|
||||
class tst_QAMQPChannel : public TestCase
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void init();
|
||||
void cleanup();
|
||||
|
||||
void close();
|
||||
void resume();
|
||||
|
||||
private:
|
||||
QScopedPointer<Client> client;
|
||||
|
||||
};
|
||||
|
||||
void tst_QAMQPChannel::init()
|
||||
{
|
||||
client.reset(new Client);
|
||||
client->connectToHost();
|
||||
QVERIFY(waitForSignal(client.data(), SIGNAL(connected())));
|
||||
}
|
||||
|
||||
void tst_QAMQPChannel::cleanup()
|
||||
{
|
||||
if (client->isConnected()) {
|
||||
client->disconnectFromHost();
|
||||
QVERIFY(waitForSignal(client.data(), SIGNAL(disconnected())));
|
||||
}
|
||||
}
|
||||
|
||||
void tst_QAMQPChannel::close()
|
||||
{
|
||||
// exchange
|
||||
Exchange *exchange = client->createExchange("test-close-channel");
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(opened())));
|
||||
exchange->declare(Exchange::Direct);
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(declared())));
|
||||
exchange->close();
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(closed())));
|
||||
exchange->reopen();
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(opened())));
|
||||
exchange->remove(Exchange::roForce);
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(removed())));
|
||||
|
||||
// queue
|
||||
Queue *queue = client->createQueue("test-close-channel");
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(opened())));
|
||||
declareQueueAndVerifyConsuming(queue);
|
||||
queue->close();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(closed())));
|
||||
}
|
||||
|
||||
void tst_QAMQPChannel::resume()
|
||||
{
|
||||
Queue *queue = client->createQueue("test-resume");
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(opened())));
|
||||
declareQueueAndVerifyConsuming(queue);
|
||||
|
||||
queue->resume();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(resumed())));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAMQPChannel)
|
||||
#include "tst_qamqpchannel.moc"
|
||||
|
|
@ -24,7 +24,6 @@ private Q_SLOTS:
|
|||
void removeIfUnused();
|
||||
void invalidMandatoryRouting();
|
||||
void invalidImmediateRouting();
|
||||
void closeChannel();
|
||||
|
||||
private:
|
||||
QScopedPointer<Client> client;
|
||||
|
|
@ -169,19 +168,5 @@ 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->close();
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(closed())));
|
||||
exchange->reopen();
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(opened())));
|
||||
exchange->remove(Exchange::roForce);
|
||||
QVERIFY(waitForSignal(exchange, SIGNAL(removed())));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAMQPExchange)
|
||||
#include "tst_qamqpexchange.moc"
|
||||
|
|
|
|||
|
|
@ -46,11 +46,8 @@ private Q_SLOTS:
|
|||
void invalidRoutingKey();
|
||||
void tableFieldDataTypes();
|
||||
void messageProperties();
|
||||
void closeChannel();
|
||||
void resumeChannel();
|
||||
|
||||
private:
|
||||
void declareQueueAndVerifyConsuming(Queue *queue);
|
||||
void verifyStandardMessageHeaders(const Message &message, const QString &routingKey,
|
||||
const QString &exchangeName = QLatin1String(""),
|
||||
bool redelivered = false);
|
||||
|
|
@ -58,19 +55,6 @@ private:
|
|||
|
||||
};
|
||||
|
||||
void tst_QAMQPQueue::declareQueueAndVerifyConsuming(Queue *queue)
|
||||
{
|
||||
queue->declare();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(declared())));
|
||||
QVERIFY(queue->consume());
|
||||
QSignalSpy spy(queue, SIGNAL(consuming(QString)));
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(consuming(QString))));
|
||||
QVERIFY(queue->isConsuming());
|
||||
QVERIFY(!spy.isEmpty());
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.at(0).toString(), queue->consumerTag());
|
||||
}
|
||||
|
||||
void tst_QAMQPQueue::verifyStandardMessageHeaders(const Message &message, const QString &routingKey,
|
||||
const QString &exchangeName, bool redelivered)
|
||||
{
|
||||
|
|
@ -666,25 +650,5 @@ 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->close();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(closed())));
|
||||
}
|
||||
|
||||
void tst_QAMQPQueue::resumeChannel()
|
||||
{
|
||||
Queue *queue = client->createQueue("test-resume");
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(opened())));
|
||||
declareQueueAndVerifyConsuming(queue);
|
||||
|
||||
queue->resume();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(resumed())));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAMQPQueue)
|
||||
#include "tst_qamqpqueue.moc"
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@
|
|||
#include <QObject>
|
||||
#include <QTestEventLoop>
|
||||
|
||||
#include "amqp_queue.h"
|
||||
|
||||
namespace QAMQP {
|
||||
|
||||
class TestCase : public QObject
|
||||
|
|
@ -23,6 +25,19 @@ protected:
|
|||
QObject::disconnect(safe, signal, &QTestEventLoop::instance(), SLOT(exitLoop()));
|
||||
return !QTestEventLoop::instance().timeout();
|
||||
}
|
||||
|
||||
void declareQueueAndVerifyConsuming(Queue *queue)
|
||||
{
|
||||
queue->declare();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(declared())));
|
||||
QVERIFY(queue->consume());
|
||||
QSignalSpy spy(queue, SIGNAL(consuming(QString)));
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(consuming(QString))));
|
||||
QVERIFY(queue->isConsuming());
|
||||
QVERIFY(!spy.isEmpty());
|
||||
QList<QVariant> arguments = spy.takeFirst();
|
||||
QCOMPARE(arguments.at(0).toString(), queue->consumerTag());
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace QAMQP
|
||||
|
|
|
|||
Loading…
Reference in New Issue