add a test for a default exchange to tst_QAMQPQueue
This commit is contained in:
parent
1a769b2b48
commit
eaee35df12
|
|
@ -200,19 +200,19 @@ void Exchange::bind(const QString &queueName, const QString &key)
|
|||
qWarning("Not implemented");
|
||||
}
|
||||
|
||||
void Exchange::publish(const QString &message, const QString &key,
|
||||
void Exchange::publish(const QString &key, const QString &message,
|
||||
const MessageProperties &properties)
|
||||
{
|
||||
publish(message.toUtf8(), key, QLatin1String("text.plain"), QVariantHash(), properties);
|
||||
publish(key, message.toUtf8(), QLatin1String("text.plain"), QVariantHash(), properties);
|
||||
}
|
||||
|
||||
void Exchange::publish(const QByteArray &message, const QString &key,
|
||||
void Exchange::publish(const QString &key, const QByteArray &message,
|
||||
const QString &mimeType, const MessageProperties &properties)
|
||||
{
|
||||
publish(message, key, mimeType, QVariantHash(), properties);
|
||||
publish(key, message, mimeType, QVariantHash(), properties);
|
||||
}
|
||||
|
||||
void Exchange::publish(const QByteArray &message, const QString &key,
|
||||
void Exchange::publish(const QString &key, const QByteArray &message,
|
||||
const QString &mimeType, const QVariantHash &headers,
|
||||
const Exchange::MessageProperties &properties)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -52,11 +52,11 @@ public:
|
|||
void bind(const QString &queueName);
|
||||
void bind(const QString &queueName, const QString &key);
|
||||
|
||||
void publish(const QString &message, const QString &key,
|
||||
void publish(const QString &key, const QString &message,
|
||||
const MessageProperties &properties = MessageProperties());
|
||||
void publish(const QByteArray &message, const QString &key,
|
||||
void publish(const QString &key, const QByteArray &message,
|
||||
const QString &mimeType, const MessageProperties &properties = MessageProperties());
|
||||
void publish(const QByteArray &message, const QString &key,
|
||||
void publish(const QString &key, const QByteArray &message,
|
||||
const QString &mimeType, const QVariantHash &headers,
|
||||
const Exchange::MessageProperties &properties = Exchange::MessageProperties());
|
||||
|
||||
|
|
|
|||
|
|
@ -2,5 +2,4 @@ TEMPLATE = subdirs
|
|||
SUBDIRS = \
|
||||
qamqpclient \
|
||||
qamqpexchange \
|
||||
queues \
|
||||
channels
|
||||
qamqpqueue
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
#include <QtTest/QtTest>
|
||||
|
||||
class tst_Channels : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void dummy();
|
||||
|
||||
};
|
||||
|
||||
void tst_Channels::dummy()
|
||||
{
|
||||
QVERIFY(true);
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_Channels)
|
||||
#include "tst_channels.moc"
|
||||
|
|
@ -12,45 +12,11 @@ class tst_QAMQPExchange : public TestCase
|
|||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void defaultExchange();
|
||||
void standardTypes_data();
|
||||
void standardTypes();
|
||||
|
||||
};
|
||||
|
||||
void tst_QAMQPExchange::defaultExchange()
|
||||
{
|
||||
/*
|
||||
* Client checks that the default exchange is active by specifying a queue
|
||||
* binding with no exchange name, and publishing a message with a suitable
|
||||
* routing key but without specifying the exchange name, then ensuring that
|
||||
* the message arrives in the queue correctly.
|
||||
*/
|
||||
|
||||
/*
|
||||
Client client;
|
||||
client.connectToHost();
|
||||
QVERIFY(waitForSignal(&client, SIGNAL(connected())));
|
||||
|
||||
Exchange *defaultExchange = client.createExchange();
|
||||
Queue *queue = client.createQueue("testDefaultExchange");
|
||||
queue->bind("", "testRoutingKey"); // bind to default exchange
|
||||
qDebug() << "HUZZAH1";
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(bound())));
|
||||
qDebug() << "HUZZAH2";
|
||||
*/
|
||||
|
||||
/*
|
||||
defaultExchange->publish("boop", "testRoutingKey");
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(messageReceived(Queue*))));
|
||||
MessagePtr message = queue->getMessage();
|
||||
qDebug() << message.data()->payload;
|
||||
QVERIFY(true);
|
||||
*/
|
||||
|
||||
QVERIFY(true);
|
||||
}
|
||||
|
||||
void tst_QAMQPExchange::standardTypes_data()
|
||||
{
|
||||
QTest::addColumn<Exchange::ExchangeType>("type");
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@ DEPTH = ../../..
|
|||
include($${DEPTH}/qamqp.pri)
|
||||
include($${DEPTH}/tests/tests.pri)
|
||||
|
||||
TARGET = tst_channels
|
||||
SOURCES = tst_channels.cpp
|
||||
TARGET = tst_qamqpqueue
|
||||
SOURCES = tst_qamqpqueue.cpp
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#include <QtTest/QtTest>
|
||||
#include "amqp_testcase.h"
|
||||
|
||||
#include "amqp_client.h"
|
||||
#include "amqp_queue.h"
|
||||
#include "amqp_exchange.h"
|
||||
|
||||
using namespace QAMQP;
|
||||
class tst_QAMQPQueue : public TestCase
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void defaultExchange();
|
||||
|
||||
};
|
||||
|
||||
void tst_QAMQPQueue::defaultExchange()
|
||||
{
|
||||
Client client;
|
||||
client.connectToHost();
|
||||
QVERIFY(waitForSignal(&client, SIGNAL(connected())));
|
||||
|
||||
Queue *queue = client.createQueue("test-default-exchange");
|
||||
queue->declare();
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(declared())));
|
||||
queue->consume();
|
||||
|
||||
Exchange *defaultExchange = client.createExchange();
|
||||
defaultExchange->publish("test-default-exchange", "first message");
|
||||
QVERIFY(waitForSignal(queue, SIGNAL(messageReceived(Queue*))));
|
||||
MessagePtr message = queue->getMessage();
|
||||
QCOMPARE(message->payload, QByteArray("first message"));
|
||||
|
||||
client.disconnectFromHost();
|
||||
QVERIFY(waitForSignal(&client, SIGNAL(disconnected())));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_QAMQPQueue)
|
||||
#include "tst_qamqpqueue.moc"
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
DEPTH = ../../..
|
||||
include($${DEPTH}/qamqp.pri)
|
||||
include($${DEPTH}/tests/tests.pri)
|
||||
|
||||
TARGET = tst_queues
|
||||
SOURCES = tst_queues.cpp
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
#include <QtTest/QtTest>
|
||||
|
||||
#include "amqp_client.h"
|
||||
#include "amqp_queue.h"
|
||||
|
||||
class tst_Queues : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
private Q_SLOTS:
|
||||
void declare();
|
||||
|
||||
};
|
||||
|
||||
void tst_Queues::declare()
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_Queues)
|
||||
#include "tst_queues.moc"
|
||||
Loading…
Reference in New Issue