mirror of
https://codeberg.org/Mercury-IM/Smack
synced 2024-11-21 22:02:06 +01:00
Rename processPacket to processStanza
and assert that 'stanza' is a Stanza.
This commit is contained in:
parent
1cd268a8f0
commit
2f219c7317
11 changed files with 33 additions and 44 deletions
|
@ -981,7 +981,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
}
|
||||
ParserUtils.assertAtEndTag(parser);
|
||||
if (stanza != null) {
|
||||
processPacket(stanza);
|
||||
processStanza(stanza);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -990,29 +990,18 @@ public abstract class AbstractXMPPConnection implements XMPPConnection {
|
|||
* stanza(/packet) collectors and listeners and letting them examine the stanza(/packet) to see if
|
||||
* they are a match with the filter.
|
||||
*
|
||||
* @param packet the stanza(/packet) to process.
|
||||
* @param stanza the stanza to process.
|
||||
*/
|
||||
protected void processPacket(Stanza packet) {
|
||||
assert(packet != null);
|
||||
protected void processStanza(final Stanza stanza) {
|
||||
assert(stanza != null);
|
||||
lastStanzaReceived = System.currentTimeMillis();
|
||||
// Deliver the incoming packet to listeners.
|
||||
executorService.submit(new ListenerNotification(packet));
|
||||
}
|
||||
|
||||
/**
|
||||
* A runnable to notify all listeners and stanza(/packet) collectors of a packet.
|
||||
*/
|
||||
private class ListenerNotification implements Runnable {
|
||||
|
||||
private final Stanza packet;
|
||||
|
||||
public ListenerNotification(Stanza packet) {
|
||||
this.packet = packet;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
invokePacketCollectorsAndNotifyRecvListeners(packet);
|
||||
}
|
||||
executorService.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
invokePacketCollectorsAndNotifyRecvListeners(stanza);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -44,7 +44,7 @@ import org.jxmpp.stringprep.XmppStringprepException;
|
|||
* used to retrieve a message that was generated by the client.
|
||||
*
|
||||
* Packets that should be processed by the client to simulate a received stanza
|
||||
* can be delivered using the {@linkplain #processPacket(Stanza)} method.
|
||||
* can be delivered using the {@linkplain #processStanza(Stanza)} method.
|
||||
* It invokes the registered stanza(/packet) interceptors and listeners.
|
||||
*
|
||||
* @see XMPPConnection
|
||||
|
@ -178,7 +178,7 @@ public class DummyConnection extends AbstractXMPPConnection {
|
|||
*
|
||||
* @param packet the stanza(/packet) to process.
|
||||
*/
|
||||
public void processPacket(Stanza packet) {
|
||||
public void processStanza(Stanza packet) {
|
||||
invokePacketCollectorsAndNotifyRecvListeners(packet);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ public class ThreadedDummyConnection extends DummyConnection {
|
|||
/**
|
||||
* Calling this method will cause the next sendStanza call with an IQ stanza(/packet) to timeout.
|
||||
* This is accomplished by simply stopping the auto creating of the reply stanza(/packet)
|
||||
* or processing one that was entered via {@link #processPacket(Stanza)}.
|
||||
* or processing one that was entered via {@link #processStanza(Stanza)}.
|
||||
*/
|
||||
public void setTimeout() {
|
||||
timeout = true;
|
||||
|
@ -99,7 +99,7 @@ public class ThreadedDummyConnection extends DummyConnection {
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
processPacket(processQ.take());
|
||||
processStanza(processQ.take());
|
||||
} catch (InterruptedException e) {
|
||||
LOGGER.log(Level.WARNING, "exception", e);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class LastActivityTest extends InitExtensions {
|
|||
IQ lastRequest = (IQ) PacketParserUtils.parseStanza(xml.asString());
|
||||
assertTrue(lastRequest instanceof LastActivity);
|
||||
|
||||
c.processPacket(lastRequest);
|
||||
c.processStanza(lastRequest);
|
||||
Stanza reply = c.getSentPacket();
|
||||
assertTrue(reply instanceof LastActivity);
|
||||
LastActivity l = (LastActivity) reply;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class VersionTest extends InitExtensions {
|
|||
|
||||
assertTrue(versionRequest instanceof Version);
|
||||
|
||||
con.processPacket(versionRequest);
|
||||
con.processStanza(versionRequest);
|
||||
|
||||
Stanza replyPacket = con.getSentPacket();
|
||||
assertTrue(replyPacket instanceof Version);
|
||||
|
|
|
@ -56,7 +56,7 @@ public class PingTest extends InitExtensions {
|
|||
|
||||
assertTrue(pingRequest instanceof Ping);
|
||||
|
||||
con.processPacket(pingRequest);
|
||||
con.processStanza(pingRequest);
|
||||
|
||||
Stanza pongPacket = con.getSentPacket();
|
||||
assertTrue(pongPacket instanceof IQ);
|
||||
|
|
|
@ -85,7 +85,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
m.setFrom(JidCreate.from("julia@capulet.com"));
|
||||
m.setStanzaId("reply-id");
|
||||
m.addExtension(new DeliveryReceipt("original-test-id"));
|
||||
c.processPacket(m);
|
||||
c.processStanza(m);
|
||||
|
||||
rrl.waitUntilInvocationOrTimeout();
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class DeliveryReceiptTest extends InitExtensions {
|
|||
DeliveryReceiptRequest.addTo(m);
|
||||
|
||||
// the DRM will send a reply-packet
|
||||
c.processPacket(m);
|
||||
c.processStanza(m);
|
||||
|
||||
Stanza reply = c.getSentPacket();
|
||||
DeliveryReceipt r = DeliveryReceipt.from((Message) reply);
|
||||
|
|
|
@ -383,7 +383,7 @@ public class ChatConnectionTest {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
con.processPacket(chatPacket);
|
||||
con.processStanza(chatPacket);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ public class RosterTest extends InitSmackIm {
|
|||
rosterListener.reset();
|
||||
|
||||
// Simulate receiving the roster push
|
||||
connection.processPacket(rosterPush);
|
||||
connection.processStanza(rosterPush);
|
||||
rosterListener.waitUntilInvocationOrTimeout();
|
||||
|
||||
// Verify the roster entry of the new contact
|
||||
|
@ -380,7 +380,7 @@ public class RosterTest extends InitSmackIm {
|
|||
|
||||
final String requestId = packet.getStanzaId();
|
||||
// Simulate receiving the roster push
|
||||
connection.processPacket(packet);
|
||||
connection.processStanza(packet);
|
||||
|
||||
// Smack should reply with an error IQ
|
||||
ErrorIQ errorIQ = (ErrorIQ) connection.getSentPacket();
|
||||
|
@ -482,7 +482,7 @@ public class RosterTest extends InitSmackIm {
|
|||
rosterListener.reset();
|
||||
|
||||
// Simulate receiving the roster push
|
||||
connection.processPacket(rosterPush);
|
||||
connection.processStanza(rosterPush);
|
||||
rosterListener.waitUntilInvocationOrTimeout();
|
||||
|
||||
// Verify the roster entry of the new contact
|
||||
|
@ -524,7 +524,7 @@ public class RosterTest extends InitSmackIm {
|
|||
rosterPush.addRosterItem(item);
|
||||
|
||||
// simulate receiving the roster push
|
||||
connection.processPacket(rosterPush);
|
||||
connection.processStanza(rosterPush);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -572,7 +572,7 @@ public class RosterTest extends InitSmackIm {
|
|||
rosterResult.addRosterItem(benvolio);
|
||||
|
||||
// simulate receiving the roster result and exit the loop
|
||||
connection.processPacket(rosterResult);
|
||||
connection.processStanza(rosterResult);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -672,11 +672,11 @@ public class RosterTest extends InitSmackIm {
|
|||
rosterPush.setType(Type.set);
|
||||
rosterPush.setTo(connection.getUser());
|
||||
rosterPush.addRosterItem(item);
|
||||
connection.processPacket(rosterPush);
|
||||
connection.processStanza(rosterPush);
|
||||
|
||||
// Create and process the IQ response
|
||||
final IQ response = IQ.createResultIQ(rosterRequest);
|
||||
connection.processPacket(response);
|
||||
connection.processStanza(response);
|
||||
|
||||
// Verify the roster update request
|
||||
assertSame("A roster set MUST contain one and only one <item/> element.",
|
||||
|
|
|
@ -152,7 +152,7 @@ public class RosterVersioningTest {
|
|||
answer.addRosterItem(vaglafItem);
|
||||
|
||||
rosterListener.reset();
|
||||
connection.processPacket(answer);
|
||||
connection.processStanza(answer);
|
||||
rosterListener.waitUntilInvocationOrTimeout();
|
||||
} else {
|
||||
assertTrue("Expected to get a RosterPacket ", false);
|
||||
|
@ -191,7 +191,7 @@ public class RosterVersioningTest {
|
|||
Item pushedItem = vaglafItem();
|
||||
rosterPush.addRosterItem(pushedItem);
|
||||
rosterListener.reset();
|
||||
connection.processPacket(rosterPush);
|
||||
connection.processStanza(rosterPush);
|
||||
rosterListener.waitAndReset();
|
||||
|
||||
assertEquals("Expect store version after push", "v97", store.getRosterVersion());
|
||||
|
@ -218,7 +218,7 @@ public class RosterVersioningTest {
|
|||
item.setItemType(ItemType.remove);
|
||||
rosterPush.addRosterItem(item);
|
||||
rosterListener.reset();
|
||||
connection.processPacket(rosterPush);
|
||||
connection.processStanza(rosterPush);
|
||||
rosterListener.waitAndReset();
|
||||
|
||||
assertNull("Store doses not contain vaglaf", store.getEntry(JidCreate.bareFrom("vaglaf@example.com")));
|
||||
|
@ -255,7 +255,7 @@ public class RosterVersioningTest {
|
|||
Stanza sentPacket = connection.getSentPacket();
|
||||
if (sentPacket instanceof RosterPacket) {
|
||||
final IQ emptyIQ = IQ.createResultIQ((RosterPacket)sentPacket);
|
||||
connection.processPacket(emptyIQ);
|
||||
connection.processStanza(emptyIQ);
|
||||
} else {
|
||||
assertTrue("Expected to get a RosterPacket ", false);
|
||||
}
|
||||
|
|
|
@ -171,11 +171,11 @@ public class SubscriptionPreApprovalTest extends InitSmackIm {
|
|||
rosterPush.setType(Type.set);
|
||||
rosterPush.setTo(connection.getUser());
|
||||
rosterPush.addRosterItem(item);
|
||||
connection.processPacket(rosterPush);
|
||||
connection.processStanza(rosterPush);
|
||||
|
||||
// Create and process the IQ response
|
||||
final IQ response = IQ.createResultIQ(rosterRequest);
|
||||
connection.processPacket(response);
|
||||
connection.processStanza(response);
|
||||
|
||||
// Verify the roster update request
|
||||
assertSame("A roster set MUST contain one and only one <item/> element.",
|
||||
|
|
Loading…
Reference in a new issue