From 5ad6c7f7c084a962b332c3b3badef6bf90f66642 Mon Sep 17 00:00:00 2001
From: Philipp Balzarek
Date: Fri, 7 Jun 2013 16:29:45 +0200
Subject: [PATCH] add a test case for closed connection
---
tests/Tests.hs | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/tests/Tests.hs b/tests/Tests.hs
index ba7dadb..c1fa991 100644
--- a/tests/Tests.hs
+++ b/tests/Tests.hs
@@ -175,7 +175,6 @@ runMain debug number multi = do
sendPresence presenceOnline context
thread1 <- forkIO $ autoAccept =<< dupSession context
thread2 <- forkIO $ iqResponder =<< dupSession context
- thread2 <- forkIO $ showPresence =<< dupSession context
when active $ do
liftIO $ threadDelay 1000000 -- Wait for the other thread to go online
-- discoTest debug'
@@ -199,3 +198,20 @@ run i multi = do
main = do
updateGlobalLogger "Pontarius.Xmpp" $ setLevel DEBUG
run 0 True
+
+
+connectionClosedTest = do
+ updateGlobalLogger "Pontarius.Xmpp" $ setLevel DEBUG
+ let debug' = infoM "Pontarius.Xmpp"
+ debug' "running"
+ let we = testUser1
+ Right context <- session (Text.unpack $ domainpart we)
+ (Just ([scramSha1 (fromJust $ localpart we) Nothing "pwd"], resourcepart we))
+ config {onConnectionClosed = \e -> do
+ debug' $ "closed: " ++ show e
+
+ }
+ sendPresence presenceOnline context
+ forkIO $ threadDelay 3000000 >> void (closeConnection context)
+ forever $ threadDelay 1000000
+ return ()