From c309e278539826b2e9f0efd0565b473d41571ddc Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Thu, 7 Feb 2013 19:10:32 +0000 Subject: [PATCH] Fix NPE in Testcases where 'createOfflineConnections() == true'. The change 13453 created the username and password array, which needs to be initilized even if the connection and the login is done manually git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@13460 b35dd754-fafc-0310-a699-88a17e54d16e --- .../smack/test/SmackTestCase.java | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/test/org/jivesoftware/smack/test/SmackTestCase.java b/test/org/jivesoftware/smack/test/SmackTestCase.java index baf682e0c..6587a666a 100644 --- a/test/org/jivesoftware/smack/test/SmackTestCase.java +++ b/test/org/jivesoftware/smack/test/SmackTestCase.java @@ -242,6 +242,15 @@ public abstract class SmackTestCase extends TestCase { connections[i] = createConnection(); if (!createOfflineConnections()) connections[i].connect(); + + String currentPassword = usernamePrefix + (i+1); + String currentUser = currentPassword; + + if (passwordPrefix != null) + currentPassword = (samePassword ? passwordPrefix : passwordPrefix + (i+1)); + + usernames[i] = currentUser; + passwords[i] = currentPassword; } // 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 @@ -251,14 +260,8 @@ public abstract class SmackTestCase extends TestCase { if (!createOfflineConnections()) { for (int i = 0; i < getMaxConnections(); i++) { - String currentPassword = usernamePrefix + (i+1); - String currentUser = currentPassword; - - if (passwordPrefix != null) - currentPassword = (samePassword ? passwordPrefix : passwordPrefix + (i+1)); - - usernames[i] = currentUser; - passwords[i] = currentPassword; + String currentUser = usernames[i]; + String currentPassword = passwords[i]; try { getConnection(i).login(currentUser, currentPassword, "Smack");