use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class HttpSessionDeliverable method testNamespaceOnEmptyStanza.
/**
* Verifies that the default namespace is set on empty stanzas.
*
* @see <a href="https://igniterealtime.org/issues/browse/OF-1087">OF-1087</a>
*/
@Test
public void testNamespaceOnEmptyStanza() throws Exception {
// Setup fixture
final Message message = new Message();
message.addChildElement("unittest", "unit:test:namespace");
final List<Packet> packets = new ArrayList<>();
packets.add(message);
// Execute system under test
final HttpSession.Deliverable deliverable = new HttpSession.Deliverable(packets);
final String result = deliverable.getDeliverable();
// verify results
// Note that this assertion depends on the Openfire XML parser-specific ordering of attributes.
assertEquals("<message xmlns=\"jabber:client\"><unittest xmlns=\"unit:test:namespace\"/></message>", result);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class HttpSessionDeliverable method testNamespaceOnEmptyStanzaWithoutChildElement.
/**
* Verifies that the default namespace is set on empty stanzas (that do not have a child element)
*
* @see <a href="https://igniterealtime.org/issues/browse/OF-1087">OF-1087</a>
*/
@Test
public void testNamespaceOnEmptyStanzaWithoutChildElement() throws Exception {
// Setup fixture
final Message message = new Message();
final List<Packet> packets = new ArrayList<>();
packets.add(message);
// Execute system under test
final HttpSession.Deliverable deliverable = new HttpSession.Deliverable(packets);
final String result = deliverable.getDeliverable();
// verify results
// Note that this assertion depends on the Openfire XML parser-specific ordering of attributes.
assertEquals("<message xmlns=\"jabber:client\"/>", result);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class PacketCounter method start.
/**
* Resets all counters, and starts counting.
*/
public void start() {
// Register a packet listener so that we can track packet traffic.
interceptor = new PacketInterceptor() {
public void interceptPacket(final Packet packet, final Session session, final boolean incoming, final boolean processed) {
if (!processed) {
// don't count packets twice!
return;
}
stanza.incrementAndGet();
if (packet instanceof Message) {
message.incrementAndGet();
}
if (packet instanceof Presence) {
presence.incrementAndGet();
}
if (packet instanceof IQ) {
iq.incrementAndGet();
switch(((IQ) packet).getType()) {
case get:
iqGet.incrementAndGet();
break;
case set:
iqSet.incrementAndGet();
break;
case result:
iqResult.incrementAndGet();
break;
case error:
iqError.incrementAndGet();
break;
}
}
}
};
// reset counters
stanza.set(0);
message.set(0);
presence.set(0);
iq.set(0);
iqGet.set(0);
iqSet.set(0);
iqResult.set(0);
iqError.set(0);
// register listener
InterceptorManager.getInstance().addInterceptor(interceptor);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class GojaraAdminManager method uptime.
private void uptime(String transport) {
Message message = generateCommand(transport, "uptime");
router.route(message);
}
use of org.xmpp.packet.Message in project Openfire by igniterealtime.
the class BaseMUCTransport method sendMessage.
/**
* Sends a simple message through he component manager.
*
* @param to Who the message is for.
* @param from Who the message is from.
* @param msg Message to be send.
* @param type Type of message to be sent.
*/
public void sendMessage(JID to, JID from, String msg, Message.Type type) {
Message m = new Message();
m.setType(type);
m.setFrom(from);
m.setTo(to);
m.setBody(msg);
sendPacket(m);
}
Aggregations