From c4d9b43fa6d461d5e97fd8612cdb17b004c8779e Mon Sep 17 00:00:00 2001 From: Gaston Dombiak Date: Wed, 29 Dec 2004 02:17:27 +0000 Subject: [PATCH] Initial version. git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2439 b35dd754-fafc-0310-a699-88a17e54d16e --- test/org/jivesoftware/smack/LoginTest.java | 80 ++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 test/org/jivesoftware/smack/LoginTest.java diff --git a/test/org/jivesoftware/smack/LoginTest.java b/test/org/jivesoftware/smack/LoginTest.java new file mode 100644 index 000000000..824c7298f --- /dev/null +++ b/test/org/jivesoftware/smack/LoginTest.java @@ -0,0 +1,80 @@ +/** + * $RCSfile$ + * $Revision$ + * $Date$ + * + * Copyright (C) 2004 Jive Software. All rights reserved. + * + * This software is published under the terms of the GNU Public License (GPL), + * a copy of which is included in this distribution. + */ + +package org.jivesoftware.smack; + +import org.jivesoftware.smack.test.SmackTestCase; + +/** + * Includes set of login tests. + * + * @author Gaston Dombiak + */ +public class LoginTest extends SmackTestCase { + + public LoginTest(String arg0) { + super(arg0); + } + + /** + * Check that the server is returning the correct error when trying to login using an invalid + * (i.e. non-existent) user. + */ + public void testInvalidLogin() { + try { + XMPPConnection connection = new XMPPConnection(getHost(), getPort()); + try { + // Login with an invalid user + connection.login("invaliduser" , "invalidpass"); + connection.close(); + fail("Invalid user was able to log into the server"); + } + catch (XMPPException e) { + assertEquals("Incorrect error code while login with an invalid user", 401, + e.getXMPPError().getCode()); + } + // Wait here while trying tests with exodus + //Thread.sleep(300); + } + catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + /** + * Check that the server handles anonymous users correctly. + */ + public void testAnonymousLogin() { + try { + XMPPConnection connection = new XMPPConnection(getHost(), getPort()); + try { + // Try to login anonymously + connection.loginAnonymously(); + } + catch (XMPPException e) { + e.printStackTrace(); + fail(e.getMessage()); + } + // Close the connection + connection.close(); + } + catch (Exception e) { + e.printStackTrace(); + fail(e.getMessage()); + } + } + + + protected int getMaxConnections() { + return 0; + } +}