mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 01:29:38 +02:00
SMACK-458 Managers should be kept on disconnects
Smack's Managers should not remove itself when the connection is closed or should re-add themselves if the connection get reconnected. This should also fix some NPE's. We are currently going with two different designs of Manager: 1. The one with WeakReferences/WeakHashMaps (SDM, EntityCapsManager) and 2. the one where the managers remove their listeners on connectionClosed() *and* connectionClosedOnError(), and later add their listeners on reconnectionSuccessful(). The first design has the Connection instance only weak referenced. The other design does reference Connection strongly (e.g. the 'managers' map in IBBManager/S5BManager), but removes this references when connectionClosed(onError)() is called. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/branches/smack_3_3_2@13788 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
parent
032fc8626e
commit
b16f34f61e
12 changed files with 298 additions and 369 deletions
|
@ -59,7 +59,7 @@ public class InitiationListenerTest {
|
|||
connection = mock(Connection.class);
|
||||
|
||||
// create service discovery manager for mocked connection
|
||||
new ServiceDiscoveryManager(connection);
|
||||
ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
// initialize Socks5ByteStreamManager to get the InitiationListener
|
||||
byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
|
||||
|
|
|
@ -95,8 +95,8 @@ public class Socks5ByteStreamManagerTest {
|
|||
* create service discovery managers for the connections because the
|
||||
* ConnectionCreationListener is not called when creating mocked connections
|
||||
*/
|
||||
new ServiceDiscoveryManager(connection1);
|
||||
new ServiceDiscoveryManager(connection2);
|
||||
ServiceDiscoveryManager.getInstanceFor(connection1);
|
||||
ServiceDiscoveryManager.getInstanceFor(connection2);
|
||||
|
||||
// get bytestream manager for the first connection twice
|
||||
Socks5BytestreamManager conn1ByteStreamManager1 = Socks5BytestreamManager.getBytestreamManager(connection1);
|
||||
|
|
|
@ -39,7 +39,7 @@ public class FileTransferNegotiatorTest {
|
|||
connection = new DummyConnection();
|
||||
connection.connect();
|
||||
connection.login("me", "secret");
|
||||
new ServiceDiscoveryManager(connection);
|
||||
ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
}
|
||||
|
||||
@After
|
||||
|
|
|
@ -70,7 +70,7 @@ public class DeliveryReceiptTest {
|
|||
@Test
|
||||
public void receiptManagerListenerTest() throws Exception {
|
||||
DummyConnection c = new DummyConnection();
|
||||
ServiceDiscoveryManager sdm = new ServiceDiscoveryManager(c);
|
||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(c);
|
||||
DeliveryReceiptManager drm = DeliveryReceiptManager.getInstanceFor(c);
|
||||
|
||||
TestReceiptReceivedListener rrl = new TestReceiptReceivedListener();
|
||||
|
@ -100,7 +100,7 @@ public class DeliveryReceiptTest {
|
|||
@Test
|
||||
public void receiptManagerAutoReplyTest() throws Exception {
|
||||
DummyConnection c = new DummyConnection();
|
||||
ServiceDiscoveryManager sdm = new ServiceDiscoveryManager(c);
|
||||
ServiceDiscoveryManager sdm = ServiceDiscoveryManager.getInstanceFor(c);
|
||||
DeliveryReceiptManager drm = DeliveryReceiptManager.getInstanceFor(c);
|
||||
|
||||
drm.enableAutoReceipts();
|
||||
|
|
|
@ -86,7 +86,7 @@ public class ConnectionUtils {
|
|||
when(collector.nextResult()).thenAnswer(answer);
|
||||
|
||||
// initialize service discovery manager for this connection
|
||||
new ServiceDiscoveryManager(connection);
|
||||
ServiceDiscoveryManager.getInstanceFor(connection);
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue