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

And add checkstyle test for lines containing only whitespace characters.
This commit is contained in:
Florian Schmaus 2015-03-17 11:33:02 +01:00
parent 05c97c494b
commit 0fde39fa45
193 changed files with 1066 additions and 1062 deletions

View File

@ -18,6 +18,10 @@
<property name="format" value="MXParser"/> <property name="format" value="MXParser"/>
<property name="message" value="Must not use MXParser, use XmlPullParserFactory instead"/> <property name="message" value="Must not use MXParser, use XmlPullParserFactory instead"/>
</module> </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="TreeWalker">
<module name="UnusedImports"> <module name="UnusedImports">
<property name="processJavadoc" value="true"/> <property name="processJavadoc" value="true"/>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -384,7 +384,7 @@ public interface XMPPConnection {
* @param packetFilter the packet filter to use. * @param packetFilter the packet filter to use.
*/ */
public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter); public void addPacketInterceptor(StanzaListener packetInterceptor, StanzaFilter packetFilter);
/** /**
* Removes a packet interceptor. * Removes a packet interceptor.
* *

View File

@ -39,7 +39,7 @@ public class XMPPConnectionRegistry {
ConnectionCreationListener connectionCreationListener) { ConnectionCreationListener connectionCreationListener) {
connectionEstablishedListeners.add(connectionCreationListener); connectionEstablishedListeners.add(connectionCreationListener);
} }
/** /**
* Removes a listener that was interested in connection creation events. * Removes a listener that was interested in connection creation events.
* *
@ -49,7 +49,7 @@ public class XMPPConnectionRegistry {
ConnectionCreationListener connectionCreationListener) { ConnectionCreationListener connectionCreationListener) {
connectionEstablishedListeners.remove(connectionCreationListener); connectionEstablishedListeners.remove(connectionCreationListener);
} }
/** /**

View File

@ -37,7 +37,7 @@ import org.jivesoftware.smack.packet.XMPPError;
*/ */
public abstract class XMPPException extends Exception { public abstract class XMPPException extends Exception {
private static final long serialVersionUID = 6881651633890968625L; private static final long serialVersionUID = 6881651633890968625L;
/** /**
* Creates a new XMPPException. * Creates a new XMPPException.

View File

@ -28,7 +28,7 @@ import org.jivesoftware.smack.util.Objects;
* *
*/ */
public class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> { public class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
public static final StanzaFilter GET = new IQTypeFilter(Type.get); public static final StanzaFilter GET = new IQTypeFilter(Type.get);
public static final StanzaFilter SET = new IQTypeFilter(Type.set); public static final StanzaFilter SET = new IQTypeFilter(Type.set);
public static final StanzaFilter RESULT = new IQTypeFilter(Type.result); public static final StanzaFilter RESULT = new IQTypeFilter(Type.result);

View File

@ -152,7 +152,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
public String getSubject() { public String getSubject() {
return getSubject(null); return getSubject(null);
} }
/** /**
* Returns the subject corresponding to the language. If the language is null, the method result * Returns the subject corresponding to the language. If the language is null, the method result
* will be the same as {@link #getSubject()}. Null will be returned if the language does not have * will be the same as {@link #getSubject()}. Null will be returned if the language does not have
@ -165,7 +165,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
Subject subject = getMessageSubject(language); Subject subject = getMessageSubject(language);
return subject == null ? null : subject.subject; return subject == null ? null : subject.subject;
} }
private Subject getMessageSubject(String language) { private Subject getMessageSubject(String language) {
language = determineLanguage(language); language = determineLanguage(language);
for (Subject subject : subjects) { for (Subject subject : subjects) {
@ -284,7 +284,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
Body body = getMessageBody(language); Body body = getMessageBody(language);
return body == null ? null : body.message; return body == null ? null : body.message;
} }
private Body getMessageBody(String language) { private Body getMessageBody(String language) {
language = determineLanguage(language); language = determineLanguage(language);
for (Body body : bodies) { for (Body body : bodies) {
@ -400,7 +400,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
} }
private String determineLanguage(String language) { private String determineLanguage(String language) {
// empty string is passed by #setSubject() and #setBody() and is the same as null // empty string is passed by #setSubject() and #setBody() and is the same as null
language = "".equals(language) ? null : language; language = "".equals(language) ? null : language;
@ -414,7 +414,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
else { else {
return language; return language;
} }
} }
@Override @Override
@ -537,7 +537,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
// simplified comparison because language and subject are always set // simplified comparison because language and subject are always set
return this.language.equals(other.language) && this.subject.equals(other.subject); return this.language.equals(other.language) && this.subject.equals(other.subject);
} }
} }
/** /**
@ -599,7 +599,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
// simplified comparison because language and message are always set // simplified comparison because language and message are always set
return this.language.equals(other.language) && this.message.equals(other.message); return this.language.equals(other.language) && this.message.equals(other.message);
} }
} }
/** /**

View File

@ -28,7 +28,7 @@ import java.util.logging.Logger;
*/ */
public class ExceptionLoggingCallback extends ParsingExceptionCallback { public class ExceptionLoggingCallback extends ParsingExceptionCallback {
private static final Logger LOGGER = Logger.getLogger(ExceptionLoggingCallback.class.getName()); private static final Logger LOGGER = Logger.getLogger(ExceptionLoggingCallback.class.getName());
@Override @Override
public void handleUnparsablePacket(UnparsablePacket unparsed) throws Exception { public void handleUnparsablePacket(UnparsablePacket unparsed) throws Exception {
LOGGER.log(Level.SEVERE, "Smack message parsing exception: ", unparsed.getParsingException()); LOGGER.log(Level.SEVERE, "Smack message parsing exception: ", unparsed.getParsingException());

View File

@ -20,13 +20,13 @@ abstract class AbstractProviderInfo {
private String element; private String element;
private String ns; private String ns;
private Object provider; private Object provider;
AbstractProviderInfo(String elementName, String namespace, Object iqOrExtProvider) { AbstractProviderInfo(String elementName, String namespace, Object iqOrExtProvider) {
element = elementName; element = elementName;
ns = namespace; ns = namespace;
provider = iqOrExtProvider; provider = iqOrExtProvider;
} }
public String getElementName() { public String getElementName() {
return element; return element;
} }
@ -34,7 +34,7 @@ abstract class AbstractProviderInfo {
public String getNamespace() { public String getNamespace() {
return ns; return ns;
} }
Object getProvider() { Object getProvider() {
return provider; return provider;
} }

View File

@ -26,7 +26,7 @@ import org.jivesoftware.smack.packet.IQ;
* *
*/ */
public final class IQProviderInfo extends AbstractProviderInfo { public final class IQProviderInfo extends AbstractProviderInfo {
/** /**
* Defines an IQ provider which implements the <code>IQProvider</code> interface. * Defines an IQ provider which implements the <code>IQProvider</code> interface.
* *

View File

@ -128,7 +128,7 @@ public final class ProviderManager {
addIQProvider(info.getElementName(), info.getNamespace(), info.getProvider()); addIQProvider(info.getElementName(), info.getNamespace(), info.getProvider());
} }
} }
if (loader.getExtensionProviderInfo() != null) { if (loader.getExtensionProviderInfo() != null) {
for (ExtensionProviderInfo info : loader.getExtensionProviderInfo()) { for (ExtensionProviderInfo info : loader.getExtensionProviderInfo()) {
addExtensionProvider(info.getElementName(), info.getNamespace(), info.getProvider()); addExtensionProvider(info.getElementName(), info.getNamespace(), info.getProvider());
@ -142,7 +142,7 @@ public final class ProviderManager {
} }
} }
} }
/** /**
* Returns the IQ provider registered to the specified XML element name and namespace. * Returns the IQ provider registered to the specified XML element name and namespace.
* For example, if a provider was registered to the element name "query" and the * For example, if a provider was registered to the element name "query" and the

View File

@ -65,7 +65,7 @@ class HTTPProxySocketFactory
throws IOException throws IOException
{ {
return httpProxifiedSocket(host.getHostAddress(), port); return httpProxifiedSocket(host.getHostAddress(), port);
} }
public Socket createSocket( InetAddress address, int port, public Socket createSocket( InetAddress address, int port,
@ -74,7 +74,7 @@ class HTTPProxySocketFactory
{ {
return httpProxifiedSocket(address.getHostAddress(), port); return httpProxifiedSocket(address.getHostAddress(), port);
} }
private Socket httpProxifiedSocket(String host, int port) private Socket httpProxifiedSocket(String host, int port)
throws IOException throws IOException
{ {
@ -96,11 +96,11 @@ class HTTPProxySocketFactory
} }
socket.getOutputStream().write((hostport + " HTTP/1.1\r\nHost: " socket.getOutputStream().write((hostport + " HTTP/1.1\r\nHost: "
+ hostport + proxyLine + "\r\n\r\n").getBytes("UTF-8")); + hostport + proxyLine + "\r\n\r\n").getBytes("UTF-8"));
InputStream in = socket.getInputStream(); InputStream in = socket.getInputStream();
StringBuilder got = new StringBuilder(100); StringBuilder got = new StringBuilder(100);
int nlchars = 0; int nlchars = 0;
while (true) while (true)
{ {
char c = (char) in.read(); char c = (char) in.read();
@ -141,30 +141,30 @@ class HTTPProxySocketFactory
} }
String gotstr = got.toString(); String gotstr = got.toString();
BufferedReader br = new BufferedReader(new StringReader(gotstr)); BufferedReader br = new BufferedReader(new StringReader(gotstr));
String response = br.readLine(); String response = br.readLine();
if (response == null) if (response == null)
{ {
throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Empty proxy " + throw new ProxyException(ProxyInfo.ProxyType.HTTP, "Empty proxy " +
"response from " + proxyhost + ", cancelling"); "response from " + proxyhost + ", cancelling");
} }
Matcher m = RESPONSE_PATTERN.matcher(response); Matcher m = RESPONSE_PATTERN.matcher(response);
if (!m.matches()) if (!m.matches())
{ {
throw new ProxyException(ProxyInfo.ProxyType.HTTP , "Unexpected " + throw new ProxyException(ProxyInfo.ProxyType.HTTP , "Unexpected " +
"proxy response from " + proxyhost + ": " + response); "proxy response from " + proxyhost + ": " + response);
} }
int code = Integer.parseInt(m.group(1)); int code = Integer.parseInt(m.group(1));
if (code != HttpURLConnection.HTTP_OK) if (code != HttpURLConnection.HTTP_OK)
{ {
throw new ProxyException(ProxyInfo.ProxyType.HTTP); throw new ProxyException(ProxyInfo.ProxyType.HTTP);
} }
return socket; return socket;
} }

View File

@ -33,12 +33,12 @@ public class ProxyException extends IOException {
{ {
super("Proxy Exception " + type.toString() + " : "+ex+", "+cause); super("Proxy Exception " + type.toString() + " : "+ex+", "+cause);
} }
public ProxyException(ProxyInfo.ProxyType type, String ex) public ProxyException(ProxyInfo.ProxyType type, String ex)
{ {
super("Proxy Exception " + type.toString() + " : "+ex); super("Proxy Exception " + type.toString() + " : "+ex);
} }
public ProxyException(ProxyInfo.ProxyType type) public ProxyException(ProxyInfo.ProxyType type)
{ {
super("Proxy Exception " + type.toString() + " : " + "Unknown Error"); super("Proxy Exception " + type.toString() + " : " + "Unknown Error");

View File

@ -34,13 +34,13 @@ public class ProxyInfo
SOCKS4, SOCKS4,
SOCKS5 SOCKS5
} }
private String proxyAddress; private String proxyAddress;
private int proxyPort; private int proxyPort;
private String proxyUsername; private String proxyUsername;
private String proxyPassword; private String proxyPassword;
private ProxyType proxyType; private ProxyType proxyType;
public ProxyInfo( ProxyType pType, String pHost, int pPort, String pUser, public ProxyInfo( ProxyType pType, String pHost, int pPort, String pUser,
String pPass) String pPass)
{ {
@ -50,60 +50,60 @@ public class ProxyInfo
this.proxyUsername = pUser; this.proxyUsername = pUser;
this.proxyPassword = pPass; this.proxyPassword = pPass;
} }
public static ProxyInfo forHttpProxy(String pHost, int pPort, String pUser, public static ProxyInfo forHttpProxy(String pHost, int pPort, String pUser,
String pPass) String pPass)
{ {
return new ProxyInfo(ProxyType.HTTP, pHost, pPort, pUser, pPass); return new ProxyInfo(ProxyType.HTTP, pHost, pPort, pUser, pPass);
} }
public static ProxyInfo forSocks4Proxy(String pHost, int pPort, String pUser, public static ProxyInfo forSocks4Proxy(String pHost, int pPort, String pUser,
String pPass) String pPass)
{ {
return new ProxyInfo(ProxyType.SOCKS4, pHost, pPort, pUser, pPass); return new ProxyInfo(ProxyType.SOCKS4, pHost, pPort, pUser, pPass);
} }
public static ProxyInfo forSocks5Proxy(String pHost, int pPort, String pUser, public static ProxyInfo forSocks5Proxy(String pHost, int pPort, String pUser,
String pPass) String pPass)
{ {
return new ProxyInfo(ProxyType.SOCKS5, pHost, pPort, pUser, pPass); return new ProxyInfo(ProxyType.SOCKS5, pHost, pPort, pUser, pPass);
} }
public static ProxyInfo forNoProxy() public static ProxyInfo forNoProxy()
{ {
return new ProxyInfo(ProxyType.NONE, null, 0, null, null); return new ProxyInfo(ProxyType.NONE, null, 0, null, null);
} }
public static ProxyInfo forDefaultProxy() public static ProxyInfo forDefaultProxy()
{ {
return new ProxyInfo(ProxyType.NONE, null, 0, null, null); return new ProxyInfo(ProxyType.NONE, null, 0, null, null);
} }
public ProxyType getProxyType() public ProxyType getProxyType()
{ {
return proxyType; return proxyType;
} }
public String getProxyAddress() public String getProxyAddress()
{ {
return proxyAddress; return proxyAddress;
} }
public int getProxyPort() public int getProxyPort()
{ {
return proxyPort; return proxyPort;
} }
public String getProxyUsername() public String getProxyUsername()
{ {
return proxyUsername; return proxyUsername;
} }
public String getProxyPassword() public String getProxyPassword()
{ {
return proxyPassword; return proxyPassword;
} }
public SocketFactory getSocketFactory() public SocketFactory getSocketFactory()
{ {
if(proxyType == ProxyType.NONE) if(proxyType == ProxyType.NONE)

View File

@ -34,7 +34,7 @@ public class Socks4ProxySocketFactory
extends SocketFactory extends SocketFactory
{ {
private ProxyInfo proxy; private ProxyInfo proxy;
public Socks4ProxySocketFactory(ProxyInfo proxy) public Socks4ProxySocketFactory(ProxyInfo proxy)
{ {
this.proxy = proxy; this.proxy = proxy;
@ -44,7 +44,7 @@ public class Socks4ProxySocketFactory
throws IOException, UnknownHostException throws IOException, UnknownHostException
{ {
return socks4ProxifiedSocket(host,port); return socks4ProxifiedSocket(host,port);
} }
public Socket createSocket(String host ,int port, InetAddress localHost, public Socket createSocket(String host ,int port, InetAddress localHost,
@ -65,9 +65,9 @@ public class Socks4ProxySocketFactory
throws IOException throws IOException
{ {
return socks4ProxifiedSocket(address.getHostAddress(),port); return socks4ProxifiedSocket(address.getHostAddress(),port);
} }
@SuppressWarnings("resource") @SuppressWarnings("resource")
private Socket socks4ProxifiedSocket(String host, int port) private Socket socks4ProxifiedSocket(String host, int port)
throws IOException throws IOException
@ -85,7 +85,7 @@ public class Socks4ProxySocketFactory
in=socket.getInputStream(); in=socket.getInputStream();
out=socket.getOutputStream(); out=socket.getOutputStream();
socket.setTcpNoDelay(true); socket.setTcpNoDelay(true);
byte[] buf=new byte[1024]; byte[] buf=new byte[1024];
int index=0; int index=0;

View File

@ -33,7 +33,7 @@ public class Socks5ProxySocketFactory
extends SocketFactory extends SocketFactory
{ {
private ProxyInfo proxy; private ProxyInfo proxy;
public Socks5ProxySocketFactory(ProxyInfo proxy) public Socks5ProxySocketFactory(ProxyInfo proxy)
{ {
this.proxy = proxy; this.proxy = proxy;
@ -49,28 +49,28 @@ public class Socks5ProxySocketFactory
int localPort) int localPort)
throws IOException, UnknownHostException throws IOException, UnknownHostException
{ {
return socks5ProxifiedSocket(host,port); return socks5ProxifiedSocket(host,port);
} }
public Socket createSocket(InetAddress host, int port) public Socket createSocket(InetAddress host, int port)
throws IOException throws IOException
{ {
return socks5ProxifiedSocket(host.getHostAddress(),port); return socks5ProxifiedSocket(host.getHostAddress(),port);
} }
public Socket createSocket( InetAddress address, int port, public Socket createSocket( InetAddress address, int port,
InetAddress localAddress, int localPort) InetAddress localAddress, int localPort)
throws IOException throws IOException
{ {
return socks5ProxifiedSocket(address.getHostAddress(),port); return socks5ProxifiedSocket(address.getHostAddress(),port);
} }
private Socket socks5ProxifiedSocket(String host, int port) private Socket socks5ProxifiedSocket(String host, int port)
throws IOException throws IOException
{ {
@ -81,7 +81,7 @@ public class Socks5ProxySocketFactory
int proxy_port = proxy.getProxyPort(); int proxy_port = proxy.getProxyPort();
String user = proxy.getProxyUsername(); String user = proxy.getProxyUsername();
String passwd = proxy.getProxyPassword(); String passwd = proxy.getProxyPassword();
try try
{ {
socket=new Socket(proxy_host, proxy_port); socket=new Socket(proxy_host, proxy_port);
@ -241,7 +241,7 @@ public class Socks5ProxySocketFactory
o DST.PORT desired destination port in network octet o DST.PORT desired destination port in network octet
order order
*/ */
index=0; index=0;
buf[index++]=5; buf[index++]=5;
buf[index++]=1; // CONNECT buf[index++]=1; // CONNECT
@ -328,7 +328,7 @@ public class Socks5ProxySocketFactory
default: default:
} }
return socket; return socket;
} }
catch(RuntimeException e) catch(RuntimeException e)
{ {
@ -355,7 +355,7 @@ public class Socks5ProxySocketFactory
throw new IOException(message); throw new IOException(message);
} }
} }
private void fill(InputStream in, byte[] buf, int len) private void fill(InputStream in, byte[] buf, int len)
throws IOException throws IOException
{ {

View File

@ -36,7 +36,7 @@ public class ObservableReader extends Reader {
public ObservableReader(Reader wrappedReader) { public ObservableReader(Reader wrappedReader) {
this.wrappedReader = wrappedReader; this.wrappedReader = wrappedReader;
} }
public int read(char[] cbuf, int off, int len) throws IOException { public int read(char[] cbuf, int off, int len) throws IOException {
int count = wrappedReader.read(cbuf, off, len); int count = wrappedReader.read(cbuf, off, len);
if (count > 0) { if (count > 0) {

View File

@ -226,7 +226,7 @@ public class PacketParserUtils {
message.setType(Message.Type.fromString(typeString)); message.setType(Message.Type.fromString(typeString));
} }
String language = getLanguageAttribute(parser); String language = getLanguageAttribute(parser);
// determine message's default language // determine message's default language
String defaultLanguage = null; String defaultLanguage = null;
if (language != null && !"".equals(language.trim())) { if (language != null && !"".equals(language.trim())) {
@ -891,7 +891,7 @@ public class PacketParserUtils {
XmlPullParser parser) throws Exception { XmlPullParser parser) throws Exception {
return parseExtensionElement(elementName, namespace, parser); return parseExtensionElement(elementName, namespace, parser);
} }
/** /**
* Parses an extension element. * Parses an extension element.
* *

View File

@ -34,5 +34,5 @@ public interface ReaderListener {
* @param str the read String * @param str the read String
*/ */
public abstract void read(String str); public abstract void read(String str);
} }

View File

@ -144,7 +144,7 @@ public class StringUtils {
throw new IllegalStateException("UTF-8 encoding not supported by platform", e); throw new IllegalStateException("UTF-8 encoding not supported by platform", e);
} }
} }
/** /**
* Pseudo-random number generator object for use with randomString(). * Pseudo-random number generator object for use with randomString().
* The Random class is not considered to be cryptographically secure, so * The Random class is not considered to be cryptographically secure, so

View File

@ -111,7 +111,7 @@ public class XmlStringBuilder implements Appendable, CharSequence {
} }
return this; return this;
} }
public XmlStringBuilder optElement(String name, Object object) { public XmlStringBuilder optElement(String name, Object object) {
if (object != null) { if (object != null) {
element(name, object.toString()); element(name, object.toString());
@ -272,7 +272,7 @@ public class XmlStringBuilder implements Appendable, CharSequence {
optAttribute("xml:lang", value); optAttribute("xml:lang", value);
return this; return this;
} }
public XmlStringBuilder escape(String text) { public XmlStringBuilder escape(String text) {
assert text != null; assert text != null;
sb.append(StringUtils.escapeForXML(text)); sb.append(StringUtils.escapeForXML(text));

View File

@ -23,10 +23,10 @@ package org.jivesoftware.smack.util.dns;
* *
*/ */
public class SRVRecord extends HostAddress implements Comparable<SRVRecord> { public class SRVRecord extends HostAddress implements Comparable<SRVRecord> {
private int weight; private int weight;
private int priority; private int priority;
/** /**
* Create a new SRVRecord * Create a new SRVRecord
* *
@ -52,11 +52,11 @@ public class SRVRecord extends HostAddress implements Comparable<SRVRecord> {
this.weight = weight; this.weight = weight;
} }
public int getPriority() { public int getPriority() {
return priority; return priority;
} }
public int getWeight() { public int getWeight() {
return weight; return weight;
} }

View File

@ -99,7 +99,7 @@ public class DummyConnection extends AbstractXMPPConnection {
protected void shutdown() { protected void shutdown() {
user = null; user = null;
authenticated = false; authenticated = false;
callConnectionClosedListener(); callConnectionClosedListener();
reconnect = true; reconnect = true;
} }

View File

@ -30,13 +30,13 @@ public class PacketCollectorTest
public void verifyRollover() throws InterruptedException public void verifyRollover() throws InterruptedException
{ {
TestPacketCollector collector = new TestPacketCollector(null, new OKEverything(), 5); TestPacketCollector collector = new TestPacketCollector(null, new OKEverything(), 5);
for (int i=0; i<6; i++) for (int i=0; i<6; i++)
{ {
Stanza testPacket = new TestPacket(i); Stanza testPacket = new TestPacket(i);
collector.processPacket(testPacket); collector.processPacket(testPacket);
} }
// Assert that '0' has rolled off // Assert that '0' has rolled off
assertEquals("1", collector.nextResultBlockForever().getStanzaId()); assertEquals("1", collector.nextResultBlockForever().getStanzaId());
assertEquals("2", collector.nextResultBlockForever().getStanzaId()); assertEquals("2", collector.nextResultBlockForever().getStanzaId());
@ -44,20 +44,20 @@ public class PacketCollectorTest
assertEquals("4", collector.nextResultBlockForever().getStanzaId()); assertEquals("4", collector.nextResultBlockForever().getStanzaId());
assertEquals("5", collector.pollResult().getStanzaId()); assertEquals("5", collector.pollResult().getStanzaId());
assertNull(collector.pollResult()); assertNull(collector.pollResult());
for (int i=10; i<15; i++) for (int i=10; i<15; i++)
{ {
Stanza testPacket = new TestPacket(i); Stanza testPacket = new TestPacket(i);
collector.processPacket(testPacket); collector.processPacket(testPacket);
} }
assertEquals("10", collector.nextResultBlockForever().getStanzaId()); assertEquals("10", collector.nextResultBlockForever().getStanzaId());
assertEquals("11", collector.nextResultBlockForever().getStanzaId()); assertEquals("11", collector.nextResultBlockForever().getStanzaId());
assertEquals("12", collector.nextResultBlockForever().getStanzaId()); assertEquals("12", collector.nextResultBlockForever().getStanzaId());
assertEquals("13", collector.nextResultBlockForever().getStanzaId()); assertEquals("13", collector.nextResultBlockForever().getStanzaId());
assertEquals("14", collector.pollResult().getStanzaId()); assertEquals("14", collector.pollResult().getStanzaId());
assertNull(collector.pollResult()); assertNull(collector.pollResult());
assertNull(collector.nextResult(1000)); assertNull(collector.nextResult(1000));
} }
@ -70,7 +70,7 @@ public class PacketCollectorTest
{ {
int insertCount = 500; int insertCount = 500;
final TestPacketCollector collector = new TestPacketCollector(null, new OKEverything(), insertCount); final TestPacketCollector collector = new TestPacketCollector(null, new OKEverything(), insertCount);
Thread consumer1 = new Thread(new Runnable() Thread consumer1 = new Thread(new Runnable()
{ {
@Override @Override
@ -105,7 +105,7 @@ public class PacketCollectorTest
public void run() public void run()
{ {
Stanza p = null; Stanza p = null;
do do
{ {
try try
@ -134,7 +134,7 @@ public class PacketCollectorTest
public void run() public void run()
{ {
Stanza p = null; Stanza p = null;
do do
{ {
try try
@ -155,7 +155,7 @@ public class PacketCollectorTest
consumer1.start(); consumer1.start();
consumer2.start(); consumer2.start();
consumer3.start(); consumer3.start();
for(int i=0; i<insertCount; i++) for(int i=0; i<insertCount; i++)
{ {
collector.processPacket(new TestPacket(i)); collector.processPacket(new TestPacket(i));
@ -183,9 +183,9 @@ public class PacketCollectorTest
{ {
return true; return true;
} }
} }
class TestPacketCollector extends PacketCollector class TestPacketCollector extends PacketCollector
{ {
protected TestPacketCollector(XMPPConnection conection, StanzaFilter packetFilter, int size) protected TestPacketCollector(XMPPConnection conection, StanzaFilter packetFilter, int size)

View File

@ -69,7 +69,7 @@ public class ThreadedDummyConnection extends DummyConnection {
public void setTimeout() { public void setTimeout() {
timeout = true; timeout = true;
} }
public void addMessage(Message msgToProcess) { public void addMessage(Message msgToProcess) {
messageQ.add(msgToProcess); messageQ.add(msgToProcess);
} }

View File

@ -166,7 +166,7 @@ public class MessageTest {
Message.Body body = message.addBody("es", "test"); Message.Body body = message.addBody("es", "test");
assertTrue(message.getBodies().size() == 1); assertTrue(message.getBodies().size() == 1);
message.removeBody(body); message.removeBody(body);
assertTrue(message.getBodies().size() == 0); assertTrue(message.getBodies().size() == 0);
} }

View File

@ -31,7 +31,7 @@ public class ProviderConfigTest {
@Test @Test
public void addGenericLoaderProvider() { public void addGenericLoaderProvider() {
ProviderManager.addLoader(new ProviderLoader() { ProviderManager.addLoader(new ProviderLoader() {
@Override @Override
public Collection<IQProviderInfo> getIQProviderInfo() { public Collection<IQProviderInfo> getIQProviderInfo() {
ArrayList<IQProviderInfo> l = new ArrayList<IQProviderInfo>(1); ArrayList<IQProviderInfo> l = new ArrayList<IQProviderInfo>(1);

View File

@ -51,19 +51,19 @@ import com.jamesmurty.utils.XMLBuilder;
* *
*/ */
public class PacketParserUtilsTest { public class PacketParserUtilsTest {
private static Properties outputProperties = new Properties(); private static Properties outputProperties = new Properties();
{ {
outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes"); outputProperties.put(javax.xml.transform.OutputKeys.OMIT_XML_DECLARATION, "yes");
} }
@Test @Test
public void singleMessageBodyTest() throws Exception { public void singleMessageBodyTest() throws Exception {
String defaultLanguage = Stanza.getDefaultLanguage(); String defaultLanguage = Stanza.getDefaultLanguage();
String otherLanguage = determineNonDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();
String control; String control;
// message has default language, body has no language // message has default language, body has no language
control = XMLBuilder.create("message") control = XMLBuilder.create("message")
.a("from", "romeo@montague.lit/orchard") .a("from", "romeo@montague.lit/orchard")
@ -74,7 +74,7 @@ public class PacketParserUtilsTest {
.e("body") .e("body")
.t(defaultLanguage) .t(defaultLanguage)
.asString(outputProperties); .asString(outputProperties);
Message message = (Message) PacketParserUtils Message message = (Message) PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control)); .parseMessage(PacketParserUtils.getParserFor(control));
@ -102,7 +102,7 @@ public class PacketParserUtilsTest {
assertEquals(otherLanguage, message.getBody(otherLanguage)); assertEquals(otherLanguage, message.getBody(otherLanguage));
assertNull(message.getBody(defaultLanguage)); assertNull(message.getBody(defaultLanguage));
assertXMLEqual(control, message.toXML().toString()); assertXMLEqual(control, message.toXML().toString());
// message has no language, body has no language // message has no language, body has no language
control = XMLBuilder.create("message") control = XMLBuilder.create("message")
.a("from", "romeo@montague.lit/orchard") .a("from", "romeo@montague.lit/orchard")
@ -112,7 +112,7 @@ public class PacketParserUtilsTest {
.e("body") .e("body")
.t(defaultLanguage) .t(defaultLanguage)
.asString(outputProperties); .asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control)); message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getBody()); assertEquals(defaultLanguage, message.getBody());
@ -212,7 +212,7 @@ public class PacketParserUtilsTest {
String otherLanguage = determineNonDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();
String control; String control;
// message has default language, subject has no language // message has default language, subject has no language
control = XMLBuilder.create("message") control = XMLBuilder.create("message")
.a("from", "romeo@montague.lit/orchard") .a("from", "romeo@montague.lit/orchard")
@ -223,7 +223,7 @@ public class PacketParserUtilsTest {
.e("subject") .e("subject")
.t(defaultLanguage) .t(defaultLanguage)
.asString(outputProperties); .asString(outputProperties);
Message message = (Message) PacketParserUtils Message message = (Message) PacketParserUtils
.parseMessage(PacketParserUtils.getParserFor(control)); .parseMessage(PacketParserUtils.getParserFor(control));
@ -251,7 +251,7 @@ public class PacketParserUtilsTest {
assertEquals(otherLanguage, message.getSubject(otherLanguage)); assertEquals(otherLanguage, message.getSubject(otherLanguage));
assertNull(message.getSubject(defaultLanguage)); assertNull(message.getSubject(defaultLanguage));
assertXMLEqual(control, message.toXML().toString()); assertXMLEqual(control, message.toXML().toString());
// message has no language, subject has no language // message has no language, subject has no language
control = XMLBuilder.create("message") control = XMLBuilder.create("message")
.a("from", "romeo@montague.lit/orchard") .a("from", "romeo@montague.lit/orchard")
@ -261,7 +261,7 @@ public class PacketParserUtilsTest {
.e("subject") .e("subject")
.t(defaultLanguage) .t(defaultLanguage)
.asString(outputProperties); .asString(outputProperties);
message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control)); message = (Message) PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(control));
assertEquals(defaultLanguage, message.getSubject()); assertEquals(defaultLanguage, message.getSubject());
@ -359,7 +359,7 @@ public class PacketParserUtilsTest {
public void multipleMessageBodiesTest() throws Exception { public void multipleMessageBodiesTest() throws Exception {
String defaultLanguage = Stanza.getDefaultLanguage(); String defaultLanguage = Stanza.getDefaultLanguage();
String otherLanguage = determineNonDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();
String control; String control;
Message message; Message message;
@ -512,7 +512,7 @@ public class PacketParserUtilsTest {
public void multipleMessageSubjectsTest() throws Exception { public void multipleMessageSubjectsTest() throws Exception {
String defaultLanguage = Stanza.getDefaultLanguage(); String defaultLanguage = Stanza.getDefaultLanguage();
String otherLanguage = determineNonDefaultLanguage(); String otherLanguage = determineNonDefaultLanguage();
String control; String control;
Message message; Message message;
@ -700,7 +700,7 @@ public class PacketParserUtilsTest {
.asString(outputProperties); .asString(outputProperties);
String invalidControl = validControl.replace("Good Message Body", "Bad </span> Body"); String invalidControl = validControl.replace("Good Message Body", "Bad </span> Body");
try { try {
PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(invalidControl)); PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(invalidControl));
fail("Exception should be thrown"); fail("Exception should be thrown");
@ -709,7 +709,7 @@ public class PacketParserUtilsTest {
} }
invalidControl = validControl.replace("Good Message Body", "Bad </body> Body"); invalidControl = validControl.replace("Good Message Body", "Bad </body> Body");
try { try {
PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(invalidControl)); PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(invalidControl));
fail("Exception should be thrown"); fail("Exception should be thrown");
@ -718,7 +718,7 @@ public class PacketParserUtilsTest {
} }
invalidControl = validControl.replace("Good Message Body", "Bad </message> Body"); invalidControl = validControl.replace("Good Message Body", "Bad </message> Body");
try { try {
PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(invalidControl)); PacketParserUtils.parseMessage(PacketParserUtils.getParserFor(invalidControl));
fail("Exception should be thrown"); fail("Exception should be thrown");
@ -755,22 +755,22 @@ public class PacketParserUtilsTest {
@Test @Test
public void validateSimplePresence() throws Exception { public void validateSimplePresence() throws Exception {
String stanza = "<presence from='juliet@example.com/balcony' to='romeo@example.net'/>"; String stanza = "<presence from='juliet@example.com/balcony' to='romeo@example.net'/>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXMLEqual(stanza, presence.toXML().toString()); assertXMLEqual(stanza, presence.toXML().toString());
} }
@Test @Test
public void validatePresenceProbe() throws Exception { public void validatePresenceProbe() throws Exception {
String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>"; String stanza = "<presence from='mercutio@example.com' id='xv291f38' to='juliet@example.com' type='unsubscribed'/>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXMLEqual(stanza, presence.toXML().toString()); assertXMLEqual(stanza, presence.toXML().toString());
assertEquals(Presence.Type.unsubscribed, presence.getType()); assertEquals(Presence.Type.unsubscribed, presence.getType());
} }
@Test @Test
public void validatePresenceOptionalElements() throws Exception { public void validatePresenceOptionalElements() throws Exception {
String stanza = "<presence xml:lang='en' type='unsubscribed'>" String stanza = "<presence xml:lang='en' type='unsubscribed'>"
@ -778,7 +778,7 @@ public class PacketParserUtilsTest {
+ "<status>Wooing Juliet</status>" + "<status>Wooing Juliet</status>"
+ "<priority>1</priority>" + "<priority>1</priority>"
+ "</presence>"; + "</presence>";
Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza)); Presence presence = PacketParserUtils.parsePresence(PacketParserUtils.getParserFor(stanza));
assertXMLEqual(stanza, presence.toXML().toString()); assertXMLEqual(stanza, presence.toXML().toString());
assertEquals(Presence.Type.unsubscribed, presence.getType()); assertEquals(Presence.Type.unsubscribed, presence.getType());

View File

@ -62,7 +62,7 @@ public class StringUtilsTest {
input = "&"; input = "&";
assertCharSequenceEquals("&amp;", StringUtils.escapeForXML(input)); assertCharSequenceEquals("&amp;", StringUtils.escapeForXML(input));
input = "It's a good day today"; input = "It's a good day today";
assertCharSequenceEquals("It&apos;s a good day today", StringUtils.escapeForXML(input)); assertCharSequenceEquals("It&apos;s a good day today", StringUtils.escapeForXML(input));
} }

View File

@ -99,7 +99,7 @@ import java.util.logging.Logger;
public class EnhancedDebugger implements SmackDebugger { public class EnhancedDebugger implements SmackDebugger {
private static final Logger LOGGER = Logger.getLogger(EnhancedDebugger.class.getName()); private static final Logger LOGGER = Logger.getLogger(EnhancedDebugger.class.getName());
private static final String NEWLINE = "\n"; private static final String NEWLINE = "\n";
private static ImageIcon packetReceivedIcon; private static ImageIcon packetReceivedIcon;
@ -354,22 +354,22 @@ public class EnhancedDebugger implements SmackDebugger {
messageTextArea.addMouseListener(new PopupListener(menu)); messageTextArea.addMouseListener(new PopupListener(menu));
JPanel sublayout = new JPanel(new BorderLayout()); JPanel sublayout = new JPanel(new BorderLayout());
sublayout.add(new JScrollPane(messageTextArea), BorderLayout.CENTER); sublayout.add(new JScrollPane(messageTextArea), BorderLayout.CENTER);
JButton clearb = new JButton("Clear All Packets"); JButton clearb = new JButton("Clear All Packets");
clearb.addActionListener(new AbstractAction() { clearb.addActionListener(new AbstractAction() {
private static final long serialVersionUID = -8576045822764763613L; private static final long serialVersionUID = -8576045822764763613L;
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
messagesTable.setRowCount(0); messagesTable.setRowCount(0);
} }
}); });
sublayout.add(clearb, BorderLayout.NORTH); sublayout.add(clearb, BorderLayout.NORTH);
allPane.setBottomComponent(sublayout); allPane.setBottomComponent(sublayout);
allPane.setDividerLocation(150); allPane.setDividerLocation(150);
tabbedPane.add("All Packets", allPane); tabbedPane.add("All Packets", allPane);

View File

@ -197,7 +197,7 @@ public class EnhancedDebuggerWindow {
getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane), getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane),
connectionActiveIcon); connectionActiveIcon);
} }
/** /**
* Creates the main debug window that provides information about Smack and also shows * Creates the main debug window that provides information about Smack and also shows
* a tab panel for each connection that is being debugged. * a tab panel for each connection that is being debugged.

View File

@ -58,7 +58,7 @@ public class CarbonManager extends Manager {
} }
}); });
} }
private volatile boolean enabled_state = false; private volatile boolean enabled_state = false;
private CarbonManager(XMPPConnection connection) { private CarbonManager(XMPPConnection connection) {

View File

@ -45,24 +45,24 @@ public class CarbonTest extends ExperimentalInitializerTest {
String control; String control;
CarbonExtension cc; CarbonExtension cc;
Forwarded fwd; Forwarded fwd;
control = XMLBuilder.create("sent") control = XMLBuilder.create("sent")
.e("forwarded") .e("forwarded")
.a("xmlns", "urn:xmpp:forwarded:0") .a("xmlns", "urn:xmpp:forwarded:0")
.e("message") .e("message")
.a("from", "romeo@montague.com") .a("from", "romeo@montague.com")
.asString(outputProperties); .asString(outputProperties);
parser = PacketParserUtils.getParserFor(control); parser = PacketParserUtils.getParserFor(control);
cc = (CarbonExtension) new CarbonManagerProvider().parse(parser); cc = (CarbonExtension) new CarbonManagerProvider().parse(parser);
fwd = cc.getForwarded(); fwd = cc.getForwarded();
// meta // meta
assertEquals(CarbonExtension.Direction.sent, cc.getDirection()); assertEquals(CarbonExtension.Direction.sent, cc.getDirection());
// no delay in packet // no delay in packet
assertEquals(null, fwd.getDelayInformation()); assertEquals(null, fwd.getDelayInformation());
// check message // check message
assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedPacket().getFrom())); assertThat("romeo@montague.com", equalsCharSequence(fwd.getForwardedPacket().getFrom()));
@ -76,19 +76,19 @@ public class CarbonTest extends ExperimentalInitializerTest {
XmlPullParser parser; XmlPullParser parser;
String control; String control;
CarbonExtension cc; CarbonExtension cc;
control = XMLBuilder.create("received") control = XMLBuilder.create("received")
.e("forwarded") .e("forwarded")
.a("xmlns", "urn:xmpp:forwarded:0") .a("xmlns", "urn:xmpp:forwarded:0")
.e("message") .e("message")
.a("from", "romeo@montague.com") .a("from", "romeo@montague.com")
.asString(outputProperties); .asString(outputProperties);
parser = PacketParserUtils.getParserFor(control); parser = PacketParserUtils.getParserFor(control);
cc = (CarbonExtension) new CarbonManagerProvider().parse(parser); cc = (CarbonExtension) new CarbonManagerProvider().parse(parser);
assertEquals(CarbonExtension.Direction.received, cc.getDirection()); assertEquals(CarbonExtension.Direction.received, cc.getDirection());
// check end of tag // check end of tag
assertEquals(XmlPullParser.END_TAG, parser.getEventType()); assertEquals(XmlPullParser.END_TAG, parser.getEventType());
assertEquals("received", parser.getName()); assertEquals("received", parser.getName());
@ -98,11 +98,11 @@ public class CarbonTest extends ExperimentalInitializerTest {
public void carbonEmptyTest() throws Exception { public void carbonEmptyTest() throws Exception {
XmlPullParser parser; XmlPullParser parser;
String control; String control;
control = XMLBuilder.create("sent") control = XMLBuilder.create("sent")
.a("xmlns", "urn:xmpp:forwarded:0") .a("xmlns", "urn:xmpp:forwarded:0")
.asString(outputProperties); .asString(outputProperties);
parser = PacketParserUtils.getParserFor(control); parser = PacketParserUtils.getParserFor(control);
new CarbonManagerProvider().parse(parser); new CarbonManagerProvider().parse(parser);
} }

View File

@ -133,7 +133,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
itemToPublish.setNode("romeo/avatar"); itemToPublish.setNode("romeo/avatar");
itemToPublish.setAction(DiscoverItems.Item.UPDATE_ACTION); itemToPublish.setAction(DiscoverItems.Item.UPDATE_ACTION);
itemsToPublish.addItem(itemToPublish); itemsToPublish.addItem(itemToPublish);
try { try {
ServiceDiscoveryManager.getInstanceFor(getConnection(0)).publishItems(getServiceName(), ServiceDiscoveryManager.getInstanceFor(getConnection(0)).publishItems(getServiceName(),
itemsToPublish); itemsToPublish);
@ -141,7 +141,7 @@ public class ServiceDiscoveryManagerTest extends SmackTestCase {
catch (Exception e) { catch (Exception e) {
fail(e.getMessage()); fail(e.getMessage());
} }
}*/ }*/
protected int getMaxConnections() { protected int getMaxConnections() {

View File

@ -140,7 +140,7 @@ public class Socks5ByteStreamTest extends SmackTestCase {
Socks5BytestreamSession session = initiatorByteStreamManager.establishSession( Socks5BytestreamSession session = initiatorByteStreamManager.establishSession(
targetConnection.getUser()); targetConnection.getUser());
OutputStream outputStream = session.getOutputStream(); OutputStream outputStream = session.getOutputStream();
assertTrue(session.isDirect()); assertTrue(session.isDirect());
// verify stream // verify stream
@ -284,9 +284,9 @@ public class Socks5ByteStreamTest extends SmackTestCase {
Socks5BytestreamManager initiatorByteStreamManager = Socks5BytestreamManager.getBytestreamManager(initiatorConnection); Socks5BytestreamManager initiatorByteStreamManager = Socks5BytestreamManager.getBytestreamManager(initiatorConnection);
Socks5BytestreamSession session = initiatorByteStreamManager.establishSession(targetConnection.getUser()); Socks5BytestreamSession session = initiatorByteStreamManager.establishSession(targetConnection.getUser());
assertTrue(session.isMediated()); assertTrue(session.isMediated());
// verify stream // verify stream
final byte[] receivedData = new byte[3]; final byte[] receivedData = new byte[3];
final InputStream inputStream = session.getInputStream(); final InputStream inputStream = session.getInputStream();

View File

@ -81,7 +81,7 @@ public class AdHocCommandDiscoTest extends SmackTestCase {
}; };
} }
}); });
AdHocCommandManager manager2 = AdHocCommandManager.getAddHocCommandsManager(getConnection(1)); AdHocCommandManager manager2 = AdHocCommandManager.getAddHocCommandsManager(getConnection(1));
DiscoverItems items = manager2.discoverCommands(getFullJID(0)); DiscoverItems items = manager2.discoverCommands(getFullJID(0));

View File

@ -47,7 +47,7 @@ public class EntityCapsTest extends SmackTestCase {
sdm1 = ServiceDiscoveryManager.getInstanceFor(con1); sdm1 = ServiceDiscoveryManager.getInstanceFor(con1);
letsAllBeFriends(); letsAllBeFriends();
} }
public void testLocalEntityCaps() throws InterruptedException { public void testLocalEntityCaps() throws InterruptedException {
DiscoverInfo info = EntityCapsManager.getDiscoveryInfoByNodeVer(ecm1.getLocalNodeVer()); DiscoverInfo info = EntityCapsManager.getDiscoveryInfoByNodeVer(ecm1.getLocalNodeVer());
assertFalse(info.containsFeature(DISCOVER_TEST_FEATURE)); assertFalse(info.containsFeature(DISCOVER_TEST_FEATURE));

View File

@ -33,7 +33,7 @@ class CarExtension implements PacketExtension
color = col; color = col;
numTires = num; numTires = num;
} }
public String getColor() public String getColor()
{ {
return color; return color;
@ -59,5 +59,5 @@ class CarExtension implements PacketExtension
return "<" + getElementName() + " xmlns='" + getNamespace() + "'><paint color='" + return "<" + getElementName() + " xmlns='" + getNamespace() + "'><paint color='" +
getColor() + "'/><tires num='" + getNumTires() + "'/></" + getElementName() + ">"; getColor() + "'/><tires num='" + getNumTires() + "'/></" + getElementName() + ">";
} }
} }

View File

@ -32,11 +32,11 @@ public class CarExtensionProvider extends PacketExtensionProvider
{ {
String color = null; String color = null;
int numTires = 0; int numTires = 0;
for (int i=0; i<2; i++) for (int i=0; i<2; i++)
{ {
while (parser.next() != XmlPullParser.START_TAG); while (parser.next() != XmlPullParser.START_TAG);
if (parser.getName().equals("paint")) if (parser.getName().equals("paint"))
{ {
color = parser.getAttributeValue(0); color = parser.getAttributeValue(0);
@ -49,5 +49,5 @@ public class CarExtensionProvider extends PacketExtensionProvider
while (parser.next() != XmlPullParser.END_TAG); while (parser.next() != XmlPullParser.END_TAG);
return new CarExtension(color, numTires); return new CarExtension(color, numTires);
} }
} }

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -43,10 +43,10 @@ public class EntityUseCases extends SingleUserTestCase
DiscoverInfo info = myNode.discoverInfo(); DiscoverInfo info = myNode.discoverInfo();
assertTrue(info.getIdentities().hasNext()); assertTrue(info.getIdentities().hasNext());
Identity ident = info.getIdentities().next(); Identity ident = info.getIdentities().next();
assertEquals("leaf", ident.getType()); assertEquals("leaf", ident.getType());
} }
public void testDiscoverNodeItems() throws Exception public void testDiscoverNodeItems() throws Exception
{ {
LeafNode myNode = getRandomPubnode(getManager(), true, false); LeafNode myNode = getRandomPubnode(getManager(), true, false);
@ -55,33 +55,33 @@ public class EntityUseCases extends SingleUserTestCase
myNode.send(new Item()); myNode.send(new Item());
myNode.send(new Item()); myNode.send(new Item());
DiscoverItems items = myNode.discoverItems(); DiscoverItems items = myNode.discoverItems();
int count = 0; int count = 0;
for(Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext(); it.next(),count++); for(Iterator<DiscoverItems.Item> it = items.getItems(); it.hasNext(); it.next(),count++);
assertEquals(4, count); assertEquals(4, count);
} }
public void testDiscoverSubscriptions() throws Exception public void testDiscoverSubscriptions() throws Exception
{ {
getManager().getSubscriptions(); getManager().getSubscriptions();
} }
public void testDiscoverNodeSubscriptions() throws Exception public void testDiscoverNodeSubscriptions() throws Exception
{ {
LeafNode myNode = getRandomPubnode(getManager(), true, true); LeafNode myNode = getRandomPubnode(getManager(), true, true);
myNode.subscribe(getConnection(0).getUser()); myNode.subscribe(getConnection(0).getUser());
List<Subscription> subscriptions = myNode.getSubscriptions(); List<Subscription> subscriptions = myNode.getSubscriptions();
assertTrue(subscriptions.size() < 3); assertTrue(subscriptions.size() < 3);
for (Subscription subscription : subscriptions) for (Subscription subscription : subscriptions)
{ {
assertNull(subscription.getNode()); assertNull(subscription.getNode());
} }
} }
public void testRetrieveAffiliation() throws Exception public void testRetrieveAffiliation() throws Exception
{ {
getManager().getAffiliations(); getManager().getAffiliations();

View File

@ -45,7 +45,7 @@ public class MultiUserSubscriptionUseCases extends PubSubTestCase
node.send((Item)null); node.send((Item)null);
node.send((Item)null); node.send((Item)null);
node.send((Item)null); node.send((Item)null);
LeafNode user2Node = (LeafNode) getManager(1).getNode(node.getId()); LeafNode user2Node = (LeafNode) getManager(1).getNode(node.getId());
user2Node.subscribe(getBareJID(1)); user2Node.subscribe(getBareJID(1));
@ -61,7 +61,7 @@ public class MultiUserSubscriptionUseCases extends PubSubTestCase
node.send((Item)null); node.send((Item)null);
node.send((Item)null); node.send((Item)null);
node.send((Item)null); node.send((Item)null);
LeafNode user2Node = (LeafNode) getManager(1).getNode(node.getId()); LeafNode user2Node = (LeafNode) getManager(1).getNode(node.getId());
Subscription sub1 = user2Node.subscribe(getBareJID(1)); Subscription sub1 = user2Node.subscribe(getBareJID(1));

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import java.util.Collection; import java.util.Collection;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
@ -46,7 +46,7 @@ public class OwnerUseCases extends SingleUserTestCase
{ {
// Generate reasonably unique for multiple tests // Generate reasonably unique for multiple tests
String id = "TestConfigNode" + System.currentTimeMillis(); String id = "TestConfigNode" + System.currentTimeMillis();
// Create and configure a node // Create and configure a node
ConfigureForm form = new ConfigureForm(FormType.submit); ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open); form.setAccessModel(AccessModel.open);
@ -56,7 +56,7 @@ public class OwnerUseCases extends SingleUserTestCase
form.setPublishModel(PublishModel.open); form.setPublishModel(PublishModel.open);
LeafNode node = (LeafNode)getManager().createNode(id, form); LeafNode node = (LeafNode)getManager().createNode(id, form);
ConfigureForm currentForm = node.getNodeConfiguration(); ConfigureForm currentForm = node.getNodeConfiguration();
assertEquals(AccessModel.open, currentForm.getAccessModel()); assertEquals(AccessModel.open, currentForm.getAccessModel());
assertFalse(currentForm.isDeliverPayloads()); assertFalse(currentForm.isDeliverPayloads());
@ -69,7 +69,7 @@ public class OwnerUseCases extends SingleUserTestCase
{ {
// Generate reasonably unique for multiple tests // Generate reasonably unique for multiple tests
String id = "TestConfigNode2" + System.currentTimeMillis(); String id = "TestConfigNode2" + System.currentTimeMillis();
// Create and configure a node // Create and configure a node
ConfigureForm form = new ConfigureForm(FormType.submit); ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open); form.setAccessModel(AccessModel.open);
@ -77,16 +77,16 @@ public class OwnerUseCases extends SingleUserTestCase
form.setNotifyRetract(true); form.setNotifyRetract(true);
form.setPersistentItems(true); form.setPersistentItems(true);
form.setPublishModel(PublishModel.open); form.setPublishModel(PublishModel.open);
LeafNode myNode = (LeafNode)getManager().createNode(id, form); LeafNode myNode = (LeafNode)getManager().createNode(id, form);
ConfigureForm config = myNode.getNodeConfiguration(); ConfigureForm config = myNode.getNodeConfiguration();
assertEquals(AccessModel.open, config.getAccessModel()); assertEquals(AccessModel.open, config.getAccessModel());
assertFalse(config.isDeliverPayloads()); assertFalse(config.isDeliverPayloads());
assertTrue(config.isNotifyRetract()); assertTrue(config.isNotifyRetract());
assertTrue(config.isPersistItems()); assertTrue(config.isPersistItems());
assertEquals(PublishModel.open, config.getPublishModel()); assertEquals(PublishModel.open, config.getPublishModel());
ConfigureForm submitForm = new ConfigureForm(config.createAnswerForm()); ConfigureForm submitForm = new ConfigureForm(config.createAnswerForm());
submitForm.setAccessModel(AccessModel.whitelist); submitForm.setAccessModel(AccessModel.whitelist);
submitForm.setDeliverPayloads(true); submitForm.setDeliverPayloads(true);
@ -108,14 +108,14 @@ public class OwnerUseCases extends SingleUserTestCase
ConfigureForm form = getManager().getDefaultConfiguration(); ConfigureForm form = getManager().getDefaultConfiguration();
assertNotNull(form); assertNotNull(form);
} }
public void testDeleteNode() throws Exception public void testDeleteNode() throws Exception
{ {
LeafNode myNode = getManager().createNode(); LeafNode myNode = getManager().createNode();
assertNotNull(getManager().getNode(myNode.getId())); assertNotNull(getManager().getNode(myNode.getId()));
getManager(0).deleteNode(myNode.getId()); getManager(0).deleteNode(myNode.getId());
try try
{ {
assertNull(getManager().getNode(myNode.getId())); assertNull(getManager().getNode(myNode.getId()));
@ -125,23 +125,23 @@ public class OwnerUseCases extends SingleUserTestCase
{ {
} }
} }
public void testPurgeItems() throws XMPPException public void testPurgeItems() throws XMPPException
{ {
LeafNode node = getRandomPubnode(getManager(), true, false); LeafNode node = getRandomPubnode(getManager(), true, false);
node.send(new Item()); node.send(new Item());
node.send(new Item()); node.send(new Item());
node.send(new Item()); node.send(new Item());
node.send(new Item()); node.send(new Item());
node.send(new Item()); node.send(new Item());
Collection<? extends Item> items = node.getItems(); Collection<? extends Item> items = node.getItems();
assertTrue(items.size() == 5); assertTrue(items.size() == 5);
node.deleteAllItems(); node.deleteAllItems();
items = node.getItems(); items = node.getItems();
// Pubsub service may keep the last notification (in spec), so 0 or 1 may be returned on get items. // Pubsub service may keep the last notification (in spec), so 0 or 1 may be returned on get items.
assertTrue(items.size() < 2); assertTrue(items.size() < 2);
} }

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@ -126,39 +126,39 @@ public class PublisherUseCases extends SingleUserTestCase
public void testDeleteItems() throws XMPPException public void testDeleteItems() throws XMPPException
{ {
LeafNode node = getPubnode(true, false); LeafNode node = getPubnode(true, false);
node.send(new Item("1")); node.send(new Item("1"));
node.send(new Item("2")); node.send(new Item("2"));
node.send(new Item("3")); node.send(new Item("3"));
node.send(new Item("4")); node.send(new Item("4"));
node.deleteItem("1"); node.deleteItem("1");
Collection<? extends Item> items = node.getItems(); Collection<? extends Item> items = node.getItems();
assertEquals(3, items.size()); assertEquals(3, items.size());
} }
public void testPersistItems() throws XMPPException public void testPersistItems() throws XMPPException
{ {
LeafNode node = getPubnode(true, false); LeafNode node = getPubnode(true, false);
node.send(new Item("1")); node.send(new Item("1"));
node.send(new Item("2")); node.send(new Item("2"));
node.send(new Item("3")); node.send(new Item("3"));
node.send(new Item("4")); node.send(new Item("4"));
Collection<? extends Item> items = node.getItems(); Collection<? extends Item> items = node.getItems();
assertTrue(items.size() == 4); assertTrue(items.size() == 4);
} }
public void testItemOverwritten() throws XMPPException public void testItemOverwritten() throws XMPPException
{ {
LeafNode node = getPubnode(true, false); LeafNode node = getPubnode(true, false);
node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("test", null, "<test/>"))); node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("test", null, "<test/>")));
node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("test2", null, "<test2/>"))); node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("test2", null, "<test2/>")));
List<? extends Item> items = node.getItems(); List<? extends Item> items = node.getItems();
assertEquals(1, items.size()); assertEquals(1, items.size());
assertEquals("1", items.get(0).getId()); assertEquals("1", items.get(0).getId());

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual; import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import java.util.ArrayList; import java.util.ArrayList;
@ -40,7 +40,7 @@ public class SubscriberUseCases extends SingleUserTestCase
{ {
LeafNode node = getPubnode(false, false); LeafNode node = getPubnode(false, false);
Subscription sub = node.subscribe(getJid()); Subscription sub = node.subscribe(getJid());
assertEquals(getJid(), sub.getJid()); assertEquals(getJid(), sub.getJid());
assertNotNull(sub.getId()); assertNotNull(sub.getId());
assertEquals(node.getId(), sub.getNode()); assertEquals(node.getId(), sub.getNode());
@ -50,7 +50,7 @@ public class SubscriberUseCases extends SingleUserTestCase
public void testSubscribeBadJid() throws Exception public void testSubscribeBadJid() throws Exception
{ {
LeafNode node = getPubnode(false, false); LeafNode node = getPubnode(false, false);
try try
{ {
node.subscribe("this@over.here"); node.subscribe("this@over.here");
@ -71,12 +71,12 @@ public class SubscriberUseCases extends SingleUserTestCase
LeafNode node = getPubnode(false, false); LeafNode node = getPubnode(false, false);
node.subscribe(getJid(), form); node.subscribe(getJid(), form);
} }
public void testSubscribeConfigRequired() throws Exception public void testSubscribeConfigRequired() throws Exception
{ {
ConfigureForm form = new ConfigureForm(FormType.submit); ConfigureForm form = new ConfigureForm(FormType.submit);
form.setAccessModel(AccessModel.open); form.setAccessModel(AccessModel.open);
// Openfire specific field - nothing in the spec yet // Openfire specific field - nothing in the spec yet
FormField required = new FormField("pubsub#subscription_required"); FormField required = new FormField("pubsub#subscription_required");
required.setType(FormField.TYPE_BOOLEAN); required.setType(FormField.TYPE_BOOLEAN);
@ -85,31 +85,31 @@ public class SubscriberUseCases extends SingleUserTestCase
LeafNode node = (LeafNode)getManager().createNode("Pubnode" + System.currentTimeMillis(), form); LeafNode node = (LeafNode)getManager().createNode("Pubnode" + System.currentTimeMillis(), form);
Subscription sub = node.subscribe(getJid()); Subscription sub = node.subscribe(getJid());
assertEquals(getJid(), sub.getJid()); assertEquals(getJid(), sub.getJid());
assertNotNull(sub.getId()); assertNotNull(sub.getId());
assertEquals(node.getId(), sub.getNode()); assertEquals(node.getId(), sub.getNode());
assertEquals(true, sub.isConfigRequired()); assertEquals(true, sub.isConfigRequired());
} }
public void testUnsubscribe() throws Exception public void testUnsubscribe() throws Exception
{ {
LeafNode node = getPubnode(false, false); LeafNode node = getPubnode(false, false);
node.subscribe(getJid()); node.subscribe(getJid());
Collection<Subscription> subs = node.getSubscriptions(); Collection<Subscription> subs = node.getSubscriptions();
node.unsubscribe(getJid()); node.unsubscribe(getJid());
Collection<Subscription> afterSubs = node.getSubscriptions(); Collection<Subscription> afterSubs = node.getSubscriptions();
assertEquals(subs.size()-1, afterSubs.size()); assertEquals(subs.size()-1, afterSubs.size());
} }
public void testUnsubscribeWithMultipleNoSubId() throws Exception public void testUnsubscribeWithMultipleNoSubId() throws Exception
{ {
LeafNode node = getPubnode(false, false); LeafNode node = getPubnode(false, false);
node.subscribe(getBareJID(0)); node.subscribe(getBareJID(0));
node.subscribe(getBareJID(0)); node.subscribe(getBareJID(0));
node.subscribe(getBareJID(0)); node.subscribe(getBareJID(0));
try try
{ {
node.unsubscribe(getBareJID(0)); node.unsubscribe(getBareJID(0));
@ -119,7 +119,7 @@ public class SubscriberUseCases extends SingleUserTestCase
{ {
} }
} }
public void testUnsubscribeWithMultipleWithSubId() throws Exception public void testUnsubscribeWithMultipleWithSubId() throws Exception
{ {
LeafNode node = getPubnode(false, false); LeafNode node = getPubnode(false, false);
@ -128,7 +128,7 @@ public class SubscriberUseCases extends SingleUserTestCase
node.subscribe(getJid()); node.subscribe(getJid());
node.unsubscribe(getJid(), sub.getId()); node.unsubscribe(getJid(), sub.getId());
} }
public void testGetOptions() throws Exception public void testGetOptions() throws Exception
{ {
LeafNode node = getPubnode(false, false); LeafNode node = getPubnode(false, false);
@ -136,7 +136,7 @@ public class SubscriberUseCases extends SingleUserTestCase
SubscribeForm form = node.getSubscriptionOptions(getJid(), sub.getId()); SubscribeForm form = node.getSubscriptionOptions(getJid(), sub.getId());
assertNotNull(form); assertNotNull(form);
} }
// public void testSubscribeWithConfig() throws Exception // public void testSubscribeWithConfig() throws Exception
// { // {
// LeafNode node = getPubnode(false, false); // LeafNode node = getPubnode(false, false);
@ -154,7 +154,7 @@ public class SubscriberUseCases extends SingleUserTestCase
LeafNode node = getPubnode(true, false); LeafNode node = getPubnode(true, false);
runNodeTests(node); runNodeTests(node);
} }
private void runNodeTests(LeafNode node) throws Exception private void runNodeTests(LeafNode node) throws Exception
{ {
node.send((Item)null); node.send((Item)null);
@ -162,17 +162,17 @@ public class SubscriberUseCases extends SingleUserTestCase
node.send((Item)null); node.send((Item)null);
node.send((Item)null); node.send((Item)null);
node.send((Item)null); node.send((Item)null);
Collection<? extends Item> items = node.getItems(); Collection<? extends Item> items = node.getItems();
assertTrue(items.size() == 5); assertTrue(items.size() == 5);
long curTime = System.currentTimeMillis(); long curTime = System.currentTimeMillis();
node.send(new Item("1-" + curTime)); node.send(new Item("1-" + curTime));
node.send(new Item("2-" + curTime)); node.send(new Item("2-" + curTime));
node.send(new Item("3-" + curTime)); node.send(new Item("3-" + curTime));
node.send(new Item("4-" + curTime)); node.send(new Item("4-" + curTime));
node.send(new Item("5-" + curTime)); node.send(new Item("5-" + curTime));
items = node.getItems(); items = node.getItems();
assertTrue(items.size() == 10); assertTrue(items.size() == 10);
@ -183,35 +183,35 @@ public class SubscriberUseCases extends SingleUserTestCase
idPayload.put("7-" + curTime, "<a href=\"/up/here\"/>"); idPayload.put("7-" + curTime, "<a href=\"/up/here\"/>");
idPayload.put("8-" + curTime, "<entity>text<inner></inner></entity>"); idPayload.put("8-" + curTime, "<entity>text<inner></inner></entity>");
idPayload.put("9-" + curTime, "<entity><inner><text></text></inner></entity>"); idPayload.put("9-" + curTime, "<entity><inner><text></text></inner></entity>");
for (Map.Entry<String, String> payload : idPayload.entrySet()) for (Map.Entry<String, String> payload : idPayload.entrySet())
{ {
payloadNode.send(new PayloadItem<SimplePayload>(payload.getKey(), new SimplePayload("a", "pubsub:test", payload.getValue()))); payloadNode.send(new PayloadItem<SimplePayload>(payload.getKey(), new SimplePayload("a", "pubsub:test", payload.getValue())));
} }
payloadNode.send(new PayloadItem<SimplePayload>("6-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test'/>"))); payloadNode.send(new PayloadItem<SimplePayload>("6-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test'/>")));
payloadNode.send(new PayloadItem<SimplePayload>("7-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href=\'/up/here\'/>"))); payloadNode.send(new PayloadItem<SimplePayload>("7-" + curTime, new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href=\'/up/here\'/>")));
payloadNode.send(new PayloadItem<SimplePayload>("8-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'>text<inner>a</inner></entity>"))); payloadNode.send(new PayloadItem<SimplePayload>("8-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'>text<inner>a</inner></entity>")));
payloadNode.send(new PayloadItem<SimplePayload>("9-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'><inner><text>b</text></inner></entity>"))); payloadNode.send(new PayloadItem<SimplePayload>("9-" + curTime, new SimplePayload("entity", "pubsub:test", "<entity xmlns='pubsub:test'><inner><text>b</text></inner></entity>")));
List<PayloadItem<SimplePayload>> payloadItems = payloadNode.getItems(); List<PayloadItem<SimplePayload>> payloadItems = payloadNode.getItems();
Map<String, PayloadItem<SimplePayload>> idMap = new HashMap<String, PayloadItem<SimplePayload>>(); Map<String, PayloadItem<SimplePayload>> idMap = new HashMap<String, PayloadItem<SimplePayload>>();
for (PayloadItem<SimplePayload> payloadItem : payloadItems) for (PayloadItem<SimplePayload> payloadItem : payloadItems)
{ {
idMap.put(payloadItem.getId(), payloadItem); idMap.put(payloadItem.getId(), payloadItem);
} }
assertEquals(4, payloadItems.size()); assertEquals(4, payloadItems.size());
PayloadItem<SimplePayload> testItem = idMap.get("6-" + curTime); PayloadItem<SimplePayload> testItem = idMap.get("6-" + curTime);
assertNotNull(testItem); assertNotNull(testItem);
assertXMLEqual("<a xmlns='pubsub:test'/>", testItem.getPayload().toXML()); assertXMLEqual("<a xmlns='pubsub:test'/>", testItem.getPayload().toXML());
testItem = idMap.get("7-" + curTime); testItem = idMap.get("7-" + curTime);
assertNotNull(testItem); assertNotNull(testItem);
assertXMLEqual("<a xmlns='pubsub:test' href=\'/up/here\'/>", testItem.getPayload().toXML()); assertXMLEqual("<a xmlns='pubsub:test' href=\'/up/here\'/>", testItem.getPayload().toXML());
testItem = idMap.get("8-" + curTime); testItem = idMap.get("8-" + curTime);
assertNotNull(testItem); assertNotNull(testItem);
assertXMLEqual("<entity xmlns='pubsub:test'>text<inner>a</inner></entity>", testItem.getPayload().toXML()); assertXMLEqual("<entity xmlns='pubsub:test'>text<inner>a</inner></entity>", testItem.getPayload().toXML());
@ -224,13 +224,13 @@ public class SubscriberUseCases extends SingleUserTestCase
public void testGetSpecifiedItems() throws Exception public void testGetSpecifiedItems() throws Exception
{ {
LeafNode node = getPubnode(true, true); LeafNode node = getPubnode(true, true);
node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>"))); node.send(new PayloadItem<SimplePayload>("1", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
node.send(new PayloadItem<SimplePayload>("2", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='2'/>"))); node.send(new PayloadItem<SimplePayload>("2", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='2'/>")));
node.send(new PayloadItem<SimplePayload>("3", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='3'/>"))); node.send(new PayloadItem<SimplePayload>("3", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='3'/>")));
node.send(new PayloadItem<SimplePayload>("4", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='4'/>"))); node.send(new PayloadItem<SimplePayload>("4", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='4'/>")));
node.send(new PayloadItem<SimplePayload>("5", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='5'/>"))); node.send(new PayloadItem<SimplePayload>("5", new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='5'/>")));
Collection<String> ids = new ArrayList<String>(3); Collection<String> ids = new ArrayList<String>(3);
ids.add("1"); ids.add("1");
ids.add("3"); ids.add("3");
@ -249,13 +249,13 @@ public class SubscriberUseCases extends SingleUserTestCase
public void testGetLastNItems() throws XMPPException public void testGetLastNItems() throws XMPPException
{ {
LeafNode node = getPubnode(true, false); LeafNode node = getPubnode(true, false);
node.send(new Item("1")); node.send(new Item("1"));
node.send(new Item("2")); node.send(new Item("2"));
node.send(new Item("3")); node.send(new Item("3"));
node.send(new Item("4")); node.send(new Item("4"));
node.send(new Item("5")); node.send(new Item("5"));
List<Item> items = node.getItems(2); List<Item> items = node.getItems(2);
assertEquals(2, items.size()); assertEquals(2, items.size());
assertTrue(listContainsId("4", items)); assertTrue(listContainsId("4", items));

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.jivesoftware.smackx.pubsub; package org.jivesoftware.smackx.pubsub;
import org.jivesoftware.smack.XMPPException; import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smackx.pubsub.test.SingleUserTestCase; import org.jivesoftware.smackx.pubsub.test.SingleUserTestCase;

View File

@ -59,7 +59,7 @@ public class TestEvents extends SmackTestCase
{ {
String nodeId = "MyTestNode"; String nodeId = "MyTestNode";
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService()); PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = null; LeafNode creatorNode = null;
try try
{ {
@ -72,10 +72,10 @@ public class TestEvents extends SmackTestCase
else else
throw e; throw e;
} }
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
assertNotNull(subNode); assertNotNull(subNode);
} }
@ -84,7 +84,7 @@ public class TestEvents extends SmackTestCase
// Setup event source // Setup event source
String nodeId = "TestNode" + System.currentTimeMillis(); String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService()); PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, false, true); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, false, true);
BlockingQueue<NodeConfigCoordinator> queue = new ArrayBlockingQueue<NodeConfigCoordinator>(3); BlockingQueue<NodeConfigCoordinator> queue = new ArrayBlockingQueue<NodeConfigCoordinator>(3);
@ -96,7 +96,7 @@ public class TestEvents extends SmackTestCase
NodeConfigListener sub1Handler = new NodeConfigCoordinator(queue, "sub1"); NodeConfigListener sub1Handler = new NodeConfigCoordinator(queue, "sub1");
subNode.subscribe(getConnection(1).getUser()); subNode.subscribe(getConnection(1).getUser());
subNode.addConfigurationListener(sub1Handler); subNode.addConfigurationListener(sub1Handler);
ConfigureForm currentConfig = creatorNode.getNodeConfiguration(); ConfigureForm currentConfig = creatorNode.getNodeConfiguration();
ConfigureForm form = new ConfigureForm(currentConfig.createAnswerForm()); ConfigureForm form = new ConfigureForm(currentConfig.createAnswerForm());
form.setPersistentItems(true); form.setPersistentItems(true);
@ -107,7 +107,7 @@ public class TestEvents extends SmackTestCase
ConfigurationEvent event = queue.poll(5, TimeUnit.SECONDS).event; ConfigurationEvent event = queue.poll(5, TimeUnit.SECONDS).event;
assertEquals(nodeId, event.getNode()); assertEquals(nodeId, event.getNode());
assertNull(event.getConfiguration()); assertNull(event.getConfiguration());
currentConfig = creatorNode.getNodeConfiguration(); currentConfig = creatorNode.getNodeConfiguration();
form = new ConfigureForm(currentConfig.createAnswerForm()); form = new ConfigureForm(currentConfig.createAnswerForm());
form.setDeliverPayloads(true); form.setDeliverPayloads(true);
@ -128,7 +128,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3); BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -136,16 +136,16 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1"); ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1");
subNode.addItemEventListener(sub1Handler); subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser()); Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
creatorNode.send(new Item(itemId)); creatorNode.send(new Item(itemId));
ItemEventCoordinator<Item> coord = queue.poll(5, TimeUnit.SECONDS); ItemEventCoordinator<Item> coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.events.getItems().size()); assertEquals(1, coord.events.getItems().size());
assertEquals(itemId, coord.events.getItems().iterator().next().getId()); assertEquals(itemId, coord.events.getItems().iterator().next().getId());
} }
public void testPublishAndReceiveNoPayload() throws Exception public void testPublishAndReceiveNoPayload() throws Exception
{ {
// Setup event source // Setup event source
@ -154,7 +154,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3); BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -162,11 +162,11 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1"); ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1");
subNode.addItemEventListener(sub1Handler); subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser()); Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
creatorNode.publish(new Item(itemId)); creatorNode.publish(new Item(itemId));
ItemEventCoordinator<Item> coord = queue.poll(5, TimeUnit.SECONDS); ItemEventCoordinator<Item> coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.events.getItems().size()); assertEquals(1, coord.events.getItems().size());
assertEquals(itemId, coord.events.getItems().get(0).getId()); assertEquals(itemId, coord.events.getItems().get(0).getId());
@ -180,7 +180,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true);
BlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>>(3); BlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>>(3);
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -188,12 +188,12 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<PayloadItem<SimplePayload>> sub1Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub1"); ItemEventCoordinator<PayloadItem<SimplePayload>> sub1Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub1");
subNode.addItemEventListener(sub1Handler); subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser()); Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
String payloadString = "<book xmlns=\"pubsub:test:book\"><author>Sir Arthur Conan Doyle</author></book>"; String payloadString = "<book xmlns=\"pubsub:test:book\"><author>Sir Arthur Conan Doyle</author></book>";
creatorNode.send(new PayloadItem<SimplePayload>(itemId, new SimplePayload("book", "pubsub:test:book", payloadString))); creatorNode.send(new PayloadItem<SimplePayload>(itemId, new SimplePayload("book", "pubsub:test:book", payloadString)));
ItemEventCoordinator<PayloadItem<SimplePayload>> coord = queue.poll(5, TimeUnit.SECONDS); ItemEventCoordinator<PayloadItem<SimplePayload>> coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.events.getItems().size()); assertEquals(1, coord.events.getItems().size());
PayloadItem<SimplePayload> item = coord.events.getItems().get(0); PayloadItem<SimplePayload> item = coord.events.getItems().get(0);
@ -221,7 +221,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true);
BlockingQueue<ItemEventCoordinator<PayloadItem<CarExtension>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<CarExtension>>>(3); BlockingQueue<ItemEventCoordinator<PayloadItem<CarExtension>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<CarExtension>>>(3);
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
Node subNode = subMgr.getNode(nodeId); Node subNode = subMgr.getNode(nodeId);
@ -229,12 +229,12 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<PayloadItem<CarExtension>> sub1Handler = new ItemEventCoordinator<PayloadItem<CarExtension>>(queue, "sub1"); ItemEventCoordinator<PayloadItem<CarExtension>> sub1Handler = new ItemEventCoordinator<PayloadItem<CarExtension>>(queue, "sub1");
subNode.addItemEventListener(sub1Handler); subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser()); Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
String payloadString = "<car xmlns='pubsub:test:vehicle'><paint color='green'/><tires num='4'/></car>"; String payloadString = "<car xmlns='pubsub:test:vehicle'><paint color='green'/><tires num='4'/></car>";
creatorNode.send(new PayloadItem(itemId, new SimplePayload("car", "pubsub:test:vehicle", payloadString))); creatorNode.send(new PayloadItem(itemId, new SimplePayload("car", "pubsub:test:vehicle", payloadString)));
ItemEventCoordinator<PayloadItem<CarExtension>> coord = queue.take(); ItemEventCoordinator<PayloadItem<CarExtension>> coord = queue.take();
assertEquals(1, coord.events.getItems().size()); assertEquals(1, coord.events.getItems().size());
PayloadItem item = coord.events.getItems().get(0); PayloadItem item = coord.events.getItems().get(0);
@ -246,7 +246,7 @@ public class TestEvents extends SmackTestCase
assertEquals(4, car.getNumTires()); assertEquals(4, car.getNumTires());
} }
*/ */
public void testSendAndReceiveMultipleSubs() throws Exception public void testSendAndReceiveMultipleSubs() throws Exception
{ {
// Setup event source // Setup event source
@ -255,7 +255,7 @@ public class TestEvents extends SmackTestCase
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3); BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -263,7 +263,7 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1"); ItemEventCoordinator<Item> sub1Handler = new ItemEventCoordinator<Item>(queue, "sub1");
subNode.addItemEventListener(sub1Handler); subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser()); Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
ItemEventCoordinator<Item> sub2Handler = new ItemEventCoordinator<Item>(queue, "sub2"); ItemEventCoordinator<Item> sub2Handler = new ItemEventCoordinator<Item>(queue, "sub2");
subNode.addItemEventListener(sub2Handler); subNode.addItemEventListener(sub2Handler);
Subscription sub2 = subNode.subscribe(getConnection(1).getUser()); Subscription sub2 = subNode.subscribe(getConnection(1).getUser());
@ -271,16 +271,16 @@ public class TestEvents extends SmackTestCase
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
creatorNode.send(new Item(itemId)); creatorNode.send(new Item(itemId));
for(int i=0; i<2; i++) for(int i=0; i<2; i++)
{ {
ItemEventCoordinator<Item> coord = queue.poll(10, TimeUnit.SECONDS); ItemEventCoordinator<Item> coord = queue.poll(10, TimeUnit.SECONDS);
if (coord == null) if (coord == null)
fail(); fail();
assertEquals(1, coord.events.getItems().size()); assertEquals(1, coord.events.getItems().size());
assertEquals(itemId, coord.events.getItems().iterator().next().getId()); assertEquals(itemId, coord.events.getItems().iterator().next().getId());
if (coord.id.equals("sub1") || coord.id.equals("sub2")) if (coord.id.equals("sub1") || coord.id.equals("sub2"))
{ {
assertEquals(2, coord.events.getSubscriptions().size()); assertEquals(2, coord.events.getSubscriptions().size());
@ -293,14 +293,14 @@ public class TestEvents extends SmackTestCase
// Setup event source // Setup event source
String nodeId = "TestNode" + System.currentTimeMillis(); String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService()); PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, true);
BlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>>(3); BlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>> queue = new ArrayBlockingQueue<ItemEventCoordinator<PayloadItem<SimplePayload>>>(3);
ItemEventCoordinator<PayloadItem<SimplePayload>> creatorHandler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "creator"); ItemEventCoordinator<PayloadItem<SimplePayload>> creatorHandler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "creator");
creatorNode.addItemEventListener(creatorHandler); creatorNode.addItemEventListener(creatorHandler);
creatorNode.subscribe(getConnection(0).getUser()); creatorNode.subscribe(getConnection(0).getUser());
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -308,24 +308,24 @@ public class TestEvents extends SmackTestCase
ItemEventCoordinator<PayloadItem<SimplePayload>> sub1Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub1"); ItemEventCoordinator<PayloadItem<SimplePayload>> sub1Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub1");
subNode.addItemEventListener(sub1Handler); subNode.addItemEventListener(sub1Handler);
Subscription sub1 = subNode.subscribe(getConnection(1).getUser()); Subscription sub1 = subNode.subscribe(getConnection(1).getUser());
ItemEventCoordinator<PayloadItem<SimplePayload>> sub2Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub2"); ItemEventCoordinator<PayloadItem<SimplePayload>> sub2Handler = new ItemEventCoordinator<PayloadItem<SimplePayload>>(queue, "sub2");
subNode.addItemEventListener(sub2Handler); subNode.addItemEventListener(sub2Handler);
Subscription sub2 = subNode.subscribe(getConnection(1).getUser()); Subscription sub2 = subNode.subscribe(getConnection(1).getUser());
assertEquals(Subscription.State.subscribed, sub1.getState()); assertEquals(Subscription.State.subscribed, sub1.getState());
assertEquals(Subscription.State.subscribed, sub2.getState()); assertEquals(Subscription.State.subscribed, sub2.getState());
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
Collection<PayloadItem<SimplePayload>> items = new ArrayList<PayloadItem<SimplePayload>>(3); Collection<PayloadItem<SimplePayload>> items = new ArrayList<PayloadItem<SimplePayload>>(3);
String ids[] = {"First-" + itemId, "Second-" + itemId, "Third-" + itemId}; String ids[] = {"First-" + itemId, "Second-" + itemId, "Third-" + itemId};
items.add(new PayloadItem<SimplePayload>(ids[0], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>"))); items.add(new PayloadItem<SimplePayload>(ids[0], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
items.add(new PayloadItem<SimplePayload>(ids[1], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>"))); items.add(new PayloadItem<SimplePayload>(ids[1], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
items.add(new PayloadItem<SimplePayload>(ids[2], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>"))); items.add(new PayloadItem<SimplePayload>(ids[2], new SimplePayload("a", "pubsub:test", "<a xmlns='pubsub:test' href='1'/>")));
creatorNode.send(items); creatorNode.send(items);
for(int i=0; i<3; i++) for(int i=0; i<3; i++)
{ {
ItemEventCoordinator<PayloadItem<SimplePayload>> coord = queue.poll(5, TimeUnit.SECONDS); ItemEventCoordinator<PayloadItem<SimplePayload>> coord = queue.poll(5, TimeUnit.SECONDS);
@ -350,7 +350,7 @@ public class TestEvents extends SmackTestCase
// Setup event source // Setup event source
String nodeId = "TestNode" + System.currentTimeMillis(); String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService()); PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
// Send event // Send event
@ -380,11 +380,11 @@ public class TestEvents extends SmackTestCase
// Setup event source // Setup event source
String nodeId = "TestNode" + System.currentTimeMillis(); String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService()); PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemDeleteCoordinator> queue = new ArrayBlockingQueue<ItemDeleteCoordinator>(3); BlockingQueue<ItemDeleteCoordinator> queue = new ArrayBlockingQueue<ItemDeleteCoordinator>(3);
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -395,7 +395,7 @@ public class TestEvents extends SmackTestCase
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
Collection<Item> items = new ArrayList<Item>(3); Collection<Item> items = new ArrayList<Item>(3);
String id1 = "First-" + itemId; String id1 = "First-" + itemId;
String id2 = "Second-" + itemId; String id2 = "Second-" + itemId;
@ -404,9 +404,9 @@ public class TestEvents extends SmackTestCase
items.add(new Item(id2)); items.add(new Item(id2));
items.add(new Item(id3)); items.add(new Item(id3));
creatorNode.send(items); creatorNode.send(items);
creatorNode.deleteItem(id1); creatorNode.deleteItem(id1);
ItemDeleteCoordinator coord = queue.poll(5, TimeUnit.SECONDS); ItemDeleteCoordinator coord = queue.poll(5, TimeUnit.SECONDS);
assertEquals(1, coord.event.getItemIds().size()); assertEquals(1, coord.event.getItemIds().size());
assertEquals(id1, coord.event.getItemIds().get(0)); assertEquals(id1, coord.event.getItemIds().get(0));
@ -424,11 +424,11 @@ public class TestEvents extends SmackTestCase
// Setup event source // Setup event source
String nodeId = "TestNode" + System.currentTimeMillis(); String nodeId = "TestNode" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService()); PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false); LeafNode creatorNode = getPubnode(creatorMgr, nodeId, true, false);
BlockingQueue<ItemDeleteCoordinator> queue = new ArrayBlockingQueue<ItemDeleteCoordinator>(3); BlockingQueue<ItemDeleteCoordinator> queue = new ArrayBlockingQueue<ItemDeleteCoordinator>(3);
// Setup event receiver // Setup event receiver
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode = (LeafNode)subMgr.getNode(nodeId); LeafNode subNode = (LeafNode)subMgr.getNode(nodeId);
@ -439,7 +439,7 @@ public class TestEvents extends SmackTestCase
// Send event // Send event
String itemId = String.valueOf(System.currentTimeMillis()); String itemId = String.valueOf(System.currentTimeMillis());
Collection<Item> items = new ArrayList<Item>(3); Collection<Item> items = new ArrayList<Item>(3);
String id1 = "First-" + itemId; String id1 = "First-" + itemId;
String id2 = "Second-" + itemId; String id2 = "Second-" + itemId;
@ -448,9 +448,9 @@ public class TestEvents extends SmackTestCase
items.add(new Item(id2)); items.add(new Item(id2));
items.add(new Item(id3)); items.add(new Item(id3));
creatorNode.send(items); creatorNode.send(items);
creatorNode.deleteAllItems(); creatorNode.deleteAllItems();
ItemDeleteCoordinator coord = queue.poll(5, TimeUnit.SECONDS); ItemDeleteCoordinator coord = queue.poll(5, TimeUnit.SECONDS);
assertNull(nodeId, coord.event); assertNull(nodeId, coord.event);
} }
@ -461,31 +461,31 @@ public class TestEvents extends SmackTestCase
String nodeId1 = "Node-1-" + System.currentTimeMillis(); String nodeId1 = "Node-1-" + System.currentTimeMillis();
PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService()); PubSubManager creatorMgr = new PubSubManager(getConnection(0), getService());
String nodeId2 = "Node-2-" + System.currentTimeMillis(); String nodeId2 = "Node-2-" + System.currentTimeMillis();
LeafNode creatorNode1 = getPubnode(creatorMgr, nodeId1, true, false); LeafNode creatorNode1 = getPubnode(creatorMgr, nodeId1, true, false);
LeafNode creatorNode2 = getPubnode(creatorMgr, nodeId2, true, false); LeafNode creatorNode2 = getPubnode(creatorMgr, nodeId2, true, false);
BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3); BlockingQueue<ItemEventCoordinator<Item>> queue = new ArrayBlockingQueue<ItemEventCoordinator<Item>>(3);
PubSubManager subMgr = new PubSubManager(getConnection(1), getService()); PubSubManager subMgr = new PubSubManager(getConnection(1), getService());
LeafNode subNode1 = (LeafNode)subMgr.getNode(nodeId1); LeafNode subNode1 = (LeafNode)subMgr.getNode(nodeId1);
LeafNode subNode2 = (LeafNode)subMgr.getNode(nodeId2); LeafNode subNode2 = (LeafNode)subMgr.getNode(nodeId2);
subNode1.addItemEventListener(new ItemEventCoordinator<Item>(queue, "sub1")); subNode1.addItemEventListener(new ItemEventCoordinator<Item>(queue, "sub1"));
subNode2.addItemEventListener(new ItemEventCoordinator<Item>(queue, "sub2")); subNode2.addItemEventListener(new ItemEventCoordinator<Item>(queue, "sub2"));
subNode1.subscribe(getConnection(1).getUser()); subNode1.subscribe(getConnection(1).getUser());
subNode2.subscribe(getConnection(1).getUser()); subNode2.subscribe(getConnection(1).getUser());
creatorNode1.send(new Item("item1")); creatorNode1.send(new Item("item1"));
creatorNode2.send(new Item("item2")); creatorNode2.send(new Item("item2"));
boolean check1 = false; boolean check1 = false;
boolean check2 = false; boolean check2 = false;
for (int i=0; i<2; i++) for (int i=0; i<2; i++)
{ {
ItemEventCoordinator<Item> event = queue.poll(5, TimeUnit.SECONDS); ItemEventCoordinator<Item> event = queue.poll(5, TimeUnit.SECONDS);
if (event.id.equals("sub1")) if (event.id.equals("sub1"))
{ {
assertEquals(event.events.getNodeId(), nodeId1); assertEquals(event.events.getNodeId(), nodeId1);
@ -506,7 +506,7 @@ public class TestEvents extends SmackTestCase
private BlockingQueue<ItemEventCoordinator<T>> theQueue; private BlockingQueue<ItemEventCoordinator<T>> theQueue;
private ItemPublishEvent<T> events; private ItemPublishEvent<T> events;
private String id; private String id;
ItemEventCoordinator(BlockingQueue<ItemEventCoordinator<T>> queue, String id) ItemEventCoordinator(BlockingQueue<ItemEventCoordinator<T>> queue, String id)
{ {
theQueue = queue; theQueue = queue;
@ -524,15 +524,15 @@ public class TestEvents extends SmackTestCase
{ {
return "ItemEventCoordinator: " + id; return "ItemEventCoordinator: " + id;
} }
} }
class NodeConfigCoordinator implements NodeConfigListener class NodeConfigCoordinator implements NodeConfigListener
{ {
private BlockingQueue<NodeConfigCoordinator> theQueue; private BlockingQueue<NodeConfigCoordinator> theQueue;
private String id; private String id;
private ConfigurationEvent event; private ConfigurationEvent event;
NodeConfigCoordinator(BlockingQueue<NodeConfigCoordinator> queue, String id) NodeConfigCoordinator(BlockingQueue<NodeConfigCoordinator> queue, String id)
{ {
theQueue = queue; theQueue = queue;
@ -558,7 +558,7 @@ public class TestEvents extends SmackTestCase
private BlockingQueue<ItemDeleteCoordinator> theQueue; private BlockingQueue<ItemDeleteCoordinator> theQueue;
private String id; private String id;
private ItemDeleteEvent event; private ItemDeleteEvent event;
ItemDeleteCoordinator(BlockingQueue<ItemDeleteCoordinator> queue, String id) ItemDeleteCoordinator(BlockingQueue<ItemDeleteCoordinator> queue, String id)
{ {
theQueue = queue; theQueue = queue;

View File

@ -26,7 +26,7 @@ import junit.framework.TestCase;
public class TestMessageContent extends TestCase public class TestMessageContent extends TestCase
{ {
String payloadXmlWithNS = "<book xmlns='pubsub:test:book'><author name='Stephen King'/></book>"; String payloadXmlWithNS = "<book xmlns='pubsub:test:book'><author name='Stephen King'/></book>";
public void testItemWithId() public void testItemWithId()
{ {
Item item = new Item("123"); Item item = new Item("123");
@ -47,21 +47,21 @@ public class TestMessageContent extends TestCase
public void testSimplePayload() public void testSimplePayload()
{ {
SimplePayload payloadNS = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS); SimplePayload payloadNS = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
assertEquals(payloadXmlWithNS, payloadNS.toXML()); assertEquals(payloadXmlWithNS, payloadNS.toXML());
String payloadXmlWithNoNS = "<book><author name='Stephen King'/></book>"; String payloadXmlWithNoNS = "<book><author name='Stephen King'/></book>";
SimplePayload payloadNoNS = new SimplePayload("book", null, "<book><author name='Stephen King'/></book>"); SimplePayload payloadNoNS = new SimplePayload("book", null, "<book><author name='Stephen King'/></book>");
assertEquals(payloadXmlWithNoNS, payloadNoNS.toXML()); assertEquals(payloadXmlWithNoNS, payloadNoNS.toXML());
} }
public void testPayloadItemWithId() public void testPayloadItemWithId()
{ {
SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS); SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("123", payload); PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("123", payload);
String xml = "<item id='123'>" + payloadXmlWithNS + "</item>"; String xml = "<item id='123'>" + payloadXmlWithNS + "</item>";
assertEquals(xml, item.toXML()); assertEquals(xml, item.toXML());
assertEquals("item", item.getElementName()); assertEquals("item", item.getElementName());
@ -71,7 +71,7 @@ public class TestMessageContent extends TestCase
{ {
SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS); SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>(null, payload); PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>(null, payload);
String xml = "<item>" + payloadXmlWithNS + "</item>"; String xml = "<item>" + payloadXmlWithNS + "</item>";
assertEquals(xml, item.toXML()); assertEquals(xml, item.toXML());
} }
@ -99,14 +99,14 @@ public class TestMessageContent extends TestCase
{ {
} }
} }
public void testRetractItem() public void testRetractItem()
{ {
RetractItem item = new RetractItem("1234"); RetractItem item = new RetractItem("1234");
assertEquals("<retract id='1234'/>", item.toXML()); assertEquals("<retract id='1234'/>", item.toXML());
assertEquals("retract", item.getElementName()); assertEquals("retract", item.getElementName());
try try
{ {
new RetractItem(null); new RetractItem(null);
@ -116,7 +116,7 @@ public class TestMessageContent extends TestCase
{ {
} }
} }
public void testGetItemsRequest() public void testGetItemsRequest()
{ {
GetItemsRequest request = new GetItemsRequest("testId"); GetItemsRequest request = new GetItemsRequest("testId");
@ -124,10 +124,10 @@ public class TestMessageContent extends TestCase
request = new GetItemsRequest("testId", 5); request = new GetItemsRequest("testId", 5);
assertEquals("<items node='testId' max_items='5'/>", request.toXML()); assertEquals("<items node='testId' max_items='5'/>", request.toXML());
request = new GetItemsRequest("testId", "qwerty"); request = new GetItemsRequest("testId", "qwerty");
assertEquals("<items node='testId' subid='qwerty'/>", request.toXML()); assertEquals("<items node='testId' subid='qwerty'/>", request.toXML());
request = new GetItemsRequest("testId", "qwerty", 5); request = new GetItemsRequest("testId", "qwerty", 5);
assertEquals("<items node='testId' subid='qwerty' max_items='5'/>", request.toXML()); assertEquals("<items node='testId' subid='qwerty' max_items='5'/>", request.toXML());
} }

View File

@ -55,7 +55,7 @@ abstract public class PubSubTestCase extends SmackTestCase
protected LeafNode getPubnode(PubSubManager pubMgr, boolean persistItems, boolean deliverPayload, String nodeId) throws XMPPException protected LeafNode getPubnode(PubSubManager pubMgr, boolean persistItems, boolean deliverPayload, String nodeId) throws XMPPException
{ {
LeafNode node = null; LeafNode node = null;
try try
{ {
node = (LeafNode)pubMgr.getNode(nodeId); node = (LeafNode)pubMgr.getNode(nodeId);
@ -76,7 +76,7 @@ abstract public class PubSubTestCase extends SmackTestCase
if (manager == null) if (manager == null)
{ {
manager = new PubSubManager[getMaxConnections()]; manager = new PubSubManager[getMaxConnections()];
for(int i=0; i<manager.length; i++) for(int i=0; i<manager.length; i++)
{ {
manager[i] = new PubSubManager(getConnection(i), getService()); manager[i] = new PubSubManager(getConnection(i), getService());
@ -84,7 +84,7 @@ abstract public class PubSubTestCase extends SmackTestCase
} }
return manager[idx]; return manager[idx];
} }
protected String getService() protected String getService()
{ {
return "pubsub." + getServiceName(); return "pubsub." + getServiceName();

View File

@ -31,7 +31,7 @@ public class SingleUserTestCase extends PubSubTestCase
{ {
return getManager(0); return getManager(0);
} }
protected LeafNode getPubnode(boolean persistItems, boolean deliverPayload) throws XMPPException protected LeafNode getPubnode(boolean persistItems, boolean deliverPayload) throws XMPPException
{ {
return getRandomPubnode(getManager(), persistItems, deliverPayload); return getRandomPubnode(getManager(), persistItems, deliverPayload);

View File

@ -32,8 +32,8 @@ import org.jivesoftware.smackx.bytestreams.BytestreamRequest;
*/ */
public abstract class InBandBytestreamListener implements BytestreamListener { public abstract class InBandBytestreamListener implements BytestreamListener {
public void incomingBytestreamRequest(BytestreamRequest request) { public void incomingBytestreamRequest(BytestreamRequest request) {
incomingBytestreamRequest((InBandBytestreamRequest) request); incomingBytestreamRequest((InBandBytestreamRequest) request);
} }

View File

@ -70,7 +70,7 @@ import org.jivesoftware.smack.SmackException;
*/ */
public class Socks5Proxy { public class Socks5Proxy {
private static final Logger LOGGER = Logger.getLogger(Socks5Proxy.class.getName()); private static final Logger LOGGER = Logger.getLogger(Socks5Proxy.class.getName());
/* SOCKS5 proxy singleton */ /* SOCKS5 proxy singleton */
private static Socks5Proxy socks5Server; private static Socks5Proxy socks5Server;

View File

@ -40,7 +40,7 @@ import org.jivesoftware.smackx.disco.packet.DiscoverInfo;
*/ */
public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache { public class SimpleDirectoryPersistentCache implements EntityCapsPersistentCache {
private static final Logger LOGGER = Logger.getLogger(SimpleDirectoryPersistentCache.class.getName()); private static final Logger LOGGER = Logger.getLogger(SimpleDirectoryPersistentCache.class.getName());
private File cacheDir; private File cacheDir;
private StringEncoder filenameEncoder; private StringEncoder filenameEncoder;

View File

@ -119,9 +119,9 @@ public class AdHocCommandManager extends Manager {
* ID matches the sessionid attribute sent by command responders. * ID matches the sessionid attribute sent by command responders.
*/ */
private final Map<String, LocalCommand> executingCommands = new ConcurrentHashMap<String, LocalCommand>(); private final Map<String, LocalCommand> executingCommands = new ConcurrentHashMap<String, LocalCommand>();
private final ServiceDiscoveryManager serviceDiscoveryManager; private final ServiceDiscoveryManager serviceDiscoveryManager;
/** /**
* Thread that reaps stale sessions. * Thread that reaps stale sessions.
*/ */

View File

@ -241,13 +241,13 @@ public class AdHocCommandData extends IQ {
public static class SpecificError implements ExtensionElement { public static class SpecificError implements ExtensionElement {
public static final String namespace = "http://jabber.org/protocol/commands"; public static final String namespace = "http://jabber.org/protocol/commands";
public SpecificErrorCondition condition; public SpecificErrorCondition condition;
public SpecificError(SpecificErrorCondition condition) { public SpecificError(SpecificErrorCondition condition) {
this.condition = condition; this.condition = condition;
} }
public String getElementName() { public String getElementName() {
return condition.toString(); return condition.toString();
} }
@ -258,7 +258,7 @@ public class AdHocCommandData extends IQ {
public SpecificErrorCondition getCondition() { public SpecificErrorCondition getCondition() {
return condition; return condition;
} }
public String toXML() { public String toXML() {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<").append(getElementName()); buf.append("<").append(getElementName());

View File

@ -440,7 +440,7 @@ public class DiscoverInfo extends IQ implements TypedCloneable<DiscoverInfo> {
public int compareTo(DiscoverInfo.Identity other) { public int compareTo(DiscoverInfo.Identity other) {
String otherLang = other.lang == null ? "" : other.lang; String otherLang = other.lang == null ? "" : other.lang;
String thisLang = lang == null ? "" : lang; String thisLang = lang == null ? "" : lang;
// This can be removed once the deprecated constructor is removed. // This can be removed once the deprecated constructor is removed.
String otherType = other.type == null ? "" : other.type; String otherType = other.type == null ? "" : other.type;
String thisType = type == null ? "" : type; String thisType = type == null ? "" : type;

View File

@ -47,7 +47,7 @@ public class JivePropertiesExtension implements ExtensionElement {
public static final String ELEMENT = "properties"; public static final String ELEMENT = "properties";
private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtension.class.getName()); private static final Logger LOGGER = Logger.getLogger(JivePropertiesExtension.class.getName());
private final Map<String, Object> properties; private final Map<String, Object> properties;
public JivePropertiesExtension() { public JivePropertiesExtension() {

View File

@ -149,7 +149,7 @@ public class DiscussionHistory {
if (!isConfigured()) { if (!isConfigured()) {
return null; return null;
} }
MUCInitialPresence.History mucHistory = new MUCInitialPresence.History(); MUCInitialPresence.History mucHistory = new MUCInitialPresence.History();
if (maxChars > -1) { if (maxChars > -1) {
mucHistory.setMaxChars(maxChars); mucHistory.setMaxChars(maxChars);

View File

@ -31,5 +31,5 @@ public interface InvitationRejectionListener {
* @param reason the reason why the invitee declined the invitation. * @param reason the reason why the invitee declined the invitation.
*/ */
public abstract void invitationDeclined(String invitee, String reason); public abstract void invitationDeclined(String invitee, String reason);
} }

View File

@ -115,7 +115,7 @@ public class PEPManager {
PEPPubSub pubSub = new PEPPubSub(item); PEPPubSub pubSub = new PEPPubSub(item);
pubSub.setType(Type.set); pubSub.setType(Type.set);
//pubSub.setFrom(connection.getUser()); //pubSub.setFrom(connection.getUser());
// Send the message that contains the roster // Send the message that contains the roster
connection.sendStanza(pubSub); connection.sendStanza(pubSub);
} }

View File

@ -48,7 +48,7 @@ public class PEPEvent implements ExtensionElement {
this.item = item; this.item = item;
} }
public void addPEPItem(PEPItem item) { public void addPEPItem(PEPItem item) {
this.item = item; this.item = item;
} }

View File

@ -28,11 +28,11 @@ import org.jivesoftware.smack.packet.ExtensionElement;
* @author Jeff Williams * @author Jeff Williams
*/ */
public abstract class PEPItem implements ExtensionElement { public abstract class PEPItem implements ExtensionElement {
String id; String id;
abstract String getNode(); abstract String getNode();
abstract String getItemDetailsXML(); abstract String getItemDetailsXML();
/** /**
* Creates a new PEPItem. * Creates a new PEPItem.
* *
@ -41,7 +41,7 @@ public abstract class PEPItem implements ExtensionElement {
super(); super();
this.id = id; this.id = id;
} }
/** /**
* Returns the XML element name of the extension sub-packet root element. * Returns the XML element name of the extension sub-packet root element.
* Always returns "x" * Always returns "x"

View File

@ -28,7 +28,7 @@ import org.jivesoftware.smack.packet.IQ;
* @author Jeff Williams * @author Jeff Williams
*/ */
public class PEPPubSub extends IQ { public class PEPPubSub extends IQ {
public static final String ELEMENT = "pubsub"; public static final String ELEMENT = "pubsub";
public static final String NAMESPACE = "http://jabber.org/protocol/pubsub"; public static final String NAMESPACE = "http://jabber.org/protocol/pubsub";

View File

@ -44,7 +44,7 @@ public class PrivacyList {
private final String listName; private final String listName;
/** Holds the list of {@link PrivacyItem} */ /** Holds the list of {@link PrivacyItem} */
private final List<PrivacyItem> items; private final List<PrivacyItem> items;
protected PrivacyList(boolean isActiveList, boolean isDefaultList, protected PrivacyList(boolean isActiveList, boolean isDefaultList,
String listName, List<PrivacyItem> privacyItems) { String listName, List<PrivacyItem> privacyItems) {
super(); super();

View File

@ -264,7 +264,7 @@ public class PrivacyListManager extends Manager {
private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { private Privacy getPrivacyWithListNames() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
// The request of the list is an empty privacy message // The request of the list is an empty privacy message
Privacy request = new Privacy(); Privacy request = new Privacy();
// Send the package to the server and get the answer // Send the package to the server and get the answer
return getRequest(request); return getRequest(request);
} }
@ -371,10 +371,10 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setPrivacyList(listName, new ArrayList<PrivacyItem>()); request.setPrivacyList(listName, new ArrayList<PrivacyItem>());
// Send the package to the server and get the answer // Send the package to the server and get the answer
Privacy privacyAnswer = getRequest(request); Privacy privacyAnswer = getRequest(request);
return privacyAnswer.getPrivacyList(listName); return privacyAnswer.getPrivacyList(listName);
} }
@ -427,7 +427,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setActiveName(listName); request.setActiveName(listName);
// Send the package to the server // Send the package to the server
setRequest(request); setRequest(request);
} }
@ -443,7 +443,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setDeclineActiveList(true); request.setDeclineActiveList(true);
// Send the package to the server // Send the package to the server
setRequest(request); setRequest(request);
} }
@ -461,7 +461,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setDefaultName(listName); request.setDefaultName(listName);
// Send the package to the server // Send the package to the server
setRequest(request); setRequest(request);
} }
@ -477,7 +477,7 @@ public class PrivacyListManager extends Manager {
// The request of the list is an privacy message with an empty list // The request of the list is an privacy message with an empty list
Privacy request = new Privacy(); Privacy request = new Privacy();
request.setDeclineDefaultList(true); request.setDeclineDefaultList(true);
// Send the package to the server // Send the package to the server
setRequest(request); setRequest(request);
} }

View File

@ -303,7 +303,7 @@ public class Privacy extends IQ {
buf.append("<default name=\"").escape(getDefaultName()).append("\"/>"); buf.append("<default name=\"").escape(getDefaultName()).append("\"/>");
} }
} }
// Add the list with their privacy items // Add the list with their privacy items
for (Map.Entry<String, List<PrivacyItem>> entry : this.getItemLists().entrySet()) { for (Map.Entry<String, List<PrivacyItem>> entry : this.getItemLists().entrySet()) {
String listName = entry.getKey(); String listName = entry.getKey();
@ -326,5 +326,5 @@ public class Privacy extends IQ {
return buf; return buf;
} }
} }

View File

@ -74,7 +74,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
return privacy; return privacy;
} }
// Parse the list complex type // Parse the list complex type
private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException { private static void parseList(XmlPullParser parser, Privacy privacy) throws XmlPullParserException, IOException, SmackException {
boolean done = false; boolean done = false;
@ -96,7 +96,7 @@ public class PrivacyProvider extends IQProvider<Privacy> {
privacy.setPrivacyList(listName, items); privacy.setPrivacyList(listName, items);
} }
// Parse the list complex type // Parse the list complex type
private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException { private static PrivacyItem parseItem(XmlPullParser parser) throws XmlPullParserException, IOException, SmackException {
// Retrieves the required attributes // Retrieves the required attributes

View File

@ -29,13 +29,13 @@ public enum AccessModel
/** Subscription request must be approved and only subscribers may retrieve items */ /** Subscription request must be approved and only subscribers may retrieve items */
authorize, authorize,
/** Anyone with a presence subscription of both or from may subscribe and retrieve items */ /** Anyone with a presence subscription of both or from may subscribe and retrieve items */
presence, presence,
/** Anyone in the specified roster group(s) may subscribe and retrieve items */ /** Anyone in the specified roster group(s) may subscribe and retrieve items */
roster, roster,
/** Only those on a whitelist may subscribe and retrieve items */ /** Only those on a whitelist may subscribe and retrieve items */
whitelist; whitelist;
} }

View File

@ -33,7 +33,7 @@ public class Affiliation implements ExtensionElement
{ {
protected String node; protected String node;
protected Type type; protected Type type;
public enum Type public enum Type
{ {
member, none, outcast, owner, publisher member, none, outcast, owner, publisher
@ -50,17 +50,17 @@ public class Affiliation implements ExtensionElement
node = nodeId; node = nodeId;
type = affiliation; type = affiliation;
} }
public String getNodeId() public String getNodeId()
{ {
return node; return node;
} }
public Type getType() public Type getType()
{ {
return type; return type;
} }
public String getElementName() public String getElementName()
{ {
return "subscription"; return "subscription";
@ -77,7 +77,7 @@ public class Affiliation implements ExtensionElement
builder.append(getElementName()); builder.append(getElementName());
appendAttribute(builder, "node", node); appendAttribute(builder, "node", node);
appendAttribute(builder, "affiliation", type.toString()); appendAttribute(builder, "affiliation", type.toString());
builder.append("/>"); builder.append("/>");
return builder.toString(); return builder.toString();
} }

View File

@ -28,12 +28,12 @@ import java.util.List;
public class AffiliationsExtension extends NodeExtension public class AffiliationsExtension extends NodeExtension
{ {
protected List<Affiliation> items = Collections.emptyList(); protected List<Affiliation> items = Collections.emptyList();
public AffiliationsExtension() public AffiliationsExtension()
{ {
super(PubSubElementType.AFFILIATIONS); super(PubSubElementType.AFFILIATIONS);
} }
public AffiliationsExtension(List<Affiliation> subList) public AffiliationsExtension(List<Affiliation> subList)
{ {
super(PubSubElementType.AFFILIATIONS); super(PubSubElementType.AFFILIATIONS);
@ -57,12 +57,12 @@ public class AffiliationsExtension extends NodeExtension
StringBuilder builder = new StringBuilder("<"); StringBuilder builder = new StringBuilder("<");
builder.append(getElementName()); builder.append(getElementName());
builder.append(">"); builder.append(">");
for (Affiliation item : items) for (Affiliation item : items)
{ {
builder.append(item.toXML()); builder.append(item.toXML());
} }
builder.append("</"); builder.append("</");
builder.append(getElementName()); builder.append(getElementName());
builder.append(">"); builder.append(">");

View File

@ -26,10 +26,10 @@ public enum ChildrenAssociationPolicy
{ {
/** Anyone may associate leaf nodes with the collection */ /** Anyone may associate leaf nodes with the collection */
all, all,
/** Only collection node owners may associate leaf nodes with the collection. */ /** Only collection node owners may associate leaf nodes with the collection. */
owners, owners,
/** Only those on a whitelist may associate leaf nodes with the collection. */ /** Only those on a whitelist may associate leaf nodes with the collection. */
whitelist; whitelist;
} }

View File

@ -32,18 +32,18 @@ import org.jivesoftware.smack.packet.ExtensionElement;
public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension public class ConfigurationEvent extends NodeExtension implements EmbeddedPacketExtension
{ {
private ConfigureForm form; private ConfigureForm form;
public ConfigurationEvent(String nodeId) public ConfigurationEvent(String nodeId)
{ {
super(PubSubElementType.CONFIGURATION, nodeId); super(PubSubElementType.CONFIGURATION, nodeId);
} }
public ConfigurationEvent(String nodeId, ConfigureForm configForm) public ConfigurationEvent(String nodeId, ConfigureForm configForm)
{ {
super(PubSubElementType.CONFIGURATION, nodeId); super(PubSubElementType.CONFIGURATION, nodeId);
form = configForm; form = configForm;
} }
public ConfigureForm getConfiguration() public ConfigureForm getConfiguration()
{ {
return form; return form;

View File

@ -45,7 +45,7 @@ public class ConfigureForm extends Form
{ {
super(configDataForm); super(configDataForm);
} }
/** /**
* Create a decorator from an existing {@link Form} for node configuration. * Create a decorator from an existing {@link Form} for node configuration.
* Typically, this can be used to create a decorator for an answer form * Typically, this can be used to create a decorator for an answer form
@ -57,7 +57,7 @@ public class ConfigureForm extends Form
{ {
super(nodeConfigForm.getDataFormToSend()); super(nodeConfigForm.getDataFormToSend());
} }
/** /**
* Create a new form for configuring a node. This would typically only be used * Create a new form for configuring a node. This would typically only be used
* when creating and configuring a node at the same time via {@link PubSubManager#createNode(String, Form)}, since * when creating and configuring a node at the same time via {@link PubSubManager#createNode(String, Form)}, since
@ -69,7 +69,7 @@ public class ConfigureForm extends Form
{ {
super(formType); super(formType);
} }
/** /**
* Get the currently configured {@link AccessModel}, null if it is not set. * Get the currently configured {@link AccessModel}, null if it is not set.
* *
@ -78,13 +78,13 @@ public class ConfigureForm extends Form
public AccessModel getAccessModel() public AccessModel getAccessModel()
{ {
String value = getFieldValue(ConfigureNodeFields.access_model); String value = getFieldValue(ConfigureNodeFields.access_model);
if (value == null) if (value == null)
return null; return null;
else else
return AccessModel.valueOf(value); return AccessModel.valueOf(value);
} }
/** /**
* Sets the value of access model. * Sets the value of access model.
* *
@ -118,7 +118,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.body_xslt, FormField.Type.text_single); addField(ConfigureNodeFields.body_xslt, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt); setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt);
} }
/** /**
* The id's of the child nodes associated with a collection node (both leaf and collection). * The id's of the child nodes associated with a collection node (both leaf and collection).
* *
@ -128,7 +128,7 @@ public class ConfigureForm extends Form
{ {
return getFieldValues(ConfigureNodeFields.children); return getFieldValues(ConfigureNodeFields.children);
} }
/** /**
* Set the list of child node ids that are associated with a collection node. * Set the list of child node ids that are associated with a collection node.
* *
@ -139,7 +139,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.children, FormField.Type.text_multi); addField(ConfigureNodeFields.children, FormField.Type.text_multi);
setAnswer(ConfigureNodeFields.children.getFieldName(), children); setAnswer(ConfigureNodeFields.children.getFieldName(), children);
} }
/** /**
* Returns the policy that determines who may associate children with the node. * Returns the policy that determines who may associate children with the node.
* *
@ -148,13 +148,13 @@ public class ConfigureForm extends Form
public ChildrenAssociationPolicy getChildrenAssociationPolicy() public ChildrenAssociationPolicy getChildrenAssociationPolicy()
{ {
String value = getFieldValue(ConfigureNodeFields.children_association_policy); String value = getFieldValue(ConfigureNodeFields.children_association_policy);
if (value == null) if (value == null)
return null; return null;
else else
return ChildrenAssociationPolicy.valueOf(value); return ChildrenAssociationPolicy.valueOf(value);
} }
/** /**
* Sets the policy that determines who may associate children with the node. * Sets the policy that determines who may associate children with the node.
* *
@ -167,7 +167,7 @@ public class ConfigureForm extends Form
values.add(policy.toString()); values.add(policy.toString());
setAnswer(ConfigureNodeFields.children_association_policy.getFieldName(), values); setAnswer(ConfigureNodeFields.children_association_policy.getFieldName(), values);
} }
/** /**
* List of JID's that are on the whitelist that determines who can associate child nodes * List of JID's that are on the whitelist that determines who can associate child nodes
* with the collection node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to * with the collection node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
@ -179,7 +179,7 @@ public class ConfigureForm extends Form
{ {
return getFieldValues(ConfigureNodeFields.children_association_whitelist); return getFieldValues(ConfigureNodeFields.children_association_whitelist);
} }
/** /**
* Set the JID's in the whitelist of users that can associate child nodes with the collection * Set the JID's in the whitelist of users that can associate child nodes with the collection
* node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to * node. This is only relevant if {@link #getChildrenAssociationPolicy()} is set to
@ -269,7 +269,7 @@ public class ConfigureForm extends Form
{ {
return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads)); return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
} }
/** /**
* Sets whether the node will deliver payloads with event notifications. * Sets whether the node will deliver payloads with event notifications.
* *
@ -289,7 +289,7 @@ public class ConfigureForm extends Form
public ItemReply getItemReply() public ItemReply getItemReply()
{ {
String value = getFieldValue(ConfigureNodeFields.itemreply); String value = getFieldValue(ConfigureNodeFields.itemreply);
if (value == null) if (value == null)
return null; return null;
else else
@ -329,7 +329,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.max_items, FormField.Type.text_single); addField(ConfigureNodeFields.max_items, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_items.getFieldName(), max); setAnswer(ConfigureNodeFields.max_items.getFieldName(), max);
} }
/** /**
* Gets the maximum payload size in bytes. * Gets the maximum payload size in bytes.
* *
@ -350,7 +350,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.max_payload_size, FormField.Type.text_single); addField(ConfigureNodeFields.max_payload_size, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max); setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max);
} }
/** /**
* Gets the node type * Gets the node type
* *
@ -359,13 +359,13 @@ public class ConfigureForm extends Form
public NodeType getNodeType() public NodeType getNodeType()
{ {
String value = getFieldValue(ConfigureNodeFields.node_type); String value = getFieldValue(ConfigureNodeFields.node_type);
if (value == null) if (value == null)
return null; return null;
else else
return NodeType.valueOf(value); return NodeType.valueOf(value);
} }
/** /**
* Sets the node type * Sets the node type
* *
@ -386,7 +386,7 @@ public class ConfigureForm extends Form
{ {
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config)); return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config));
} }
/** /**
* Sets whether subscribers should be notified when the configuration changes. * Sets whether subscribers should be notified when the configuration changes.
* *
@ -407,7 +407,7 @@ public class ConfigureForm extends Form
{ {
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete)); return parseBoolean(getFieldValue(ConfigureNodeFields.notify_delete));
} }
/** /**
* Sets whether subscribers should be notified when the node is deleted. * Sets whether subscribers should be notified when the node is deleted.
* *
@ -429,7 +429,7 @@ public class ConfigureForm extends Form
{ {
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract)); return parseBoolean(getFieldValue(ConfigureNodeFields.notify_retract));
} }
/** /**
* Sets whether subscribers should be notified when items are deleted * Sets whether subscribers should be notified when items are deleted
* from the node. * from the node.
@ -441,7 +441,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.notify_retract, FormField.Type.bool); addField(ConfigureNodeFields.notify_retract, FormField.Type.bool);
setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify); setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify);
} }
/** /**
* Determines whether items should be persisted in the node. * Determines whether items should be persisted in the node.
* *
@ -451,7 +451,7 @@ public class ConfigureForm extends Form
{ {
return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items)); return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items));
} }
/** /**
* Sets whether items should be persisted in the node. * Sets whether items should be persisted in the node.
* *
@ -472,7 +472,7 @@ public class ConfigureForm extends Form
{ {
return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery)); return parseBoolean(getFieldValue(ConfigureNodeFields.presence_based_delivery));
} }
/** /**
* Sets whether to deliver notifications to available users only. * Sets whether to deliver notifications to available users only.
* *
@ -492,7 +492,7 @@ public class ConfigureForm extends Form
public PublishModel getPublishModel() public PublishModel getPublishModel()
{ {
String value = getFieldValue(ConfigureNodeFields.publish_model); String value = getFieldValue(ConfigureNodeFields.publish_model);
if (value == null) if (value == null)
return null; return null;
else else
@ -509,7 +509,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.publish_model, FormField.Type.list_single); addField(ConfigureNodeFields.publish_model, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString())); setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString()));
} }
/** /**
* List of the multi user chat rooms that are specified as reply rooms. * List of the multi user chat rooms that are specified as reply rooms.
* *
@ -519,7 +519,7 @@ public class ConfigureForm extends Form
{ {
return getFieldValues(ConfigureNodeFields.replyroom); return getFieldValues(ConfigureNodeFields.replyroom);
} }
/** /**
* Sets the multi user chat rooms that are specified as reply rooms. * Sets the multi user chat rooms that are specified as reply rooms.
* *
@ -530,7 +530,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.replyroom, FormField.Type.list_multi); addField(ConfigureNodeFields.replyroom, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms); setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms);
} }
/** /**
* Gets the specific JID's for reply to. * Gets the specific JID's for reply to.
* *
@ -540,7 +540,7 @@ public class ConfigureForm extends Form
{ {
return getFieldValues(ConfigureNodeFields.replyto); return getFieldValues(ConfigureNodeFields.replyto);
} }
/** /**
* Sets the specific JID's for reply to. * Sets the specific JID's for reply to.
* *
@ -551,7 +551,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.replyto, FormField.Type.list_multi); addField(ConfigureNodeFields.replyto, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos); setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos);
} }
/** /**
* Gets the roster groups that are allowed to subscribe and retrieve items. * Gets the roster groups that are allowed to subscribe and retrieve items.
* *
@ -561,7 +561,7 @@ public class ConfigureForm extends Form
{ {
return getFieldValues(ConfigureNodeFields.roster_groups_allowed); return getFieldValues(ConfigureNodeFields.roster_groups_allowed);
} }
/** /**
* Sets the roster groups that are allowed to subscribe and retrieve items. * Sets the roster groups that are allowed to subscribe and retrieve items.
* *
@ -572,7 +572,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.roster_groups_allowed, FormField.Type.list_multi); addField(ConfigureNodeFields.roster_groups_allowed, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups); setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups);
} }
/** /**
* Determines if subscriptions are allowed. * Determines if subscriptions are allowed.
* *
@ -604,7 +604,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.subscribe, FormField.Type.bool); addField(ConfigureNodeFields.subscribe, FormField.Type.bool);
setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe); setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe);
} }
/** /**
* Gets the human readable node title. * Gets the human readable node title.
* *
@ -625,7 +625,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.title, FormField.Type.text_single); addField(ConfigureNodeFields.title, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.title.getFieldName(), title); setAnswer(ConfigureNodeFields.title.getFieldName(), title);
} }
/** /**
* The type of node data, usually specified by the namespace of the payload (if any). * The type of node data, usually specified by the namespace of the payload (if any).
* *
@ -646,27 +646,27 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.type, FormField.Type.text_single); addField(ConfigureNodeFields.type, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.type.getFieldName(), type); setAnswer(ConfigureNodeFields.type.getFieldName(), type);
} }
@Override @Override
public String toString() public String toString()
{ {
StringBuilder result = new StringBuilder(getClass().getName() + " Content ["); StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
for (FormField formField : getFields()) for (FormField formField : getFields())
{ {
result.append('('); result.append('(');
result.append(formField.getVariable()); result.append(formField.getVariable());
result.append(':'); result.append(':');
StringBuilder valuesBuilder = new StringBuilder(); StringBuilder valuesBuilder = new StringBuilder();
for (String value : formField.getValues()) for (String value : formField.getValues())
{ {
if (valuesBuilder.length() > 0) if (valuesBuilder.length() > 0)
result.append(','); result.append(',');
valuesBuilder.append(value); valuesBuilder.append(value);
} }
if (valuesBuilder.length() == 0) if (valuesBuilder.length() == 0)
valuesBuilder.append("NOT SET"); valuesBuilder.append("NOT SET");
result.append(valuesBuilder); result.append(valuesBuilder);
@ -684,21 +684,21 @@ public class ConfigureForm extends Form
private String getFieldValue(ConfigureNodeFields field) private String getFieldValue(ConfigureNodeFields field)
{ {
FormField formField = getField(field.getFieldName()); FormField formField = getField(field.getFieldName());
return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0); return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0);
} }
private List<String> getFieldValues(ConfigureNodeFields field) private List<String> getFieldValues(ConfigureNodeFields field)
{ {
FormField formField = getField(field.getFieldName()); FormField formField = getField(field.getFieldName());
return formField.getValues(); return formField.getValues();
} }
private void addField(ConfigureNodeFields nodeField, FormField.Type type) private void addField(ConfigureNodeFields nodeField, FormField.Type type)
{ {
String fieldName = nodeField.getFieldName(); String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null) if (getField(fieldName) == null)
{ {
FormField field = new FormField(fieldName); FormField field = new FormField(fieldName);

View File

@ -44,7 +44,7 @@ public enum ConfigureNodeFields
* <p><b>Value: {@link URL}</b></p> * <p><b>Value: {@link URL}</b></p>
*/ */
body_xslt, body_xslt,
/** /**
* The collection with which a node is affiliated * The collection with which a node is affiliated
* *
@ -68,21 +68,21 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p> * <p><b>Value: boolean</b></p>
*/ */
deliver_payloads, deliver_payloads,
/** /**
* Whether owners or publisher should receive replies to items * Whether owners or publisher should receive replies to items
* *
* <p><b>Value: {@link ItemReply}</b></p> * <p><b>Value: {@link ItemReply}</b></p>
*/ */
itemreply, itemreply,
/** /**
* Who may associate leaf nodes with a collection * Who may associate leaf nodes with a collection
* *
* <p><b>Value: {@link ChildrenAssociationPolicy}</b></p> * <p><b>Value: {@link ChildrenAssociationPolicy}</b></p>
*/ */
children_association_policy, children_association_policy,
/** /**
* The list of JIDs that may associate leaf nodes with a * The list of JIDs that may associate leaf nodes with a
* collection * collection
@ -90,14 +90,14 @@ public enum ConfigureNodeFields
* <p><b>Value: List of JIDs as Strings</b></p> * <p><b>Value: List of JIDs as Strings</b></p>
*/ */
children_association_whitelist, children_association_whitelist,
/** /**
* The child nodes (leaf or collection) associated with a collection * The child nodes (leaf or collection) associated with a collection
* *
* <p><b>Value: List of Strings</b></p> * <p><b>Value: List of Strings</b></p>
*/ */
children, children,
/** /**
* The maximum number of child nodes that can be associated with a * The maximum number of child nodes that can be associated with a
* collection * collection
@ -105,35 +105,35 @@ public enum ConfigureNodeFields
* <p><b>Value: int</b></p> * <p><b>Value: int</b></p>
*/ */
children_max, children_max,
/** /**
* The maximum number of items to persist * The maximum number of items to persist
* *
* <p><b>Value: int</b></p> * <p><b>Value: int</b></p>
*/ */
max_items, max_items,
/** /**
* The maximum payload size in bytes * The maximum payload size in bytes
* *
* <p><b>Value: int</b></p> * <p><b>Value: int</b></p>
*/ */
max_payload_size, max_payload_size,
/** /**
* Whether the node is a leaf (default) or collection * Whether the node is a leaf (default) or collection
* *
* <p><b>Value: {@link NodeType}</b></p> * <p><b>Value: {@link NodeType}</b></p>
*/ */
node_type, node_type,
/** /**
* Whether to notify subscribers when the node configuration changes * Whether to notify subscribers when the node configuration changes
* *
* <p><b>Value: boolean</b></p> * <p><b>Value: boolean</b></p>
*/ */
notify_config, notify_config,
/** /**
* Whether to notify subscribers when the node is deleted * Whether to notify subscribers when the node is deleted
* *
@ -147,7 +147,7 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p> * <p><b>Value: boolean</b></p>
*/ */
notify_retract, notify_retract,
/** /**
* Whether to persist items to storage. This is required to have multiple * Whether to persist items to storage. This is required to have multiple
* items in the node. * items in the node.
@ -155,7 +155,7 @@ public enum ConfigureNodeFields
* <p><b>Value: boolean</b></p> * <p><b>Value: boolean</b></p>
*/ */
persist_items, persist_items,
/** /**
* Whether to deliver notifications to available users only * Whether to deliver notifications to available users only
* *
@ -169,42 +169,42 @@ public enum ConfigureNodeFields
* <p><b>Value: {@link PublishModel}</b></p> * <p><b>Value: {@link PublishModel}</b></p>
*/ */
publish_model, publish_model,
/** /**
* The specific multi-user chat rooms to specify for replyroom * The specific multi-user chat rooms to specify for replyroom
* *
* <p><b>Value: List of JIDs as Strings</b></p> * <p><b>Value: List of JIDs as Strings</b></p>
*/ */
replyroom, replyroom,
/** /**
* The specific JID(s) to specify for replyto * The specific JID(s) to specify for replyto
* *
* <p><b>Value: List of JIDs as Strings</b></p> * <p><b>Value: List of JIDs as Strings</b></p>
*/ */
replyto, replyto,
/** /**
* The roster group(s) allowed to subscribe and retrieve items * The roster group(s) allowed to subscribe and retrieve items
* *
* <p><b>Value: List of strings</b></p> * <p><b>Value: List of strings</b></p>
*/ */
roster_groups_allowed, roster_groups_allowed,
/** /**
* Whether to allow subscriptions * Whether to allow subscriptions
* *
* <p><b>Value: boolean</b></p> * <p><b>Value: boolean</b></p>
*/ */
subscribe, subscribe,
/** /**
* A friendly name for the node * A friendly name for the node
* *
* <p><b>Value: String</b></p> * <p><b>Value: String</b></p>
*/ */
title, title,
/** /**
* The type of node data, ussually specified by the namespace * The type of node data, ussually specified by the namespace
* of the payload(if any);MAY be a list-single rather than a * of the payload(if any);MAY be a list-single rather than a
@ -213,7 +213,7 @@ public enum ConfigureNodeFields
* <p><b>Value: String</b></p> * <p><b>Value: String</b></p>
*/ */
type; type;
public String getFieldName() public String getFieldName()
{ {
return "pubsub#" + toString(); return "pubsub#" + toString();

View File

@ -34,13 +34,13 @@ public class EventElement implements EmbeddedPacketExtension
{ {
private EventElementType type; private EventElementType type;
private NodeExtension ext; private NodeExtension ext;
public EventElement(EventElementType eventType, NodeExtension eventExt) public EventElement(EventElementType eventType, NodeExtension eventExt)
{ {
type = eventType; type = eventType;
ext = eventExt; ext = eventExt;
} }
public EventElementType getEventType() public EventElementType getEventType()
{ {
return type; return type;

View File

@ -29,16 +29,16 @@ public enum EventElementType
/** A node has had its configuration changed */ /** A node has had its configuration changed */
configuration, configuration,
/** A node has been deleted */ /** A node has been deleted */
delete, delete,
/** Items have been published to a node */ /** Items have been published to a node */
items, items,
/** All items have been purged from a node */ /** All items have been purged from a node */
purge, purge,
/** A node has been subscribed to */ /** A node has been subscribed to */
subscription subscription
} }

View File

@ -29,7 +29,7 @@ import org.jivesoftware.smackx.xdata.Form;
public class FormNode extends NodeExtension public class FormNode extends NodeExtension
{ {
private Form configForm; private Form configForm;
/** /**
* Create a {@link FormNode} which contains the specified form. * Create a {@link FormNode} which contains the specified form.
* *
@ -44,7 +44,7 @@ public class FormNode extends NodeExtension
throw new IllegalArgumentException("Submit form cannot be null"); throw new IllegalArgumentException("Submit form cannot be null");
configForm = submitForm; configForm = submitForm;
} }
/** /**
* Create a {@link FormNode} which contains the specified form, which is * Create a {@link FormNode} which contains the specified form, which is
* associated with the specified node. * associated with the specified node.
@ -61,7 +61,7 @@ public class FormNode extends NodeExtension
throw new IllegalArgumentException("Submit form cannot be null"); throw new IllegalArgumentException("Submit form cannot be null");
configForm = submitForm; configForm = submitForm;
} }
/** /**
* Get the Form that is to be sent, or was retrieved from the server. * Get the Form that is to be sent, or was retrieved from the server.
* *
@ -71,7 +71,7 @@ public class FormNode extends NodeExtension
{ {
return configForm; return configForm;
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML()
{ {
@ -83,7 +83,7 @@ public class FormNode extends NodeExtension
{ {
StringBuilder builder = new StringBuilder("<"); StringBuilder builder = new StringBuilder("<");
builder.append(getElementName()); builder.append(getElementName());
if (getNode() != null) if (getNode() != null)
{ {
builder.append(" node='"); builder.append(" node='");

View File

@ -29,16 +29,16 @@ public enum FormNodeType
{ {
/** Form for configuring an existing node */ /** Form for configuring an existing node */
CONFIGURE_OWNER, CONFIGURE_OWNER,
/** Form for configuring a node during creation */ /** Form for configuring a node during creation */
CONFIGURE, CONFIGURE,
/** Form for configuring subscription options */ /** Form for configuring subscription options */
OPTIONS, OPTIONS,
/** Form which represents the default node configuration options */ /** Form which represents the default node configuration options */
DEFAULT; DEFAULT;
public PubSubElementType getNodeElement() public PubSubElementType getNodeElement()
{ {
return PubSubElementType.valueOf(toString()); return PubSubElementType.valueOf(toString());

View File

@ -27,12 +27,12 @@ public class GetItemsRequest extends NodeExtension
{ {
protected final String subId; protected final String subId;
protected final int maxItems; protected final int maxItems;
public GetItemsRequest(String nodeId) public GetItemsRequest(String nodeId)
{ {
this(nodeId, null, -1); this(nodeId, null, -1);
} }
public GetItemsRequest(String nodeId, String subscriptionId) public GetItemsRequest(String nodeId, String subscriptionId)
{ {
this(nodeId, subscriptionId, -1); this(nodeId, subscriptionId, -1);

View File

@ -45,7 +45,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class Item extends NodeExtension public class Item extends NodeExtension
{ {
private String id; private String id;
/** /**
* Create an empty <tt>Item</tt> with no id. This is a valid item for nodes which are configured * Create an empty <tt>Item</tt> with no id. This is a valid item for nodes which are configured
* so that {@link ConfigureForm#isDeliverPayloads()} is false. In most cases an id will be generated by the server. * so that {@link ConfigureForm#isDeliverPayloads()} is false. In most cases an id will be generated by the server.
@ -57,7 +57,7 @@ public class Item extends NodeExtension
{ {
super(PubSubElementType.ITEM); super(PubSubElementType.ITEM);
} }
/** /**
* Create an <tt>Item</tt> with an id but no payload. This is a valid item for nodes which are configured * Create an <tt>Item</tt> with an id but no payload. This is a valid item for nodes which are configured
* so that {@link ConfigureForm#isDeliverPayloads()} is false. * so that {@link ConfigureForm#isDeliverPayloads()} is false.
@ -88,7 +88,7 @@ public class Item extends NodeExtension
super(PubSubElementType.ITEM_EVENT, nodeId); super(PubSubElementType.ITEM_EVENT, nodeId);
id = itemId; id = itemId;
} }
/** /**
* Get the item id. Unique to the node it is associated with. * Get the item id. Unique to the node it is associated with.
* *
@ -98,7 +98,7 @@ public class Item extends NodeExtension
{ {
return id; return id;
} }
@Override @Override
public String getNamespace() public String getNamespace()
{ {
@ -109,14 +109,14 @@ public class Item extends NodeExtension
public String toXML() public String toXML()
{ {
StringBuilder builder = new StringBuilder("<item"); StringBuilder builder = new StringBuilder("<item");
if (id != null) if (id != null)
{ {
builder.append(" id='"); builder.append(" id='");
builder.append(id); builder.append(id);
builder.append("'"); builder.append("'");
} }
if (getNode() != null) { if (getNode() != null) {
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());

View File

@ -27,7 +27,7 @@ import java.util.List;
public class ItemDeleteEvent extends SubscriptionEvent public class ItemDeleteEvent extends SubscriptionEvent
{ {
private List<String> itemIds = Collections.emptyList(); private List<String> itemIds = Collections.emptyList();
/** /**
* Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied * Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied
* items (by id) have been deleted, and that the event matches the listed * items (by id) have been deleted, and that the event matches the listed
@ -41,12 +41,12 @@ public class ItemDeleteEvent extends SubscriptionEvent
public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds) public ItemDeleteEvent(String nodeId, List<String> deletedItemIds, List<String> subscriptionIds)
{ {
super(nodeId, subscriptionIds); super(nodeId, subscriptionIds);
if (deletedItemIds == null) if (deletedItemIds == null)
throw new IllegalArgumentException("deletedItemIds cannot be null"); throw new IllegalArgumentException("deletedItemIds cannot be null");
itemIds = deletedItemIds; itemIds = deletedItemIds;
} }
/** /**
* Get the item id's of the items that have been deleted. * Get the item id's of the items that have been deleted.
* *
@ -56,7 +56,7 @@ public class ItemDeleteEvent extends SubscriptionEvent
{ {
return Collections.unmodifiableList(itemIds); return Collections.unmodifiableList(itemIds);
} }
@Override @Override
public String toString() public String toString()
{ {

View File

@ -29,7 +29,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{ {
private List<T> items; private List<T> items;
private Date originalDate; private Date originalDate;
/** /**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list * Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published. * of {@link Item} that were published.
@ -42,7 +42,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
super(nodeId); super(nodeId);
items = eventItems; items = eventItems;
} }
/** /**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list * Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published. The list of subscription ids * of {@link Item} that were published. The list of subscription ids
@ -58,7 +58,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
super(nodeId, subscriptionIds); super(nodeId, subscriptionIds);
items = eventItems; items = eventItems;
} }
/** /**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list * Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published in the past. The published * of {@link Item} that were published in the past. The published
@ -74,11 +74,11 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{ {
super(nodeId, subscriptionIds); super(nodeId, subscriptionIds);
items = eventItems; items = eventItems;
if (publishedDate != null) if (publishedDate != null)
originalDate = publishedDate; originalDate = publishedDate;
} }
/** /**
* Get the list of {@link Item} that were published. * Get the list of {@link Item} that were published.
* *
@ -88,7 +88,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{ {
return Collections.unmodifiableList(items); return Collections.unmodifiableList(items);
} }
/** /**
* Indicates whether this event was delayed. That is, the items * Indicates whether this event was delayed. That is, the items
* were published to the node at some time in the past. This will * were published to the node at some time in the past. This will
@ -103,7 +103,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{ {
return (originalDate != null); return (originalDate != null);
} }
/** /**
* Gets the original date the items were published. This is only * Gets the original date the items were published. This is only
* valid if {@link #isDelayed()} is true. * valid if {@link #isDelayed()} is true.
@ -120,5 +120,5 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " + return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " +
(isDelayed() ? originalDate.toString() : "false") + ']'; (isDelayed() ? originalDate.toString() : "false") + ']';
} }
} }

View File

@ -26,7 +26,7 @@ public enum ItemReply
{ {
/** The node owner */ /** The node owner */
owner, owner,
/** The item publisher */ /** The item publisher */
publisher; publisher;
} }

View File

@ -42,19 +42,19 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{ {
/** An items element, which has an optional <b>max_items</b> attribute when requesting items */ /** An items element, which has an optional <b>max_items</b> attribute when requesting items */
items(PubSubElementType.ITEMS, "max_items"), items(PubSubElementType.ITEMS, "max_items"),
/** A retract element, which has an optional <b>notify</b> attribute when publishing deletions */ /** A retract element, which has an optional <b>notify</b> attribute when publishing deletions */
retract(PubSubElementType.RETRACT, "notify"); retract(PubSubElementType.RETRACT, "notify");
private PubSubElementType elem; private PubSubElementType elem;
private String att; private String att;
private ItemsElementType(PubSubElementType nodeElement, String attribute) private ItemsElementType(PubSubElementType nodeElement, String attribute)
{ {
elem = nodeElement; elem = nodeElement;
att = attribute; att = attribute;
} }
public PubSubElementType getNodeElement() public PubSubElementType getNodeElement()
{ {
return elem; return elem;
@ -89,7 +89,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
type = itemsType; type = itemsType;
this.items = items; this.items = items;
} }
/** /**
* Construct an instance with a list representing items that have been published or deleted. * Construct an instance with a list representing items that have been published or deleted.
* *
@ -113,7 +113,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
this.items = items; this.items = items;
this.notify = notify; this.notify = notify;
} }
/** /**
* Get the type of element * Get the type of element
* *
@ -123,13 +123,13 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{ {
return type; return type;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<ExtensionElement> getExtensions() public List<ExtensionElement> getExtensions()
{ {
return (List<ExtensionElement>)getItems(); return (List<ExtensionElement>)getItems();
} }
/** /**
* Gets the items related to the type of request or event. * Gets the items related to the type of request or event.
* *
@ -149,7 +149,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{ {
return notify; return notify;
} }
@Override @Override
public CharSequence toXML() public CharSequence toXML()
{ {
@ -163,7 +163,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(getElementName()); builder.append(getElementName());
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());
if (notify != null) if (notify != null)
{ {
builder.append("' "); builder.append("' ");
@ -180,7 +180,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(item.toXML()); builder.append(item.toXML());
} }
} }
builder.append("</"); builder.append("</");
builder.append(getElementName()); builder.append(getElementName());
builder.append(">"); builder.append(">");

View File

@ -43,7 +43,7 @@ public class LeafNode extends Node
{ {
super(connection, nodeName); super(connection, nodeName);
} }
/** /**
* Get information on the items in the node in standard * Get information on the items in the node in standard
* {@link DiscoverItems} format. * {@link DiscoverItems} format.
@ -75,7 +75,7 @@ public class LeafNode extends Node
{ {
return getItems((List<ExtensionElement>) null, (List<ExtensionElement>) null); return getItems((List<ExtensionElement>) null, (List<ExtensionElement>) null);
} }
/** /**
* Get the current items stored in the node based * Get the current items stored in the node based
* on the subscription associated with the provided * on the subscription associated with the provided
@ -113,7 +113,7 @@ public class LeafNode extends Node
public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> List<T> getItems(Collection<String> ids) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{ {
List<Item> itemList = new ArrayList<Item>(ids.size()); List<Item> itemList = new ArrayList<Item>(ids.size());
for (String id : ids) for (String id : ids)
{ {
itemList.add(new Item(id)); itemList.add(new Item(id));
@ -138,7 +138,7 @@ public class LeafNode extends Node
PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems)); PubSub request = createPubsubPacket(Type.get, new GetItemsRequest(getId(), maxItems));
return getItems(request); return getItems(request);
} }
/** /**
* Get items persisted on the node, limited to the specified number * Get items persisted on the node, limited to the specified number
* based on the subscription associated with the provided subscriptionId. * based on the subscription associated with the provided subscriptionId.
@ -218,10 +218,10 @@ public class LeafNode extends Node
public void publish() throws NotConnectedException, InterruptedException public void publish() throws NotConnectedException, InterruptedException
{ {
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId())); PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
con.sendStanza(packet); con.sendStanza(packet);
} }
/** /**
* Publishes an event to the node. This is a simple item * Publishes an event to the node. This is a simple item
* with no payload. * with no payload.
@ -265,7 +265,7 @@ public class LeafNode extends Node
public <T extends Item> void publish(Collection<T> items) throws NotConnectedException, InterruptedException public <T extends Item> void publish(Collection<T> items) throws NotConnectedException, InterruptedException
{ {
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items)); PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
con.sendStanza(packet); con.sendStanza(packet);
} }
@ -289,10 +289,10 @@ public class LeafNode extends Node
public void send() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public void send() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{ {
PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId())); PubSub packet = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PUBLISH, getId()));
con.createPacketCollectorAndSend(packet).nextResultOrThrow(); con.createPacketCollectorAndSend(packet).nextResultOrThrow();
} }
/** /**
* Publishes an event to the node. This can be either a simple item * Publishes an event to the node. This can be either a simple item
* with no payload, or one with it. This is determined by the Node * with no payload, or one with it. This is determined by the Node
@ -324,7 +324,7 @@ public class LeafNode extends Node
items.add((item == null ? (T)new Item() : item)); items.add((item == null ? (T)new Item() : item));
send(items); send(items);
} }
/** /**
* Publishes multiple events to the node. Same rules apply as in {@link #send(Item)}. * Publishes multiple events to the node. Same rules apply as in {@link #send(Item)}.
* *
@ -346,10 +346,10 @@ public class LeafNode extends Node
public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public <T extends Item> void send(Collection<T> items) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{ {
PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items)); PubSub packet = createPubsubPacket(Type.set, new PublishItem<T>(getId(), items));
con.createPacketCollectorAndSend(packet).nextResultOrThrow(); con.createPacketCollectorAndSend(packet).nextResultOrThrow();
} }
/** /**
* Purges the node of all items. * Purges the node of all items.
* *
@ -363,10 +363,10 @@ public class LeafNode extends Node
public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public void deleteAllItems() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{ {
PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace()); PubSub request = createPubsubPacket(Type.set, new NodeExtension(PubSubElementType.PURGE_OWNER, getId()), PubSubElementType.PURGE_OWNER.getNamespace());
con.createPacketCollectorAndSend(request).nextResultOrThrow(); con.createPacketCollectorAndSend(request).nextResultOrThrow();
} }
/** /**
* Delete the item with the specified id from the node. * Delete the item with the specified id from the node.
* *
@ -382,7 +382,7 @@ public class LeafNode extends Node
items.add(itemId); items.add(itemId);
deleteItem(items); deleteItem(items);
} }
/** /**
* Delete the items with the specified id's from the node. * Delete the items with the specified id's from the node.
* *
@ -395,7 +395,7 @@ public class LeafNode extends Node
public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException public void deleteItem(Collection<String> itemIds) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
{ {
List<Item> items = new ArrayList<Item>(itemIds.size()); List<Item> items = new ArrayList<Item>(itemIds.size());
for (String id : itemIds) for (String id : itemIds)
{ {
items.add(new Item(id)); items.add(new Item(id));

View File

@ -50,11 +50,11 @@ abstract public class Node
protected XMPPConnection con; protected XMPPConnection con;
protected String id; protected String id;
protected Jid to; protected Jid to;
protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, StanzaListener>(); protected ConcurrentHashMap<ItemEventListener<Item>, StanzaListener> itemEventToListenerMap = new ConcurrentHashMap<ItemEventListener<Item>, StanzaListener>();
protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, StanzaListener>(); protected ConcurrentHashMap<ItemDeleteListener, StanzaListener> itemDeleteToListenerMap = new ConcurrentHashMap<ItemDeleteListener, StanzaListener>();
protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, StanzaListener>(); protected ConcurrentHashMap<NodeConfigListener, StanzaListener> configEventToListenerMap = new ConcurrentHashMap<NodeConfigListener, StanzaListener>();
/** /**
* Construct a node associated to the supplied connection with the specified * Construct a node associated to the supplied connection with the specified
* node id. * node id.
@ -105,7 +105,7 @@ abstract public class Node
Stanza reply = sendPubsubPacket(pubSub); Stanza reply = sendPubsubPacket(pubSub);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER); return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
} }
/** /**
* Update the configuration with the contents of the new {@link Form} * Update the configuration with the contents of the new {@link Form}
* *
@ -121,7 +121,7 @@ abstract public class Node
getId(), submitForm), PubSubNamespace.OWNER); getId(), submitForm), PubSubNamespace.OWNER);
con.createPacketCollectorAndSend(packet).nextResultOrThrow(); con.createPacketCollectorAndSend(packet).nextResultOrThrow();
} }
/** /**
* Discover node information in standard {@link DiscoverInfo} format. * Discover node information in standard {@link DiscoverInfo} format.
* *
@ -138,7 +138,7 @@ abstract public class Node
info.setNode(getId()); info.setNode(getId());
return (DiscoverInfo) con.createPacketCollectorAndSend(info).nextResultOrThrow(); return (DiscoverInfo) con.createPacketCollectorAndSend(info).nextResultOrThrow();
} }
/** /**
* Get the subscriptions currently associated with this node. * Get the subscriptions currently associated with this node.
* *
@ -308,7 +308,7 @@ abstract public class Node
PubSub reply = sendPubsubPacket(pubSub); PubSub reply = sendPubsubPacket(pubSub);
return reply.getExtension(PubSubElementType.SUBSCRIPTION); return reply.getExtension(PubSubElementType.SUBSCRIPTION);
} }
/** /**
* The user subscribes to the node using the supplied jid and subscription * The user subscribes to the node using the supplied jid and subscription
* options. The bare jid portion of this one must match the jid for the * options. The bare jid portion of this one must match the jid for the
@ -352,7 +352,7 @@ abstract public class Node
{ {
unsubscribe(jid, null); unsubscribe(jid, null);
} }
/** /**
* Remove the specific subscription related to the specified JID. * Remove the specific subscription related to the specified JID.
* *
@ -427,7 +427,7 @@ abstract public class Node
public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener) public void removeItemEventListener(@SuppressWarnings("rawtypes") ItemEventListener listener)
{ {
StanzaListener conListener = itemEventToListenerMap.remove(listener); StanzaListener conListener = itemEventToListenerMap.remove(listener);
if (conListener != null) if (conListener != null)
con.removeSyncStanzaListener(conListener); con.removeSyncStanzaListener(conListener);
} }
@ -453,11 +453,11 @@ abstract public class Node
public void removeConfigurationListener(NodeConfigListener listener) public void removeConfigurationListener(NodeConfigListener listener)
{ {
StanzaListener conListener = configEventToListenerMap .remove(listener); StanzaListener conListener = configEventToListenerMap .remove(listener);
if (conListener != null) if (conListener != null)
con.removeSyncStanzaListener(conListener); con.removeSyncStanzaListener(conListener);
} }
/** /**
* Register an listener for item delete events. This listener * Register an listener for item delete events. This listener
* gets called whenever an item is deleted from the node. * gets called whenever an item is deleted from the node.
@ -470,7 +470,7 @@ abstract public class Node
itemDeleteToListenerMap.put(listener, delListener); itemDeleteToListenerMap.put(listener, delListener);
EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract"); EventContentFilter deleteItem = new EventContentFilter(EventElementType.items.toString(), "retract");
EventContentFilter purge = new EventContentFilter(EventElementType.purge.toString()); EventContentFilter purge = new EventContentFilter(EventElementType.purge.toString());
con.addSyncStanzaListener(delListener, new OrFilter(deleteItem, purge)); con.addSyncStanzaListener(delListener, new OrFilter(deleteItem, purge));
} }
@ -482,7 +482,7 @@ abstract public class Node
public void removeItemDeleteListener(ItemDeleteListener listener) public void removeItemDeleteListener(ItemDeleteListener listener)
{ {
StanzaListener conListener = itemDeleteToListenerMap .remove(listener); StanzaListener conListener = itemDeleteToListenerMap .remove(listener);
if (conListener != null) if (conListener != null)
con.removeSyncStanzaListener(conListener); con.removeSyncStanzaListener(conListener);
} }
@ -492,12 +492,12 @@ abstract public class Node
{ {
return super.toString() + " " + getClass().getName() + " id: " + id; return super.toString() + " " + getClass().getName() + " id: " + id;
} }
protected PubSub createPubsubPacket(Type type, ExtensionElement ext) protected PubSub createPubsubPacket(Type type, ExtensionElement ext)
{ {
return createPubsubPacket(type, ext, null); return createPubsubPacket(type, ext, null);
} }
protected PubSub createPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns) protected PubSub createPubsubPacket(Type type, ExtensionElement ext, PubSubNamespace ns)
{ {
return PubSub.createPubsubPacket(to, type, ext, ns); return PubSub.createPubsubPacket(to, type, ext, ns);
@ -513,11 +513,11 @@ abstract public class Node
{ {
HeadersExtension headers = (HeadersExtension)packet.getExtension("headers", "http://jabber.org/protocol/shim"); HeadersExtension headers = (HeadersExtension)packet.getExtension("headers", "http://jabber.org/protocol/shim");
List<String> values = null; List<String> values = null;
if (headers != null) if (headers != null)
{ {
values = new ArrayList<String>(headers.getHeaders().size()); values = new ArrayList<String>(headers.getHeaders().size());
for (Header header : headers.getHeaders()) for (Header header : headers.getHeaders())
{ {
values.add(header.getValue()); values.add(header.getValue());
@ -541,7 +541,7 @@ abstract public class Node
{ {
listener = eventListener; listener = eventListener;
} }
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({ "rawtypes", "unchecked" })
public void processPacket(Stanza packet) public void processPacket(Stanza packet)
{ {
@ -566,13 +566,13 @@ abstract public class Node
{ {
listener = eventListener; listener = eventListener;
} }
public void processPacket(Stanza packet) public void processPacket(Stanza packet)
{ {
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
List<ExtensionElement> extList = event.getExtensions(); List<ExtensionElement> extList = event.getExtensions();
if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName())) if (extList.get(0).getElementName().equals(PubSubElementType.PURGE_EVENT.getElementName()))
{ {
listener.handlePurge(); listener.handlePurge();
@ -594,7 +594,7 @@ abstract public class Node
} }
} }
} }
/** /**
* This class translates low level node configuration events into api level objects for * This class translates low level node configuration events into api level objects for
* user consumption. * user consumption.
@ -609,7 +609,7 @@ abstract public class Node
{ {
listener = eventListener; listener = eventListener;
} }
public void processPacket(Stanza packet) public void processPacket(Stanza packet)
{ {
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
@ -629,7 +629,7 @@ abstract public class Node
{ {
private String firstElement; private String firstElement;
private String secondElement; private String secondElement;
EventContentFilter(String elementName) EventContentFilter(String elementName)
{ {
firstElement = elementName; firstElement = elementName;
@ -647,27 +647,27 @@ abstract public class Node
return false; return false;
EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns()); EventElement event = (EventElement)packet.getExtension("event", PubSubNamespace.EVENT.getXmlns());
if (event == null) if (event == null)
return false; return false;
NodeExtension embedEvent = event.getEvent(); NodeExtension embedEvent = event.getEvent();
if (embedEvent == null) if (embedEvent == null)
return false; return false;
if (embedEvent.getElementName().equals(firstElement)) if (embedEvent.getElementName().equals(firstElement))
{ {
if (!embedEvent.getNode().equals(getId())) if (!embedEvent.getNode().equals(getId()))
return false; return false;
if (secondElement == null) if (secondElement == null)
return true; return true;
if (embedEvent instanceof EmbeddedPacketExtension) if (embedEvent instanceof EmbeddedPacketExtension)
{ {
List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions(); List<ExtensionElement> secondLevelList = ((EmbeddedPacketExtension)embedEvent).getExtensions();
if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement)) if (secondLevelList.size() > 0 && secondLevelList.get(0).getElementName().equals(secondElement))
return true; return true;
} }

View File

@ -19,12 +19,12 @@ package org.jivesoftware.smackx.pubsub;
abstract public class NodeEvent abstract public class NodeEvent
{ {
private String nodeId; private String nodeId;
protected NodeEvent(String id) protected NodeEvent(String id)
{ {
nodeId = id; nodeId = id;
} }
public String getNodeId() public String getNodeId()
{ {
return nodeId; return nodeId;

View File

@ -30,7 +30,7 @@ public class NodeExtension implements ExtensionElement
{ {
private final PubSubElementType element; private final PubSubElementType element;
private final String node; private final String node;
/** /**
* Constructs a <tt>NodeExtension</tt> with an element name specified * Constructs a <tt>NodeExtension</tt> with an element name specified
* by {@link PubSubElementType} and the specified node id. * by {@link PubSubElementType} and the specified node id.
@ -64,7 +64,7 @@ public class NodeExtension implements ExtensionElement
{ {
return node; return node;
} }
public String getElementName() public String getElementName()
{ {
return element.getElementName(); return element.getElementName();

View File

@ -27,29 +27,29 @@ public class OptionsExtension extends NodeExtension
{ {
protected String jid; protected String jid;
protected String id; protected String id;
public OptionsExtension(String subscriptionJid) public OptionsExtension(String subscriptionJid)
{ {
this(subscriptionJid, null, null); this(subscriptionJid, null, null);
} }
public OptionsExtension(String subscriptionJid, String nodeId) public OptionsExtension(String subscriptionJid, String nodeId)
{ {
this(subscriptionJid, nodeId, null); this(subscriptionJid, nodeId, null);
} }
public OptionsExtension(String jid, String nodeId, String subscriptionId) public OptionsExtension(String jid, String nodeId, String subscriptionId)
{ {
super(PubSubElementType.OPTIONS, nodeId); super(PubSubElementType.OPTIONS, nodeId);
this.jid = jid; this.jid = jid;
id = subscriptionId; id = subscriptionId;
} }
public String getJid() public String getJid()
{ {
return jid; return jid;
} }
public String getId() public String getId()
{ {
return id; return id;

View File

@ -46,7 +46,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class PayloadItem<E extends ExtensionElement> extends Item public class PayloadItem<E extends ExtensionElement> extends Item
{ {
private E payload; private E payload;
/** /**
* Create an <tt>Item</tt> with no id and a payload The id will be set by the server. * Create an <tt>Item</tt> with no id and a payload The id will be set by the server.
* *
@ -55,7 +55,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(E payloadExt) public PayloadItem(E payloadExt)
{ {
super(); super();
if (payloadExt == null) if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'"); throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt; payload = payloadExt;
@ -70,12 +70,12 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(String itemId, E payloadExt) public PayloadItem(String itemId, E payloadExt)
{ {
super(itemId); super(itemId);
if (payloadExt == null) if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'"); throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt; payload = payloadExt;
} }
/** /**
* Create an <tt>Item</tt> with an id, node id and payload. * Create an <tt>Item</tt> with an id, node id and payload.
* *
@ -92,12 +92,12 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(String itemId, String nodeId, E payloadExt) public PayloadItem(String itemId, String nodeId, E payloadExt)
{ {
super(itemId, nodeId); super(itemId, nodeId);
if (payloadExt == null) if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'"); throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt; payload = payloadExt;
} }
/** /**
* Get the payload associated with this <tt>Item</tt>. Customising the payload * Get the payload associated with this <tt>Item</tt>. Customising the payload
* parsing from the server can be accomplished as described in {@link ItemProvider}. * parsing from the server can be accomplished as described in {@link ItemProvider}.
@ -108,19 +108,19 @@ public class PayloadItem<E extends ExtensionElement> extends Item
{ {
return payload; return payload;
} }
@Override @Override
public String toXML() public String toXML()
{ {
StringBuilder builder = new StringBuilder("<item"); StringBuilder builder = new StringBuilder("<item");
if (getId() != null) if (getId() != null)
{ {
builder.append(" id='"); builder.append(" id='");
builder.append(getId()); builder.append(getId());
builder.append("'"); builder.append("'");
} }
if (getNode() != null) { if (getNode() != null) {
builder.append(" node='"); builder.append(" node='");
builder.append(getNode()); builder.append(getNode());
@ -129,7 +129,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
builder.append(">"); builder.append(">");
builder.append(payload.toXML()); builder.append(payload.toXML());
builder.append("</item>"); builder.append("</item>");
return builder.toString(); return builder.toString();
} }

Some files were not shown because too many files have changed in this diff Show More