mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-12-22 20:47:57 +01:00
Bump jxmpp to 0.5.0-alpha5 and change Roster API
to only allow bare JIDs as roster entires.
This commit is contained in:
parent
2f219c7317
commit
58402c5615
16 changed files with 111 additions and 114 deletions
|
@ -48,7 +48,7 @@ public class FromMatchesFilter implements StanzaFilter {
|
|||
*/
|
||||
public FromMatchesFilter(Jid address, boolean ignoreResourcepart) {
|
||||
if (address != null && ignoreResourcepart) {
|
||||
this.address = address.withoutResource();
|
||||
this.address = address.asBareJid();
|
||||
}
|
||||
else {
|
||||
this.address = address;
|
||||
|
@ -99,7 +99,7 @@ public class FromMatchesFilter implements StanzaFilter {
|
|||
}
|
||||
|
||||
if (ignoreResourcepart) {
|
||||
from = from.withoutResource();
|
||||
from = from.asBareJid();
|
||||
}
|
||||
return from.equals(address);
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ public class BindIQProvider extends IQProvider<Bind> {
|
|||
bind = Bind.newSet(Resourcepart.from(resourceString));
|
||||
break;
|
||||
case "jid":
|
||||
EntityFullJid fullJid = JidCreate.fullFrom(parser.nextText());
|
||||
EntityFullJid fullJid = JidCreate.entityFullFrom(parser.nextText());
|
||||
bind = Bind.newResult(fullJid);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ public class ParserUtils {
|
|||
if (jidString == null) {
|
||||
return null;
|
||||
}
|
||||
return JidCreate.bareFrom(jidString);
|
||||
return JidCreate.entityBareFrom(jidString);
|
||||
}
|
||||
|
||||
public static Resourcepart getResourcepartAttribute(XmlPullParser parser, String name) throws XmppStringprepException {
|
||||
|
|
|
@ -67,7 +67,7 @@ public class DummyConnection extends AbstractXMPPConnection {
|
|||
|
||||
private EntityFullJid getUserJid() {
|
||||
try {
|
||||
return JidCreate.fullFrom(config.getUsername()
|
||||
return JidCreate.entityFullFrom(config.getUsername()
|
||||
+ "@"
|
||||
+ config.getXMPPServiceDomain()
|
||||
+ "/"
|
||||
|
|
|
@ -180,7 +180,7 @@ public class MultipleRecipientManager {
|
|||
// Remove the sender from the TO/CC list (try with bare JID too)
|
||||
EntityFullJid from = connection.getUser();
|
||||
if (!to.remove(from) && !cc.remove(from)) {
|
||||
EntityBareJid bareJID = from.asBareJid();
|
||||
EntityBareJid bareJID = from.asEntityBareJid();
|
||||
to.remove(bareJID);
|
||||
cc.remove(bareJID);
|
||||
}
|
||||
|
|
|
@ -257,7 +257,7 @@ public final class ChatManager extends Manager{
|
|||
Chat chat = new Chat(this, userJID, threadID);
|
||||
threadChats.put(threadID, chat);
|
||||
jidChats.put(userJID, chat);
|
||||
baseJidChats.put(userJID.asBareJid(), chat);
|
||||
baseJidChats.put(userJID.asEntityBareJid(), chat);
|
||||
|
||||
for(ChatManagerListener listener : chatManagerListeners) {
|
||||
listener.chatCreated(chat, createdLocally);
|
||||
|
@ -270,7 +270,7 @@ public final class ChatManager extends Manager{
|
|||
threadChats.remove(chat.getThreadID());
|
||||
EntityJid userJID = chat.getParticipant();
|
||||
jidChats.remove(userJID);
|
||||
baseJidChats.remove(userJID.withoutResource());
|
||||
baseJidChats.remove(userJID.asEntityBareJid());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -146,7 +146,7 @@ public final class Roster extends Manager {
|
|||
* A map of JIDs to another Map of Resourceparts to Presences. The 'inner' map may contain
|
||||
* {@link Resourcepart#EMPTY} if there are no other Presences available.
|
||||
*/
|
||||
private final Map<Jid, Map<Resourcepart, Presence>> presenceMap = new ConcurrentHashMap<>();
|
||||
private final Map<BareJid, Map<Resourcepart, Presence>> presenceMap = new ConcurrentHashMap<>();
|
||||
|
||||
/**
|
||||
* Listeners called when the Roster was loaded.
|
||||
|
@ -698,28 +698,27 @@ public final class Roster extends Manager {
|
|||
* Returns the roster entry associated with the given XMPP address or
|
||||
* <tt>null</tt> if the user is not an entry in the roster.
|
||||
*
|
||||
* @param user the XMPP address of the user (eg "jsmith@example.com"). The address could be
|
||||
* @param jid the XMPP address of the user (eg "jsmith@example.com"). The address could be
|
||||
* in any valid format (e.g. "domain/resource", "user@domain" or "user@domain/resource").
|
||||
* @return the roster entry or <tt>null</tt> if it does not exist.
|
||||
*/
|
||||
public RosterEntry getEntry(Jid user) {
|
||||
if (user == null) {
|
||||
public RosterEntry getEntry(BareJid jid) {
|
||||
if (jid == null) {
|
||||
return null;
|
||||
}
|
||||
Jid key = getMapKey(user);
|
||||
return entries.get(key);
|
||||
return entries.get(jid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the specified XMPP address is an entry in the roster.
|
||||
*
|
||||
* @param user the XMPP address of the user (eg "jsmith@example.com"). The
|
||||
* address could be in any valid format (e.g. "domain/resource",
|
||||
* "user@domain" or "user@domain/resource").
|
||||
* @param jid the XMPP address of the user (eg "jsmith@example.com"). The
|
||||
* address must be a bare JID e.g. "domain/resource" or
|
||||
* "user@domain".
|
||||
* @return true if the XMPP address is an entry in the roster.
|
||||
*/
|
||||
public boolean contains(Jid user) {
|
||||
return getEntry(user) != null;
|
||||
public boolean contains(BareJid jid) {
|
||||
return getEntry(jid) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -775,18 +774,17 @@ public final class Roster extends Manager {
|
|||
* {@link RosterListener}.
|
||||
* </p>
|
||||
*
|
||||
* @param user an XMPP ID. The address could be in any valid format (e.g.
|
||||
* "domain/resource", "user@domain" or "user@domain/resource"). Any resource
|
||||
* information that's part of the ID will be discarded.
|
||||
* @param jid the XMPP address of the user (eg "jsmith@example.com"). The
|
||||
* address must be a bare JID e.g. "domain/resource" or
|
||||
* "user@domain".
|
||||
* @return the user's current presence, or unavailable presence if the user is offline
|
||||
* or if no presence information is available..
|
||||
*/
|
||||
public Presence getPresence(Jid user) {
|
||||
Jid key = getMapKey(user);
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(key);
|
||||
public Presence getPresence(Jid jid) {
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(jid);
|
||||
if (userPresences == null) {
|
||||
Presence presence = new Presence(Presence.Type.unavailable);
|
||||
presence.setFrom(user);
|
||||
presence.setFrom(jid);
|
||||
return presence;
|
||||
}
|
||||
else {
|
||||
|
@ -829,7 +827,7 @@ public final class Roster extends Manager {
|
|||
}
|
||||
else {
|
||||
presence = new Presence(Presence.Type.unavailable);
|
||||
presence.setFrom(user);
|
||||
presence.setFrom(jid);
|
||||
return presence;
|
||||
}
|
||||
}
|
||||
|
@ -849,7 +847,7 @@ public final class Roster extends Manager {
|
|||
* or if no presence information is available.
|
||||
*/
|
||||
public Presence getPresenceResource(FullJid userWithResource) {
|
||||
Jid key = getMapKey(userWithResource);
|
||||
BareJid key = userWithResource.asBareJid();
|
||||
Resourcepart resource = userWithResource.getResourcepart();
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(key);
|
||||
if (userPresences == null) {
|
||||
|
@ -878,8 +876,8 @@ public final class Roster extends Manager {
|
|||
* @return a List of Presence objects for all the user's current presences, or an unavailable presence if no
|
||||
* presence information is available.
|
||||
*/
|
||||
public List<Presence> getAllPresences(Jid bareJid) {
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(getMapKey(bareJid));
|
||||
public List<Presence> getAllPresences(BareJid bareJid) {
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(bareJid);
|
||||
List<Presence> res;
|
||||
if (userPresences == null) {
|
||||
// Create an unavailable presence if none was found
|
||||
|
@ -902,7 +900,7 @@ public final class Roster extends Manager {
|
|||
* @param bareJid the bare JID from which the presences should be retrieved.
|
||||
* @return available presences for the bare JID.
|
||||
*/
|
||||
public List<Presence> getAvailablePresences(Jid bareJid) {
|
||||
public List<Presence> getAvailablePresences(BareJid bareJid) {
|
||||
List<Presence> allPresences = getAllPresences(bareJid);
|
||||
List<Presence> res = new ArrayList<>(allPresences.size());
|
||||
for (Presence presence : allPresences) {
|
||||
|
@ -920,18 +918,17 @@ public final class Roster extends Manager {
|
|||
* information is available, such as when you are not subscribed to the user's presence
|
||||
* updates.
|
||||
*
|
||||
* @param user an XMPP ID, e.g. jdoe@example.com.
|
||||
* @param jid an XMPP ID, e.g. jdoe@example.com.
|
||||
* @return a List of Presence objects for all the user's current presences,
|
||||
* or an unavailable presence if the user is offline or if no presence information
|
||||
* is available.
|
||||
*/
|
||||
public List<Presence> getPresences(Jid user) {
|
||||
public List<Presence> getPresences(BareJid jid) {
|
||||
List<Presence> res;
|
||||
Jid key = getMapKey(user);
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(key);
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(jid);
|
||||
if (userPresences == null) {
|
||||
Presence presence = new Presence(Presence.Type.unavailable);
|
||||
presence.setFrom(user);
|
||||
presence.setFrom(jid);
|
||||
res = Arrays.asList(presence);
|
||||
}
|
||||
else {
|
||||
|
@ -954,7 +951,7 @@ public final class Roster extends Manager {
|
|||
}
|
||||
else {
|
||||
Presence presence = new Presence(Presence.Type.unavailable);
|
||||
presence.setFrom(user);
|
||||
presence.setFrom(jid);
|
||||
res = Arrays.asList(presence);
|
||||
}
|
||||
}
|
||||
|
@ -976,10 +973,14 @@ public final class Roster extends Manager {
|
|||
* @since 4.1
|
||||
*/
|
||||
public boolean isSubscribedToMyPresence(Jid jid) {
|
||||
if (connection().getXMPPServiceDomain().equals(jid)) {
|
||||
if (jid == null) {
|
||||
return false;
|
||||
}
|
||||
BareJid bareJid = jid.asBareJid();
|
||||
if (connection().getXMPPServiceDomain().equals(bareJid)) {
|
||||
return true;
|
||||
}
|
||||
RosterEntry entry = getEntry(jid);
|
||||
RosterEntry entry = getEntry(bareJid);
|
||||
if (entry == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -1019,34 +1020,6 @@ public final class Roster extends Manager {
|
|||
return rosterStore;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the key to use in the presenceMap and entries Map for a fully qualified XMPP ID.
|
||||
* The roster can contain any valid address format such us "domain/resource",
|
||||
* "user@domain" or "user@domain/resource". If the roster contains an entry
|
||||
* associated with the fully qualified XMPP ID then use the fully qualified XMPP
|
||||
* ID as the key in presenceMap, otherwise use the bare address. Note: When the
|
||||
* key in presenceMap is a fully qualified XMPP ID, the userPresences is useless
|
||||
* since it will always contain one entry for the user.
|
||||
*
|
||||
* @param user the bare or fully qualified XMPP ID, e.g. jdoe@example.com or
|
||||
* jdoe@example.com/Work.
|
||||
* @return the key to use in the presenceMap and entries Map for the fully qualified XMPP ID.
|
||||
*/
|
||||
private Jid getMapKey(Jid user) {
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
if (entries.containsKey(user)) {
|
||||
return user;
|
||||
}
|
||||
EntityBareJid bareJid = user.asEntityBareJidIfPossible();
|
||||
if (bareJid != null) {
|
||||
return bareJid;
|
||||
}
|
||||
// jid validate, log this case?
|
||||
return user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the presence of available contacts offline by simulating an unavailable
|
||||
* presence sent from the server. After a disconnection, every Presence is set
|
||||
|
@ -1280,7 +1253,7 @@ public final class Roster extends Manager {
|
|||
* @param key the presence map key
|
||||
* @return the user presences
|
||||
*/
|
||||
private Map<Resourcepart, Presence> getUserPresences(Jid key) {
|
||||
private Map<Resourcepart, Presence> getUserPresences(BareJid key) {
|
||||
Map<Resourcepart, Presence> userPresences = presenceMap.get(key);
|
||||
if (userPresences == null) {
|
||||
userPresences = new ConcurrentHashMap<>();
|
||||
|
@ -1300,7 +1273,7 @@ public final class Roster extends Manager {
|
|||
fromResource = Resourcepart.EMPTY;
|
||||
}
|
||||
}
|
||||
Jid key = getMapKey(from);
|
||||
BareJid key = from != null ? from.asBareJid() : null;
|
||||
Map<Resourcepart, Presence> userPresences;
|
||||
|
||||
// If an "available" presence, add it to the presence map. Each presence
|
||||
|
@ -1471,7 +1444,7 @@ public final class Roster extends Manager {
|
|||
|
||||
// Roster push (RFC 6121, 2.1.6)
|
||||
// A roster push with a non-empty from not matching our address MUST be ignored
|
||||
EntityBareJid jid = connection.getUser().asBareJid();
|
||||
EntityBareJid jid = connection.getUser().asEntityBareJid();
|
||||
Jid from = rosterPacket.getFrom();
|
||||
if (from != null && !from.equals(jid)) {
|
||||
LOGGER.warning("Ignoring roster push with a non matching 'from' ourJid='" + jid + "' from='" + from
|
||||
|
|
|
@ -124,7 +124,7 @@ public class RosterGroup extends Manager {
|
|||
}
|
||||
// Roster entries never include a resource so remove the resource
|
||||
// if it's a part of the XMPP address.
|
||||
user = user.withoutResource();
|
||||
user = user.asBareJid();
|
||||
synchronized (entries) {
|
||||
for (RosterEntry entry : entries) {
|
||||
if (entry.getJid().equals(user)) {
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.jivesoftware.smack.roster.packet.RosterPacket;
|
|||
import org.jivesoftware.smack.util.ParserUtils;
|
||||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
|
@ -49,7 +50,18 @@ public class RosterPacketProvider extends IQProvider<RosterPacket> {
|
|||
case "item":
|
||||
String jidString = parser.getAttributeValue("", "jid");
|
||||
String name = parser.getAttributeValue("", "name");
|
||||
BareJid jid = JidCreate.bareFrom(jidString);
|
||||
|
||||
// workaround for bug in jxmpp 0.5.0-alpha5, where
|
||||
// JidCreate.bareFrom(String), which we would want to use
|
||||
// here, does not produce correct results
|
||||
String localpart = XmppStringUtils.parseLocalpart(jidString);
|
||||
BareJid jid;
|
||||
if (localpart.length() != 0) {
|
||||
jid = JidCreate.entityBareFrom(jidString);
|
||||
} else {
|
||||
jid = JidCreate.domainBareFrom(jidString);
|
||||
}
|
||||
|
||||
// Create packet.
|
||||
item = new RosterPacket.Item(jid, name);
|
||||
// Set status.
|
||||
|
|
|
@ -34,6 +34,7 @@ import org.jivesoftware.smack.util.stringencoder.Base32;
|
|||
import org.jxmpp.jid.BareJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.util.XmppStringUtils;
|
||||
import org.xmlpull.v1.XmlPullParserFactory;
|
||||
import org.xmlpull.v1.XmlPullParser;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
@ -208,7 +209,18 @@ public final class DirectoryRosterStore implements RosterStore {
|
|||
}
|
||||
else if (parserName.equals("user")) {
|
||||
parser.next();
|
||||
user = JidCreate.bareFrom(parser.getText());
|
||||
|
||||
String jidString = parser.getText();
|
||||
// workaround for bug in jxmpp 0.5.0-alpha5, where
|
||||
// JidCreate.bareFrom(String), which we would want to
|
||||
// use here, does not produce correct results
|
||||
String localpart = XmppStringUtils.parseLocalpart(jidString);
|
||||
if (localpart.length() != 0) {
|
||||
user = JidCreate.entityBareFrom(jidString);
|
||||
}
|
||||
else {
|
||||
user = JidCreate.domainBareFrom(jidString);
|
||||
}
|
||||
}
|
||||
else if (parserName.equals("name")) {
|
||||
parser.next();
|
||||
|
|
|
@ -106,9 +106,9 @@ public class RosterTest extends InitSmackIm {
|
|||
|
||||
// Verify roster
|
||||
assertTrue("Roster can't be loaded!", roster.waitUntilLoaded());
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.from("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.from("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.from("benvolio@example.net")));
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.entityBareFrom("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("benvolio@example.net")));
|
||||
assertSame("Wrong number of roster entries.", 3, roster.getEntries().size());
|
||||
|
||||
// Verify roster listener
|
||||
|
@ -134,7 +134,7 @@ public class RosterTest extends InitSmackIm {
|
|||
@Test
|
||||
public void testAddRosterItem() throws Throwable {
|
||||
// Constants for the new contact
|
||||
final BareJid contactJID = JidCreate.bareFrom("nurse@example.com");
|
||||
final BareJid contactJID = JidCreate.entityBareFrom("nurse@example.com");
|
||||
final String contactName = "Nurse";
|
||||
final String[] contactGroup = {"Servants"};
|
||||
|
||||
|
@ -191,9 +191,9 @@ public class RosterTest extends InitSmackIm {
|
|||
addedEntry.getGroups().iterator().next().getName());
|
||||
|
||||
// Verify the unchanged roster items
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.from("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.from("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.from("benvolio@example.net")));
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.entityBareFrom("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("benvolio@example.net")));
|
||||
assertSame("Wrong number of roster entries.", 4, roster.getEntries().size());
|
||||
}
|
||||
|
||||
|
@ -205,7 +205,7 @@ public class RosterTest extends InitSmackIm {
|
|||
@Test
|
||||
public void testUpdateRosterItem() throws Throwable {
|
||||
// Constants for the updated contact
|
||||
final Jid contactJID = JidCreate.from("romeo@example.net");
|
||||
final BareJid contactJID = JidCreate.entityBareFrom("romeo@example.net");
|
||||
final String contactName = "Romeo";
|
||||
final String[] contactGroups = {"Friends", "Lovers"};
|
||||
|
||||
|
@ -265,8 +265,8 @@ public class RosterTest extends InitSmackIm {
|
|||
addedEntry.getGroups().size());
|
||||
|
||||
// Verify the unchanged roster items
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.from("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.from("benvolio@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("benvolio@example.net")));
|
||||
assertSame("Wrong number of roster entries (" + roster.getEntries() + ").",
|
||||
3,
|
||||
roster.getEntries().size());
|
||||
|
@ -280,7 +280,7 @@ public class RosterTest extends InitSmackIm {
|
|||
@Test
|
||||
public void testDeleteRosterItem() throws Throwable {
|
||||
// The contact which should be deleted
|
||||
final Jid contactJID = JidCreate.from("romeo@example.net");
|
||||
final BareJid contactJID = JidCreate.entityBareFrom("romeo@example.net");
|
||||
|
||||
// Setup
|
||||
assertNotNull("Can't get the roster from the provided connection!", roster);
|
||||
|
@ -312,8 +312,8 @@ public class RosterTest extends InitSmackIm {
|
|||
assertNull("The contact wasn't deleted from the roster!", deletedEntry);
|
||||
assertTrue("The roster listener wasn't invoked for the deleted contact!",
|
||||
rosterListener.getDeletedAddresses().contains(contactJID));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.from("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.from("benvolio@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("benvolio@example.net")));
|
||||
assertSame("Wrong number of roster entries (" + roster.getEntries() + ").",
|
||||
2,
|
||||
roster.getEntries().size());
|
||||
|
@ -326,7 +326,7 @@ public class RosterTest extends InitSmackIm {
|
|||
*/
|
||||
@Test
|
||||
public void testSimpleRosterPush() throws Throwable {
|
||||
final Jid contactJID = JidCreate.from("nurse@example.com");
|
||||
final BareJid contactJID = JidCreate.entityBareFrom("nurse@example.com");
|
||||
assertNotNull("Can't get the roster from the provided connection!", roster);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("<iq id=\"rostertest1\" type=\"set\" ")
|
||||
|
@ -357,9 +357,9 @@ public class RosterTest extends InitSmackIm {
|
|||
addedEntry.getGroups().size());
|
||||
|
||||
// Verify the unchanged roster items
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.from("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.from("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.from("benvolio@example.net")));
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.entityBareFrom("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("benvolio@example.net")));
|
||||
assertSame("Wrong number of roster entries.", 4, roster.getEntries().size());
|
||||
}
|
||||
|
||||
|
@ -371,11 +371,11 @@ public class RosterTest extends InitSmackIm {
|
|||
*/
|
||||
@Test
|
||||
public void testIgnoreInvalidFrom() throws XmppStringprepException {
|
||||
final BareJid spammerJid = JidCreate.bareFrom("spam@example.com");
|
||||
final BareJid spammerJid = JidCreate.entityBareFrom("spam@example.com");
|
||||
RosterPacket packet = new RosterPacket();
|
||||
packet.setType(Type.set);
|
||||
packet.setTo(connection.getUser());
|
||||
packet.setFrom(JidCreate.from("mallory@example.com"));
|
||||
packet.setFrom(JidCreate.entityBareFrom("mallory@example.com"));
|
||||
packet.addRosterItem(new Item(spammerJid, "Cool products!"));
|
||||
|
||||
final String requestId = packet.getStanzaId();
|
||||
|
@ -399,7 +399,7 @@ public class RosterTest extends InitSmackIm {
|
|||
@Test(timeout=5000)
|
||||
public void testAddEmptyGroupEntry() throws Throwable {
|
||||
// Constants for the new contact
|
||||
final BareJid contactJID = JidCreate.bareFrom("nurse@example.com");
|
||||
final BareJid contactJID = JidCreate.entityBareFrom("nurse@example.com");
|
||||
final String contactName = "Nurse";
|
||||
final String[] contactGroup = {""};
|
||||
|
||||
|
@ -451,9 +451,9 @@ public class RosterTest extends InitSmackIm {
|
|||
addedEntry.getGroups().size());
|
||||
|
||||
// Verify the unchanged roster items
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.from("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.from("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.from("benvolio@example.net")));
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.entityBareFrom("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("benvolio@example.net")));
|
||||
assertSame("Wrong number of roster entries.", 4, roster.getEntries().size());
|
||||
}
|
||||
|
||||
|
@ -465,7 +465,7 @@ public class RosterTest extends InitSmackIm {
|
|||
*/
|
||||
@Test
|
||||
public void testEmptyGroupRosterPush() throws Throwable {
|
||||
final Jid contactJID = JidCreate.from("nurse@example.com");
|
||||
final BareJid contactJID = JidCreate.entityBareFrom("nurse@example.com");
|
||||
assertNotNull("Can't get the roster from the provided connection!", roster);
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
sb.append("<iq id=\"rostertest2\" type=\"set\" ")
|
||||
|
@ -498,9 +498,9 @@ public class RosterTest extends InitSmackIm {
|
|||
addedEntry.getGroups().size());
|
||||
|
||||
// Verify the unchanged roster items
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.from("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.from("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.from("benvolio@example.net")));
|
||||
verifyRomeosEntry(roster.getEntry(JidCreate.entityBareFrom("romeo@example.net")));
|
||||
verifyMercutiosEntry(roster.getEntry(JidCreate.entityBareFrom("mercutio@example.com")));
|
||||
verifyBenvoliosEntry(roster.getEntry(JidCreate.entityBareFrom("benvolio@example.net")));
|
||||
assertSame("Wrong number of roster entries.", 4, roster.getEntries().size());
|
||||
}
|
||||
|
||||
|
@ -556,18 +556,18 @@ public class RosterTest extends InitSmackIm {
|
|||
rosterResult.setStanzaId(rosterRequest.getStanzaId());
|
||||
|
||||
// prepare romeo's roster entry
|
||||
final Item romeo = new Item(JidCreate.bareFrom("romeo@example.net"), "Romeo");
|
||||
final Item romeo = new Item(JidCreate.entityBareFrom("romeo@example.net"), "Romeo");
|
||||
romeo.addGroupName("Friends");
|
||||
romeo.setItemType(ItemType.both);
|
||||
rosterResult.addRosterItem(romeo);
|
||||
|
||||
// prepare mercutio's roster entry
|
||||
final Item mercutio = new Item(JidCreate.bareFrom("mercutio@example.com"), "Mercutio");
|
||||
final Item mercutio = new Item(JidCreate.entityBareFrom("mercutio@example.com"), "Mercutio");
|
||||
mercutio.setItemType(ItemType.from);
|
||||
rosterResult.addRosterItem(mercutio);
|
||||
|
||||
// prepare benvolio's roster entry
|
||||
final Item benvolio = new Item(JidCreate.bareFrom("benvolio@example.net"), "Benvolio");
|
||||
final Item benvolio = new Item(JidCreate.entityBareFrom("benvolio@example.net"), "Benvolio");
|
||||
benvolio.setItemType(ItemType.both);
|
||||
rosterResult.addRosterItem(benvolio);
|
||||
|
||||
|
|
|
@ -99,7 +99,7 @@ public class RosterVersioningTest {
|
|||
* @throws SmackException
|
||||
* @throws XMPPException
|
||||
*/
|
||||
@Test(timeout = 5000)
|
||||
@Test(timeout = 300000)
|
||||
public void testEqualVersionStored() throws InterruptedException, IOException, XMPPException, SmackException {
|
||||
answerWithEmptyRosterResult();
|
||||
roster.waitUntilLoaded();
|
||||
|
@ -214,20 +214,20 @@ public class RosterVersioningTest {
|
|||
rosterPush.setType(Type.set);
|
||||
rosterPush.setVersion("v98");
|
||||
|
||||
Item item = new Item(JidCreate.bareFrom("vaglaf@example.com"), "vaglaf the only");
|
||||
Item item = new Item(JidCreate.entityBareFrom("vaglaf@example.com"), "vaglaf the only");
|
||||
item.setItemType(ItemType.remove);
|
||||
rosterPush.addRosterItem(item);
|
||||
rosterListener.reset();
|
||||
connection.processStanza(rosterPush);
|
||||
rosterListener.waitAndReset();
|
||||
|
||||
assertNull("Store doses not contain vaglaf", store.getEntry(JidCreate.bareFrom("vaglaf@example.com")));
|
||||
assertNull("Store doses not contain vaglaf", store.getEntry(JidCreate.entityBareFrom("vaglaf@example.com")));
|
||||
assertEquals("Expect store version after push", "v98", store.getRosterVersion());
|
||||
}
|
||||
}
|
||||
|
||||
private static Item vaglafItem() throws XmppStringprepException {
|
||||
Item item = new Item(JidCreate.bareFrom("vaglaf@example.com"), "vaglaf the only");
|
||||
Item item = new Item(JidCreate.entityBareFrom("vaglaf@example.com"), "vaglaf the only");
|
||||
item.setItemType(ItemType.both);
|
||||
item.addGroupName("all");
|
||||
item.addGroupName("friends");
|
||||
|
@ -236,14 +236,14 @@ public class RosterVersioningTest {
|
|||
}
|
||||
|
||||
private static void populateStore(RosterStore store) throws IOException {
|
||||
store.addEntry(new RosterPacket.Item(JidCreate.bareFrom("geoff@example.com"), "geoff hurley"), "");
|
||||
store.addEntry(new RosterPacket.Item(JidCreate.entityBareFrom("geoff@example.com"), "geoff hurley"), "");
|
||||
|
||||
RosterPacket.Item item = new RosterPacket.Item(JidCreate.bareFrom("joe@example.com"), "joe stevens");
|
||||
RosterPacket.Item item = new RosterPacket.Item(JidCreate.entityBareFrom("joe@example.com"), "joe stevens");
|
||||
item.addGroupName("friends");
|
||||
item.addGroupName("partners");
|
||||
store.addEntry(item, "");
|
||||
|
||||
item = new RosterPacket.Item(JidCreate.bareFrom("higgins@example.com"), "higgins mcmann");
|
||||
item = new RosterPacket.Item(JidCreate.entityBareFrom("higgins@example.com"), "higgins mcmann");
|
||||
item.addGroupName("all");
|
||||
item.addGroupName("friends");
|
||||
store.addEntry(item, "v96");
|
||||
|
|
|
@ -72,7 +72,7 @@ public class RosterIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
}
|
||||
private void checkIfAddedAndSubscribed(Collection<Jid> addresses) {
|
||||
for (Jid jid : addresses) {
|
||||
if (!jid.equals(conTwo.getUser().asBareJidString())) {
|
||||
if (!jid.equals(conTwo.getUser().asBareJid())) {
|
||||
continue;
|
||||
}
|
||||
RosterEntry rosterEntry = rosterOne.getEntry(conTwo.getUser().asBareJid());
|
||||
|
|
|
@ -63,7 +63,7 @@ public class MultiUserChatIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
@SmackIntegrationTest
|
||||
public void mucTest() throws TimeoutException, Exception {
|
||||
EntityBareJid mucAddress = JidCreate.bareFrom(Localpart.from("smack-inttest-" + randomString), mucService.getDomain());
|
||||
EntityBareJid mucAddress = JidCreate.entityBareFrom(Localpart.from("smack-inttest-" + randomString), mucService.getDomain());
|
||||
|
||||
MultiUserChat mucAsSeenByOne = mucManagerOne.getMultiUserChat(mucAddress);
|
||||
MultiUserChat mucAsSeenByTwo = mucManagerTwo.getMultiUserChat(mucAddress);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class MultiUserChatLowLevelIntegrationTest extends AbstractSmackLowLevelI
|
|||
final Resourcepart mucNickname = Resourcepart.from("Nick-" + StringUtils.randomString(6));
|
||||
final String randomMucName = StringUtils.randomString(6);
|
||||
final DomainBareJid mucComponent = multiUserChatManager.getXMPPServiceDomains().get(0);
|
||||
final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.bareFrom(
|
||||
final MultiUserChat muc = multiUserChatManager.getMultiUserChat(JidCreate.entityBareFrom(
|
||||
Localpart.from(randomMucName), mucComponent));
|
||||
|
||||
MucCreateConfigFormHandle handle = muc.createOrJoin(mucNickname);
|
||||
|
|
|
@ -2,7 +2,7 @@ allprojects {
|
|||
ext {
|
||||
shortVersion = '4.2.0-alpha2'
|
||||
isSnapshot = true
|
||||
jxmppVersion = '0.5.0-alpha4'
|
||||
jxmppVersion = '0.5.0-alpha5'
|
||||
smackMinAndroidSdk = 8
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue