Remove `TODO:method should not throw any exception but currently does`

`mgr.getNode(...)` method is not supposed to throw any type
of exception. It threw two kinds of exceptions: `NotConnectedException`
and `SmackException`.
By using `ThreadedDummyConnection.newInstance()` method,
`NotConnectedException` can be removed. And `SmackException`
can be removed by correctly building the DiscoverInfo packet.
This commit is contained in:
adiaholic 2020-04-28 13:56:24 +05:30 committed by Florian Schmaus
parent 321c91c264
commit afa42a8b41
1 changed files with 11 additions and 9 deletions

View File

@ -79,23 +79,25 @@ public class ConfigureFormTest extends SmackTestSuite {
}
@Test
public void getConfigFormWithTimeout() throws XMPPException, InterruptedException {
ThreadedDummyConnection con = new ThreadedDummyConnection();
public void getConfigFormWithTimeout() throws XMPPException, InterruptedException, SmackException, IOException {
ThreadedDummyConnection con = ThreadedDummyConnection.newInstance();
PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result");
DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result")
.ofType(IQ.Type.result)
.from(PubSubManagerTest.DUMMY_PUBSUB_SERVICE);
Identity ident = new Identity("pubsub", null, "leaf");
info.addIdentity(ident);
DiscoverInfo discoverInfo = info.build();
con.addIQReply(discoverInfo);
Node node = mgr.getNode("princely_musings");
SmackConfiguration.setDefaultReplyTimeout(100);
con.setTimeout();
assertThrows(SmackException.class, () -> {
// TODO: This method should not throw any exception but currently does.
Node node = mgr.getNode("princely_musings");
SmackConfiguration.setDefaultReplyTimeout(100);
con.setTimeout();
node.getNodeConfiguration();
});
}