's;^\s+$;;' on all source files

And add checkstyle test for lines containing only whitespace characters.
filetransferTypos
Florian Schmaus 8 years ago
parent 05c97c494b
commit 0fde39fa45
  1. 4
      config/checkstyle.xml
  2. 2
      smack-core/src/integration-test/java/org/jivesoftware/smack/LoginTest.java
  3. 10
      smack-core/src/integration-test/java/org/jivesoftware/smack/ReconnectionTest.java
  4. 66
      smack-core/src/integration-test/java/org/jivesoftware/smack/RosterSmackTest.java
  5. 54
      smack-core/src/integration-test/java/org/jivesoftware/smack/packet/PrivacyProviderTest.java
  6. 124
      smack-core/src/integration-test/java/org/jivesoftware/smack/packet/PrivacyTest.java
  7. 18
      smack-core/src/integration-test/java/org/jivesoftware/smack/test/SmackTestCase.java
  8. 2
      smack-core/src/integration-test/java/org/jivesoftware/smack/util/ConnectionUtils.java
  9. 4
      smack-core/src/integration-test/java/org/jivesoftware/smack/util/DNSUtilTest.java
  10. 32
      smack-core/src/integration-test/java/org/jivesoftware/smack/util/XMPPErrorTest.java
  11. 4
      smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java
  12. 2
      smack-core/src/main/java/org/jivesoftware/smack/PacketCollector.java
  13. 2
      smack-core/src/main/java/org/jivesoftware/smack/SmackConfiguration.java
  14. 2
      smack-core/src/main/java/org/jivesoftware/smack/XMPPConnection.java
  15. 4
      smack-core/src/main/java/org/jivesoftware/smack/XMPPConnectionRegistry.java
  16. 2
      smack-core/src/main/java/org/jivesoftware/smack/XMPPException.java
  17. 2
      smack-core/src/main/java/org/jivesoftware/smack/filter/IQTypeFilter.java
  18. 14
      smack-core/src/main/java/org/jivesoftware/smack/packet/Message.java
  19. 2
      smack-core/src/main/java/org/jivesoftware/smack/parsing/ExceptionLoggingCallback.java
  20. 6
      smack-core/src/main/java/org/jivesoftware/smack/provider/AbstractProviderInfo.java
  21. 2
      smack-core/src/main/java/org/jivesoftware/smack/provider/IQProviderInfo.java
  22. 4
      smack-core/src/main/java/org/jivesoftware/smack/provider/ProviderManager.java
  23. 20
      smack-core/src/main/java/org/jivesoftware/smack/proxy/HTTPProxySocketFactory.java
  24. 4
      smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyException.java
  25. 26
      smack-core/src/main/java/org/jivesoftware/smack/proxy/ProxyInfo.java
  26. 10
      smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks4ProxySocketFactory.java
  27. 24
      smack-core/src/main/java/org/jivesoftware/smack/proxy/Socks5ProxySocketFactory.java
  28. 2
      smack-core/src/main/java/org/jivesoftware/smack/util/ObservableReader.java
  29. 4
      smack-core/src/main/java/org/jivesoftware/smack/util/PacketParserUtils.java
  30. 2
      smack-core/src/main/java/org/jivesoftware/smack/util/ReaderListener.java
  31. 2
      smack-core/src/main/java/org/jivesoftware/smack/util/StringUtils.java
  32. 4
      smack-core/src/main/java/org/jivesoftware/smack/util/XmlStringBuilder.java
  33. 8
      smack-core/src/main/java/org/jivesoftware/smack/util/dns/SRVRecord.java
  34. 2
      smack-core/src/test/java/org/jivesoftware/smack/DummyConnection.java
  35. 22
      smack-core/src/test/java/org/jivesoftware/smack/PacketCollectorTest.java
  36. 2
      smack-core/src/test/java/org/jivesoftware/smack/ThreadedDummyConnection.java
  37. 2
      smack-core/src/test/java/org/jivesoftware/smack/packet/MessageTest.java
  38. 2
      smack-core/src/test/java/org/jivesoftware/smack/provider/ProviderConfigTest.java
  39. 44
      smack-core/src/test/java/org/jivesoftware/smack/util/PacketParserUtilsTest.java
  40. 2
      smack-core/src/test/java/org/jivesoftware/smack/util/StringUtilsTest.java
  41. 10
      smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebugger.java
  42. 2
      smack-debug/src/main/java/org/jivesoftware/smackx/debugger/EnhancedDebuggerWindow.java
  43. 2
      smack-experimental/src/main/java/org/jivesoftware/smackx/carbons/CarbonManager.java
  44. 18
      smack-experimental/src/test/java/org/jivesoftware/smackx/carbons/CarbonTest.java
  45. 4
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/ServiceDiscoveryManagerTest.java
  46. 6
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5ByteStreamTest.java
  47. 2
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/commands/AdHocCommandDiscoTest.java
  48. 2
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/entitycaps/EntityCapsTest.java
  49. 4
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/CarExtension.java
  50. 6
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/CarExtensionProvider.java
  51. 22
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/EntityUseCases.java
  52. 4
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/MultiUserSubscriptionUseCases.java
  53. 28
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/OwnerUseCases.java
  54. 20
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/PublisherUseCases.java
  55. 56
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/SubscriberUseCases.java
  56. 2
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/TestAPI.java
  57. 108
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/TestEvents.java
  58. 28
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/TestMessageContent.java
  59. 6
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/test/PubSubTestCase.java
  60. 2
      smack-extensions/src/integration-test/java/org/jivesoftware/smackx/pubsub/test/SingleUserTestCase.java
  61. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/ibb/InBandBytestreamListener.java
  62. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/bytestreams/socks5/Socks5Proxy.java
  63. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/caps/cache/SimpleDirectoryPersistentCache.java
  64. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/commands/AdHocCommandManager.java
  65. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/commands/packet/AdHocCommandData.java
  66. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/disco/packet/DiscoverInfo.java
  67. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/jiveproperties/packet/JivePropertiesExtension.java
  68. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/DiscussionHistory.java
  69. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/muc/InvitationRejectionListener.java
  70. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/pep/PEPManager.java
  71. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPEvent.java
  72. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPItem.java
  73. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/pep/packet/PEPPubSub.java
  74. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyList.java
  75. 14
      smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/PrivacyListManager.java
  76. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/packet/Privacy.java
  77. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/privacy/provider/PrivacyProvider.java
  78. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AccessModel.java
  79. 10
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Affiliation.java
  80. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/AffiliationsExtension.java
  81. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ChildrenAssociationPolicy.java
  82. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigurationEvent.java
  83. 84
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureForm.java
  84. 40
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ConfigureNodeFields.java
  85. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElement.java
  86. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/EventElementType.java
  87. 10
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNode.java
  88. 6
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/FormNodeType.java
  89. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/GetItemsRequest.java
  90. 12
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Item.java
  91. 8
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemDeleteEvent.java
  92. 16
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemPublishEvent.java
  93. 2
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemReply.java
  94. 22
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/ItemsExtension.java
  95. 32
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/LeafNode.java
  96. 58
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/Node.java
  97. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeEvent.java
  98. 4
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/NodeExtension.java
  99. 10
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/OptionsExtension.java
  100. 20
      smack-extensions/src/main/java/org/jivesoftware/smackx/pubsub/PayloadItem.java
  101. Some files were not shown because too many files have changed in this diff Show More

@ -18,6 +18,10 @@
<property name="format" value="MXParser"/>
<property name="message" value="Must not use MXParser, use XmlPullParserFactory instead"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="^\s+$"/>
<property name="message" value="Line containing only whitespace character(s)"/>
</module>
<module name="TreeWalker">
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>

@ -113,7 +113,7 @@ public class LoginTest extends SmackTestCase {
config.setSASLAuthenticationEnabled(false);
XMPPTCPConnection conn2 = new XMPPConnection(config);
conn2.connect();
try {
// Try to login anonymously
conn1.loginAnonymously();

@ -29,7 +29,7 @@ import org.jivesoftware.smackx.ping.PingManager;
public class ReconnectionTest extends SmackTestCase {
private static final long MIN_RECONNECT_WAIT = 17; // Seconds
public ReconnectionTest(String arg0) {
super(arg0);
}
@ -48,7 +48,7 @@ public class ReconnectionTest extends SmackTestCase {
// Simulates an error in the connection
connection.notifyConnectionError(new Exception("Simulated Error"));
latch.await(MIN_RECONNECT_WAIT, TimeUnit.SECONDS);
// After 10 seconds, the reconnection manager must reestablishes the connection
assertEquals("The ConnectionListener.connectionStablished() notification was not fired", true, listener.reconnected);
assertTrue("The ReconnectionManager algorithm has reconnected without waiting at least 5 seconds", listener.attemptsNotifications > 0);
@ -81,7 +81,7 @@ public class ReconnectionTest extends SmackTestCase {
// Simulates an error in the connection
connection.notifyConnectionError(new Exception("Simulated Error"));
latch.await(MIN_RECONNECT_WAIT, TimeUnit.SECONDS);
// After 10 seconds, the reconnection manager must reestablishes the connection
assertEquals("The ConnectionListener.connectionEstablished() notification was not fired", true, listener.reconnected);
assertTrue("The ReconnectionManager algorithm has reconnected without waiting at least 5 seconds", listener.attemptsNotifications > 0);
@ -106,7 +106,7 @@ public class ReconnectionTest extends SmackTestCase {
"An error occurs but the ConnectionListener.connectionClosedOnError(e) was not notified",
true, listener.connectionClosedOnError);
// Thread.sleep(1000);
// Cancels the automatic reconnection
connection.getConfiguration().setReconnectionAllowed(false);
// Waits for a reconnection that must not happened.
@ -218,7 +218,7 @@ public class ReconnectionTest extends SmackTestCase {
*/
public void connectionClosed() {
connectionClosed = true;
if (countDownLatch != null)
countDownLatch.countDown();
}

@ -44,7 +44,7 @@ public class RosterSmackTest extends SmackTestCase {
super(name);
}
/**
* 1. Create entries in roster groups
* 2. Iterate on the groups and remove the entry from each group
@ -57,29 +57,29 @@ public class RosterSmackTest extends SmackTestCase {
CountDownLatch latch = new CountDownLatch(2);
setupCountdown(latch, roster);
roster.createEntry(getBareJID(1), "gato11", new String[] { "Friends", "Family" });
roster.createEntry(getBareJID(2), "gato12", new String[] { "Family" });
waitForCountdown(latch, roster, 2);
final CountDownLatch removeLatch = new CountDownLatch(3);
RosterListener latchCounter = new RosterListener() {
@Override
public void presenceChanged(Presence presence) {}
@Override
public void entriesUpdated(Collection<String> addresses) {
removeLatch.countDown();
}
@Override
public void entriesDeleted(Collection<String> addresses) {}
@Override
public void entriesAdded(Collection<String> addresses) {}
};
roster.addRosterListener(latchCounter);
for (RosterEntry entry : roster.getEntries()) {
@ -87,10 +87,10 @@ public class RosterSmackTest extends SmackTestCase {
rosterGroup.removeEntry(entry);
}
}
removeLatch.await(5, TimeUnit.SECONDS);
roster.removeRosterListener(latchCounter);
assertEquals("The number of entries in connection 1 should be 1", 1, getConnection(1).getRoster().getEntryCount());
assertEquals("The number of groups in connection 1 should be 0", 0, getConnection(1).getRoster().getGroupCount());
assertEquals("The number of entries in connection 2 should be 1", 1, getConnection(2).getRoster().getEntryCount());
@ -105,18 +105,18 @@ public class RosterSmackTest extends SmackTestCase {
private void setupCountdown(final CountDownLatch latch, Roster roster) {
roster.addRosterListener(new RosterListener() {
@Override
public void presenceChanged(Presence presence) {}
@Override
public void entriesUpdated(Collection<String> addresses) {
latch.countDown();
}
@Override
public void entriesDeleted(Collection<String> addresses) {}
@Override
public void entriesAdded(Collection<String> addresses) {}
});
@ -135,10 +135,10 @@ public class RosterSmackTest extends SmackTestCase {
public void testDeleteAllRosterEntries() throws Exception {
// Add a new roster entry
Roster roster = getConnection(0).getRoster();
CountDownLatch latch = new CountDownLatch(2);
setupCountdown(latch, roster);
roster.createEntry(getBareJID(1), "gato11", new String[] { "Friends" });
roster.createEntry(getBareJID(2), "gato12", new String[] { "Family" });
@ -170,10 +170,10 @@ public class RosterSmackTest extends SmackTestCase {
try {
// Add a new roster entry
Roster roster = getConnection(0).getRoster();
CountDownLatch latch = new CountDownLatch(2);
setupCountdown(latch, roster);
roster.createEntry(getBareJID(1), "gato11", null);
roster.createEntry(getBareJID(2), "gato12", null);
@ -212,9 +212,9 @@ public class RosterSmackTest extends SmackTestCase {
Roster roster = getConnection(0).getRoster();
CountDownLatch latch = new CountDownLatch(1);
setupCountdown(latch, roster);
roster.createEntry(getBareJID(1), null, null);
waitForCountdown(latch, roster, 1);
final CountDownLatch updateLatch = new CountDownLatch(2);
@ -242,9 +242,9 @@ public class RosterSmackTest extends SmackTestCase {
}
// Reload the roster and check the name again
roster.reload();
updateLatch.await(5, TimeUnit.SECONDS);
for (RosterEntry entry : roster.getEntries()) {
assertEquals("gato11", entry.getName());
}
@ -588,22 +588,22 @@ public class RosterSmackTest extends SmackTestCase {
Roster roster = getConnection(i).getRoster();
final CountDownLatch removalLatch = new CountDownLatch(roster.getEntryCount());
roster.addRosterListener(new RosterListener() {
@Override
public void presenceChanged(Presence presence) {}
@Override
public void entriesUpdated(Collection<String> addresses) {}
@Override
public void entriesDeleted(Collection<String> addresses) {
removalLatch.countDown();
}
@Override
public void entriesAdded(Collection<String> addresses) {}
});
for (RosterEntry entry : roster.getEntries()) {
try {
roster.removeEntry(entry);
@ -668,7 +668,7 @@ public class RosterSmackTest extends SmackTestCase {
assertEquals("Presence should be online after a connection reconnection",
Presence.Type.available, presence.getType());
}
protected int getMaxConnections() {
return 3;
}
@ -684,25 +684,25 @@ public class RosterSmackTest extends SmackTestCase {
cleanUpRoster();
super.tearDown();
}
private class RemovalListener implements RosterListener {
private CountDownLatch latch;
private RemovalListener(CountDownLatch removalLatch) {
latch = removalLatch;
}
@Override
public void presenceChanged(Presence presence) {}
@Override
public void entriesUpdated(Collection<String> addresses) {}
@Override
public void entriesDeleted(Collection<String> addresses) {
latch.countDown();
}
@Override
public void entriesAdded(Collection<String> addresses) {}
};

@ -126,22 +126,22 @@ public class PrivacyProviderTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser);
// check if it exist
assertNotNull(packet);
// assertEquals(xml, packet.getChildElementXML());
// check the default and active names
assertEquals("testFilter", packet.getActiveName());
assertEquals("testSubscription", packet.getDefaultName());
// check the list
assertEquals(2, packet.getPrivacyList("testFilter").size());
assertEquals(5, packet.getPrivacyList("testSubscription").size());
assertEquals(4, packet.getPrivacyList("testJID").size());
assertEquals(2, packet.getPrivacyList("testGroup").size());
assertEquals(0, packet.getPrivacyList("testEmpty").size());
// check each privacy item
PrivacyItem item = packet.getItem("testGroup", 4);
assertEquals("Enemies", item.getValue());
@ -152,7 +152,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(false, item.isFilterEverything());
item = packet.getItem("testFilter", 1);
assertEquals("tybalt@example.com", item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
@ -162,7 +162,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testFilter", 2);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
@ -193,7 +193,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testSubscription", 12);
assertEquals("from", item.getValue());
assertEquals(PrivacyItem.Type.subscription, item.getType());
@ -203,7 +203,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testSubscription", 5);
assertEquals("none", item.getValue());
assertEquals(PrivacyItem.Type.subscription, item.getType());
@ -213,7 +213,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(false, item.isFilterEverything());
item = packet.getItem("testSubscription", 15);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
@ -225,7 +225,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(true, item.isFilterEverything());
// TEST THE testJID LIST
item = packet.getItem("testJID", 6);
assertEquals("juliet@example.com", item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
@ -235,7 +235,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testJID", 7);
assertEquals("benvolio@example.org/palm", item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
@ -245,7 +245,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testJID", 42);
assertEquals(null, item.getValue());
assertEquals(PrivacyItem.Type.jid, item.getType());
@ -255,7 +255,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
item = packet.getItem("testJID", 666);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
@ -265,9 +265,9 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(true, item.isFilterEverything());
// TEST THE testGroup LIST
item = packet.getItem("testGroup", 4);
assertEquals("Enemies", item.getValue());
assertEquals(PrivacyItem.Type.group, item.getType());
@ -277,7 +277,7 @@ public class PrivacyProviderTest extends SmackTestCase {
assertEquals(false, item.isFilterPresence_in());
assertEquals(false, item.isFilterPresence_out());
assertEquals(false, item.isFilterEverything());
item = packet.getItem("testGroup", 666);
assertEquals(null, item.getValue());
assertEquals(null, item.getType());
@ -293,8 +293,8 @@ public class PrivacyProviderTest extends SmackTestCase {
fail(e.getMessage());
}
}
/**
* Check the parser with an xml with empty lists. It includes the active,
* default and special list.
@ -318,13 +318,13 @@ public class PrivacyProviderTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser);
assertNotNull(packet);
assertNotNull(packet.getChildElementXML());
assertEquals("public", packet.getDefaultName());
assertEquals(null, packet.getActiveName());
assertEquals(0, packet.getPrivacyList("public").size());
assertEquals(0, packet.getPrivacyList("private").size());
assertEquals(0, packet.getPrivacyList("special").size());
@ -336,7 +336,7 @@ public class PrivacyProviderTest extends SmackTestCase {
fail(e.getMessage());
}
}
/**
* Check the parser with an xml with empty lists. It includes the active,
* default and special list.
@ -357,12 +357,12 @@ public class PrivacyProviderTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
Privacy packet = (Privacy) (new PrivacyProvider()).parse(parser);
assertNotNull(packet);
assertEquals(null, packet.getDefaultName());
assertEquals(null, packet.getActiveName());
assertEquals(true, packet.isDeclineActiveList());
assertEquals(true, packet.isDeclineDefaultList());
} catch (Exception e) {
@ -370,14 +370,14 @@ public class PrivacyProviderTest extends SmackTestCase {
fail(e.getMessage());
}
}
private XmlPullParser getParserFromXML(String xml) throws XmlPullParserException {
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(new StringReader(xml));
return parser;
}
protected int getMaxConnections() {
return 0;
}

@ -30,33 +30,33 @@ public class PrivacyTest extends SmackTestCase {
public PrivacyTest(String arg0) {
super(arg0);
}
/**
* Check when a client set a new active list.
*/
public void testCreateActiveList() {
try {
String listName = "testCreateActiveList";
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
// Add the list that will be set as the active
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
item.setValue(getConnection(0).getUser());
items.add(item);
privacyManager.createPrivacyList(listName, items);
Thread.sleep(500);
// Set the active list
privacyManager.setActiveListName(listName);
Thread.sleep(500);
// Assert the list composition.
assertEquals(listName, privacyManager.getActiveList().toString());
List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
@ -67,7 +67,7 @@ public class PrivacyTest extends SmackTestCase {
assertEquals(1, receivedItem.getOrder());
assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
assertEquals(true, receivedItem.isAllow());
privacyManager.deletePrivacyList(listName);
} catch (Exception e) {
e.printStackTrace();
@ -83,20 +83,20 @@ public class PrivacyTest extends SmackTestCase {
String listName1 = "1testCreateTwoLists";
String listName2 = "2testCreateTwoLists";
String groupName = "testCreateTwoListsGroup";
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
// Add a list
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
item.setValue(getConnection(0).getUser());
items.add(item);
privacyManager.createPrivacyList(listName1, items);
Thread.sleep(500);
// Add the another list
ArrayList<PrivacyItem> itemsList2 = new ArrayList<PrivacyItem>();
item = new PrivacyItem(PrivacyItem.Type.group.name(), false, 2);
@ -104,9 +104,9 @@ public class PrivacyTest extends SmackTestCase {
item.setFilterMessage(true);
itemsList2.add(item);
privacyManager.createPrivacyList(listName2, itemsList2);
Thread.sleep(500);
// Assert the list composition.
PrivacyList[] privacyLists = privacyManager.getPrivacyLists();
PrivacyList receivedList1 = null;
@ -119,8 +119,8 @@ public class PrivacyTest extends SmackTestCase {
receivedList2 = privacyList;
}
}
PrivacyItem receivedItem;
// Assert on the list 1
assertNotNull(receivedList1);
@ -130,7 +130,7 @@ public class PrivacyTest extends SmackTestCase {
assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
assertEquals(true, receivedItem.isAllow());
assertEquals(getConnection(0).getUser(), receivedItem.getValue());
// Assert on the list 2
assertNotNull(receivedList2);
assertEquals(1, receivedList2.getItems().size());
@ -144,7 +144,7 @@ public class PrivacyTest extends SmackTestCase {
assertEquals(true, receivedItem.isFilterMessage());
assertEquals(false, receivedItem.isFilterPresence_in());
assertEquals(false, receivedItem.isFilterPresence_out());
privacyManager.deletePrivacyList(listName1);
privacyManager.deletePrivacyList(listName2);
} catch (Exception e) {
@ -152,7 +152,7 @@ public class PrivacyTest extends SmackTestCase {
fail(e.getMessage());
}
}
/**
* Check when a client set a new list and then update its content.
*/
@ -160,20 +160,20 @@ public class PrivacyTest extends SmackTestCase {
try {
String listName = "testCreateAndUpdateList";
String user = "tybalt@example.com";
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
// Add the list that will be set as the active
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
item.setValue(getConnection(0).getUser());
items.add(item);
privacyManager.createPrivacyList(listName, items);
Thread.sleep(500);
// Remove the existing item and add a new one.
items.remove(item);
item = new PrivacyItem(PrivacyItem.Type.jid.name(), false, 2);
@ -182,12 +182,12 @@ public class PrivacyTest extends SmackTestCase {
item.setFilterPresence_in(true);
item.setFilterMessage(true);
items.add(item);
// Update the list on server
privacyManager.updatePrivacyList(listName, items);
Thread.sleep(500);
// Assert the list composition.
PrivacyList list = privacyManager.getPrivacyList(listName);
assertEquals(1, list.getItems().size());
@ -210,7 +210,7 @@ public class PrivacyTest extends SmackTestCase {
fail(e.getMessage());
}
}
/**
* Check when a client denies the use of a default list.
*/
@ -219,18 +219,18 @@ public class PrivacyTest extends SmackTestCase {
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
privacyManager.declineDefaultList();
Thread.sleep(500);
try {
// The list should not exist and an error will be raised
privacyManager.getDefaultList();
} catch (XMPPException xmppException) {
assertEquals(404, xmppException.getXMPPError().getCode());
}
assertEquals(null, null);
} catch (Exception e) {
e.printStackTrace();
@ -246,50 +246,50 @@ public class PrivacyTest extends SmackTestCase {
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
privacyManager.declineActiveList();
Thread.sleep(500);
try {
// The list should not exist and an error will be raised
privacyManager.getActiveList();
} catch (XMPPException xmppException) {
assertEquals(404, xmppException.getXMPPError().getCode());
}
assertEquals(null, null);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
/**
* Check when a client set a new default list.
*/
public void testCreateDefaultList() {
try {
String listName = "testCreateDefaultList";
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
// Add the list that will be set as the Default
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
item.setValue(getConnection(0).getUser());
items.add(item);
privacyManager.createPrivacyList(listName, items);
Thread.sleep(500);
// Set the Default list
privacyManager.setDefaultListName(listName);
Thread.sleep(500);
// Assert the list composition.
assertEquals(listName, privacyManager.getDefaultList().toString());
List<PrivacyItem> privacyItems = privacyManager.getPrivacyList(listName).getItems();
@ -300,7 +300,7 @@ public class PrivacyTest extends SmackTestCase {
assertEquals(1, receivedItem.getOrder());
assertEquals(PrivacyItem.Type.jid, receivedItem.getType());
assertEquals(true, receivedItem.isAllow());
privacyManager.deletePrivacyList(listName);
} catch (Exception e) {
e.printStackTrace();
@ -314,27 +314,27 @@ public class PrivacyTest extends SmackTestCase {
public void testRemoveList() {
try {
String listName = "testRemoveList";
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
// Add the list that will be set as the Default
ArrayList<PrivacyItem> items = new ArrayList<PrivacyItem>();
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, 1);
item.setValue(getConnection(0).getUser());
items.add(item);
privacyManager.createPrivacyList(listName, items);
Thread.sleep(500);
// Set the Default list
privacyManager.setDefaultListName(listName);
Thread.sleep(500);
privacyManager.deletePrivacyList(listName);
Thread.sleep(500);
try {
@ -357,14 +357,14 @@ public class PrivacyTest extends SmackTestCase {
String listName = "testPrivacyItems";
String user = "tybalt@example.com";
String groupName = "enemies";
PrivacyListManager privacyManager = PrivacyListManager.getInstanceFor(getConnection(0));
PrivacyClient client = new PrivacyClient(privacyManager);
privacyManager.addListener(client);
PrivacyItem[] originalPrivacyItems = new PrivacyItem[12];
int i=0;
// Items to test JID
PrivacyItem item = new PrivacyItem(PrivacyItem.Type.jid.name(), true, i);
item.setValue(i + "_" + user);
@ -396,38 +396,38 @@ public class PrivacyTest extends SmackTestCase {
item.setValue(PrivacyRule.SUBSCRIPTION_NONE);
originalPrivacyItems[i] = item;
i = i + 1;
// Items to test Group
item = new PrivacyItem(PrivacyItem.Type.group.name(), false, i);
item.setValue(groupName);
originalPrivacyItems[i] = item;
i = i + 1;
// Items to test messages
item = new PrivacyItem(PrivacyItem.Type.group.name(), false, i);
item.setValue(groupName);
item.setFilterMessage(true);
originalPrivacyItems[i] = item;
i = i + 1;
// Items to test presence notifications
item = new PrivacyItem(PrivacyItem.Type.group.name(), false, i);
item.setValue(groupName);
item.setFilterMessage(true);
originalPrivacyItems[i] = item;
i = i + 1;
item = new PrivacyItem(null, false, i);
item.setFilterPresence_in(true);
originalPrivacyItems[i] = item;
i = i + 1;
item = new PrivacyItem(PrivacyItem.Type.subscription.name(), false, i);
item.setValue(PrivacyRule.SUBSCRIPTION_TO);
item.setFilterPresence_out(true);
originalPrivacyItems[i] = item;
i = i + 1;
item = new PrivacyItem(PrivacyItem.Type.jid.name(), false, i);
item.setValue(i + "_" + user);
item.setFilterPresence_out(true);
@ -457,7 +457,7 @@ public class PrivacyTest extends SmackTestCase {
index++;
}
originalItem = originalPrivacyItems[index];
// Assert the items
assertEquals(originalItem.getOrder(), receivedItem.getOrder());
assertEquals(originalItem.getType(), receivedItem.getType());
@ -469,14 +469,14 @@ public class PrivacyTest extends SmackTestCase {
assertEquals(originalItem.isFilterPresence_in(), receivedItem.isFilterPresence_in());
assertEquals(originalItem.isFilterPresence_out(), receivedItem.isFilterPresence_out());
}
privacyManager.deletePrivacyList(listName);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
protected int getMaxConnections() {
return 1;
}

@ -66,7 +66,7 @@ public abstract class SmackTestCase extends TestCase {
private String[] usernames;
private String[] passwords;
private String chatDomain = "chat";
private String mucDomain = "conference";
@ -118,7 +118,7 @@ public abstract class SmackTestCase extends TestCase {
protected boolean createOfflineConnections() {
return false;
}
/**
* Returns the XMPPTCPConnection located at the requested position. Each test case holds a
* pool of connections which is initialized while setting up the test case. The maximum
@ -165,7 +165,7 @@ public abstract class SmackTestCase extends TestCase {
protected String getUsername(int index) {
return usernames[index];
}
/**
* Returns the password of the user (e.g. johndoe) that is using the connection
* located at the requested position.
@ -238,7 +238,7 @@ public abstract class SmackTestCase extends TestCase {
connections = new XMPPTCPConnection[getMaxConnections()];
usernames = new String[getMaxConnections()];
passwords = new String[getMaxConnections()];
try {
// Connect to the server
for (int i = 0; i < getMaxConnections(); i++) {
@ -260,19 +260,19 @@ public abstract class SmackTestCase extends TestCase {
// that will not resolve as a network connection.
host = connections[0].getHost();
serviceName = connections[0].getServiceName();
if (!createOfflineConnections()) {
for (int i = 0; i < getMaxConnections(); i++) {
String currentUser = usernames[i];
String currentPassword = passwords[i];
try {
getConnection(i).login(currentUser, currentPassword, "Smack");
} catch (XMPPException e) {
// Create the test accounts
if (!getConnection(0).getAccountManager().supportsAccountCreation())
fail("Server does not support account creation");
// Create the account and try logging in again as the
// same user.
try {
@ -297,12 +297,12 @@ public abstract class SmackTestCase extends TestCase {
protected void connectAndLogin(int connectionIndex) throws XMPPException
{
String password = usernamePrefix + (connectionIndex + 1);
if (passwordPrefix != null)
password = (samePassword ? passwordPrefix : passwordPrefix + (connectionIndex + 1));
TCPConnection con = getConnection(connectionIndex);
if (!con.isConnected())
con.connect();
try {

@ -7,7 +7,7 @@ import org.jivesoftware.smack.XMPPException;
public class ConnectionUtils {
private ConnectionUtils() {}
public static void becomeFriends(XMPPConnection con0, XMPPConnection con1) throws XMPPException {
Roster r0 = con0.getRoster();
Roster r1 = con1.getRoster();

@ -116,14 +116,14 @@ public class DNSUtilTest {
assertEquals(ha.getFQDN(), igniterealtimeXMPPServer);
assertEquals(ha.getPort(), igniterealtimeClientPort);
}
private void xmppServerDomainTest() {
List<HostAddress> hostAddresses = DNSUtil.resolveXMPPServerDomain(igniterealtimeDomain);
HostAddress ha = hostAddresses.get(0);
assertEquals(ha.getFQDN(), igniterealtimeXMPPServer);
assertEquals(ha.getPort(), igniterealtimeServerPort);
}
private static List<SRVRecord> createSRVRecords() {
List<SRVRecord> records = new ArrayList<SRVRecord>();
// We create one record with priority 0 that should also be tried first

@ -29,7 +29,7 @@ public class XMPPErrorTest extends SmackTestCase {
public XMPPErrorTest(String arg0) {
super(arg0);
}
/**
* Check the creation of a new xmppError locally.
*/
@ -42,7 +42,7 @@ public class XMPPErrorTest extends SmackTestCase {
assertEquals(error.getType(), XMPPError.Type.CANCEL);
assertNull(error.getMessage());
}
/**
* Check the creation of a new xmppError locally.
*/
@ -56,7 +56,7 @@ public class XMPPErrorTest extends SmackTestCase {
assertEquals(error.getType(), XMPPError.Type.CANCEL);
assertEquals(error.getMessage(), message);
}
/**
* Check the creation of a new xmppError locally where there is not a default defined.
*/
@ -70,7 +70,7 @@ public class XMPPErrorTest extends SmackTestCase {
assertNull(error.getType());
assertEquals(error.getMessage(), message);
}
/**
* Check the parser with an xml with the 404 error.
*/
@ -84,14 +84,14 @@ public class XMPPErrorTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
XMPPError packet = parseError(parser);
assertNotNull(packet);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
/**
* Check the parser with an xml with the 404 error.
*/
@ -105,14 +105,14 @@ public class XMPPErrorTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
XMPPError error = parseError(parser);
assertNotNull(error);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
public void testMessageAndApplicationDefinedError() {
String xml = "<error type='modify' code='404'>" +
"<undefined-condition xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
@ -126,9 +126,9 @@ public class XMPPErrorTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
XMPPError error = parseError(parser);
String sendingXML = error.toXML();
assertNotNull(error);
assertNotNull(sendingXML);
} catch (Exception e) {
@ -152,14 +152,14 @@ public class XMPPErrorTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
XMPPError error = parseError(parser);
assertNotNull(error);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
/**
* Check the parser with an xml with the 404 error.
*/
@ -177,26 +177,26 @@ public class XMPPErrorTest extends SmackTestCase {
XmlPullParser parser = getParserFromXML(xml);
// Create a packet from the xml
XMPPError error = parseError(parser);
assertNotNull(error);
} catch (Exception e) {
e.printStackTrace();
fail(e.getMessage());
}
}
private XMPPError parseError(XmlPullParser parser) throws Exception {
parser.next();
return PacketParserUtils.parseError(parser);
}
private XmlPullParser getParserFromXML(String xml) throws XmlPullParserException {
XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
parser.setInput(new StringReader(xml));
return parser;
}
protected int getMaxConnections() {
return 0;
}

@ -108,7 +108,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
protected static Collection<ConnectionCreationListener> getConnectionCreationListeners() {
return XMPPConnectionRegistry.getConnectionCreationListeners();
}
/**
* A collection of ConnectionListeners which listen for connection closing
* and reconnection events.
@ -208,7 +208,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
*/
protected final SynchronizationPoint<SmackException> saslFeatureReceived = new SynchronizationPoint<SmackException>(
AbstractXMPPConnection.this);
/**
* The SASLAuthentication manager that is responsible for authenticating with the server.
*/

@ -102,7 +102,7 @@ public class PacketCollector {
public StanzaFilter getStanzaFilter() {
return packetFilter;
}
/**
* Polls to see if a packet is currently available and returns it, or
* immediately returns <tt>null</tt> if no packets are currently in the

@ -142,7 +142,7 @@ public final class SmackConfiguration {
public static void setPacketCollectorSize(int collectorSize) {
packetCollectorSize = collectorSize;
}
/**
* Add a SASL mechanism to the list to be used.
*