mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-25 03:57:58 +01:00
Fix checkstyle issues in PubSubIntegrationTest
This commit is contained in:
parent
04e5f78411
commit
f3740fe53d
1 changed files with 230 additions and 286 deletions
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
*
|
||||
* Copyright 2015-2020 Florian Schmaus
|
||||
* Copyright 2015-2020 Florian Schmaus, Guus der Kinderen, Paul Schaub
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
@ -16,31 +16,13 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.pubsub;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.*;
|
||||
|
||||
import org.jivesoftware.smackx.geoloc.packet.GeoLocation;
|
||||
import org.jivesoftware.smackx.pubsub.form.FillableSubscribeForm;
|
||||
import org.jivesoftware.smackx.pubsub.form.SubscribeForm;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
import org.jivesoftware.smackx.pubsub.form.ConfigureForm;
|
||||
import org.jivesoftware.smackx.pubsub.form.FillableConfigureForm;
|
||||
import org.jivesoftware.smackx.xdata.packet.DataForm;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
||||
import org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest;
|
||||
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
@ -48,13 +30,38 @@ import java.util.concurrent.ExecutionException;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
||||
import org.jivesoftware.smack.SmackConfiguration;
|
||||
import org.jivesoftware.smack.SmackException;
|
||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.StandardExtensionElement;
|
||||
import org.jivesoftware.smack.packet.Stanza;
|
||||
import org.jivesoftware.smack.packet.StanzaError;
|
||||
import org.jivesoftware.smack.packet.XmlEnvironment;
|
||||
import org.jivesoftware.smackx.geoloc.packet.GeoLocation;
|
||||
import org.jivesoftware.smackx.pubsub.form.ConfigureForm;
|
||||
import org.jivesoftware.smackx.pubsub.form.FillableConfigureForm;
|
||||
import org.jivesoftware.smackx.pubsub.form.FillableSubscribeForm;
|
||||
import org.jivesoftware.smackx.pubsub.packet.PubSub;
|
||||
|
||||
import org.igniterealtime.smack.inttest.AbstractSmackIntegrationTest;
|
||||
import org.igniterealtime.smack.inttest.SmackIntegrationTestEnvironment;
|
||||
import org.igniterealtime.smack.inttest.TestNotPossibleException;
|
||||
import org.igniterealtime.smack.inttest.annotations.SmackIntegrationTest;
|
||||
import org.jxmpp.jid.DomainBareJid;
|
||||
import org.jxmpp.jid.EntityBareJid;
|
||||
import org.jxmpp.jid.impl.JidCreate;
|
||||
import org.jxmpp.stringprep.XmppStringprepException;
|
||||
|
||||
public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||
|
||||
private final PubSubManager pubSubManagerOne;
|
||||
private final PubSubManager pubSubManagerTwo;
|
||||
|
||||
public PubSubIntegrationTest(SmackIntegrationTestEnvironment environment)
|
||||
throws TestNotPossibleException, NoResponseException, XMPPErrorException,
|
||||
throws TestNotPossibleException, SmackException.NoResponseException, XMPPErrorException,
|
||||
NotConnectedException, InterruptedException {
|
||||
super(environment);
|
||||
DomainBareJid pubSubService = PubSubManager.getPubSubService(conOne);
|
||||
|
@ -88,8 +95,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
// Retrieve items and assert that the item that was just published is among them.
|
||||
final List<Item> items = node.getItems();
|
||||
assertTrue(items.stream().anyMatch(stanza -> stanza.toXML().toString().contains(needle)));
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -117,12 +123,9 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final List<Subscription> subscriptions = pubSubManagerTwo.getNode(nodename).getSubscriptions();
|
||||
assertNotNull(subscriptions);
|
||||
assertTrue(subscriptions.stream().anyMatch(s -> subscriber.equals(s.getJid())));
|
||||
}
|
||||
catch ( PubSubException.NotAPubSubNodeException e )
|
||||
{
|
||||
} catch (PubSubException.NotAPubSubNodeException e) {
|
||||
throw new AssertionError("The published item was not received by the subscriber.", e);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -153,8 +156,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribeJIDsDoNotMatchTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, XmppStringprepException, PubSubException.NotAPubSubNodeException
|
||||
{
|
||||
public void subscribeJIDsDoNotMatchTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, XmppStringprepException, PubSubException.NotAPubSubNodeException {
|
||||
final String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||
pubSubManagerOne.createNode(nodename);
|
||||
try {
|
||||
|
@ -163,12 +165,9 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final EntityBareJid subscriber = JidCreate.entityBareFrom("this-jid-does-not-match@example.org");
|
||||
subscriberNode.subscribe(subscriber);
|
||||
fail("The server should have returned a <bad-request/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e )
|
||||
{
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.bad_request, e.getStanzaError().getCondition());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -192,8 +191,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribePresenceSubscriptionRequiredTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void subscribePresenceSubscriptionRequiredTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
final String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||
|
@ -209,12 +207,9 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||
subscriberNode.subscribe(subscriber);
|
||||
fail("The server should have returned a <not-authorized/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e )
|
||||
{
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.not_authorized, e.getStanzaError().getCondition());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -238,8 +233,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribeNotInRosterGroupTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void subscribeNotInRosterGroupTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
final String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||
|
@ -255,12 +249,9 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||
subscriberNode.subscribe(subscriber);
|
||||
fail("The server should have returned a <not-authorized/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e )
|
||||
{
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.not_authorized, e.getStanzaError().getCondition());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -285,8 +276,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribeNotOnWhitelistTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void subscribeNotOnWhitelistTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
final String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||
|
@ -302,13 +292,10 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||
subscriberNode.subscribe(subscriber);
|
||||
fail("The server should have returned a <not-allowed/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e )
|
||||
{
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.not_allowed, e.getStanzaError().getCondition());
|
||||
assertNotNull(e.getStanzaError().getExtension("closed-node", "http://jabber.org/protocol/pubsub#errors"));
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -332,8 +319,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribePendingSubscriptionTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void subscribePendingSubscriptionTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
final String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||
|
@ -350,13 +336,10 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
subscriberNode.subscribe(subscriber);
|
||||
subscriberNode.subscribe(subscriber);
|
||||
fail("The server should have returned a <not-authorized/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e )
|
||||
{
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.not_authorized, e.getStanzaError().getCondition());
|
||||
assertNotNull(e.getStanzaError().getExtension("pending-subscription", "http://jabber.org/protocol/pubsub#errors"));
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -379,8 +362,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribeApprovalRequiredGeneratesNotificationTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void subscribeApprovalRequiredGeneratesNotificationTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
final String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||
|
@ -397,8 +379,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final Subscription result = subscriberNode.subscribe(subscriber);
|
||||
|
||||
assertEquals(Subscription.State.pending, result.getState());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -424,8 +405,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribeMultipleSubscriptionsTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void subscribeMultipleSubscriptionsTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
if (!pubSubManagerOne.getSupportedFeatures().containsFeature(PubSubFeature.multi_subscribe)) {
|
||||
throw new TestNotPossibleException("Feature 'multi-subscribe' not supported on the server.");
|
||||
}
|
||||
|
@ -448,8 +428,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
assertNotNull(subscriptionA.getId());
|
||||
assertNotNull(subscriptionB.getId());
|
||||
assertNotEquals(subscriptionA.getId(), subscriptionB.getId());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -474,8 +453,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void subscribeMultipleSubscriptionNotSupportedTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void subscribeMultipleSubscriptionNotSupportedTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
if (pubSubManagerOne.getSupportedFeatures().containsFeature(PubSubFeature.multi_subscribe)) {
|
||||
throw new TestNotPossibleException("Feature 'multi-subscribe' allowed on the server (this test verifies behavior for when it's not).");
|
||||
}
|
||||
|
@ -499,8 +477,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final String normalizedRepresentationA = subscriptionA.toXML(XmlEnvironment.EMPTY).toString();
|
||||
final String normalizedRepresentationB = subscriptionB.toXML(XmlEnvironment.EMPTY).toString();
|
||||
assertEquals(normalizedRepresentationA, normalizedRepresentationB);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -521,8 +498,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws PubSubException.NotAPubSubNodeException If an error occurred while creating the node.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void unsubscribeTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException
|
||||
{
|
||||
public void unsubscribeTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException {
|
||||
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||
pubSubManagerOne.createNode(nodename);
|
||||
|
||||
|
@ -534,12 +510,10 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
try {
|
||||
subscriberNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||
}
|
||||
catch ( NoResponseException | XMPPErrorException e ) {
|
||||
} catch (NoResponseException | XMPPErrorException e) {
|
||||
throw new AssertionError("Unsubscribe from a node failed.", e);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -564,8 +538,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void unsubscribeNoSubscriptionIDTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void unsubscribeNoSubscriptionIDTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
if (!pubSubManagerOne.getSupportedFeatures().containsFeature(PubSubFeature.multi_subscribe)) {
|
||||
throw new TestNotPossibleException("Feature 'multi-subscribe' not supported on the server.");
|
||||
}
|
||||
|
@ -588,12 +561,10 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
try {
|
||||
subscriberNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||
fail("The server should have returned a <bad_request/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e ) {
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.bad_request, e.getStanzaError().getCondition());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -615,8 +586,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void unsubscribeNoSuchSubscriberTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException
|
||||
{
|
||||
public void unsubscribeNoSuchSubscriberTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException {
|
||||
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||
pubSubManagerOne.createNode(nodename);
|
||||
|
||||
|
@ -627,11 +597,9 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
subscriberNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||
fail("The server should have returned an error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e ) {
|
||||
} catch (XMPPErrorException e) {
|
||||
// SHOULD be <unexpected-request/> (but that's not a 'MUST')
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -653,8 +621,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void unsubscribeInsufficientPrivilegesTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException
|
||||
{
|
||||
public void unsubscribeInsufficientPrivilegesTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException {
|
||||
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||
final PubSubManager pubSubManagerThree = PubSubManager.getInstanceFor(conThree, PubSubManager.getPubSubService(conThree));
|
||||
pubSubManagerOne.createNode(nodename);
|
||||
|
@ -669,12 +636,10 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
try {
|
||||
unprivilegedNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||
fail("The server should have returned a <forbidden/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e ) {
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.forbidden, e.getStanzaError().getCondition());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -695,8 +660,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void unsubscribeNodeDoesNotExistTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||
{
|
||||
public void unsubscribeNodeDoesNotExistTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||
try {
|
||||
// Smack righteously doesn't facilitate unsubscribing from a non-existing node. Manually crafting stanza:
|
||||
|
@ -705,12 +669,10 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
try {
|
||||
pubSubManagerOne.sendPubsubPacket(unsubscribe);
|
||||
fail("The server should have returned a <item-not-found/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e ) {
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.item_not_found, e.getStanzaError().getCondition());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -735,8 +697,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void unsubscribeBadSubscriptionIDTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException
|
||||
{
|
||||
public void unsubscribeBadSubscriptionIDTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException, TestNotPossibleException {
|
||||
// Depending on multi-subscribe is a fail-safe way to be sure that subscription IDs will exist.
|
||||
if (!pubSubManagerOne.getSupportedFeatures().containsFeature(PubSubFeature.multi_subscribe)) {
|
||||
throw new TestNotPossibleException("Feature 'multi-subscribe' not supported on the server.");
|
||||
|
@ -760,12 +721,10 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
try {
|
||||
subscriberNode.unsubscribe(subscriber.asEntityBareJidString(), "this-is-not-an-existing-subscription-id");
|
||||
fail("The server should have returned a <not-acceptable/> error, but did not.");
|
||||
}
|
||||
catch ( XMPPErrorException e ) {
|
||||
} catch (XMPPErrorException e) {
|
||||
assertEquals(StanzaError.Condition.not_acceptable, e.getStanzaError().getCondition());
|
||||
}
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -787,8 +746,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void getEmptySubscriptionsTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException
|
||||
{
|
||||
public void getEmptySubscriptionsTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, PubSubException.NotAPubSubNodeException {
|
||||
final String nodename = "sinttest-get-empty-subscriptions-test-nodename-" + testRunId;
|
||||
pubSubManagerOne.createNode(nodename);
|
||||
try {
|
||||
|
@ -796,8 +754,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
final List<Subscription> subscriptions = pubSubManagerTwo.getNode(nodename).getSubscriptions();
|
||||
assertNotNull(subscriptions);
|
||||
assertTrue(subscriptions.isEmpty());
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -813,8 +770,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws PubSubException if the involved node is not a pubsub node.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void receivePublishedItemTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, ExecutionException, PubSubException
|
||||
{
|
||||
public void receivePublishedItemTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException, ExecutionException, PubSubException {
|
||||
final String nodename = "sinttest-receive-published-item-nodename-" + testRunId;
|
||||
final String needle = "test content " + Math.random();
|
||||
LeafNode publisherNode = pubSubManagerOne.createNode(nodename);
|
||||
|
@ -829,12 +785,9 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
publisherNode.publish(new PayloadItem<>(GeoLocation.builder().setDescription(needle).build()));
|
||||
|
||||
assertNotNull(result.get(conOne.getReplyTimeout(), TimeUnit.MILLISECONDS));
|
||||
}
|
||||
catch ( TimeoutException e )
|
||||
{
|
||||
} catch (TimeoutException e) {
|
||||
throw new AssertionError("The published item was not received by the subscriber.", e);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -861,8 +814,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
try {
|
||||
LeafNode leafNode = (LeafNode) node;
|
||||
leafNode.publish();
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -916,8 +868,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
});
|
||||
assertEquals(StanzaError.Type.MODIFY, e.getStanzaError().getType());
|
||||
assertNotNull(e.getStanzaError().getExtension("item-forbidden", "http://jabber.org/protocol/pubsub#errors"));
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
@ -948,7 +899,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
|
||||
/**
|
||||
* Assert that the server send a notification to subscribers when deleting a
|
||||
* node that exist
|
||||
* node that exist.
|
||||
*
|
||||
* <p>
|
||||
* From XEP-0060 § 8.4.1:
|
||||
|
@ -957,14 +908,11 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* deletion request, consisting of a <delete/> element whose 'node'
|
||||
* attribute specifies the NodeID of the node to be deleted </blockquote>
|
||||
*
|
||||
* @throws NoResponseException if there was no response from
|
||||
* the remote entity.
|
||||
* @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.
|
||||
* @throws NoResponseException if there was no response from the remote entity.
|
||||
* @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.
|
||||
* @throws ExecutionException if the execution was aborted by an exception
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void deleteNodeAndNotifySubscribersTest() throws NoResponseException, ExecutionException,
|
||||
|
@ -972,7 +920,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
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);
|
||||
@SuppressWarnings("unused") LeafNode node = pubSubManagerOne.createNode(nodename);
|
||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||
subscriberNode.subscribe(subscriber);
|
||||
|
@ -1005,8 +953,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
* @throws InterruptedException if the calling thread was interrupted.
|
||||
*/
|
||||
@SmackIntegrationTest
|
||||
public void publishOverrideItemTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
||||
{
|
||||
public void publishOverrideItemTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||
final String nodename = "sinttest-publish-item-nodename-" + testRunId;
|
||||
final String itemId = "reused-id-for-testrun-" + testRunId;
|
||||
final String needleA = "test content A" + Math.random();
|
||||
|
@ -1018,8 +965,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
config.setMaxItems(2);
|
||||
|
||||
LeafNode node = (LeafNode) pubSubManagerOne.createNode(nodename, config);
|
||||
try
|
||||
{
|
||||
try {
|
||||
// Publish a new item.
|
||||
node.publish(new PayloadItem<>(itemId, GeoLocation.builder().setDescription(needleA).build()));
|
||||
node.publish(new PayloadItem<>(itemId, GeoLocation.builder().setDescription(needleB).build()));
|
||||
|
@ -1031,9 +977,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
|||
assertEquals(itemId, item.getId());
|
||||
assertFalse(item.toXML().toString().contains(needleA));
|
||||
assertTrue(item.toXML().toString().contains(needleB));
|
||||
}
|
||||
finally
|
||||
{
|
||||
} finally {
|
||||
pubSubManagerOne.deleteNode(nodename);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue