use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class Node method getNodeConfiguration.
/**
* Returns a configuration form, from which you can create an answer form to be submitted
* via the {@link #sendConfigurationForm(FillableConfigureForm)}.
*
* @return the configuration form
* @throws XMPPErrorException if there was an XMPP error returned.
* @throws NoResponseException if there was no response from the remote entity.
* @throws NotConnectedException if the XMPP connection is not connected.
* @throws InterruptedException if the calling thread was interrupted.
*/
public ConfigureForm getNodeConfiguration() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
PubSub pubSub = createPubsubPacket(IQ.Type.get, new NodeExtension(PubSubElementType.CONFIGURE_OWNER, getId()));
Stanza reply = sendPubsubPacket(pubSub);
return NodeUtils.getFormFromPacket(reply, PubSubElementType.CONFIGURE_OWNER);
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class VersionTest method checkProvider.
@Test
public void checkProvider() throws Exception {
// @formatter:off
String control = "<iq from='capulet.lit' to='juliet@capulet.lit/balcony' id='s2c1' type='get'>" + "<query xmlns='jabber:iq:version'/>" + "</iq>";
// @formatter:on
DummyConnection con = new DummyConnection();
con.connect();
// Enable version replys for this connection
VersionManager.setAutoAppendSmackVersion(false);
VersionManager.getInstanceFor(con).setVersion("Test", "0.23", "DummyOS");
IQ versionRequest = PacketParserUtils.parseStanza(control);
assertTrue(versionRequest instanceof Version);
con.processStanza(versionRequest);
Stanza replyPacket = con.getSentPacket();
assertTrue(replyPacket instanceof Version);
Version reply = (Version) replyPacket;
// getFrom check is pending for SMACK-547
// assertEquals("juliet@capulet.lit/balcony", reply.getFrom());
assertThat("capulet.lit", equalsCharSequence(reply.getTo()));
assertEquals("s2c1", reply.getStanzaId());
assertEquals(IQ.Type.result, reply.getType());
assertEquals("Test", reply.getName());
assertEquals("0.23", reply.getVersion());
assertEquals("DummyOS", reply.getOs());
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class CommandsProviderTest method parseErrorWithRequest.
@Test
public void parseErrorWithRequest() throws Exception {
final String errorWithRequest = "<iq id='sid' type='error' from='from@example.com' to='to@example.com'>" + "<command xmlns='http://jabber.org/protocol/commands' node='http://example.com' action='execute'>" + "</command>" + "<error type='cancel'>" + "<bad-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" + "</error>" + "</iq>";
final Stanza requestStanza = PacketParserUtils.parseStanza(errorWithRequest);
final AdHocCommandData adHocIq = (AdHocCommandData) requestStanza;
assertEquals(IQ.Type.error, adHocIq.getType());
assertEquals(AdHocCommand.Action.execute, adHocIq.getAction());
StanzaError error = adHocIq.getError();
assertEquals(StanzaError.Type.CANCEL, error.getType());
assertEquals(StanzaError.Condition.bad_request, error.getCondition());
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class FileTransferNegotiatorTest method verifyForm.
@Test
public void verifyForm() throws Exception {
FileTransferNegotiator fileNeg = FileTransferNegotiator.getInstanceFor(connection);
try {
fileNeg.negotiateOutgoingTransfer(JidTestUtil.DUMMY_AT_EXAMPLE_ORG, "streamid", "file", 1024, null, 10);
} catch (NoResponseException e) {
// We do not expect an answer. This unit test only checks the request sent.
}
Stanza packet = connection.getSentPacket();
String xml = packet.toXML().toString();
assertTrue(xml.indexOf("var='stream-method' type='list-single'") != -1);
}
use of org.jivesoftware.smack.packet.Stanza in project Smack by igniterealtime.
the class LastActivityTest method checkProvider.
@Test
public void checkProvider() throws Exception {
XMLBuilder xml = XMLBuilder.create("iq");
xml.a("from", "romeo@montague.net/orchard").a("id", "last2").a("to", "juliet@capulet.com/balcony").a("type", "get").e("query").namespace(LastActivity.NAMESPACE);
DummyConnection c = new DummyConnection();
c.connect();
IQ lastRequest = PacketParserUtils.parseStanza(xml.asString());
assertTrue(lastRequest instanceof LastActivity);
c.processStanza(lastRequest);
Stanza reply = c.getSentPacket();
assertTrue(reply instanceof LastActivity);
LastActivity l = (LastActivity) reply;
assertEquals("last2", l.getStanzaId());
assertEquals(IQ.Type.result, l.getType());
}
Aggregations