1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-09 17:19:39 +02: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

@ -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));
}