mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-11-27 14:32:06 +01:00
Add (failing) Jingle S5B test
This commit is contained in:
parent
45563b75fe
commit
22a7e38f66
2 changed files with 30 additions and 5 deletions
|
@ -131,7 +131,7 @@ public final class JingleFileTransferManager extends Manager implements JingleDe
|
|||
public void notifyIncomingFileOfferListeners(JingleIncomingFileOffer offer) {
|
||||
LOGGER.log(Level.INFO, "Incoming File transfer: [" + offer.getNamespace() + ", "
|
||||
+ offer.getParent().getTransport().getNamespace() + ", "
|
||||
+ offer.getParent().getSecurity().getNamespace());
|
||||
+ (offer.getParent().getSecurity() != null ? offer.getParent().getSecurity().getNamespace() : "") + "]");
|
||||
for (IncomingFileOfferListener l : offerListeners) {
|
||||
l.onIncomingFileOffer(offer);
|
||||
}
|
||||
|
|
|
@ -26,9 +26,15 @@ import java.util.logging.Level;
|
|||
|
||||
import org.jivesoftware.smack.util.Async;
|
||||
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
|
||||
import org.jivesoftware.smackx.jingle.JingleManager;
|
||||
import org.jivesoftware.smackx.jingle.callbacks.JingleTransportCallback;
|
||||
import org.jivesoftware.smackx.jingle.components.JingleContent;
|
||||
import org.jivesoftware.smackx.jingle.components.JingleSession;
|
||||
import org.jivesoftware.smackx.jingle.components.JingleTransport;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentElement;
|
||||
import org.jivesoftware.smackx.jingle.transport.jingle_ibb.JingleIBBTransport;
|
||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.JingleS5BTransport;
|
||||
import org.jivesoftware.smackx.jingle.transport.jingle_s5b.JingleS5BTransportManager;
|
||||
import org.jivesoftware.smackx.jingle.util.Role;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest;
|
||||
|
@ -40,17 +46,36 @@ import org.junit.Assert;
|
|||
/**
|
||||
* Test the JingleIBBTransport in a very basic case.
|
||||
*/
|
||||
public class JingleIBBTransportTest extends AbstractSmackIntegrationTest {
|
||||
public class JingleTransportTest extends AbstractSmackIntegrationTest {
|
||||
|
||||
public JingleIBBTransportTest(SmackIntegrationTestEnvironment environment) {
|
||||
public JingleTransportTest(SmackIntegrationTestEnvironment environment) {
|
||||
super(environment);
|
||||
}
|
||||
|
||||
@SmackIntegrationTest
|
||||
public void basicJIBBTTest() throws Exception {
|
||||
public void JingleIBBTest() throws Exception {
|
||||
JingleIBBTransport sender = new JingleIBBTransport();
|
||||
final JingleIBBTransport receiver = new JingleIBBTransport(sender.getSid(), sender.getBlockSize());
|
||||
|
||||
basicTransportTest(sender, receiver);
|
||||
}
|
||||
|
||||
@SmackIntegrationTest
|
||||
public void JingleS5BTest() throws Exception {
|
||||
JingleSession sSession = new JingleSession(JingleManager.getInstanceFor(conOne), conOne.getUser().asFullJidOrThrow(), conTwo.getUser().asFullJidOrThrow(), Role.initiator, "session");
|
||||
JingleSession rSession = new JingleSession(JingleManager.getInstanceFor(conTwo), conTwo.getUser().asFullJidOrThrow(), conOne.getUser().asFullJidOrThrow(), Role.responder, "session");
|
||||
JingleContent sContent = new JingleContent(null, null, null, "content", null, JingleContentElement.Creator.initiator, JingleContentElement.Senders.initiator);
|
||||
JingleContent rContent = new JingleContent(null, null, null, "content", null, JingleContentElement.Creator.initiator, JingleContentElement.Senders.initiator);
|
||||
sSession.addContent(sContent);
|
||||
rSession.addContent(rContent);
|
||||
JingleS5BTransport sender = (JingleS5BTransport) JingleS5BTransportManager.getInstanceFor(conOne).createTransport(sContent);
|
||||
JingleS5BTransport receiver = (JingleS5BTransport) JingleS5BTransportManager.getInstanceFor(conTwo).createTransport(rContent, sender);
|
||||
|
||||
basicTransportTest(sender, receiver);
|
||||
}
|
||||
|
||||
|
||||
public void basicTransportTest(final JingleTransport<?> sender, final JingleTransport<?> receiver) throws Exception {
|
||||
JingleSession senderSession = new JingleSession(null, conTwo.getUser().asFullJidOrThrow(), conOne.getUser().asFullJidOrThrow(), Role.initiator, "sid");
|
||||
JingleSession receiverSession = new JingleSession(null, conTwo.getUser().asFullJidOrThrow(), conOne.getUser().asFullJidOrThrow(), Role.responder, "sid");
|
||||
|
||||
|
@ -71,7 +96,7 @@ public class JingleIBBTransportTest extends AbstractSmackIntegrationTest {
|
|||
try {
|
||||
InputStream inputStream = bytestreamSession.getInputStream();
|
||||
|
||||
byte[] buf = new byte[receiver.getBlockSize()];
|
||||
byte[] buf = new byte[512];
|
||||
int read = 0;
|
||||
while (read < size) {
|
||||
int r = inputStream.read(buf);
|
Loading…
Reference in a new issue