\ No newline at end of file
Index: test/org/jivesoftware/smack/test/SmackTestCase.java
===================================================================
— test/org/jivesoftware/smack/test/SmackTestCase.java (revision 12905)
+++ test/org/jivesoftware/smack/test/SmackTestCase.java (working copy)
@@ -31,7 +31,9 @@
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
- Base class for all the test cases which provides a pre-configured execution context. This
@@ -57,6 +59,8 @@
private String usernamePrefix = “user”;
private String passwordPrefix;
private boolean samePassword;
-
private boolean testAnonymousLogin = false;
-
private Map<String, String> accountCreationParameters = new HashMap<String, String>();
private List createdUserIdx = new ArrayList();
private String chatDomain = “chat”;
@@ -353,7 +357,7 @@
try {
boolean found = false;
// Try to load the configutation from an XML file specific for this test case
ClassLoader.getSystemClassLoader().getResources(getConfigurationFilename());
while (resources.hasMoreElements()) {
found = parseURL((URL) resources.nextElement());
@@ -416,6 +420,21 @@
samePassword = “true”.equals(parser.getAttributeValue(0));
passwordPrefix = parser.nextText();
}
-
else if (parser.getName().equals("testAnonymousLogin")) {
-
testAnonymousLogin = "true".equals(parser.nextText());
-
}
-
else if (parser.getName().equals("accountCreationParameters")) {
-
int numAttributes = parser.getAttributeCount();
-
String key = null;
-
String value = null;
-
-
for (int i = 0; i < numAttributes; i++) {
-
key = parser.getAttributeName(i);
-
value = parser.getAttributeValue(i);
-
accountCreationParameters.put(key, value);
-
}
-
}
-
}
eventType = parser.next();
}
@@ -476,4 +495,11 @@
}
}
-
public boolean isTestAnonymousLogin() {
-
return testAnonymousLogin;
-
}
-
-
public Map<String, String> getAccountCreationParameters() {
-
return accountCreationParameters;
-
}
}
Index: test/org/jivesoftware/smack/LoginTest.java
===================================================================
— test/org/jivesoftware/smack/LoginTest.java (revision 12905)
+++ test/org/jivesoftware/smack/LoginTest.java (working copy)
@@ -67,6 +67,11 @@
- Check that the server handles anonymous users correctly.
*/
public void testSASLAnonymousLogin() {
try {
XMPPConnection conn1 = createConnection();
XMPPConnection conn2 = createConnection();
@@ -84,8 +89,8 @@
assertNotNull(“Username is null”, StringUtils.parseName(conn2.getUser()));
}
catch (XMPPException e) {
-
e.printStackTrace();
-
//fail(e.getMessage());
-
// e.printStackTrace();
-
fail(e.getMessage());
}
finally {
// Close the connection
@@ -103,6 +108,11 @@
- Check that the server handles anonymous users correctly.
*/
public void testNonSASLAnonymousLogin() {
try {
ConnectionConfiguration config = new ConnectionConfiguration(getHost(), getPort());
config.setSASLAuthenticationEnabled(false);
@@ -147,27 +157,39 @@
XMPPConnection conn = createConnection();
conn.connect();
try {
} catch (XMPPException e) {
if (e.getXMPPError().getCode() != 409) {
throw e;
}
-
-
// Else recreate the connection, in case the server closed it as
-
// a result of the error, so we can login.
-
conn = createConnection();
-
conn.connect();
}
conn.login(“user_1”, “user_1”, (String) null);
if (conn.getSASLAuthentication().isAuthenticated()) {
// Check that the server assigned a resource
assertNotNull(“JID assigned by server is missing”, conn.getUser());
assertNotNull(“JID assigned by server does not have a resource”,
StringUtils.parseResource(conn.getUser()));
}
else {
}
} catch (XMPPException e) {
-
if (e.getXMPPError() != null) {
-
assertEquals("Wrong error code returned", 406, e.getXMPPError()
-
.getCode());
-
} else {
-
fail(e.getMessage());
-
}
}
}
patch.txt.zip (2145 Bytes)