Files
@ 762d04e9c140
Branch filter:
Location: libtransport.git/src/tests/gatewayresponder.cpp - annotation
762d04e9c140
3.0 KiB
text/x-c++hdr
Skype: check for new messages every 10 seconds
978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee 978808c187ee | #include "transport/userregistry.h"
#include "transport/config.h"
#include "transport/storagebackend.h"
#include "transport/user.h"
#include "transport/transport.h"
#include "transport/conversation.h"
#include "transport/rosterresponder.h"
#include "transport/usermanager.h"
#include "transport/localbuddy.h"
#include "transport/gatewayresponder.h"
#include <cppunit/TestFixture.h>
#include <cppunit/extensions/HelperMacros.h>
#include <Swiften/Swiften.h>
#include <Swiften/EventLoop/DummyEventLoop.h>
#include <Swiften/Server/Server.h>
#include <Swiften/Network/DummyNetworkFactories.h>
#include <Swiften/Network/DummyConnectionServer.h>
#include "Swiften/Server/ServerStanzaChannel.h"
#include "Swiften/Server/ServerFromClientSession.h"
#include "Swiften/Parser/PayloadParsers/FullPayloadParserFactoryCollection.h"
#include "basictest.h"
using namespace Transport;
class GatewayResponderTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
CPPUNIT_TEST_SUITE(GatewayResponderTest);
CPPUNIT_TEST(escape);
CPPUNIT_TEST(noEscapeEscaped);
CPPUNIT_TEST_SUITE_END();
public:
GatewayResponder *m_gatewayResponder;
void setUp (void) {
setMeUp();
connectUser();
m_gatewayResponder = new GatewayResponder(component->getIQRouter(), userManager);
m_gatewayResponder->start();
received.clear();
}
void tearDown (void) {
received.clear();
disconnectUser();
delete m_gatewayResponder;
tearMeDown();
}
void escape() {
boost::shared_ptr<Swift::IQ> iq(new Swift::IQ(Swift::IQ::Set));
iq->setTo("icq.localhost");
iq->setFrom("user@localhost");
iq->addPayload(boost::shared_ptr<Swift::GatewayPayload>(new Swift::GatewayPayload(Swift::JID(), "", "a@b")));
iq->setID("123");
injectIQ(iq);
CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::GatewayPayload>());
CPPUNIT_ASSERT_EQUAL(std::string("a\\40b@localhost"), getStanza(received[0])->getPayload<Swift::GatewayPayload>()->getJID().toString());
}
void noEscapeEscaped() {
boost::shared_ptr<Swift::IQ> iq(new Swift::IQ(Swift::IQ::Set));
iq->setTo("icq.localhost");
iq->setFrom("user@localhost");
iq->addPayload(boost::shared_ptr<Swift::GatewayPayload>(new Swift::GatewayPayload(Swift::JID(), "", "a\\40b")));
iq->setID("123");
injectIQ(iq);
CPPUNIT_ASSERT_EQUAL(1, (int) received.size());
CPPUNIT_ASSERT(dynamic_cast<Swift::IQ *>(getStanza(received[0])));
CPPUNIT_ASSERT_EQUAL(Swift::IQ::Result, dynamic_cast<Swift::IQ *>(getStanza(received[0]))->getType());
CPPUNIT_ASSERT(getStanza(received[0])->getPayload<Swift::GatewayPayload>());
CPPUNIT_ASSERT_EQUAL(std::string("a\\40b@localhost"), getStanza(received[0])->getPayload<Swift::GatewayPayload>()->getJID().toString());
}
};
CPPUNIT_TEST_SUITE_REGISTRATION (GatewayResponderTest);
|