added test for invalid routing keys
also added a debug message for attempts to write shortstr's greater than acceptable length.
This commit is contained in:
parent
a89dbb3805
commit
dec9ef72d3
|
|
@ -6,6 +6,8 @@
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
#include "amqp_global.h"
|
||||||
|
|
||||||
using namespace QAMQP;
|
using namespace QAMQP;
|
||||||
using namespace QAMQP::Frame;
|
using namespace QAMQP::Frame;
|
||||||
|
|
||||||
|
|
@ -342,7 +344,6 @@ void Frame::print(const TableField &f)
|
||||||
|
|
||||||
void Frame::writeField(qint8 valueType, QDataStream &s, const QVariant &value, bool withType)
|
void Frame::writeField(qint8 valueType, QDataStream &s, const QVariant &value, bool withType)
|
||||||
{
|
{
|
||||||
QByteArray tmp;
|
|
||||||
if (withType)
|
if (withType)
|
||||||
s << valueType;
|
s << valueType;
|
||||||
|
|
||||||
|
|
@ -390,6 +391,10 @@ void Frame::writeField(qint8 valueType, QDataStream &s, const QVariant &value, b
|
||||||
case 's':
|
case 's':
|
||||||
{
|
{
|
||||||
QString str = value.toString();
|
QString str = value.toString();
|
||||||
|
if (str.length() >= 256) {
|
||||||
|
qAmqpDebug() << Q_FUNC_INFO << "invalid shortstr length: " << str.length();
|
||||||
|
}
|
||||||
|
|
||||||
s << quint8(str.length());
|
s << quint8(str.length());
|
||||||
s.writeRawData(str.toLatin1().data(), str.length());
|
s.writeRawData(str.toLatin1().data(), str.length());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ private Q_SLOTS:
|
||||||
void defineQos();
|
void defineQos();
|
||||||
void invalidQos();
|
void invalidQos();
|
||||||
void qos();
|
void qos();
|
||||||
|
void invalidRoutingKey();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void declareQueueAndVerifyConsuming(Queue *queue);
|
void declareQueueAndVerifyConsuming(Queue *queue);
|
||||||
|
|
@ -468,5 +469,14 @@ void tst_QAMQPQueue::qos()
|
||||||
QCOMPARE(messageReceivedCount, messageCount);
|
QCOMPARE(messageReceivedCount, messageCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_QAMQPQueue::invalidRoutingKey()
|
||||||
|
{
|
||||||
|
QString routingKey = QString("%1").arg('1', 256, QLatin1Char('0'));
|
||||||
|
Queue *queue = client->createQueue(routingKey);
|
||||||
|
queue->declare();
|
||||||
|
QVERIFY(waitForSignal(client.data(), SIGNAL(error(QAMQP::Error))));
|
||||||
|
QCOMPARE(client->error(), QAMQP::FrameError);
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QAMQPQueue)
|
QTEST_MAIN(tst_QAMQPQueue)
|
||||||
#include "tst_qamqpqueue.moc"
|
#include "tst_qamqpqueue.moc"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue