1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-11-22 22:32:06 +01:00

Replaced #getHost with #getServiceName. SMACK-75

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2729 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2005-08-27 02:21:24 +00:00 committed by gato
parent 42fd837376
commit 991e958097
6 changed files with 20 additions and 14 deletions

View file

@ -107,7 +107,7 @@ public class MessageTest extends SmackTestCase {
// Try now sending huge messages over an SSL connection
XMPPConnection conn = null;
try {
conn = new SSLXMPPConnection(getHost());
conn = new SSLXMPPConnection(getServiceName());
conn.login(getUsername(0), getUsername(0), "Other resource");
// Send the first message

View file

@ -389,7 +389,7 @@ public class RosterTest extends SmackTestCase {
Presence presence = null;
// Create another connection for the same user of connection 1
XMPPConnection conn4 = new XMPPConnection(getHost());
XMPPConnection conn4 = new XMPPConnection(getServiceName());
conn4.login(getUsername(1), getUsername(1), "Home");
// Add a new roster entry
@ -408,7 +408,7 @@ public class RosterTest extends SmackTestCase {
assertNotNull("Returned a null Presence for an existing user", presence);
// Check that the right presence is returned for a user+resource
presence = roster.getPresenceResource(getUsername(1) + "@" + conn4.getHost() + "/Home");
presence = roster.getPresenceResource(getUsername(1) + "@" + conn4.getServiceName() + "/Home");
assertEquals(
"Returned the wrong Presence",
StringUtils.parseResource(presence.getFrom()),
@ -422,7 +422,7 @@ public class RosterTest extends SmackTestCase {
"Smack");
// Check that the no presence is returned for a non-existent user+resource
presence = roster.getPresenceResource("noname@" + getHost() + "/Smack");
presence = roster.getPresenceResource("noname@" + getServiceName() + "/Smack");
assertNull("Returned a Presence for a non-existing user", presence);
// Check that the returned presences are correct

View file

@ -83,6 +83,7 @@ import junit.framework.TestCase;
public abstract class SmackTestCase extends TestCase {
private String host = "localhost";
private String serviceName = "localhost";
private int port = 5222;
private String chatDomain = "chat.localhost";
@ -161,7 +162,7 @@ public abstract class SmackTestCase extends TestCase {
* @return the bare XMPP address of the user (e.g. johndoe@jabber.org).
*/
protected String getBareJID(int index) {
return getUsername(index) + "@" + getConnection(index).getHost();
return getUsername(index) + "@" + getConnection(index).getServiceName();
}
/**
@ -183,6 +184,10 @@ public abstract class SmackTestCase extends TestCase {
return port;
}
protected String getServiceName() {
return serviceName;
}
/**
* Returns the default groupchat service domain.
*
@ -215,13 +220,14 @@ public abstract class SmackTestCase extends TestCase {
connections[i] = new XMPPConnection(host, port);
}
else {
connections[i] = new XMPPConnection(host, port, getSocketFactory());
connections[i] = new XMPPConnection(host, port, host, getSocketFactory());
}
}
// Use the host name that the server reports. This is a good idea in most
// cases, but could fail if the user set a hostname in their XMPP server
// that will not resolve as a network connection.
host = connections[0].getHost();
serviceName = connections[0].getServiceName();
// Create the test accounts
if (!getConnection(0).getAccountManager().supportsAccountCreation())
fail("Server does not support account creation");
@ -316,7 +322,9 @@ public abstract class SmackTestCase extends TestCase {
}
else if (parser.getName().equals("port")) {
port = parseIntProperty(parser, port);
;
}
else if (parser.getName().equals("serviceName")) {
serviceName = parser.nextText();
}
else if (parser.getName().equals("chat")) {
chatDomain = parser.nextText();

View file

@ -54,11 +54,9 @@ package org.jivesoftware.smackx;
import java.util.Iterator;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.test.SmackTestCase;
import org.jivesoftware.smackx.packet.DiscoverInfo;
import org.jivesoftware.smackx.packet.DiscoverItems;
/**
@ -138,7 +136,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
assertFalse(XHTMLManager.isServiceEnabled(getConnection(1), getBareJID(0)));
// Using a full JID check that the other client supports XHTML.
assertTrue(XHTMLManager.isServiceEnabled(getConnection(1), getFullJID(0)));
// Disable the XHTML Message support in connection1
XHTMLManager.setServiceEnabled(getConnection(0), false);
// Check for local XHTML service support
@ -154,7 +152,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
public void testDiscoverPublishItemsSupport() {
try {
boolean canPublish = ServiceDiscoveryManager.getInstanceFor(getConnection(0))
.canPublishItems(getHost());
.canPublishItems(getServiceName());
assertFalse("Messenger does not support publishing...so far!!", canPublish);
}
catch (Exception e) {
@ -175,7 +173,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
itemsToPublish.addItem(itemToPublish);
try {
ServiceDiscoveryManager.getInstanceFor(getConnection(0)).publishItems(getHost(),
ServiceDiscoveryManager.getInstanceFor(getConnection(0)).publishItems(getServiceName(),
itemsToPublish);
}
catch (Exception e) {

View file

@ -46,7 +46,7 @@ public class VersionTest extends SmackTestCase {
public void testGetServerVersion() {
Version version = new Version();
version.setType(IQ.Type.GET);
version.setTo(getHost());
version.setTo(getServiceName());
// Create a packet collector to listen for a response.
PacketCollector collector = getConnection(0).createPacketCollector(new PacketIDFilter(version.getPacketID()));

View file

@ -1723,7 +1723,7 @@ public class MultiUserChatTest extends SmackTestCase {
// Create 20 more connections for user2
XMPPConnection[] conns = new XMPPConnection[20];
for (int i = 0; i < conns.length; i++) {
conns[i] = new XMPPConnection(getHost());
conns[i] = new XMPPConnection(getServiceName());
conns[i].login(getUsername(1), getUsername(1), "resource-" + i);
}