diff --git a/build/build.properties b/build/build.properties
index ca1880e71..8f911148d 100644
--- a/build/build.properties
+++ b/build/build.properties
@@ -10,6 +10,6 @@
# test.host=
# test.port=
# test.admin.username=
-# test.admin.password=
+test.admin.password="Kd513PmX/"
# test.admin.resource=
-# test.smack.debug=
\ No newline at end of file
+# test.smack.debug=
diff --git a/build/build.xml b/build/build.xml
index e7766b640..804190014 100644
--- a/build/build.xml
+++ b/build/build.xml
@@ -290,13 +290,13 @@
-
+
-
+
diff --git a/test-unit/org/jivesoftware/smack/RosterTest.java b/test-unit/org/jivesoftware/smack/RosterTest.java
index 9f6581aa3..c65a213ec 100644
--- a/test-unit/org/jivesoftware/smack/RosterTest.java
+++ b/test-unit/org/jivesoftware/smack/RosterTest.java
@@ -355,6 +355,123 @@ public class RosterTest {
assertSame("Wrong number of roster entries.", 4, roster.getEntries().size());
}
+ /**
+ * Test if adding an user with an empty group is equivalent with providing
+ * no group.
+ *
+ * @see SMACK-294
+ */
+ @Test(timeout=5000)
+ public void testAddEmptyGroupEntry() throws Throwable {
+ // Constants for the new contact
+ final String contactJID = "nurse@example.com";
+ final String contactName = "Nurse";
+ final String[] contactGroup = {""};
+
+ // Setup
+ final Roster roster = connection.getRoster();
+ assertNotNull("Can't get the roster from the provided connection!", roster);
+ initRoster(connection, roster);
+ rosterListener.reset();
+
+ // Adding the new roster item
+ final RosterUpdateResponder serverSimulator = new RosterUpdateResponder() {
+ void verifyUpdateRequest(final RosterPacket updateRequest) {
+ final Item item = updateRequest.getRosterItems().iterator().next();
+ assertSame("The provided JID doesn't match the requested!",
+ contactJID,
+ item.getUser());
+ assertSame("The provided name doesn't match the requested!",
+ contactName,
+ item.getName());
+ assertSame("Shouldn't provide an empty group element!",
+ 0,
+ item.getGroupNames().size());
+
+ }
+ };
+ serverSimulator.start();
+ roster.createEntry(contactJID, contactName, contactGroup);
+ serverSimulator.join();
+
+ // Check if an error occurred within the simulator
+ final Throwable exception = serverSimulator.getException();
+ if (exception != null) {
+ throw exception;
+ }
+
+ // Verify the roster entry of the new contact
+ final RosterEntry addedEntry = roster.getEntry(contactJID);
+ assertNotNull("The new contact wasn't added to the roster!", addedEntry);
+ assertTrue("The roster listener wasn't invoked for the new contact!",
+ rosterListener.getAddedAddresses().contains(contactJID));
+ assertSame("Setup wrong name for the new contact!",
+ contactName,
+ addedEntry.getName());
+ assertSame("Setup wrong default subscription status!",
+ ItemType.none,
+ addedEntry.getType());
+ assertSame("The new contact shouldn't be member of any group!",
+ 0,
+ addedEntry.getGroups().size());
+
+ // Verify the unchanged roster items
+ verifyRomeosEntry(roster.getEntry("romeo@example.net"));
+ verifyMercutiosEntry(roster.getEntry("mercutio@example.com"));
+ verifyBenvoliosEntry(roster.getEntry("benvolio@example.net"));
+ assertSame("Wrong number of roster entries.", 4, roster.getEntries().size());
+ }
+
+ /**
+ * Test processing a roster push with an empty group is equivalent with providing
+ * no group.
+ *
+ * @see SMACK-294
+ */
+ @Test(timeout=5000)
+ public void testEmptyGroupRosterPush() throws Throwable {
+ final String contactJID = "nurse@example.com";
+ final Roster roster = connection.getRoster();
+ assertNotNull("Can't get the roster from the provided connection!", roster);
+ final MXParser parser = new MXParser();
+ parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
+ final StringBuilder sb = new StringBuilder();
+ sb.append("")
+ .append("")
+ .append("- ")
+ .append("")
+ .append("
")
+ .append("")
+ .append("");
+ parser.setInput(new StringReader(sb.toString()));
+ parser.next();
+ final IQ rosterPush = PacketParserUtils.parseIQ(parser, connection);
+ initRoster(connection, roster);
+ rosterListener.reset();
+
+ // Simulate receiving the roster push
+ connection.processPacket(rosterPush);
+
+ // Verify the roster entry of the new contact
+ final RosterEntry addedEntry = roster.getEntry(contactJID);
+ assertNotNull("The new contact wasn't added to the roster!", addedEntry);
+ assertTrue("The roster listener wasn't invoked for the new contact!",
+ rosterListener.getAddedAddresses().contains(contactJID));
+ assertSame("Setup wrong default subscription status!",
+ ItemType.none,
+ addedEntry.getType());
+ assertSame("The new contact shouldn't be member of any group!",
+ 0,
+ addedEntry.getGroups().size());
+
+ // Verify the unchanged roster items
+ verifyRomeosEntry(roster.getEntry("romeo@example.net"));
+ verifyMercutiosEntry(roster.getEntry("mercutio@example.com"));
+ verifyBenvoliosEntry(roster.getEntry("benvolio@example.net"));
+ assertSame("Wrong number of roster entries.", 4, roster.getEntries().size());
+ }
+
/**
* Remove all roster entries by iterating trough {@see Roster#getEntries()}
* and simulating receiving roster pushes from the server.