1 52 package org.jivesoftware.smack; 53 54 import junit.framework.TestCase; 55 56 public class MessengerLoginTest extends TestCase { 57 58 private String host; 59 private int port; 60 61 public void setUp() { 62 if (System.getProperty("smack.test.host") != null) { 64 host = System.getProperty("smack.test.host"); 65 } 66 if (System.getProperty("smack.test.port") != null) { 67 try { 68 port = Integer.parseInt(System.getProperty("smack.test.port")); 69 } 70 catch (Exception ignored) {} 71 } 72 } 73 74 public void testAdminLogin() { 75 76 String username = System.getProperty("smack.test.admin.username"); 77 String password = System.getProperty("smack.test.admin.password"); 78 String resource = System.getProperty("smack.test.admin.resource"); 79 boolean debug = false; 80 try { 81 debug = Boolean.valueOf(System.getProperty("smack.debug")).booleanValue(); 82 } 83 catch (Exception ignored) {} 84 85 XMPPConnection.DEBUG_ENABLED = debug; 86 87 try { 88 XMPPConnection con = new XMPPConnection(host, port); 89 con.login(username, password, resource); 90 } 91 catch (XMPPException e) { 92 String message = e.getMessage(); 93 if (e.getXMPPError() != null) { 94 message = "XMPPError code: " + e.getXMPPError().getCode() + ", message: " 95 + e.getXMPPError().getMessage(); 96 } 97 99 } 100 } 101 } 102 | Popular Tags |