1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-12-22 02:27:58 +01:00

'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="message" value="Must not use MXParser, use XmlPullParserFactory instead"/>
</module>
<module name="RegexpSingleline">
<property name="format" value="^\s+$"/>
<property name="message" value="Line containing only whitespace character(s)"/>
</module>
<module name="TreeWalker">
<module name="UnusedImports">
<property name="processJavadoc" value="true"/>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -28,7 +28,7 @@ import org.jivesoftware.smack.util.Objects;
*
*/
public class IQTypeFilter extends FlexibleStanzaTypeFilter<IQ> {
public static final StanzaFilter GET = new IQTypeFilter(Type.get);
public static final StanzaFilter SET = new IQTypeFilter(Type.set);
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() {
return getSubject(null);
}
/**
* 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
@ -165,7 +165,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
Subject subject = getMessageSubject(language);
return subject == null ? null : subject.subject;
}
private Subject getMessageSubject(String language) {
language = determineLanguage(language);
for (Subject subject : subjects) {
@ -284,7 +284,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
Body body = getMessageBody(language);
return body == null ? null : body.message;
}
private Body getMessageBody(String language) {
language = determineLanguage(language);
for (Body body : bodies) {
@ -400,7 +400,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
}
private String determineLanguage(String language) {
// empty string is passed by #setSubject() and #setBody() and is the same as null
language = "".equals(language) ? null : language;
@ -414,7 +414,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
else {
return language;
}
}
@Override
@ -537,7 +537,7 @@ public final class Message extends Stanza implements TypedCloneable<Message> {
// simplified comparison because language and subject are always set
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
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 {
private static final Logger LOGGER = Logger.getLogger(ExceptionLoggingCallback.class.getName());
@Override
public void handleUnparsablePacket(UnparsablePacket unparsed) throws Exception {
LOGGER.log(Level.SEVERE, "Smack message parsing exception: ", unparsed.getParsingException());

View file

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

View file

@ -26,7 +26,7 @@ import org.jivesoftware.smack.packet.IQ;
*
*/
public final class IQProviderInfo extends AbstractProviderInfo {
/**
* 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());
}
}
if (loader.getExtensionProviderInfo() != null) {
for (ExtensionProviderInfo info : loader.getExtensionProviderInfo()) {
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.
* For example, if a provider was registered to the element name "query" and the

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -34,5 +34,5 @@ public interface ReaderListener {
* @param str the read String
*/
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);
}
}
/**
* Pseudo-random number generator object for use with randomString().
* 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;
}
public XmlStringBuilder optElement(String name, Object object) {
if (object != null) {
element(name, object.toString());
@ -272,7 +272,7 @@ public class XmlStringBuilder implements Appendable, CharSequence {
optAttribute("xml:lang", value);
return this;
}
public XmlStringBuilder escape(String text) {
assert text != null;
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> {
private int weight;
private int priority;
/**
* Create a new SRVRecord
*
@ -52,11 +52,11 @@ public class SRVRecord extends HostAddress implements Comparable<SRVRecord> {
this.weight = weight;
}
public int getPriority() {
return priority;
}
public int getWeight() {
return weight;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -62,7 +62,7 @@ public class StringUtilsTest {
input = "&";
assertCharSequenceEquals("&amp;", StringUtils.escapeForXML(input));
input = "It's a good day today";
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 {
private static final Logger LOGGER = Logger.getLogger(EnhancedDebugger.class.getName());
private static final String NEWLINE = "\n";
private static ImageIcon packetReceivedIcon;
@ -354,22 +354,22 @@ public class EnhancedDebugger implements SmackDebugger {
messageTextArea.addMouseListener(new PopupListener(menu));
JPanel sublayout = new JPanel(new BorderLayout());
sublayout.add(new JScrollPane(messageTextArea), BorderLayout.CENTER);
JButton clearb = new JButton("Clear All Packets");
clearb.addActionListener(new AbstractAction() {
private static final long serialVersionUID = -8576045822764763613L;
@Override
public void actionPerformed(ActionEvent e) {
messagesTable.setRowCount(0);
}
});
sublayout.add(clearb, BorderLayout.NORTH);
allPane.setBottomComponent(sublayout);
allPane.setDividerLocation(150);
tabbedPane.add("All Packets", allPane);

View file

@ -197,7 +197,7 @@ public class EnhancedDebuggerWindow {
getInstance().tabbedPane.indexOfComponent(debugger.tabbedPane),
connectionActiveIcon);
}
/**
* Creates the main debug window that provides information about Smack and also shows
* 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 CarbonManager(XMPPConnection connection) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -26,7 +26,7 @@ import junit.framework.TestCase;
public class TestMessageContent extends TestCase
{
String payloadXmlWithNS = "<book xmlns='pubsub:test:book'><author name='Stephen King'/></book>";
public void testItemWithId()
{
Item item = new Item("123");
@ -47,21 +47,21 @@ public class TestMessageContent extends TestCase
public void testSimplePayload()
{
SimplePayload payloadNS = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
assertEquals(payloadXmlWithNS, payloadNS.toXML());
String payloadXmlWithNoNS = "<book><author name='Stephen King'/></book>";
SimplePayload payloadNoNS = new SimplePayload("book", null, "<book><author name='Stephen King'/></book>");
assertEquals(payloadXmlWithNoNS, payloadNoNS.toXML());
}
public void testPayloadItemWithId()
{
SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>("123", payload);
String xml = "<item id='123'>" + payloadXmlWithNS + "</item>";
assertEquals(xml, item.toXML());
assertEquals("item", item.getElementName());
@ -71,7 +71,7 @@ public class TestMessageContent extends TestCase
{
SimplePayload payload = new SimplePayload("book", "pubsub:test:book", payloadXmlWithNS);
PayloadItem<SimplePayload> item = new PayloadItem<SimplePayload>(null, payload);
String xml = "<item>" + payloadXmlWithNS + "</item>";
assertEquals(xml, item.toXML());
}
@ -99,14 +99,14 @@ public class TestMessageContent extends TestCase
{
}
}
public void testRetractItem()
{
RetractItem item = new RetractItem("1234");
assertEquals("<retract id='1234'/>", item.toXML());
assertEquals("retract", item.getElementName());
try
{
new RetractItem(null);
@ -116,7 +116,7 @@ public class TestMessageContent extends TestCase
{
}
}
public void testGetItemsRequest()
{
GetItemsRequest request = new GetItemsRequest("testId");
@ -124,10 +124,10 @@ public class TestMessageContent extends TestCase
request = new GetItemsRequest("testId", 5);
assertEquals("<items node='testId' max_items='5'/>", request.toXML());
request = new GetItemsRequest("testId", "qwerty");
assertEquals("<items node='testId' subid='qwerty'/>", request.toXML());
request = new GetItemsRequest("testId", "qwerty", 5);
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
{
LeafNode node = null;
try
{
node = (LeafNode)pubMgr.getNode(nodeId);
@ -76,7 +76,7 @@ abstract public class PubSubTestCase extends SmackTestCase
if (manager == null)
{
manager = new PubSubManager[getMaxConnections()];
for(int i=0; i<manager.length; i++)
{
manager[i] = new PubSubManager(getConnection(i), getService());
@ -84,7 +84,7 @@ abstract public class PubSubTestCase extends SmackTestCase
}
return manager[idx];
}
protected String getService()
{
return "pubsub." + getServiceName();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -45,7 +45,7 @@ public class ConfigureForm extends Form
{
super(configDataForm);
}
/**
* Create a decorator from an existing {@link Form} for node configuration.
* 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());
}
/**
* 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
@ -69,7 +69,7 @@ public class ConfigureForm extends Form
{
super(formType);
}
/**
* Get the currently configured {@link AccessModel}, null if it is not set.
*
@ -78,13 +78,13 @@ public class ConfigureForm extends Form
public AccessModel getAccessModel()
{
String value = getFieldValue(ConfigureNodeFields.access_model);
if (value == null)
return null;
else
return AccessModel.valueOf(value);
}
/**
* Sets the value of access model.
*
@ -118,7 +118,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.body_xslt, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.body_xslt.getFieldName(), bodyXslt);
}
/**
* 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);
}
/**
* 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);
setAnswer(ConfigureNodeFields.children.getFieldName(), children);
}
/**
* Returns the policy that determines who may associate children with the node.
*
@ -148,13 +148,13 @@ public class ConfigureForm extends Form
public ChildrenAssociationPolicy getChildrenAssociationPolicy()
{
String value = getFieldValue(ConfigureNodeFields.children_association_policy);
if (value == null)
return null;
else
return ChildrenAssociationPolicy.valueOf(value);
}
/**
* 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());
setAnswer(ConfigureNodeFields.children_association_policy.getFieldName(), values);
}
/**
* 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
@ -179,7 +179,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.children_association_whitelist);
}
/**
* 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
@ -269,7 +269,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.deliver_payloads));
}
/**
* Sets whether the node will deliver payloads with event notifications.
*
@ -289,7 +289,7 @@ public class ConfigureForm extends Form
public ItemReply getItemReply()
{
String value = getFieldValue(ConfigureNodeFields.itemreply);
if (value == null)
return null;
else
@ -329,7 +329,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.max_items, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.max_items.getFieldName(), max);
}
/**
* 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);
setAnswer(ConfigureNodeFields.max_payload_size.getFieldName(), max);
}
/**
* Gets the node type
*
@ -359,13 +359,13 @@ public class ConfigureForm extends Form
public NodeType getNodeType()
{
String value = getFieldValue(ConfigureNodeFields.node_type);
if (value == null)
return null;
else
return NodeType.valueOf(value);
}
/**
* Sets the node type
*
@ -386,7 +386,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.notify_config));
}
/**
* 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));
}
/**
* 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));
}
/**
* Sets whether subscribers should be notified when items are deleted
* from the node.
@ -441,7 +441,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.notify_retract, FormField.Type.bool);
setAnswer(ConfigureNodeFields.notify_retract.getFieldName(), notify);
}
/**
* Determines whether items should be persisted in the node.
*
@ -451,7 +451,7 @@ public class ConfigureForm extends Form
{
return parseBoolean(getFieldValue(ConfigureNodeFields.persist_items));
}
/**
* 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));
}
/**
* Sets whether to deliver notifications to available users only.
*
@ -492,7 +492,7 @@ public class ConfigureForm extends Form
public PublishModel getPublishModel()
{
String value = getFieldValue(ConfigureNodeFields.publish_model);
if (value == null)
return null;
else
@ -509,7 +509,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.publish_model, FormField.Type.list_single);
setAnswer(ConfigureNodeFields.publish_model.getFieldName(), getListSingle(publish.toString()));
}
/**
* 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);
}
/**
* 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);
setAnswer(ConfigureNodeFields.replyroom.getFieldName(), replyRooms);
}
/**
* Gets the specific JID's for reply to.
*
@ -540,7 +540,7 @@ public class ConfigureForm extends Form
{
return getFieldValues(ConfigureNodeFields.replyto);
}
/**
* Sets the specific JID's for reply to.
*
@ -551,7 +551,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.replyto, FormField.Type.list_multi);
setAnswer(ConfigureNodeFields.replyto.getFieldName(), replyTos);
}
/**
* 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);
}
/**
* 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);
setAnswer(ConfigureNodeFields.roster_groups_allowed.getFieldName(), groups);
}
/**
* Determines if subscriptions are allowed.
*
@ -604,7 +604,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.subscribe, FormField.Type.bool);
setAnswer(ConfigureNodeFields.subscribe.getFieldName(), subscribe);
}
/**
* Gets the human readable node title.
*
@ -625,7 +625,7 @@ public class ConfigureForm extends Form
addField(ConfigureNodeFields.title, FormField.Type.text_single);
setAnswer(ConfigureNodeFields.title.getFieldName(), title);
}
/**
* 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);
setAnswer(ConfigureNodeFields.type.getFieldName(), type);
}
@Override
public String toString()
{
StringBuilder result = new StringBuilder(getClass().getName() + " Content [");
for (FormField formField : getFields())
{
result.append('(');
result.append(formField.getVariable());
result.append(':');
StringBuilder valuesBuilder = new StringBuilder();
for (String value : formField.getValues())
{
if (valuesBuilder.length() > 0)
result.append(',');
valuesBuilder.append(value);
}
if (valuesBuilder.length() == 0)
valuesBuilder.append("NOT SET");
result.append(valuesBuilder);
@ -684,21 +684,21 @@ public class ConfigureForm extends Form
private String getFieldValue(ConfigureNodeFields field)
{
FormField formField = getField(field.getFieldName());
return (formField.getValues().isEmpty()) ? null : formField.getValues().get(0);
}
private List<String> getFieldValues(ConfigureNodeFields field)
{
FormField formField = getField(field.getFieldName());
return formField.getValues();
}
private void addField(ConfigureNodeFields nodeField, FormField.Type type)
{
String fieldName = nodeField.getFieldName();
if (getField(fieldName) == null)
{
FormField field = new FormField(fieldName);

View file

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

View file

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

View file

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

View file

@ -29,7 +29,7 @@ import org.jivesoftware.smackx.xdata.Form;
public class FormNode extends NodeExtension
{
private Form configForm;
/**
* 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");
configForm = submitForm;
}
/**
* Create a {@link FormNode} which contains the specified form, which is
* associated with the specified node.
@ -61,7 +61,7 @@ public class FormNode extends NodeExtension
throw new IllegalArgumentException("Submit form cannot be null");
configForm = submitForm;
}
/**
* 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;
}
@Override
public CharSequence toXML()
{
@ -83,7 +83,7 @@ public class FormNode extends NodeExtension
{
StringBuilder builder = new StringBuilder("<");
builder.append(getElementName());
if (getNode() != null)
{
builder.append(" node='");

View file

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

View file

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

View file

@ -45,7 +45,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class Item extends NodeExtension
{
private String id;
/**
* 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.
@ -57,7 +57,7 @@ public class Item extends NodeExtension
{
super(PubSubElementType.ITEM);
}
/**
* 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.
@ -88,7 +88,7 @@ public class Item extends NodeExtension
super(PubSubElementType.ITEM_EVENT, nodeId);
id = itemId;
}
/**
* Get the item id. Unique to the node it is associated with.
*
@ -98,7 +98,7 @@ public class Item extends NodeExtension
{
return id;
}
@Override
public String getNamespace()
{
@ -109,14 +109,14 @@ public class Item extends NodeExtension
public String toXML()
{
StringBuilder builder = new StringBuilder("<item");
if (id != null)
{
builder.append(" id='");
builder.append(id);
builder.append("'");
}
if (getNode() != null) {
builder.append(" node='");
builder.append(getNode());

View file

@ -27,7 +27,7 @@ import java.util.List;
public class ItemDeleteEvent extends SubscriptionEvent
{
private List<String> itemIds = Collections.emptyList();
/**
* Constructs an <tt>ItemDeleteEvent</tt> that indicates the the supplied
* 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)
{
super(nodeId, subscriptionIds);
if (deletedItemIds == null)
throw new IllegalArgumentException("deletedItemIds cannot be null");
itemIds = deletedItemIds;
}
/**
* 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);
}
@Override
public String toString()
{

View file

@ -29,7 +29,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
{
private List<T> items;
private Date originalDate;
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* of {@link Item} that were published.
@ -42,7 +42,7 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
super(nodeId);
items = eventItems;
}
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* 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);
items = eventItems;
}
/**
* Constructs an <tt>ItemPublishEvent</tt> with the provided list
* 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);
items = eventItems;
if (publishedDate != null)
originalDate = publishedDate;
}
/**
* 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);
}
/**
* Indicates whether this event was delayed. That is, the items
* 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);
}
/**
* Gets the original date the items were published. This is only
* valid if {@link #isDelayed()} is true.
@ -120,5 +120,5 @@ public class ItemPublishEvent<T extends Item> extends SubscriptionEvent
return getClass().getName() + " [subscriptions: " + getSubscriptions() + "], [Delayed: " +
(isDelayed() ? originalDate.toString() : "false") + ']';
}
}

View file

@ -26,7 +26,7 @@ public enum ItemReply
{
/** The node owner */
owner,
/** The item 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 */
items(PubSubElementType.ITEMS, "max_items"),
/** A retract element, which has an optional <b>notify</b> attribute when publishing deletions */
retract(PubSubElementType.RETRACT, "notify");
private PubSubElementType elem;
private String att;
private ItemsElementType(PubSubElementType nodeElement, String attribute)
{
elem = nodeElement;
att = attribute;
}
public PubSubElementType getNodeElement()
{
return elem;
@ -89,7 +89,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
type = itemsType;
this.items = items;
}
/**
* 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.notify = notify;
}
/**
* Get the type of element
*
@ -123,13 +123,13 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
return type;
}
@SuppressWarnings("unchecked")
public List<ExtensionElement> getExtensions()
{
return (List<ExtensionElement>)getItems();
}
/**
* Gets the items related to the type of request or event.
*
@ -149,7 +149,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
{
return notify;
}
@Override
public CharSequence toXML()
{
@ -163,7 +163,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(getElementName());
builder.append(" node='");
builder.append(getNode());
if (notify != null)
{
builder.append("' ");
@ -180,7 +180,7 @@ public class ItemsExtension extends NodeExtension implements EmbeddedPacketExten
builder.append(item.toXML());
}
}
builder.append("</");
builder.append(getElementName());
builder.append(">");

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -46,7 +46,7 @@ import org.jivesoftware.smackx.pubsub.provider.ItemProvider;
public class PayloadItem<E extends ExtensionElement> extends Item
{
private E payload;
/**
* 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)
{
super();
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
@ -70,12 +70,12 @@ public class PayloadItem<E extends ExtensionElement> extends Item
public PayloadItem(String itemId, E payloadExt)
{
super(itemId);
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
}
/**
* 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)
{
super(itemId, nodeId);
if (payloadExt == null)
throw new IllegalArgumentException("payload cannot be 'null'");
payload = payloadExt;
}
/**
* Get the payload associated with this <tt>Item</tt>. Customising the payload
* 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;
}
@Override
public String toXML()
{
StringBuilder builder = new StringBuilder("<item");
if (getId() != null)
{
builder.append(" id='");
builder.append(getId());
builder.append("'");
}
if (getNode() != null) {
builder.append(" node='");
builder.append(getNode());
@ -129,7 +129,7 @@ public class PayloadItem<E extends ExtensionElement> extends Item
builder.append(">");
builder.append(payload.toXML());
builder.append("</item>");
return builder.toString();
}

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