From afa42a8b4105a969ef1c40df0009d510510ec93a Mon Sep 17 00:00:00 2001 From: adiaholic Date: Tue, 28 Apr 2020 13:56:24 +0530 Subject: [PATCH] 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. --- .../smackx/pubsub/ConfigureFormTest.java | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java index 320acba82..f350bb1ab 100644 --- a/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java +++ b/smack-extensions/src/test/java/org/jivesoftware/smackx/pubsub/ConfigureFormTest.java @@ -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(); }); }