From eb0c5e282df3a357d4a7c20692cb467d3d672d93 Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Mon, 27 Feb 2006 20:01:30 +0000 Subject: [PATCH] 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 --- test/org/jivesoftware/smack/LoginTest.java | 45 +++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/test/org/jivesoftware/smack/LoginTest.java b/test/org/jivesoftware/smack/LoginTest.java index f69a75592..68e5c66fb 100644 --- a/test/org/jivesoftware/smack/LoginTest.java +++ b/test/org/jivesoftware/smack/LoginTest.java @@ -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();