Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

catch the TimeoutException #9

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -947,4 +947,50 @@ public void deleteNonExistentNodeTest() throws NoResponseException, XMPPErrorExc
assertEquals(StanzaError.Condition.item_not_found, e.getStanzaError().getCondition());
}
}

/**
* Assert that the server send a notification to subscribers when deleting a
* node that exist
*
* <p>
* From XEP-0060 § 8.4.1:
* </p>
* <blockquote> In order to delete a node, a node owner MUST send a node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't the correct quote. It does not describe what you're testing here!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not yet the complete test. It's just a step

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know. Just leave this comment open until you fixed it. :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quote still is not correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have already changed the quote

* deletion request, consisting of a &lt;delete/&gt; element whose 'node'
* attribute specifies the NodeID of the node to be deleted </bloquote>
*
* @throws NoResponseException if there was no response from
* the remote entity.
* @throws XMPPErrorException if there was an XMPP error
* returned.
* @throws NotConnectedException if the XMPP connection is not
* connected.
* @throws InterruptedException if the calling thread was
* interrupted.
* @throws PubSubException.NotAPubSubNodeException if the node cannot be
* accessed.
*/
@SmackIntegrationTest
public void deleteNodeAndNotifySubscribersTest() throws NoResponseException, XMPPErrorException,
NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException {
final String nodename = "sinttest-delete-node-that-exist-" + testRunId;
final String needle = "<event xmlns='http://jabber.org/protocol/pubsub#event'>";
try {
LeafNode node = pubSubManagerOne.createNode(nodename);
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
subscriberNode.subscribe(subscriber);
final CompletableFuture<Stanza> result = new CompletableFuture<>();
conTwo.addAsyncStanzaListener(result::complete, stanza -> stanza.toXML("").toString().contains(needle));
// Delete an existent node
pubSubManagerOne.deleteNode(nodename);
assertNull(result.get(conOne.getReplyTimeout(), TimeUnit.MILLISECONDS));
} catch (XMPPErrorException e) {
assertEquals(StanzaError.Condition.item_not_found, e.getStanzaError().getCondition());
} catch (ExecutionException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
}
}
}