2013-02-07 15:19:47 +01:00
|
|
|
/**
|
|
|
|
*
|
2013-04-07 21:15:32 +02:00
|
|
|
* Copyright 2011 Robin Collier
|
2013-02-07 15:19:47 +01:00
|
|
|
*
|
2014-02-17 18:57:38 +01:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
2013-02-07 15:19:47 +01:00
|
|
|
* 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.
|
|
|
|
*/
|
2013-04-07 21:15:32 +02:00
|
|
|
package org.jivesoftware.smackx.filetransfer;
|
|
|
|
|
2020-04-06 13:25:07 +02:00
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
2013-04-07 21:15:32 +02:00
|
|
|
|
|
|
|
import org.jivesoftware.smack.DummyConnection;
|
2014-08-04 18:16:56 +02:00
|
|
|
import org.jivesoftware.smack.SmackException.NoResponseException;
|
2015-02-05 11:17:27 +01:00
|
|
|
import org.jivesoftware.smack.packet.Stanza;
|
2020-04-12 09:34:08 +02:00
|
|
|
import org.jivesoftware.smack.test.util.SmackTestSuite;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2014-02-15 11:35:08 +01:00
|
|
|
import org.jivesoftware.smackx.disco.ServiceDiscoveryManager;
|
2017-06-14 17:12:43 +02:00
|
|
|
|
2020-04-06 13:25:07 +02:00
|
|
|
import org.junit.jupiter.api.AfterEach;
|
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
|
import org.junit.jupiter.api.Test;
|
2015-02-14 17:15:02 +01:00
|
|
|
import org.jxmpp.jid.JidTestUtil;
|
2013-04-07 21:15:32 +02:00
|
|
|
|
2020-04-12 09:34:08 +02:00
|
|
|
public class FileTransferNegotiatorTest extends SmackTestSuite {
|
2013-04-07 21:15:32 +02:00
|
|
|
private DummyConnection connection;
|
|
|
|
|
2020-04-06 13:25:07 +02:00
|
|
|
@BeforeEach
|
2013-04-07 21:15:32 +02:00
|
|
|
public void setUp() throws Exception {
|
|
|
|
connection = new DummyConnection();
|
|
|
|
connection.connect();
|
2014-11-09 18:30:16 +01:00
|
|
|
connection.login();
|
2013-10-26 13:17:16 +02:00
|
|
|
ServiceDiscoveryManager.getInstanceFor(connection);
|
2013-04-07 21:15:32 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 13:25:07 +02:00
|
|
|
@AfterEach
|
2013-04-07 21:15:32 +02:00
|
|
|
public void tearDown() throws Exception {
|
|
|
|
if (connection != null)
|
|
|
|
connection.disconnect();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
public void verifyForm() throws Exception {
|
|
|
|
FileTransferNegotiator fileNeg = FileTransferNegotiator.getInstanceFor(connection);
|
2014-08-04 18:16:56 +02:00
|
|
|
try {
|
2015-02-14 17:15:02 +01:00
|
|
|
fileNeg.negotiateOutgoingTransfer(JidTestUtil.DUMMY_AT_EXAMPLE_ORG, "streamid", "file", 1024, null, 10);
|
2014-08-04 18:16:56 +02:00
|
|
|
} catch (NoResponseException e) {
|
2016-08-26 10:58:00 +02:00
|
|
|
// We do not expect an answer. This unit test only checks the request sent.
|
2014-08-04 18:16:56 +02:00
|
|
|
}
|
2015-02-05 11:17:27 +01:00
|
|
|
Stanza packet = connection.getSentPacket();
|
2019-02-04 13:27:41 +01:00
|
|
|
String xml = packet.toXML().toString();
|
2014-06-19 11:48:01 +02:00
|
|
|
assertTrue(xml.indexOf("var='stream-method' type='list-single'") != -1);
|
2013-04-07 21:15:32 +02:00
|
|
|
}
|
|
|
|
}
|