1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-15 03:59:38 +02:00

Introduce packet.Element

Re-work filetransfer/bytestream stanza toXML() method to use
XmlStringBuilder. Move the ELEMENT and NAMESPACE definitions in the
right place, ie. the stanza class.
This commit is contained in:
Florian Schmaus 2014-07-05 11:58:13 +02:00
parent f05b208120
commit 8526f8ab29
20 changed files with 203 additions and 199 deletions

View file

@ -99,7 +99,7 @@ public class InBandBytestreamSessionMessageTest {
public void verify(Message request, IQ response) {
DataPacketExtension dpe = (DataPacketExtension) request.getExtension(
DataPacketExtension.ELEMENT_NAME, InBandBytestreamManager.NAMESPACE);
DataPacketExtension.ELEMENT, DataPacketExtension.NAMESPACE);
assertEquals(lastSeq++, dpe.getSeq());
}

View file

@ -93,7 +93,7 @@ public class DataPacketExtensionTest {
.asString(outputProperties);
DataPacketExtension data = new DataPacketExtension("i781hf64", 0, "DATA");
assertXMLEqual(control, data.toXML());
assertXMLEqual(control, data.toXML().toString());
}
}

View file

@ -18,13 +18,13 @@ package org.jivesoftware.smackx.bytestreams.ibb.packet;
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.*;
import java.util.Properties;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smack.util.XmlStringBuilder;
import org.jivesoftware.smackx.bytestreams.ibb.packet.Data;
import org.jivesoftware.smackx.bytestreams.ibb.packet.DataPacketExtension;
import org.junit.Test;
@ -72,12 +72,14 @@ public class DataTest {
.asString(outputProperties);
DataPacketExtension dpe = mock(DataPacketExtension.class);
String dataTag = XMLBuilder.create("data")
.a("xmlns", "http://jabber.org/protocol/ibb")
.a("seq", "0")
.a("sid", "i781hf64")
.t(encodedData)
.asString(outputProperties);
XmlStringBuilder dataTag = new XmlStringBuilder();
dataTag.halfOpenElement(DataPacketExtension.ELEMENT);
dataTag.xmlnsAttribute(DataPacketExtension.NAMESPACE);
dataTag.attribute("seq", "0");
dataTag.attribute("sid", "i781hf64");
dataTag.rightAngelBracket();
dataTag.escape(encodedData);
dataTag.closeElement(DataPacketExtension.ELEMENT);
when(dpe.toXML()).thenReturn(dataTag);
Data data = new Data(dpe);
data.setFrom("romeo@montague.lit/orchard");

View file

@ -127,11 +127,11 @@ public class Socks5ByteStreamManagerTest {
Socks5BytestreamManager byteStreamManager = Socks5BytestreamManager.getBytestreamManager(connection);
ServiceDiscoveryManager discoveryManager = ServiceDiscoveryManager.getInstanceFor(connection);
assertTrue(discoveryManager.includesFeature(Socks5BytestreamManager.NAMESPACE));
assertTrue(discoveryManager.includesFeature(Bytestream.NAMESPACE));
byteStreamManager.disableService();
assertFalse(discoveryManager.includesFeature(Socks5BytestreamManager.NAMESPACE));
assertFalse(discoveryManager.includesFeature(Bytestream.NAMESPACE));
}
/**
@ -182,7 +182,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -233,7 +233,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -297,7 +297,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -388,7 +388,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -478,7 +478,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -560,7 +560,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -654,7 +654,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -773,7 +773,7 @@ public class Socks5ByteStreamManagerTest {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,
@ -1003,7 +1003,7 @@ public class Socks5ByteStreamManagerTest {
private void createResponses(Verification<Bytestream, Bytestream> streamHostUsedVerification) {
// build discover info that supports the SOCKS5 feature
DiscoverInfo discoverInfo = Socks5PacketUtils.createDiscoverInfo(targetJID, initiatorJID);
discoverInfo.addFeature(Socks5BytestreamManager.NAMESPACE);
discoverInfo.addFeature(Bytestream.NAMESPACE);
// return that SOCKS5 is supported if target is queried
protocol.addResponse(discoverInfo, Verification.correspondingSenderReceiver,