mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-26 05:52:06 +01:00
Use StandardExtensionElement in JingleProvider
and some further minor jingle fixes: - deprecate getJingleTransport() in favor of getTransport() - Jingle.Builder now checks if the session ID is not empty
This commit is contained in:
parent
ed9eae4793
commit
7f851d806c
13 changed files with 275 additions and 18 deletions
|
@ -1,6 +1,6 @@
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Copyright 2015 Florian Schmaus.
|
* Copyright 2015-2017 Florian Schmaus.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -46,6 +46,9 @@ public class StandardExtensionElementParserTest {
|
||||||
assertEquals("attr2-value", barNs2Element.getAttributeValue("attr2"));
|
assertEquals("attr2-value", barNs2Element.getAttributeValue("attr2"));
|
||||||
|
|
||||||
assertEquals("another-element-text", parsedElement.getFirstElement("another-element").getText());
|
assertEquals("another-element-text", parsedElement.getFirstElement("another-element").getText());
|
||||||
|
|
||||||
|
String parsedElementString = parsedElement.toXML().toString();
|
||||||
|
assertEquals(elementString, parsedElementString);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -79,7 +79,7 @@ public final class JingleTransportMethodManager extends Manager {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
JingleContentTransport transport = content.getJingleTransport();
|
JingleContentTransport transport = content.getTransport();
|
||||||
if (transport == null) {
|
if (transport == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -190,6 +190,7 @@ public final class Jingle extends IQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setSessionId(String sessionId) {
|
public Builder setSessionId(String sessionId) {
|
||||||
|
StringUtils.requireNotNullOrEmpty(sessionId, "Session ID must not be null or empty");
|
||||||
this.sid = sessionId;
|
this.sid = sessionId;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,8 +110,19 @@ public final class JingleContent implements NamedElement {
|
||||||
* Returns an Iterator for the JingleTransports in the packet.
|
* Returns an Iterator for the JingleTransports in the packet.
|
||||||
*
|
*
|
||||||
* @return an Iterator for the JingleTransports in the packet.
|
* @return an Iterator for the JingleTransports in the packet.
|
||||||
|
* @deprecated use {@link #getTransport()} instead.
|
||||||
*/
|
*/
|
||||||
|
@Deprecated
|
||||||
public JingleContentTransport getJingleTransport() {
|
public JingleContentTransport getJingleTransport() {
|
||||||
|
return getTransport();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an Iterator for the JingleTransports in the packet.
|
||||||
|
*
|
||||||
|
* @return an Iterator for the JingleTransports in the packet.
|
||||||
|
*/
|
||||||
|
public JingleContentTransport getTransport() {
|
||||||
return transport;
|
return transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.jivesoftware.smack.packet.ExtensionElement;
|
import org.jivesoftware.smack.packet.ExtensionElement;
|
||||||
|
import org.jivesoftware.smack.packet.NamedElement;
|
||||||
import org.jivesoftware.smack.util.XmlStringBuilder;
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -30,9 +31,9 @@ public abstract class JingleContentDescription implements ExtensionElement {
|
||||||
|
|
||||||
public static final String ELEMENT = "description";
|
public static final String ELEMENT = "description";
|
||||||
|
|
||||||
private final List<JingleContentDescriptionChildElement> payloads;
|
private final List<NamedElement> payloads;
|
||||||
|
|
||||||
protected JingleContentDescription(List<JingleContentDescriptionChildElement> payloads) {
|
protected JingleContentDescription(List<? extends NamedElement> payloads) {
|
||||||
if (payloads != null) {
|
if (payloads != null) {
|
||||||
this.payloads = Collections.unmodifiableList(payloads);
|
this.payloads = Collections.unmodifiableList(payloads);
|
||||||
}
|
}
|
||||||
|
@ -46,7 +47,7 @@ public abstract class JingleContentDescription implements ExtensionElement {
|
||||||
return ELEMENT;
|
return ELEMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JingleContentDescriptionChildElement> getJingleContentDescriptionChildren() {
|
public List<NamedElement> getJingleContentDescriptionChildren() {
|
||||||
return payloads;
|
return payloads;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +56,7 @@ public abstract class JingleContentDescription implements ExtensionElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final XmlStringBuilder toXML() {
|
public XmlStringBuilder toXML() {
|
||||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||||
addExtraAttributes(xml);
|
addExtraAttributes(xml);
|
||||||
xml.rightAngleBracket();
|
xml.rightAngleBracket();
|
||||||
|
|
|
@ -66,7 +66,7 @@ public abstract class JingleContentTransport implements ExtensionElement {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final XmlStringBuilder toXML() {
|
public XmlStringBuilder toXML() {
|
||||||
XmlStringBuilder xml = new XmlStringBuilder(this);
|
XmlStringBuilder xml = new XmlStringBuilder(this);
|
||||||
addExtraAttributes(xml);
|
addExtraAttributes(xml);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2017 Florian Schmaus.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smackx.jingle.element;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
||||||
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
|
public final class UnknownJingleContentDescription extends JingleContentDescription {
|
||||||
|
|
||||||
|
private final StandardExtensionElement standardExtensionElement;
|
||||||
|
|
||||||
|
public UnknownJingleContentDescription(StandardExtensionElement standardExtensionElement) {
|
||||||
|
super(standardExtensionElement.getElements());
|
||||||
|
this.standardExtensionElement = standardExtensionElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getElementName() {
|
||||||
|
return standardExtensionElement.getElementName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return standardExtensionElement.getNamespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XmlStringBuilder toXML() {
|
||||||
|
return standardExtensionElement.toXML();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StandardExtensionElement getStandardExtensionElement() {
|
||||||
|
return standardExtensionElement;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2017 Florian Schmaus.
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smackx.jingle.element;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
||||||
|
import org.jivesoftware.smack.util.XmlStringBuilder;
|
||||||
|
|
||||||
|
public final class UnknownJingleContentTransport extends JingleContentTransport {
|
||||||
|
|
||||||
|
private final StandardExtensionElement standardExtensionElement;
|
||||||
|
|
||||||
|
public UnknownJingleContentTransport(StandardExtensionElement standardExtensionElement) {
|
||||||
|
super(null, null);
|
||||||
|
this.standardExtensionElement = standardExtensionElement;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getElementName() {
|
||||||
|
return standardExtensionElement.getElementName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNamespace() {
|
||||||
|
return standardExtensionElement.getNamespace();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public XmlStringBuilder toXML() {
|
||||||
|
return standardExtensionElement.toXML();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<JingleContentTransportCandidate> getCandidates() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JingleContentTransportInfo getInfo() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StandardExtensionElement getStandardExtensionElement() {
|
||||||
|
return standardExtensionElement;
|
||||||
|
}
|
||||||
|
}
|
|
@ -18,6 +18,8 @@ package org.jivesoftware.smackx.jingle.provider;
|
||||||
|
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
||||||
|
import org.jivesoftware.smack.parsing.StandardExtensionElementProvider;
|
||||||
import org.jivesoftware.smack.provider.IQProvider;
|
import org.jivesoftware.smack.provider.IQProvider;
|
||||||
import org.jivesoftware.smack.util.ParserUtils;
|
import org.jivesoftware.smack.util.ParserUtils;
|
||||||
|
|
||||||
|
@ -28,6 +30,8 @@ import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
||||||
import org.jivesoftware.smackx.jingle.element.JingleReason.Reason;
|
import org.jivesoftware.smackx.jingle.element.JingleReason.Reason;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.UnknownJingleContentDescription;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.UnknownJingleContentTransport;
|
||||||
|
|
||||||
import org.jxmpp.jid.FullJid;
|
import org.jxmpp.jid.FullJid;
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
@ -122,22 +126,28 @@ public class JingleProvider extends IQProvider<Jingle> {
|
||||||
String namespace = parser.getNamespace();
|
String namespace = parser.getNamespace();
|
||||||
switch (tagName) {
|
switch (tagName) {
|
||||||
case JingleContentDescription.ELEMENT: {
|
case JingleContentDescription.ELEMENT: {
|
||||||
|
JingleContentDescription description;
|
||||||
JingleContentDescriptionProvider<?> provider = JingleContentProviderManager.getJingleContentDescriptionProvider(namespace);
|
JingleContentDescriptionProvider<?> provider = JingleContentProviderManager.getJingleContentDescriptionProvider(namespace);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
// TODO handle this case (DefaultExtensionElement wrapped in something?)
|
StandardExtensionElement standardExtensionElement = StandardExtensionElementProvider.INSTANCE.parse(parser);
|
||||||
break;
|
description = new UnknownJingleContentDescription(standardExtensionElement);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
description = provider.parse(parser);
|
||||||
}
|
}
|
||||||
JingleContentDescription description = provider.parse(parser);
|
|
||||||
builder.setDescription(description);
|
builder.setDescription(description);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case JingleContentTransport.ELEMENT: {
|
case JingleContentTransport.ELEMENT: {
|
||||||
|
JingleContentTransport transport;
|
||||||
JingleContentTransportProvider<?> provider = JingleContentProviderManager.getJingleContentTransportProvider(namespace);
|
JingleContentTransportProvider<?> provider = JingleContentProviderManager.getJingleContentTransportProvider(namespace);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
// TODO handle this case (DefaultExtensionElement wrapped in something?)
|
StandardExtensionElement standardExtensionElement = StandardExtensionElementProvider.INSTANCE.parse(parser);
|
||||||
break;
|
transport = new UnknownJingleContentTransport(standardExtensionElement);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
transport = provider.parse(parser);
|
||||||
}
|
}
|
||||||
JingleContentTransport transport = provider.parse(parser);
|
|
||||||
builder.setTransport(transport);
|
builder.setTransport(transport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public abstract class JingleTransportSession<T extends JingleContentTransport> {
|
||||||
}
|
}
|
||||||
|
|
||||||
JingleContent content = jingle.getContents().get(0);
|
JingleContent content = jingle.getContents().get(0);
|
||||||
JingleContentTransport t = content.getJingleTransport();
|
JingleContentTransport t = content.getTransport();
|
||||||
|
|
||||||
if (t != null && t.getNamespace().equals(getNamespace())) {
|
if (t != null && t.getNamespace().equals(getNamespace())) {
|
||||||
setTheirProposal(t);
|
setTheirProposal(t);
|
||||||
|
|
|
@ -189,7 +189,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IQ handleTransportInfo(Jingle transportInfo) {
|
public IQ handleTransportInfo(Jingle transportInfo) {
|
||||||
JingleS5BTransportInfo info = (JingleS5BTransportInfo) transportInfo.getContents().get(0).getJingleTransport().getInfo();
|
JingleS5BTransportInfo info = (JingleS5BTransportInfo) transportInfo.getContents().get(0).getTransport().getInfo();
|
||||||
|
|
||||||
switch (info.getElementName()) {
|
switch (info.getElementName()) {
|
||||||
case JingleS5BTransportInfo.CandidateUsed.ELEMENT:
|
case JingleS5BTransportInfo.CandidateUsed.ELEMENT:
|
||||||
|
@ -209,7 +209,7 @@ public class JingleS5BTransportSession extends JingleTransportSession<JingleS5BT
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQ handleCandidateUsed(Jingle jingle) {
|
public IQ handleCandidateUsed(Jingle jingle) {
|
||||||
JingleS5BTransportInfo info = (JingleS5BTransportInfo) jingle.getContents().get(0).getJingleTransport().getInfo();
|
JingleS5BTransportInfo info = (JingleS5BTransportInfo) jingle.getContents().get(0).getTransport().getInfo();
|
||||||
String candidateId = ((JingleS5BTransportInfo.CandidateUsed) info).getCandidateId();
|
String candidateId = ((JingleS5BTransportInfo.CandidateUsed) info).getCandidateId();
|
||||||
theirChoice = new UsedCandidate(ourProposal, ourProposal.getCandidate(candidateId), null);
|
theirChoice = new UsedCandidate(ourProposal, ourProposal.getCandidate(candidateId), null);
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,12 @@
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.jingle;
|
package org.jivesoftware.smackx.jingle.provider;
|
||||||
|
|
||||||
import static junit.framework.TestCase.assertEquals;
|
import static junit.framework.TestCase.assertEquals;
|
||||||
import static junit.framework.TestCase.assertNull;
|
import static junit.framework.TestCase.assertNull;
|
||||||
|
|
||||||
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
||||||
import org.jivesoftware.smackx.jingle.provider.JingleContentProviderManager;
|
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.element.JingleIBBTransport;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider;
|
import org.jivesoftware.smackx.jingle.transports.jingle_ibb.provider.JingleIBBTransportProvider;
|
||||||
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
import org.jivesoftware.smackx.jingle.transports.jingle_s5b.elements.JingleS5BTransport;
|
|
@ -0,0 +1,122 @@
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Copyright 2017 Florian Schmaus
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package org.jivesoftware.smackx.jingle.provider;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.jivesoftware.smack.util.PacketParserUtils;
|
||||||
|
|
||||||
|
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
||||||
|
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
import org.xmlpull.v1.XmlPullParserException;
|
||||||
|
|
||||||
|
public class JingleProviderTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParseUnknownJingleContentDescrption() throws Exception {
|
||||||
|
final String unknownJingleContentDescriptionNamespace = "urn:xmpp:jingle:unknown-description:5";
|
||||||
|
final String unknownJingleContentDescription =
|
||||||
|
// @formatter:off
|
||||||
|
"<description xmlns='" + unknownJingleContentDescriptionNamespace + "'>" +
|
||||||
|
"<file>" +
|
||||||
|
"<date>1969-07-21T02:56:15Z</date>" +
|
||||||
|
"<desc>This is a test. If this were a real file...</desc>" +
|
||||||
|
"<media-type>text/plain</media-type>" +
|
||||||
|
"<name>test.txt</name>" +
|
||||||
|
"<range/>" +
|
||||||
|
"<size>6144</size>" +
|
||||||
|
"<hash xmlns='urn:xmpp:hashes:2'" +
|
||||||
|
" algo='sha-1'>w0mcJylzCn+AfvuGdqkty2+KP48=</hash>" +
|
||||||
|
"</file>" +
|
||||||
|
"</description>";
|
||||||
|
// @formatter:on
|
||||||
|
XmlPullParser parser = createTestJingle(unknownJingleContentDescription);
|
||||||
|
Jingle jingle = (Jingle) PacketParserUtils.parseIQ(parser);
|
||||||
|
|
||||||
|
JingleContentDescription jingleContentDescription = jingle.getSoleContentOrThrow().getDescription();
|
||||||
|
|
||||||
|
String parsedUnknownJingleContentDescrptionNamespace = jingleContentDescription.getNamespace();
|
||||||
|
assertEquals(unknownJingleContentDescriptionNamespace, parsedUnknownJingleContentDescrptionNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParseUnknownJingleContentTransport() throws Exception {
|
||||||
|
final String unknownJingleContentTransportNamespace = "urn:xmpp:jingle:unknown-transport:foo:1";
|
||||||
|
final String unknownJingleContentTransport =
|
||||||
|
// @formatter:off
|
||||||
|
"<transport xmlns='" + unknownJingleContentTransportNamespace + "'" +
|
||||||
|
" mode='tcp'" +
|
||||||
|
" sid='vj3hs98y'>" +
|
||||||
|
"<candidate cid='hft54dqy'" +
|
||||||
|
" host='192.168.4.1'" +
|
||||||
|
" jid='romeo@montague.example/dr4hcr0st3lup4c'" +
|
||||||
|
" port='5086'" +
|
||||||
|
" priority='8257636'" +
|
||||||
|
" type='direct'/>" +
|
||||||
|
"<candidate cid='hutr46fe'" +
|
||||||
|
" host='24.24.24.1'" +
|
||||||
|
" jid='romeo@montague.example/dr4hcr0st3lup4c'" +
|
||||||
|
" port='5087'" +
|
||||||
|
" priority='8258636'" +
|
||||||
|
" type='direct'/>" +
|
||||||
|
"</transport>";
|
||||||
|
// @formatter:on
|
||||||
|
XmlPullParser parser = createTestJingle(unknownJingleContentTransport);
|
||||||
|
Jingle jingle = (Jingle) PacketParserUtils.parseIQ(parser);
|
||||||
|
|
||||||
|
JingleContentTransport jingleContentTransport = jingle.getSoleContentOrThrow().getTransport();
|
||||||
|
|
||||||
|
String parsedUnknownJingleContentTransportNamespace = jingleContentTransport.getNamespace();
|
||||||
|
assertEquals(unknownJingleContentTransportNamespace, parsedUnknownJingleContentTransportNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static XmlPullParser createTestJingle(String... childs) throws XmlPullParserException, IOException {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(// @formatter:off
|
||||||
|
"<iq from='romeo@montague.example/dr4hcr0st3lup4c'" +
|
||||||
|
" id='nzu25s8'" +
|
||||||
|
" to='juliet@capulet.example/yn0cl4bnw0yr3vym'" +
|
||||||
|
" type='set'>" +
|
||||||
|
"<jingle xmlns='urn:xmpp:jingle:1' " +
|
||||||
|
" action='session-initiate' " +
|
||||||
|
" initiator='romeo@montague.example/dr4hcr0st3lup4c' " +
|
||||||
|
" sid='851ba2'>" +
|
||||||
|
"<content creator='initiator' name='a-file-offer' senders='initiator'>"
|
||||||
|
// @formatter:on
|
||||||
|
);
|
||||||
|
for (String child : childs) {
|
||||||
|
sb.append(child);
|
||||||
|
}
|
||||||
|
sb.append(// @formatter:off
|
||||||
|
"</content>" +
|
||||||
|
"</jingle>" +
|
||||||
|
"</iq>"
|
||||||
|
// @formatter:on
|
||||||
|
);
|
||||||
|
|
||||||
|
String jingleStanza = sb.toString();
|
||||||
|
|
||||||
|
XmlPullParser parser = PacketParserUtils.getParserFor(jingleStanza);
|
||||||
|
return parser;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue