1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-23 13:07:59 +01:00

Added new anonymous test case and improved assertions of existing one.

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@3493 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Gaston Dombiak 2006-02-27 20:01:30 +00:00 committed by gato
parent 5247fce7ca
commit eb0c5e282d

View file

@ -56,7 +56,7 @@ public class LoginTest extends SmackTestCase {
/**
* Check that the server handles anonymous users correctly.
*/
public void testAnonymousLogin() {
public void testSASLAnonymousLogin() {
try {
XMPPConnection conn1 = new XMPPConnection(getHost(), getPort());
XMPPConnection conn2 = new XMPPConnection(getHost(), getPort());
@ -64,6 +64,49 @@ public class LoginTest extends SmackTestCase {
// Try to login anonymously
conn1.loginAnonymously();
conn2.loginAnonymously();
assertNotNull("Resource is null", StringUtils.parseResource(conn1.getUser()));
assertNotNull("Resource is null", StringUtils.parseResource(conn2.getUser()));
assertNotNull("Username is null", StringUtils.parseName(conn1.getUser()));
assertNotNull("Username is null", StringUtils.parseName(conn2.getUser()));
}
catch (XMPPException e) {
e.printStackTrace();
fail(e.getMessage());
}
// Close the connection
conn1.close();
conn2.close();
}
catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
/**
* Check that the server handles anonymous users correctly.
*/
public void testNonSASLAnonymousLogin() {
try {
ConnectionConfiguration config = new ConnectionConfiguration(getHost(), getPort());
config.setSASLAuthenticationEnabled(false);
XMPPConnection conn1 = new XMPPConnection(config);
config = new ConnectionConfiguration(getHost(), getPort());
config.setSASLAuthenticationEnabled(false);
XMPPConnection conn2 = new XMPPConnection(config);
try {
// Try to login anonymously
conn1.loginAnonymously();
conn2.loginAnonymously();
assertNotNull("Resource is null", StringUtils.parseResource(conn1.getUser()));
assertNotNull("Resource is null", StringUtils.parseResource(conn2.getUser()));
assertNotNull("Username is null", StringUtils.parseName(conn1.getUser()));
assertNotNull("Username is null", StringUtils.parseName(conn2.getUser()));
}
catch (XMPPException e) {
e.printStackTrace();