1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-10 17:49:38 +02:00

Small bugfix and session-initiate test

This commit is contained in:
vanitasvitae 2017-07-12 14:46:00 +02:00
parent b08e03af8d
commit e2d2f67982
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
3 changed files with 170 additions and 4 deletions

View file

@ -660,7 +660,7 @@ public class JingleUtil {
public IQ createErrorUnsupportedInfo(Jingle request) {
XMPPError.Builder error = XMPPError.getBuilder();
error.setCondition(XMPPError.Condition.feature_not_implemented)
.addExtension(JingleError.UNSUPPORTED_INFO);
.addExtension(JingleError.UNSUPPORTED_INFO).setType(XMPPError.Type.MODIFY);
return IQ.createErrorResponse(request, error);
}

View file

@ -250,6 +250,23 @@ public class JingleUtilTest extends SmackTestSuite {
assertEquals(JingleContent.Creator.initiator, content.getCreator());
}
@Test
public void createSessionTerminateIncompatibleParameters() throws IOException, SAXException {
Jingle terminate = jutil.createSessionTerminateIncompatibleParameters(juliet, "incompatibleSID");
String jingleXML =
"<jingle xmlns='urn:xmpp:jingle:1' " +
"action='session-terminate' " +
"sid='incompatibleSID'>" +
"<reason>" +
"<incompatible-parameters/>" +
"</reason>" +
"</jingle>";
String xml = getIQXML(romeo, juliet, terminate.getStanzaId(), jingleXML);
assertXMLEqual(xml, terminate.toXML().toString());
assertEquals(JingleReason.Reason.incompatible_parameters, terminate.getReason().asEnum());
assertEquals("incompatibleSID", terminate.getSid());
}
@Test
public void createErrorMalformedRequestTest() throws Exception {
Jingle j = defaultJingle(romeo, "error123");
@ -330,14 +347,34 @@ public class JingleUtilTest extends SmackTestSuite {
"from='" + romeo + "' " +
"id='" + j.getStanzaId() + "' " +
"type='error'>" +
"<error type='cancel'>" +
"<unexpected-result xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
//"<error type='cancel'>" +
"<error type='modify'>" + //TODO: Why?
"<unexpected-request xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
"<out-of-order xmlns='urn:xmpp:jingle:errors:1'/>" +
"</error>" +
"</iq>";
assertXMLEqual(xml, error.toXML().toString());
}
private String getIQXML(FullJid from, FullJid to, String stanzaId, String jingleXML) {
@Test
public void createErrorUnsupportedInfoTest() throws IOException, SAXException {
Jingle j = defaultJingle(romeo, "thisstatementiswrong");
IQ error = jutil.createErrorUnsupportedInfo(j);
String xml =
"<iq " +
"to='" + romeo + "' " +
"from='" + romeo + "' " +
"id='" + j.getStanzaId() + "' " +
"type='error'>" +
"<error type='modify'>" +
"<feature-not-implemented xmlns='urn:ietf:params:xml:ns:xmpp-stanzas'/>" +
"<unsupported-info xmlns='urn:xmpp:jingle:errors:1'/>" +
"</error>" +
"</iq>";
assertXMLEqual(xml, error.toXML().toString());
}
public static String getIQXML(FullJid from, FullJid to, String stanzaId, String jingleXML) {
return "<iq from='" + from + "' id='" + stanzaId + "' to='" + to + "' type='set'>" +
jingleXML +
"</iq>";