mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2025-09-10 18:59:41 +02:00
Merge branch '4.2' into master-paul-merged
This commit is contained in:
commit
431e5b3c67
434 changed files with 1770 additions and 1517 deletions
|
@ -31,10 +31,10 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class BlockContactsIQTest {
|
||||
|
||||
String blockContactIQExample = "<iq id='block1' type='set'>" + "<block xmlns='urn:xmpp:blocking'>"
|
||||
private static final String blockContactIQExample = "<iq id='block1' type='set'>" + "<block xmlns='urn:xmpp:blocking'>"
|
||||
+ "<item jid='romeo@montague.net'/>" + "<item jid='pepe@montague.net'/>" + "</block>" + "</iq>";
|
||||
|
||||
String blockContactPushIQExample = "<iq to='juliet@capulet.com/chamber' type='set' id='push1'>"
|
||||
private static final String blockContactPushIQExample = "<iq to='juliet@capulet.com/chamber' type='set' id='push1'>"
|
||||
+ "<block xmlns='urn:xmpp:blocking'>" + "<item jid='romeo@montague.net'/>"
|
||||
+ "<item jid='pepe@montague.net'/>" + "</block>" + "</iq>";
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class BlockContactsIQTest {
|
|||
|
||||
@Test
|
||||
public void checkBlockContactPushIQ() throws Exception {
|
||||
IQ iq = (IQ) PacketParserUtils.parseStanza(blockContactPushIQExample);
|
||||
IQ iq = PacketParserUtils.parseStanza(blockContactPushIQExample);
|
||||
BlockContactsIQ blockContactIQ = (BlockContactsIQ) iq;
|
||||
Assert.assertEquals(JidCreate.from("romeo@montague.net"), blockContactIQ.getJids().get(0));
|
||||
Assert.assertEquals(JidCreate.from("pepe@montague.net"), blockContactIQ.getJids().get(1));
|
||||
|
|
|
@ -26,16 +26,16 @@ import org.junit.Test;
|
|||
|
||||
public class BlockedErrorExtensionTest {
|
||||
|
||||
String messageWithoutError = "<message from='gardano@erlang-solutions.com' "
|
||||
private static final String messageWithoutError = "<message from='gardano@erlang-solutions.com' "
|
||||
+ "to='griveroa-inaka@erlang-solutions.com/9b7b3fce28742983' "
|
||||
+ "type='normal' xml:lang='en' id='5x41G-120'>" + "</message>";
|
||||
|
||||
String messageWithError = "<message from='gardano@erlang-solutions.com' "
|
||||
private static final String messageWithError = "<message from='gardano@erlang-solutions.com' "
|
||||
+ "to='griveroa-inaka@erlang-solutions.com/9b7b3fce28742983' "
|
||||
+ "type='error' xml:lang='en' id='5x41G-121'>" + "<error code='406' type='cancel'>"
|
||||
+ "<not-acceptable xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" + "</error>" + "</message>";
|
||||
|
||||
String messageWithBlockedError = "<message from='gardano@erlang-solutions.com' "
|
||||
private static final String messageWithBlockedError = "<message from='gardano@erlang-solutions.com' "
|
||||
+ "to='griveroa-inaka@erlang-solutions.com/9b7b3fce28742983' "
|
||||
+ "type='error' xml:lang='en' id='5x41G-122'>" + "<error code='406' type='cancel'>"
|
||||
+ "<blocked xmlns='urn:xmpp:blocking:errors'/>"
|
||||
|
@ -43,13 +43,13 @@ public class BlockedErrorExtensionTest {
|
|||
|
||||
@Test
|
||||
public void checkErrorHasBlockedExtension() throws Exception {
|
||||
Message message1 = (Message) PacketParserUtils.parseStanza(messageWithoutError);
|
||||
Message message1 = PacketParserUtils.parseStanza(messageWithoutError);
|
||||
Assert.assertFalse(BlockedErrorExtension.isInside(message1));
|
||||
|
||||
Message message2 = (Message) PacketParserUtils.parseStanza(messageWithError);
|
||||
Message message2 = PacketParserUtils.parseStanza(messageWithError);
|
||||
Assert.assertFalse(BlockedErrorExtension.isInside(message2));
|
||||
|
||||
Message message3 = (Message) PacketParserUtils.parseStanza(messageWithBlockedError);
|
||||
Message message3 = PacketParserUtils.parseStanza(messageWithBlockedError);
|
||||
Assert.assertTrue(BlockedErrorExtension.isInside(message3));
|
||||
}
|
||||
|
||||
|
|
|
@ -28,13 +28,13 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class GetBlockingListTest {
|
||||
|
||||
String getBlockingListIQExample = "<iq id='blocklist1' type='get'>"
|
||||
private static final String getBlockingListIQExample = "<iq id='blocklist1' type='get'>"
|
||||
+ "<blocklist xmlns='urn:xmpp:blocking'/>" + "</iq>";
|
||||
|
||||
String blockListIQExample = "<iq type='result' id='blocklist1'>" + "<blocklist xmlns='urn:xmpp:blocking'>"
|
||||
private static final String blockListIQExample = "<iq type='result' id='blocklist1'>" + "<blocklist xmlns='urn:xmpp:blocking'>"
|
||||
+ "<item jid='romeo@montague.net'/>" + "<item jid='iago@shakespeare.lit'/>" + "</blocklist>" + "</iq>";
|
||||
|
||||
String emptyBlockListIQExample = "<iq type='result' id='blocklist1'>" + "<blocklist xmlns='urn:xmpp:blocking'/>"
|
||||
private static final String emptyBlockListIQExample = "<iq type='result' id='blocklist1'>" + "<blocklist xmlns='urn:xmpp:blocking'/>"
|
||||
+ "</iq>";
|
||||
|
||||
@Test
|
||||
|
@ -47,13 +47,13 @@ public class GetBlockingListTest {
|
|||
|
||||
@Test
|
||||
public void checkBlockListIQ() throws Exception {
|
||||
IQ iq = (IQ) PacketParserUtils.parseStanza(blockListIQExample);
|
||||
IQ iq = PacketParserUtils.parseStanza(blockListIQExample);
|
||||
BlockListIQ blockListIQ = (BlockListIQ) iq;
|
||||
Assert.assertEquals(2, blockListIQ.getBlockedJids().size());
|
||||
Assert.assertEquals(JidCreate.from("romeo@montague.net"), blockListIQ.getBlockedJids().get(0));
|
||||
Assert.assertEquals(JidCreate.from("iago@shakespeare.lit"), blockListIQ.getBlockedJids().get(1));
|
||||
|
||||
IQ iq2 = (IQ) PacketParserUtils.parseStanza(emptyBlockListIQExample);
|
||||
IQ iq2 = PacketParserUtils.parseStanza(emptyBlockListIQExample);
|
||||
BlockListIQ emptyBlockListIQ = (BlockListIQ) iq2;
|
||||
Assert.assertEquals(0, emptyBlockListIQ.getBlockedJids().size());
|
||||
}
|
||||
|
|
|
@ -31,17 +31,17 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class UnblockContactsIQTest {
|
||||
|
||||
String unblockContactIQExample = "<iq id='unblock1' type='set'>" + "<unblock xmlns='urn:xmpp:blocking'>"
|
||||
private static final String unblockContactIQExample = "<iq id='unblock1' type='set'>" + "<unblock xmlns='urn:xmpp:blocking'>"
|
||||
+ "<item jid='romeo@montague.net'/>" + "<item jid='pepe@montague.net'/>" + "</unblock>" + "</iq>";
|
||||
|
||||
String unblockContactPushIQExample = "<iq to='juliet@capulet.com/chamber' type='set' id='push3'>"
|
||||
private static final String unblockContactPushIQExample = "<iq to='juliet@capulet.com/chamber' type='set' id='push3'>"
|
||||
+ "<unblock xmlns='urn:xmpp:blocking'>" + "<item jid='romeo@montague.net'/>"
|
||||
+ "<item jid='pepe@montague.net'/>" + "</unblock>" + "</iq>";
|
||||
|
||||
String unblockAllIQExample = "<iq id='unblock2' type='set'>" + "<unblock xmlns='urn:xmpp:blocking'/>"
|
||||
private static final String unblockAllIQExample = "<iq id='unblock2' type='set'>" + "<unblock xmlns='urn:xmpp:blocking'/>"
|
||||
+ "</iq>";
|
||||
|
||||
String unblockAllPushIQExample = "<iq to='juliet@capulet.com/chamber' type='set' id='push5'>"
|
||||
private static final String unblockAllPushIQExample = "<iq to='juliet@capulet.com/chamber' type='set' id='push5'>"
|
||||
+ "<unblock xmlns='urn:xmpp:blocking'/>" + "</iq>";
|
||||
|
||||
@Test
|
||||
|
@ -58,7 +58,7 @@ public class UnblockContactsIQTest {
|
|||
|
||||
@Test
|
||||
public void checkUnblockContactPushIQ() throws Exception {
|
||||
IQ iq = (IQ) PacketParserUtils.parseStanza(unblockContactPushIQExample);
|
||||
IQ iq = PacketParserUtils.parseStanza(unblockContactPushIQExample);
|
||||
UnblockContactsIQ unblockContactIQ = (UnblockContactsIQ) iq;
|
||||
Assert.assertEquals(JidCreate.from("romeo@montague.net"), unblockContactIQ.getJids().get(0));
|
||||
Assert.assertEquals(JidCreate.from("pepe@montague.net"), unblockContactIQ.getJids().get(1));
|
||||
|
@ -73,7 +73,7 @@ public class UnblockContactsIQTest {
|
|||
|
||||
@Test
|
||||
public void checkUnblockAllPushIQ() throws Exception {
|
||||
IQ iq = (IQ) PacketParserUtils.parseStanza(unblockAllPushIQExample);
|
||||
IQ iq = PacketParserUtils.parseStanza(unblockAllPushIQExample);
|
||||
UnblockContactsIQ unblockAllIQ = (UnblockContactsIQ) iq;
|
||||
Assert.assertNull(unblockAllIQ.getJids());
|
||||
}
|
||||
|
|
|
@ -29,10 +29,10 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
|
||||
public class BoBIQTest extends SmackTestSuite {
|
||||
|
||||
String sampleBoBIQRequest = "<iq to='ladymacbeth@shakespeare.lit/castle' id='sarasa' type='get'>"
|
||||
private static final String sampleBoBIQRequest = "<iq to='ladymacbeth@shakespeare.lit/castle' id='sarasa' type='get'>"
|
||||
+ "<data xmlns='urn:xmpp:bob' cid='sha1+8f35fef110ffc5df08d579a50083ff9308fb6242@bob.xmpp.org'/>" + "</iq>";
|
||||
|
||||
String sampleBoBIQResponse = "<iq to='doctor@shakespeare.lit/pda' id='sarasa' type='result'>"
|
||||
private static final String sampleBoBIQResponse = "<iq to='doctor@shakespeare.lit/pda' id='sarasa' type='result'>"
|
||||
+ "<data xmlns='urn:xmpp:bob' cid='sha1+8f35fef110ffc5df08d579a50083ff9308fb6242@bob.xmpp.org' "
|
||||
+ "max-age='86400' type='image/png'>" + "c2FyYXNhZGUyMzU0ajI=" + "</data>" + "</iq>";
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ import org.powermock.reflect.Whitebox;
|
|||
*/
|
||||
public class CloseListenerTest extends InitExtensions {
|
||||
|
||||
static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
|
||||
/**
|
||||
* If a close request to an unknown session is received it should be replied
|
||||
|
|
|
@ -41,8 +41,8 @@ import org.powermock.reflect.Whitebox;
|
|||
*/
|
||||
public class DataListenerTest extends InitExtensions {
|
||||
|
||||
static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
|
||||
/**
|
||||
* If a data stanza(/packet) of an unknown session is received it should be replied
|
||||
|
|
|
@ -50,16 +50,16 @@ import org.jxmpp.jid.JidTestUtil;
|
|||
public class InBandBytestreamManagerTest extends InitExtensions {
|
||||
|
||||
// settings
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
String sessionID = "session_id";
|
||||
|
||||
// protocol verifier
|
||||
Protocol protocol;
|
||||
private Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
XMPPConnection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -42,13 +42,13 @@ import org.mockito.ArgumentCaptor;
|
|||
*/
|
||||
public class InBandBytestreamRequestTest extends InitExtensions {
|
||||
|
||||
static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
String sessionID = "session_id";
|
||||
private static final Jid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final Jid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private String sessionID = "session_id";
|
||||
|
||||
XMPPConnection connection;
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
Open initBytestream;
|
||||
private XMPPConnection connection;
|
||||
private InBandBytestreamManager byteStreamManager;
|
||||
private Open initBytestream;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -58,24 +58,24 @@ import org.powermock.reflect.Whitebox;
|
|||
public class InBandBytestreamSessionMessageTest extends InitExtensions {
|
||||
|
||||
// settings
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
String sessionID = "session_id";
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
private static final String sessionID = "session_id";
|
||||
|
||||
int blockSize = 10;
|
||||
private static final int blockSize = 10;
|
||||
|
||||
// protocol verifier
|
||||
Protocol protocol;
|
||||
private Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
XMPPConnection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
private InBandBytestreamManager byteStreamManager;
|
||||
|
||||
Open initBytestream;
|
||||
private Open initBytestream;
|
||||
|
||||
Verification<Message, IQ> incrementingSequence;
|
||||
private Verification<Message, IQ> incrementingSequence;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
@ -106,7 +106,7 @@ public class InBandBytestreamSessionMessageTest extends InitExtensions {
|
|||
|
||||
@Override
|
||||
public void verify(Message request, IQ response) {
|
||||
DataPacketExtension dpe = (DataPacketExtension) request.getExtension(
|
||||
DataPacketExtension dpe = request.getExtension(
|
||||
DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
|
||||
assertEquals(lastSeq++, dpe.getSeq());
|
||||
}
|
||||
|
|
|
@ -59,24 +59,24 @@ import org.powermock.reflect.Whitebox;
|
|||
public class InBandBytestreamSessionTest extends InitExtensions {
|
||||
|
||||
// settings
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
String sessionID = "session_id";
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
private static final String sessionID = "session_id";
|
||||
|
||||
int blockSize = 10;
|
||||
private static final int blockSize = 10;
|
||||
|
||||
// protocol verifier
|
||||
Protocol protocol;
|
||||
private Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
XMPPConnection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
private InBandBytestreamManager byteStreamManager;
|
||||
|
||||
Open initBytestream;
|
||||
private Open initBytestream;
|
||||
|
||||
Verification<Data, IQ> incrementingSequence;
|
||||
private Verification<Data, IQ> incrementingSequence;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -44,14 +44,14 @@ import org.powermock.reflect.Whitebox;
|
|||
*/
|
||||
public class InitiationListenerTest extends InitExtensions {
|
||||
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
String sessionID = "session_id";
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final String sessionID = "session_id";
|
||||
|
||||
XMPPConnection connection;
|
||||
InBandBytestreamManager byteStreamManager;
|
||||
InitiationListener initiationListener;
|
||||
Open initBytestream;
|
||||
private XMPPConnection connection;
|
||||
private InBandBytestreamManager byteStreamManager;
|
||||
private InitiationListener initiationListener;
|
||||
private Open initBytestream;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -58,7 +58,7 @@ public class CloseTest extends InitExtensions {
|
|||
assertEquals("sessionID", close.getSessionID());
|
||||
}
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
private static final Properties outputProperties = new Properties();
|
||||
{
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ public class DataPacketExtensionTest extends InitExtensions {
|
|||
assertNull(data.getDecodedData());
|
||||
}
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
private static final Properties outputProperties = new Properties();
|
||||
{
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ public class DataTest extends InitExtensions {
|
|||
assertEquals(IQ.Type.set, data.getType());
|
||||
}
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
private static final Properties outputProperties = new Properties();
|
||||
{
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ public class OpenTest extends InitExtensions {
|
|||
assertEquals(StanzaType.MESSAGE, open.getStanza());
|
||||
}
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
private static final Properties outputProperties = new Properties();
|
||||
{
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ import org.xmlpull.v1.XmlPullParserFactory;
|
|||
*/
|
||||
public class OpenIQProviderTest extends InitExtensions {
|
||||
|
||||
private static Properties outputProperties = new Properties();
|
||||
private static final Properties outputProperties = new Properties();
|
||||
{
|
||||
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||
}
|
||||
|
|
|
@ -46,19 +46,19 @@ import org.powermock.reflect.Whitebox;
|
|||
*/
|
||||
public class InitiationListenerTest {
|
||||
|
||||
private final int TIMEOUT = 10000;
|
||||
private static final int TIMEOUT = 10000;
|
||||
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
String proxyAddress = "127.0.0.1";
|
||||
String sessionID = "session_id";
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
private static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
private static final String proxyAddress = "127.0.0.1";
|
||||
private static final String sessionID = "session_id";
|
||||
|
||||
XMPPConnection connection;
|
||||
Socks5BytestreamManager byteStreamManager;
|
||||
InitiationListener initiationListener;
|
||||
Bytestream initBytestream;
|
||||
private XMPPConnection connection;
|
||||
private Socks5BytestreamManager byteStreamManager;
|
||||
private InitiationListener initiationListener;
|
||||
private Bytestream initBytestream;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -66,18 +66,18 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
|||
public class Socks5ByteStreamManagerTest {
|
||||
|
||||
// settings
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
String proxyAddress = "127.0.0.1";
|
||||
String sessionID = "session_id";
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
private static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
private static final String proxyAddress = "127.0.0.1";
|
||||
private static final String sessionID = "session_id";
|
||||
|
||||
// protocol verifier
|
||||
Protocol protocol;
|
||||
private Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
XMPPConnection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -55,16 +55,16 @@ import org.jxmpp.jid.impl.JidCreate;
|
|||
public class Socks5ByteStreamRequestTest {
|
||||
|
||||
// settings
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
String proxyAddress = "127.0.0.1";
|
||||
String sessionID = "session_id";
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
private static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
private static final String proxyAddress = "127.0.0.1";
|
||||
private static final String sessionID = "session_id";
|
||||
|
||||
Protocol protocol;
|
||||
private Protocol protocol;
|
||||
|
||||
XMPPConnection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
@ -121,7 +121,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
assertEquals(initiatorJID, targetResponse.getTo());
|
||||
assertEquals(IQ.Type.error, ((IQ) targetResponse).getType());
|
||||
assertEquals(XMPPError.Condition.item_not_found,
|
||||
((IQ) targetResponse).getError().getCondition());
|
||||
targetResponse.getError().getCondition());
|
||||
|
||||
}
|
||||
|
||||
|
@ -165,7 +165,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
assertEquals(initiatorJID, targetResponse.getTo());
|
||||
assertEquals(IQ.Type.error, ((IQ) targetResponse).getType());
|
||||
assertEquals(XMPPError.Condition.item_not_found,
|
||||
((IQ) targetResponse).getError().getCondition());
|
||||
targetResponse.getError().getCondition());
|
||||
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
assertEquals(initiatorJID, targetResponse.getTo());
|
||||
assertEquals(IQ.Type.error, ((IQ) targetResponse).getType());
|
||||
assertEquals(XMPPError.Condition.item_not_found,
|
||||
((IQ) targetResponse).getError().getCondition());
|
||||
targetResponse.getError().getCondition());
|
||||
}
|
||||
|
||||
// create test data for stream
|
||||
|
@ -305,7 +305,7 @@ public class Socks5ByteStreamRequestTest {
|
|||
assertEquals(initiatorJID, targetResponse.getTo());
|
||||
assertEquals(IQ.Type.error, ((IQ) targetResponse).getType());
|
||||
assertEquals(XMPPError.Condition.item_not_found,
|
||||
((IQ) targetResponse).getError().getCondition());
|
||||
targetResponse.getError().getCondition());
|
||||
}
|
||||
|
||||
// enable blacklisting
|
||||
|
|
|
@ -56,22 +56,22 @@ import org.jxmpp.jid.JidTestUtil;
|
|||
public class Socks5ClientForInitiatorTest {
|
||||
|
||||
// settings
|
||||
static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
static final String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress();
|
||||
private static final EntityFullJid initiatorJID = JidTestUtil.DUMMY_AT_EXAMPLE_ORG_SLASH_DUMMYRESOURCE;
|
||||
private static final EntityFullJid targetJID = JidTestUtil.FULL_JID_1_RESOURCE_1;
|
||||
private static final DomainBareJid xmppServer = JidTestUtil.DOMAIN_BARE_JID_1;
|
||||
private static final DomainBareJid proxyJID = JidTestUtil.MUC_EXAMPLE_ORG;
|
||||
private static final String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress();
|
||||
|
||||
private static final int GET_SOCKET_TIMEOUT = 90 * 1000;
|
||||
|
||||
int proxyPort = 7890;
|
||||
String sessionID = "session_id";
|
||||
private static final int proxyPort = 7890;
|
||||
private static final String sessionID = "session_id";
|
||||
|
||||
// protocol verifier
|
||||
Protocol protocol;
|
||||
private Protocol protocol;
|
||||
|
||||
// mocked XMPP connection
|
||||
XMPPConnection connection;
|
||||
private XMPPConnection connection;
|
||||
|
||||
/**
|
||||
* Initialize fields used in the tests.
|
||||
|
|
|
@ -46,7 +46,7 @@ import org.junit.Test;
|
|||
*/
|
||||
public class Socks5ProxyTest {
|
||||
|
||||
static final String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress();
|
||||
private static final String loopbackAddress = InetAddress.getLoopbackAddress().getHostAddress();
|
||||
|
||||
/**
|
||||
* The SOCKS5 proxy should be a singleton used by all XMPP connections.
|
||||
|
@ -130,7 +130,7 @@ public class Socks5ProxyTest {
|
|||
@Test
|
||||
public void shouldPreserveAddressOrderOnReplace() {
|
||||
Socks5Proxy proxy = Socks5Proxy.getSocks5Proxy();
|
||||
List<String> addresses = new ArrayList<String>(proxy.getLocalAddresses());
|
||||
List<String> addresses = new ArrayList<>(proxy.getLocalAddresses());
|
||||
addresses.add("1");
|
||||
addresses.add("2");
|
||||
addresses.add("3");
|
||||
|
@ -346,7 +346,7 @@ public class Socks5ProxyTest {
|
|||
Socks5Proxy socks5Proxy = Socks5Proxy.getSocks5Proxy();
|
||||
try {
|
||||
String address = InetAddress.getLocalHost().getHostAddress();
|
||||
List<String> addresses = new ArrayList<String>();
|
||||
List<String> addresses = new ArrayList<>();
|
||||
addresses.add(address);
|
||||
socks5Proxy.replaceLocalAddresses(addresses);
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.forward;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence;
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
|
|
@ -105,10 +105,10 @@ public class GeoLocationTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message messageWithGeoLocation = (Message) PacketParserUtils.parseStanza(geoLocationMessageString);
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationMessageString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = (GeoLocation) messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
assertNotNull(geoLocation);
|
||||
assertNotNull(geoLocation.toXML());
|
||||
|
|
|
@ -65,10 +65,10 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message messageWithGeoLocation = (Message) PacketParserUtils.parseStanza(geoLocationString);
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = (GeoLocation) messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
assertNotNull(geoLocation);
|
||||
|
||||
|
@ -132,10 +132,10 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message messageWithGeoLocation = (Message) PacketParserUtils.parseStanza(geoLocationString);
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
assertNotNull(messageWithGeoLocation);
|
||||
|
||||
GeoLocation geoLocation = (GeoLocation) messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
assertNotNull(geoLocation);
|
||||
|
||||
|
@ -177,9 +177,9 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message messageWithGeoLocation = (Message) PacketParserUtils.parseStanza(geoLocationString);
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = (GeoLocation) messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getError());
|
||||
|
@ -197,9 +197,9 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message messageWithGeoLocation = (Message) PacketParserUtils.parseStanza(geoLocationString);
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = (GeoLocation) messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getAccuracy());
|
||||
|
@ -218,9 +218,9 @@ public class GeoLocationProviderTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message messageWithGeoLocation = (Message) PacketParserUtils.parseStanza(geoLocationString);
|
||||
Message messageWithGeoLocation = PacketParserUtils.parseStanza(geoLocationString);
|
||||
|
||||
GeoLocation geoLocation = (GeoLocation) messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation geoLocation = messageWithGeoLocation.getExtension(GeoLocation.ELEMENT,
|
||||
GeoLocation.NAMESPACE);
|
||||
|
||||
assertEquals((Double) 90d, geoLocation.getAccuracy());
|
||||
|
|
|
@ -44,7 +44,7 @@ public class LastActivityTest extends InitExtensions {
|
|||
|
||||
DummyConnection c = new DummyConnection();
|
||||
c.connect();
|
||||
IQ lastRequest = (IQ) PacketParserUtils.parseStanza(xml.asString());
|
||||
IQ lastRequest = PacketParserUtils.parseStanza(xml.asString());
|
||||
assertTrue(lastRequest instanceof LastActivity);
|
||||
|
||||
c.processStanza(lastRequest);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.iqversion;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence;
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -45,7 +45,7 @@ public class VersionTest extends InitExtensions {
|
|||
// Enable version replys for this connection
|
||||
VersionManager.setAutoAppendSmackVersion(false);
|
||||
VersionManager.getInstanceFor(con).setVersion("Test", "0.23", "DummyOS");
|
||||
IQ versionRequest = (IQ) PacketParserUtils.parseStanza(control);
|
||||
IQ versionRequest = PacketParserUtils.parseStanza(control);
|
||||
|
||||
assertTrue(versionRequest instanceof Version);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class JivePropertiesExtensionTest extends InitExtensions {
|
|||
+ "</message>";
|
||||
// @formatter:on
|
||||
|
||||
Message message = (Message) PacketParserUtils.parseStanza(properties);
|
||||
Message message = PacketParserUtils.parseStanza(properties);
|
||||
JivePropertiesExtension jpe = JivePropertiesExtension.from(message);
|
||||
assertNotNull(jpe);
|
||||
|
||||
|
|
|
@ -26,20 +26,20 @@ import org.junit.Test;
|
|||
|
||||
public class MessageCorrectExtensionTest {
|
||||
|
||||
private final String idInitialMessage = "bad1";
|
||||
private static final String idInitialMessage = "bad1";
|
||||
|
||||
private final String initialMessageXml = "<message to='juliet@capulet.net/balcony' id='good1'>"
|
||||
private static final String initialMessageXml = "<message to='juliet@capulet.net/balcony' id='good1'>"
|
||||
+ "<body>But soft, what light through yonder window breaks?</body>" + "</message>";
|
||||
|
||||
private final CharSequence messageCorrectionXml = "<replace xmlns='urn:xmpp:message-correct:0' id='bad1'/>";
|
||||
private static final CharSequence messageCorrectionXml = "<replace xmlns='urn:xmpp:message-correct:0' id='bad1'/>";
|
||||
|
||||
private final CharSequence expectedXml = "<message to='juliet@capulet.net/balcony' id='good1'>"
|
||||
private static final CharSequence expectedXml = "<message to='juliet@capulet.net/balcony' id='good1'>"
|
||||
+ "<body>But soft, what light through yonder window breaks?</body>"
|
||||
+ "<replace xmlns='urn:xmpp:message-correct:0' id='bad1'/>" + "</message>";
|
||||
|
||||
@Test
|
||||
public void checkStanzas() throws Exception {
|
||||
Message initialMessage = (Message) PacketParserUtils.parseStanza(initialMessageXml);
|
||||
Message initialMessage = PacketParserUtils.parseStanza(initialMessageXml);
|
||||
MessageCorrectExtension messageCorrectExtension = new MessageCorrectExtension(idInitialMessage);
|
||||
|
||||
Assert.assertEquals(messageCorrectExtension.toXML().toString(), messageCorrectionXml);
|
||||
|
|
|
@ -28,10 +28,10 @@ import org.junit.Test;
|
|||
|
||||
public class MUCUserTest {
|
||||
|
||||
private static final Set<Status> createStatusSet() {
|
||||
private static Set<Status> createStatusSet() {
|
||||
Status status301 = Status.create(301);
|
||||
Status status110 = Status.create(110);
|
||||
Set<Status> statusSet = new HashSet<Status>();
|
||||
Set<Status> statusSet = new HashSet<>();
|
||||
statusSet.add(status301);
|
||||
statusSet.add(status110);
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.ping;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence;
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -54,7 +54,7 @@ public class PingTest extends InitExtensions {
|
|||
con.connect();
|
||||
// Enable ping for this connection
|
||||
PingManager.getInstanceFor(con);
|
||||
IQ pingRequest = (IQ) PacketParserUtils.parseStanza(control);
|
||||
IQ pingRequest = PacketParserUtils.parseStanza(control);
|
||||
|
||||
assertTrue(pingRequest instanceof Ping);
|
||||
|
||||
|
@ -71,7 +71,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
@Test
|
||||
public void checkSendingPing() throws InterruptedException, SmackException, IOException, XMPPException {
|
||||
DummyConnection dummyCon = getAuthentiactedDummyConnection();
|
||||
DummyConnection dummyCon = getAuthenticatedDummyConnection();
|
||||
PingManager pinger = PingManager.getInstanceFor(dummyCon);
|
||||
try {
|
||||
pinger.ping(DUMMY_AT_EXAMPLE_ORG);
|
||||
|
@ -86,7 +86,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
@Test
|
||||
public void checkSuccessfulPing() throws Exception {
|
||||
ThreadedDummyConnection threadedCon = getAuthentiactedDummyConnection();
|
||||
ThreadedDummyConnection threadedCon = getAuthenticatedDummyConnection();
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(threadedCon);
|
||||
|
||||
|
@ -123,7 +123,7 @@ public class PingTest extends InitExtensions {
|
|||
*/
|
||||
@Test
|
||||
public void checkFailedPingToEntityError() throws Exception {
|
||||
ThreadedDummyConnection threadedCon = getAuthentiactedDummyConnection();
|
||||
ThreadedDummyConnection threadedCon = getAuthenticatedDummyConnection();
|
||||
// @formatter:off
|
||||
String reply =
|
||||
"<iq type='error' id='qrzSp-16' to='test@myserver.com'>" +
|
||||
|
@ -133,7 +133,7 @@ public class PingTest extends InitExtensions {
|
|||
"</error>" +
|
||||
"</iq>";
|
||||
// @formatter:on
|
||||
IQ serviceUnavailable = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
IQ serviceUnavailable = PacketParserUtils.parseStanza(reply);
|
||||
threadedCon.addIQReply(serviceUnavailable);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(threadedCon);
|
||||
|
@ -145,7 +145,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
@Test
|
||||
public void checkPingToServerSuccess() throws Exception {
|
||||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
ThreadedDummyConnection con = getAuthenticatedDummyConnection();
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
||||
boolean pingSuccess = pinger.pingMyServer();
|
||||
|
@ -159,7 +159,7 @@ public class PingTest extends InitExtensions {
|
|||
*/
|
||||
@Test
|
||||
public void checkPingToServerError() throws Exception {
|
||||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
ThreadedDummyConnection con = getAuthenticatedDummyConnection();
|
||||
// @formatter:off
|
||||
String reply =
|
||||
"<iq type='error' id='qrzSp-16' to='test@myserver.com' from='" + con.getXMPPServiceDomain() + "'>" +
|
||||
|
@ -169,7 +169,7 @@ public class PingTest extends InitExtensions {
|
|||
"</error>" +
|
||||
"</iq>";
|
||||
// @formatter:on
|
||||
IQ serviceUnavailable = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
IQ serviceUnavailable = PacketParserUtils.parseStanza(reply);
|
||||
con.addIQReply(serviceUnavailable);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
@ -190,7 +190,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
@Test
|
||||
public void checkSuccessfulDiscoRequest() throws Exception {
|
||||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
ThreadedDummyConnection con = getAuthenticatedDummyConnection();
|
||||
DiscoverInfo info = new DiscoverInfo();
|
||||
info.addFeature(Ping.NAMESPACE);
|
||||
|
||||
|
@ -201,7 +201,7 @@ public class PingTest extends InitExtensions {
|
|||
"<feature var='urn:xmpp:ping'/>" +
|
||||
"</query></iq>";
|
||||
// @formatter:on
|
||||
IQ discoReply = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
IQ discoReply = PacketParserUtils.parseStanza(reply);
|
||||
con.addIQReply(discoReply);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
@ -211,8 +211,8 @@ public class PingTest extends InitExtensions {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void checkUnuccessfulDiscoRequest() throws Exception {
|
||||
ThreadedDummyConnection con = getAuthentiactedDummyConnection();
|
||||
public void checkUnsuccessfulDiscoRequest() throws Exception {
|
||||
ThreadedDummyConnection con = getAuthenticatedDummyConnection();
|
||||
DiscoverInfo info = new DiscoverInfo();
|
||||
info.addFeature(Ping.NAMESPACE);
|
||||
|
||||
|
@ -223,7 +223,7 @@ public class PingTest extends InitExtensions {
|
|||
"<feature var='urn:xmpp:noping'/>" +
|
||||
"</query></iq>";
|
||||
// @formatter:on
|
||||
IQ discoReply = (IQ) PacketParserUtils.parseStanza(reply);
|
||||
IQ discoReply = PacketParserUtils.parseStanza(reply);
|
||||
con.addIQReply(discoReply);
|
||||
|
||||
PingManager pinger = PingManager.getInstanceFor(con);
|
||||
|
@ -232,7 +232,7 @@ public class PingTest extends InitExtensions {
|
|||
assertFalse(pingSupported);
|
||||
}
|
||||
|
||||
private static ThreadedDummyConnection getAuthentiactedDummyConnection() throws SmackException, IOException, XMPPException, InterruptedException {
|
||||
private static ThreadedDummyConnection getAuthenticatedDummyConnection() throws SmackException, IOException, XMPPException, InterruptedException {
|
||||
ThreadedDummyConnection connection = new ThreadedDummyConnection();
|
||||
connection.connect();
|
||||
connection.login();
|
||||
|
|
|
@ -49,7 +49,7 @@ public class PrivacyProviderTest extends InitExtensions {
|
|||
+ "</query>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
|
||||
IQ iqPrivacyList = PacketParserUtils.parseStanza(xmlPrivacyList);
|
||||
assertTrue(iqPrivacyList instanceof Privacy);
|
||||
|
||||
Privacy privacyList = (Privacy) iqPrivacyList;
|
||||
|
@ -85,7 +85,7 @@ public class PrivacyProviderTest extends InitExtensions {
|
|||
+ "</query>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqPrivacyList = (IQ) PacketParserUtils.parseStanza(xmlPrivacyList);
|
||||
IQ iqPrivacyList = PacketParserUtils.parseStanza(xmlPrivacyList);
|
||||
assertTrue(iqPrivacyList instanceof Privacy);
|
||||
|
||||
Privacy privacyList = (Privacy) iqPrivacyList;
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2017 Florian Schmaus
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.jivesoftware.smackx.pubsub.Affiliation.Type;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.JidTestUtil;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
public class AffiliationsExtensionTest {
|
||||
|
||||
@Test
|
||||
public void testAffiliationsExtensionToXml() throws SAXException, IOException {
|
||||
BareJid affiliatedJid = JidTestUtil.BARE_JID_1;
|
||||
Affiliation affiliation = new Affiliation(affiliatedJid, Type.member);
|
||||
List<Affiliation> affiliationsList = new ArrayList<>();
|
||||
affiliationsList.add(affiliation);
|
||||
|
||||
AffiliationsExtension affiliationsExtension = new AffiliationsExtension(affiliationsList, "testNode");
|
||||
|
||||
CharSequence xml = affiliationsExtension.toXML();
|
||||
|
||||
assertXMLEqual("<affiliations node='testNode'><affiliation xmlns='http://jabber.org/protocol/pubsub#owner' jid='one@exampleone.org' affiliation='member'/></affiliations>",
|
||||
xml.toString());
|
||||
}
|
||||
|
||||
}
|
|
@ -54,7 +54,7 @@ public class ConfigureFormTest extends InitExtensions
|
|||
}
|
||||
|
||||
@Test
|
||||
public void getConfigFormWithInsufficientPriviliges() throws XMPPException, SmackException, IOException, InterruptedException
|
||||
public void getConfigFormWithInsufficientPrivileges() throws XMPPException, SmackException, IOException, InterruptedException
|
||||
{
|
||||
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
|
||||
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
|
||||
|
|
|
@ -80,15 +80,15 @@ public class ItemValidationTest extends InitExtensions {
|
|||
{
|
||||
SimplePayload payload = new SimplePayload(null, null, "<data>This is the payload</data>");
|
||||
|
||||
PayloadItem<SimplePayload> simpleItem = new PayloadItem<SimplePayload>(payload);
|
||||
PayloadItem<SimplePayload> simpleItem = new PayloadItem<>(payload);
|
||||
String simpleCtrl = "<item>" + payload.toXML() + "</item>";
|
||||
assertXMLEqual(simpleCtrl, simpleItem.toXML());
|
||||
|
||||
PayloadItem<SimplePayload> idItem = new PayloadItem<SimplePayload>("uniqueid", payload);
|
||||
PayloadItem<SimplePayload> idItem = new PayloadItem<>("uniqueid", payload);
|
||||
String idCtrl = "<item id='uniqueid'>" + payload.toXML() + "</item>";
|
||||
assertXMLEqual(idCtrl, idItem.toXML());
|
||||
|
||||
PayloadItem<SimplePayload> itemWithNodeId = new PayloadItem<SimplePayload>("testId", "testNode", payload);
|
||||
PayloadItem<SimplePayload> itemWithNodeId = new PayloadItem<>("testId", "testNode", payload);
|
||||
String nodeIdCtrl = "<item id='testId' node='testNode'>" + payload.toXML() + "</item>";
|
||||
assertXMLEqual(nodeIdCtrl, itemWithNodeId.toXML());
|
||||
}
|
||||
|
@ -233,6 +233,6 @@ public class ItemValidationTest extends InitExtensions {
|
|||
assertEquals("testid1", item.getId());
|
||||
assertTrue(item.getPayload() instanceof SimplePayload);
|
||||
|
||||
assertXMLEqual(itemContent, ((SimplePayload) item.getPayload()).toXML().toString());
|
||||
assertXMLEqual(itemContent, item.getPayload().toXML().toString());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.receipts;
|
||||
|
||||
import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence;
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -61,8 +61,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
parser = PacketParserUtils.getParserFor(control);
|
||||
Message p = PacketParserUtils.parseMessage(parser);
|
||||
|
||||
DeliveryReceiptRequest drr = (DeliveryReceiptRequest) p.getExtension(
|
||||
DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||
DeliveryReceiptRequest drr = p.getExtension(DeliveryReceiptRequest.ELEMENT, DeliveryReceipt.NAMESPACE);
|
||||
assertNotNull(drr);
|
||||
|
||||
assertTrue(DeliveryReceiptManager.hasDeliveryReceiptRequest(p));
|
||||
|
|
|
@ -48,8 +48,8 @@ public class RSMSetProviderTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
IQ iqWithRsm = (IQ) PacketParserUtils.parseStanza(rsmset);
|
||||
RSMSet rsm = (RSMSet) iqWithRsm.getExtension(RSMSet.ELEMENT, RSMSet.NAMESPACE);
|
||||
IQ iqWithRsm = PacketParserUtils.parseStanza(rsmset);
|
||||
RSMSet rsm = iqWithRsm.getExtension(RSMSet.ELEMENT, RSMSet.NAMESPACE);
|
||||
assertNotNull(rsm);
|
||||
assertEquals("aftervalue", rsm.getAfter());
|
||||
assertEquals("beforevalue", rsm.getBefore());
|
||||
|
|
|
@ -39,7 +39,7 @@ public class TimeProviderTest {
|
|||
+ "<time xmlns='urn:xmpp:time'/>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqRequest = (IQ) PacketParserUtils.parseStanza(request);
|
||||
IQ iqRequest = PacketParserUtils.parseStanza(request);
|
||||
assertTrue(iqRequest instanceof Time);
|
||||
|
||||
// @formatter:off
|
||||
|
@ -54,7 +54,7 @@ public class TimeProviderTest {
|
|||
+ "</time>"
|
||||
+ "</iq>";
|
||||
// @formatter:on
|
||||
IQ iqResponse = (IQ) PacketParserUtils.parseStanza(response);
|
||||
IQ iqResponse = PacketParserUtils.parseStanza(response);
|
||||
assertTrue(iqResponse instanceof Time);
|
||||
Time time = (Time) iqResponse;
|
||||
assertEquals("-06:00", time.getTzo());
|
||||
|
|
|
@ -90,7 +90,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
assertEquals("User", vCard.getFirstName());
|
||||
assertEquals("Name", vCard.getLastName());
|
||||
|
@ -139,7 +139,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
assertEquals("foo@fee.www.bar", vCard.getEmailHome());
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
assertEquals("3443233", vCard.getPhoneWork("FAX"));
|
||||
}
|
||||
|
@ -169,7 +169,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
assertEquals("1234", vCard.getField("UNKNOWN"));
|
||||
}
|
||||
|
@ -184,7 +184,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
assertEquals(null, vCard.getField("UNKNOWN"));
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
assertEquals(null, vCard.getField("UNKNOWN"));
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
assertEquals(null, vCard.getField("UNKNOWN"));
|
||||
}
|
||||
|
||||
|
@ -227,7 +227,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
assertEquals("Some street", vCard.getAddressFieldWork("STREET"));
|
||||
assertEquals("ddss", vCard.getAddressFieldWork("FF"));
|
||||
|
@ -244,7 +244,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
assertEquals("kir max", vCard.getField("FN"));
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ public class VCardTest extends InitExtensions {
|
|||
+ "</iq>";
|
||||
// @formatter:on
|
||||
|
||||
VCard vCard = (VCard) PacketParserUtils.parseStanza(request);
|
||||
VCard vCard = PacketParserUtils.parseStanza(request);
|
||||
|
||||
byte[] avatar = vCard.getAvatar();
|
||||
String mimeType = vCard.getAvatarMimeType();
|
||||
|
|
|
@ -46,7 +46,7 @@ public class DataFormTest {
|
|||
private static final String TEST_OUTPUT_2 = "<x xmlns='jabber:x:data' type='submit'><instructions>InstructionTest1</instructions><field var='testField1'></field><page xmlns='http://jabber.org/protocol/xdata-layout' label='Label'><fieldref var='testField1'/><section label='section Label'><text>SectionText</text></section><text>PageText</text></page></x>";
|
||||
private static final String TEST_OUTPUT_3 = "<x xmlns='jabber:x:data' type='submit'><instructions>InstructionTest1</instructions><field var='testField1'><validate xmlns='http://jabber.org/protocol/xdata-validate' datatype='xs:integer'><range min='1111' max='9999'/></validate></field></x>";
|
||||
|
||||
DataFormProvider pr = new DataFormProvider();
|
||||
private static final DataFormProvider pr = new DataFormProvider();
|
||||
|
||||
@Test
|
||||
public void test() throws Exception {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
package org.jivesoftware.smackx.xhtmlim.provider;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
import static org.jivesoftware.smack.test.util.CharsequenceEquals.equalsCharSequence;
|
||||
import static org.jivesoftware.smack.test.util.CharSequenceEquals.equalsCharSequence;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
|
@ -94,16 +94,16 @@ public class Protocol {
|
|||
public boolean printProtocol = false;
|
||||
|
||||
// responses to requests are taken form this queue
|
||||
Queue<Stanza> responses = new LinkedList<Stanza>();
|
||||
private final Queue<Stanza> responses = new LinkedList<>();
|
||||
|
||||
// list of verifications
|
||||
List<Verification<?, ?>[]> verificationList = new ArrayList<Verification<?, ?>[]>();
|
||||
private final List<Verification<?, ?>[]> verificationList = new ArrayList<>();
|
||||
|
||||
// list of requests
|
||||
List<Stanza> requests = new ArrayList<Stanza>();
|
||||
private final List<Stanza> requests = new ArrayList<>();
|
||||
|
||||
// list of all responses
|
||||
List<Stanza> responsesList = new ArrayList<Stanza>();
|
||||
private final List<Stanza> responsesList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Adds a responses and all verifications for the request/response pair to
|
||||
|
|
|
@ -37,7 +37,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
* Verifies that the "To" field of the request corresponds with the "From" field of
|
||||
* the response.
|
||||
*/
|
||||
public static Verification<Stanza, Stanza> correspondingSenderReceiver = new Verification<Stanza, Stanza>() {
|
||||
Verification<Stanza, Stanza> correspondingSenderReceiver = new Verification<Stanza, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(Stanza request, Stanza response) {
|
||||
|
@ -49,7 +49,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
/**
|
||||
* Verifies that the type of the request is a GET.
|
||||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeGET = new Verification<IQ, Stanza>() {
|
||||
Verification<IQ, Stanza> requestTypeGET = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
|
@ -61,7 +61,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
/**
|
||||
* Verifies that the type of the request is a SET.
|
||||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeSET = new Verification<IQ, Stanza>() {
|
||||
Verification<IQ, Stanza> requestTypeSET = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
|
@ -73,7 +73,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
/**
|
||||
* Verifies that the type of the request is a RESULT.
|
||||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeRESULT = new Verification<IQ, Stanza>() {
|
||||
Verification<IQ, Stanza> requestTypeRESULT = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
|
@ -85,7 +85,7 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
/**
|
||||
* Verifies that the type of the request is an ERROR.
|
||||
*/
|
||||
public static Verification<IQ, Stanza> requestTypeERROR = new Verification<IQ, Stanza>() {
|
||||
Verification<IQ, Stanza> requestTypeERROR = new Verification<IQ, Stanza>() {
|
||||
|
||||
@Override
|
||||
public void verify(IQ request, Stanza response) {
|
||||
|
@ -100,6 +100,6 @@ public interface Verification<T extends Stanza, S extends Stanza> {
|
|||
* @param request the request collected by the mocked XMPP connection
|
||||
* @param response the response added to the protocol instance
|
||||
*/
|
||||
public void verify(T request, S response);
|
||||
void verify(T request, S response);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue