summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-06-18 10:34:41 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-06-18 10:41:11 (GMT)
commit362b2d147e4050e997104c24b2ed2e818adab5ed (patch)
tree63340cf49072e2cc0d9d876859249eb22fd540d3 /Swiften/Server/UnitTest
parent0328d98d29b383ecfcb5ffb66df0a9b7b4d85654 (diff)
parent7af8a078c57d94ff63eb81f26de2f55eca6b5c00 (diff)
downloadswift-contrib-362b2d147e4050e997104c24b2ed2e818adab5ed.zip
swift-contrib-362b2d147e4050e997104c24b2ed2e818adab5ed.tar.bz2
Merge branch 'swift-1.x'
* swift-1.x: Moving unused server code out of Swiften into Limber. Conflicts: Limber/Server/ServerFromClientSession.cpp Limber/Server/ServerSession.cpp Limber/Server/ServerStanzaRouter.cpp Limber/Server/SimpleUserRegistry.cpp Limber/Server/SimpleUserRegistry.h Limber/Server/UnitTest/ServerStanzaRouterTest.cpp Limber/Server/UserRegistry.cpp Limber/main.cpp Slimber/Server.cpp Slimber/Server.h
Diffstat (limited to 'Swiften/Server/UnitTest')
-rw-r--r--Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp150
1 files changed, 0 insertions, 150 deletions
diff --git a/Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp b/Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp
deleted file mode 100644
index 0941665..0000000
--- a/Swiften/Server/UnitTest/ServerStanzaRouterTest.cpp
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (c) 2010 Remko Tronçon
- * Licensed under the GNU General Public License v3.
- * See Documentation/Licenses/GPLv3.txt for more information.
- */
-
-#include <cppunit/extensions/HelperMacros.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-
-#include <Swiften/Elements/Message.h>
-#include <Swiften/Server/ServerStanzaRouter.h>
-#include <Swiften/Server/ServerSession.h>
-
-using namespace Swift;
-
-class ServerStanzaRouterTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(ServerStanzaRouterTest);
- CPPUNIT_TEST(testRouteStanza_FullJID);
- CPPUNIT_TEST(testRouteStanza_FullJIDWithNegativePriority);
- CPPUNIT_TEST(testRouteStanza_FullJIDWithOnlyBareJIDMatchingSession);
- CPPUNIT_TEST(testRouteStanza_BareJIDWithoutMatchingSession);
- CPPUNIT_TEST(testRouteStanza_BareJIDWithMultipleSessions);
- CPPUNIT_TEST(testRouteStanza_BareJIDWithOnlyNegativePriorities);
- CPPUNIT_TEST(testRouteStanza_BareJIDWithChangingPresence);
- CPPUNIT_TEST_SUITE_END();
-
- public:
- ServerStanzaRouterTest() {}
-
- void setUp() {
- }
-
- void tearDown() {
- }
-
- void testRouteStanza_FullJID() {
- ServerStanzaRouter testling;
- MockServerSession session1(JID("foo@bar.com/Bla"), 0);
- testling.addClientSession(&session1);
- MockServerSession session2(JID("foo@bar.com/Baz"), 0);
- testling.addClientSession(&session2);
-
- bool result = testling.routeStanza(createMessageTo("foo@bar.com/Baz"));
-
- CPPUNIT_ASSERT(result);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(session1.sentStanzas.size()));
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(session2.sentStanzas.size()));
- }
-
- void testRouteStanza_FullJIDWithNegativePriority() {
- ServerStanzaRouter testling;
- MockServerSession session1(JID("foo@bar.com/Bla"), -1);
- testling.addClientSession(&session1);
- MockServerSession session2(JID("foo@bar.com/Baz"), 0);
- testling.addClientSession(&session2);
-
- bool result = testling.routeStanza(createMessageTo("foo@bar.com/Bla"));
-
- CPPUNIT_ASSERT(result);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(session1.sentStanzas.size()));
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(session2.sentStanzas.size()));
- }
-
- void testRouteStanza_FullJIDWithOnlyBareJIDMatchingSession() {
- ServerStanzaRouter testling;
- MockServerSession session(JID("foo@bar.com/Bla"), 0);
- testling.addClientSession(&session);
-
- bool result = testling.routeStanza(createMessageTo("foo@bar.com/Baz"));
-
- CPPUNIT_ASSERT(result);
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(session.sentStanzas.size()));
- }
-
- void testRouteStanza_BareJIDWithoutMatchingSession() {
- ServerStanzaRouter testling;
-
- bool result = testling.routeStanza(createMessageTo("foo@bar.com"));
-
- CPPUNIT_ASSERT(!result);
- }
-
- void testRouteStanza_BareJIDWithMultipleSessions() {
- ServerStanzaRouter testling;
- MockServerSession session1(JID("foo@bar.com/Bla"), 1);
- testling.addClientSession(&session1);
- MockServerSession session2(JID("foo@bar.com/Baz"), 8);
- testling.addClientSession(&session2);
- MockServerSession session3(JID("foo@bar.com/Bar"), 5);
- testling.addClientSession(&session3);
-
- bool result = testling.routeStanza(createMessageTo("foo@bar.com"));
-
- CPPUNIT_ASSERT(result);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(session1.sentStanzas.size()));
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(session2.sentStanzas.size()));
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(session3.sentStanzas.size()));
- }
-
- void testRouteStanza_BareJIDWithOnlyNegativePriorities() {
- ServerStanzaRouter testling;
- MockServerSession session(JID("foo@bar.com/Bla"), -1);
- testling.addClientSession(&session);
-
- bool result = testling.routeStanza(createMessageTo("foo@bar.com"));
-
- CPPUNIT_ASSERT(!result);
- }
-
- void testRouteStanza_BareJIDWithChangingPresence() {
- ServerStanzaRouter testling;
- MockServerSession session1(JID("foo@bar.com/Baz"), 8);
- testling.addClientSession(&session1);
- MockServerSession session2(JID("foo@bar.com/Bar"), 5);
- testling.addClientSession(&session2);
-
- session1.priority = 3;
- session2.priority = 4;
- bool result = testling.routeStanza(createMessageTo("foo@bar.com"));
-
- CPPUNIT_ASSERT(result);
- CPPUNIT_ASSERT_EQUAL(0, static_cast<int>(session1.sentStanzas.size()));
- CPPUNIT_ASSERT_EQUAL(1, static_cast<int>(session2.sentStanzas.size()));
- }
-
- private:
- boost::shared_ptr<Message> createMessageTo(const std::string& recipient) {
- boost::shared_ptr<Message> message(new Message());
- message->setTo(JID(recipient));
- return message;
- }
-
- class MockServerSession : public ServerSession {
- public:
- MockServerSession(const JID& jid, int priority) : jid(jid), priority(priority) {}
-
- virtual const JID& getJID() const { return jid; }
- virtual int getPriority() const { return priority; }
-
- virtual void sendStanza(boost::shared_ptr<Stanza> stanza) {
- sentStanzas.push_back(stanza);
- }
-
- JID jid;
- int priority;
- std::vector< boost::shared_ptr<Stanza> > sentStanzas;
- };
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(ServerStanzaRouterTest);