-
Notifications
You must be signed in to change notification settings - Fork 2
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
base: master
Are you sure you want to change the base?
Changes from 5 commits
28d75b4
1d3a8f4
4cb5efd
11aebc4
ffea943
81d1954
8bf28fb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -947,4 +947,49 @@ 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.2: | ||
* </p> | ||
* <blockquote> In order to delete a node, a node owner MUST send a node | ||
* deletion request, consisting of a <delete/> 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, TimeoutException, ExecutionException { | ||
final String nodename = "sinttest-delete-node-that-exist-" + testRunId; | ||
final String needle = "<event xmlns='http://jabber.org/protocol/pubsub#event'>"; | ||
final String delete_confirm = "<delete node='princely_musings'>"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This won't work. You're creating a node wit a name that starts with |
||
final String regex = "#^." + needle + "." + delete_confirm + ".$#"; | ||
try { | ||
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().matches(regex)); | ||
// Delete an existent node | ||
pubSubManagerOne.deleteNode(nodename); | ||
assertNotNull(result.get(conOne.getReplyTimeout(), TimeUnit.MILLISECONDS)); | ||
} | ||
catch (PubSubException.NotAPubSubNodeException e) { | ||
throw new AssertionError("The published item was not received by the subscriber.", e); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A test can have three results:
Assertions are used to verify expected behavior. When you write a test, you test for a very specific thing to happen. That is where you use an assertion: if the things does not happen, the assertion fails. This means that the test fails. If something unexpected happens - something that went wrong, without it being the subject of the test - then the test should exit in error. By catching There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sometimes I used to have errors due to the duration too long when I made tests |
||
} | ||
} | ||
} |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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. :)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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