INT-4340: Disable XMPP Roster properly
JIRA: https://jira.spring.io/browse/INT-4340 * Roster is now disabled on login as well * Fixed tagging and formatting issues * Checkstyle and documented the changed behaviour as well Polishing: rely on the `AbstractFactoryBean.getObject()` **Cherry-pick to 4.3.x**
This commit is contained in:
committed by
Artem Bilan
parent
9751608225
commit
1f220e0e66
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
package org.springframework.integration.xmpp.config;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.roster.Roster;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnection;
|
||||
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -29,6 +33,7 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Artem Bilan
|
||||
* @author Philipp Etschel
|
||||
*/
|
||||
public class XmppConnectionFactoryBeanTests {
|
||||
|
||||
@@ -46,4 +51,44 @@ public class XmppConnectionFactoryBeanTests {
|
||||
// the fact that no exception was thrown satisfies this test
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmppConnectionFactoryBeanNoRoster() throws Exception {
|
||||
XmppConnectionFactoryBean xmppConnectionFactoryBean =
|
||||
new XmppConnectionFactoryBean() {
|
||||
|
||||
@Override
|
||||
protected XMPPConnection createInstance() throws Exception {
|
||||
return mock(XMPPTCPConnection.class);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
xmppConnectionFactoryBean.setSubscriptionMode(null);
|
||||
xmppConnectionFactoryBean.afterPropertiesSet();
|
||||
xmppConnectionFactoryBean.start();
|
||||
XMPPConnection connection = xmppConnectionFactoryBean.getObject();
|
||||
|
||||
assertFalse(Roster.getInstanceFor(connection).isRosterLoadedAtLogin());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXmppConnectionFactoryBeanWithRoster() throws Exception {
|
||||
XmppConnectionFactoryBean xmppConnectionFactoryBean =
|
||||
new XmppConnectionFactoryBean() {
|
||||
|
||||
@Override
|
||||
protected XMPPConnection createInstance() throws Exception {
|
||||
return mock(XMPPTCPConnection.class);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
xmppConnectionFactoryBean.setSubscriptionMode(Roster.SubscriptionMode.accept_all);
|
||||
xmppConnectionFactoryBean.afterPropertiesSet();
|
||||
xmppConnectionFactoryBean.start();
|
||||
XMPPConnection connection = xmppConnectionFactoryBean.getObject();
|
||||
|
||||
assertTrue(Roster.getInstanceFor(connection).isRosterLoadedAtLogin());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user