mirror of
https://github.com/vanitasvitae/Smack.git
synced 2024-12-25 12:08:00 +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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -16,31 +16,13 @@
|
||||||
*/
|
*/
|
||||||
package org.jivesoftware.smackx.pubsub;
|
package org.jivesoftware.smackx.pubsub;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||||
import org.jivesoftware.smack.SmackException.NoResponseException;
|
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||||
import org.jivesoftware.smack.SmackException.NotConnectedException;
|
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||||
import org.jivesoftware.smack.XMPPException.XMPPErrorException;
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
import org.jivesoftware.smack.packet.*;
|
import static org.junit.jupiter.api.Assertions.fail;
|
||||||
|
|
||||||
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 java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
@ -48,13 +30,38 @@ import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.TimeoutException;
|
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 {
|
public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
|
|
||||||
private final PubSubManager pubSubManagerOne;
|
private final PubSubManager pubSubManagerOne;
|
||||||
private final PubSubManager pubSubManagerTwo;
|
private final PubSubManager pubSubManagerTwo;
|
||||||
|
|
||||||
public PubSubIntegrationTest(SmackIntegrationTestEnvironment environment)
|
public PubSubIntegrationTest(SmackIntegrationTestEnvironment environment)
|
||||||
throws TestNotPossibleException, NoResponseException, XMPPErrorException,
|
throws TestNotPossibleException, SmackException.NoResponseException, XMPPErrorException,
|
||||||
NotConnectedException, InterruptedException {
|
NotConnectedException, InterruptedException {
|
||||||
super(environment);
|
super(environment);
|
||||||
DomainBareJid pubSubService = PubSubManager.getPubSubService(conOne);
|
DomainBareJid pubSubService = PubSubManager.getPubSubService(conOne);
|
||||||
|
@ -83,14 +90,13 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
LeafNode node = pubSubManagerOne.createNode(nodename);
|
LeafNode node = pubSubManagerOne.createNode(nodename);
|
||||||
try {
|
try {
|
||||||
// Publish a new item.
|
// Publish a new item.
|
||||||
node.publish( new PayloadItem<>( GeoLocation.builder().setDescription( needle ).build() ) );
|
node.publish(new PayloadItem<>(GeoLocation.builder().setDescription(needle).build()));
|
||||||
|
|
||||||
// Retrieve items and assert that the item that was just published is among them.
|
// Retrieve items and assert that the item that was just published is among them.
|
||||||
final List<Item> items = node.getItems();
|
final List<Item> items = node.getItems();
|
||||||
assertTrue( items.stream().anyMatch( stanza -> stanza.toXML().toString().contains( needle ) ) );
|
assertTrue(items.stream().anyMatch(stanza -> stanza.toXML().toString().contains(needle)));
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,20 +116,17 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
final Subscription subscription = subscriberNode.subscribe( subscriber );
|
final Subscription subscription = subscriberNode.subscribe(subscriber);
|
||||||
assertNotNull( subscription );
|
assertNotNull(subscription);
|
||||||
|
|
||||||
// Assert that subscription is correctly reported when the subscriber requests its subscriptions.
|
// Assert that subscription is correctly reported when the subscriber requests its subscriptions.
|
||||||
final List<Subscription> subscriptions = pubSubManagerTwo.getNode( nodename ).getSubscriptions();
|
final List<Subscription> subscriptions = pubSubManagerTwo.getNode(nodename).getSubscriptions();
|
||||||
assertNotNull( subscriptions );
|
assertNotNull(subscriptions);
|
||||||
assertTrue( subscriptions.stream().anyMatch( s -> subscriber.equals(s.getJid())) );
|
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);
|
throw new AssertionError("The published item was not received by the subscriber.", e);
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,23 +156,19 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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;
|
final String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode(nodename);
|
pubSubManagerOne.createNode(nodename);
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = JidCreate.entityBareFrom( "this-jid-does-not-match@example.org" );
|
final EntityBareJid subscriber = JidCreate.entityBareFrom("this-jid-does-not-match@example.org");
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
fail( "The server should have returned a <bad-request/> error, but did not." );
|
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 {
|
||||||
assertEquals( StanzaError.Condition.bad_request, e.getStanzaError().getCondition() );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -192,30 +191,26 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||||
config.setAccessModel(AccessModel.presence);
|
config.setAccessModel(AccessModel.presence);
|
||||||
try {
|
try {
|
||||||
pubSubManagerOne.createNode( nodename, config );
|
pubSubManagerOne.createNode(nodename, config);
|
||||||
} catch ( XMPPErrorException e ) {
|
} catch (XMPPErrorException e) {
|
||||||
throw new TestNotPossibleException( "Access model 'presence' not supported on the server." );
|
throw new TestNotPossibleException("Access model 'presence' not supported on the server.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
fail( "The server should have returned a <not-authorized/> error, but did not." );
|
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 {
|
||||||
assertEquals( StanzaError.Condition.not_authorized, e.getStanzaError().getCondition() );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,30 +233,26 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||||
config.setAccessModel(AccessModel.roster);
|
config.setAccessModel(AccessModel.roster);
|
||||||
try {
|
try {
|
||||||
pubSubManagerOne.createNode( nodename, config );
|
pubSubManagerOne.createNode(nodename, config);
|
||||||
} catch ( XMPPErrorException e ) {
|
} catch (XMPPErrorException e) {
|
||||||
throw new TestNotPossibleException( "Access model 'roster' not supported on the server." );
|
throw new TestNotPossibleException("Access model 'roster' not supported on the server.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
fail( "The server should have returned a <not-authorized/> error, but did not." );
|
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 {
|
||||||
assertEquals( StanzaError.Condition.not_authorized, e.getStanzaError().getCondition() );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,31 +276,27 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||||
config.setAccessModel(AccessModel.whitelist);
|
config.setAccessModel(AccessModel.whitelist);
|
||||||
try {
|
try {
|
||||||
pubSubManagerOne.createNode( nodename, config );
|
pubSubManagerOne.createNode(nodename, config);
|
||||||
} catch ( XMPPErrorException e ) {
|
} catch (XMPPErrorException e) {
|
||||||
throw new TestNotPossibleException( "Access model 'whitelist' not supported on the server." );
|
throw new TestNotPossibleException("Access model 'whitelist' not supported on the server.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
fail( "The server should have returned a <not-allowed/> error, but did not." );
|
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"));
|
||||||
assertEquals( StanzaError.Condition.not_allowed, e.getStanzaError().getCondition() );
|
} finally {
|
||||||
assertNotNull( e.getStanzaError().getExtension( "closed-node", "http://jabber.org/protocol/pubsub#errors" ));
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,32 +319,28 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||||
config.setAccessModel(AccessModel.authorize);
|
config.setAccessModel(AccessModel.authorize);
|
||||||
try {
|
try {
|
||||||
pubSubManagerOne.createNode( nodename, config );
|
pubSubManagerOne.createNode(nodename, config);
|
||||||
} catch ( XMPPErrorException e ) {
|
} catch (XMPPErrorException e) {
|
||||||
throw new TestNotPossibleException( "Access model 'authorize' not supported on the server." );
|
throw new TestNotPossibleException("Access model 'authorize' not supported on the server.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
fail( "The server should have returned a <not-authorized/> error, but did not." );
|
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"));
|
||||||
assertEquals( StanzaError.Condition.not_authorized, e.getStanzaError().getCondition() );
|
} finally {
|
||||||
assertNotNull( e.getStanzaError().getExtension( "pending-subscription", "http://jabber.org/protocol/pubsub#errors" ));
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -379,27 +362,25 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 String nodename = "sinttest-subscribe-nodename-" + testRunId;
|
||||||
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
final ConfigureForm defaultConfiguration = pubSubManagerOne.getDefaultConfiguration();
|
||||||
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
final FillableConfigureForm config = defaultConfiguration.getFillableForm();
|
||||||
config.setAccessModel(AccessModel.authorize);
|
config.setAccessModel(AccessModel.authorize);
|
||||||
try {
|
try {
|
||||||
pubSubManagerOne.createNode( nodename, config );
|
pubSubManagerOne.createNode(nodename, config);
|
||||||
} catch ( XMPPErrorException e ) {
|
} catch (XMPPErrorException e) {
|
||||||
throw new TestNotPossibleException( "Access model 'authorize' not supported on the server." );
|
throw new TestNotPossibleException("Access model 'authorize' not supported on the server.");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
final Subscription result = subscriberNode.subscribe( subscriber );
|
final Subscription result = subscriberNode.subscribe(subscriber);
|
||||||
|
|
||||||
assertEquals( Subscription.State.pending, result.getState() );
|
assertEquals(Subscription.State.pending, result.getState());
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -424,33 +405,31 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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)) {
|
||||||
if ( !pubSubManagerOne.getSupportedFeatures().containsFeature( PubSubFeature.multi_subscribe ) ) {
|
throw new TestNotPossibleException("Feature 'multi-subscribe' not supported on the server.");
|
||||||
throw new TestNotPossibleException( "Feature 'multi-subscribe' not supported on the server." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String nodename = "sinttest-multisubscribe-nodename-" + testRunId;
|
final String nodename = "sinttest-multisubscribe-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode( nodename );
|
pubSubManagerOne.createNode(nodename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node twice, using different configuration
|
// Subscribe to the node twice, using different configuration
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formA.setDigestFrequency( 1 );
|
formA.setDigestFrequency(1);
|
||||||
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formB.setDigestFrequency( 2 );
|
formB.setDigestFrequency(2);
|
||||||
|
|
||||||
final Subscription subscriptionA = subscriberNode.subscribe( subscriber, formA );
|
final Subscription subscriptionA = subscriberNode.subscribe(subscriber, formA);
|
||||||
final Subscription subscriptionB = subscriberNode.subscribe( subscriber, formB );
|
final Subscription subscriptionB = subscriberNode.subscribe(subscriber, formB);
|
||||||
|
|
||||||
assertNotNull( subscriptionA.getId() );
|
assertNotNull(subscriptionA.getId());
|
||||||
assertNotNull( subscriptionB.getId() );
|
assertNotNull(subscriptionB.getId());
|
||||||
assertNotEquals( subscriptionA.getId(), subscriptionB.getId() );
|
assertNotEquals(subscriptionA.getId(), subscriptionB.getId());
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,34 +453,32 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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)) {
|
||||||
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).");
|
||||||
throw new TestNotPossibleException( "Feature 'multi-subscribe' allowed on the server (this test verifies behavior for when it's not)." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String nodename = "sinttest-multisubscribe-nodename-" + testRunId;
|
final String nodename = "sinttest-multisubscribe-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode( nodename );
|
pubSubManagerOne.createNode(nodename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node twice, using different configuration
|
// Subscribe to the node twice, using different configuration
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formA.setDigestFrequency( 1 );
|
formA.setDigestFrequency(1);
|
||||||
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formB.setDigestFrequency( 2 );
|
formB.setDigestFrequency(2);
|
||||||
|
|
||||||
final Subscription subscriptionA = subscriberNode.subscribe( subscriber, formA );
|
final Subscription subscriptionA = subscriberNode.subscribe(subscriber, formA);
|
||||||
final Subscription subscriptionB = subscriberNode.subscribe( subscriber, formB );
|
final Subscription subscriptionB = subscriberNode.subscribe(subscriber, formB);
|
||||||
|
|
||||||
// A poor-man's "equal"
|
// A poor-man's "equal"
|
||||||
final String normalizedRepresentationA = subscriptionA.toXML( XmlEnvironment.EMPTY ).toString();
|
final String normalizedRepresentationA = subscriptionA.toXML(XmlEnvironment.EMPTY).toString();
|
||||||
final String normalizedRepresentationB = subscriptionB.toXML( XmlEnvironment.EMPTY ).toString();
|
final String normalizedRepresentationB = subscriptionB.toXML(XmlEnvironment.EMPTY).toString();
|
||||||
assertEquals( normalizedRepresentationA, normalizedRepresentationB );
|
assertEquals(normalizedRepresentationA, normalizedRepresentationB);
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -521,26 +498,23 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws PubSubException.NotAPubSubNodeException If an error occurred while creating the node.
|
* @throws PubSubException.NotAPubSubNodeException If an error occurred while creating the node.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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;
|
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode(nodename);
|
pubSubManagerOne.createNode(nodename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode( nodename );
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
subscriberNode.unsubscribe( subscriber.asEntityBareJidString() );
|
subscriberNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||||
|
} catch (NoResponseException | XMPPErrorException e) {
|
||||||
|
throw new AssertionError("Unsubscribe from a node failed.", e);
|
||||||
}
|
}
|
||||||
catch ( NoResponseException | XMPPErrorException e ) {
|
} finally {
|
||||||
throw new AssertionError( "Unsubscribe from a node failed.", e );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -564,37 +538,34 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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)) {
|
||||||
if ( !pubSubManagerOne.getSupportedFeatures().containsFeature( PubSubFeature.multi_subscribe ) ) {
|
throw new TestNotPossibleException("Feature 'multi-subscribe' not supported on the server.");
|
||||||
throw new TestNotPossibleException( "Feature 'multi-subscribe' not supported on the server." );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode( nodename );
|
pubSubManagerOne.createNode(nodename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node twice, using different configuration
|
// Subscribe to the node twice, using different configuration
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formA.setDigestFrequency( 1 );
|
formA.setDigestFrequency(1);
|
||||||
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formB.setDigestFrequency( 2 );
|
formB.setDigestFrequency(2);
|
||||||
|
|
||||||
subscriberNode.subscribe( subscriber, formA );
|
subscriberNode.subscribe(subscriber, formA);
|
||||||
subscriberNode.subscribe( subscriber, formB );
|
subscriberNode.subscribe(subscriber, formB);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
subscriberNode.unsubscribe( subscriber.asEntityBareJidString() );
|
subscriberNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||||
fail( "The server should have returned a <bad_request/> error, but did not." );
|
fail("The server should have returned a <bad_request/> error, but did not.");
|
||||||
|
} catch (XMPPErrorException e) {
|
||||||
|
assertEquals(StanzaError.Condition.bad_request, e.getStanzaError().getCondition());
|
||||||
}
|
}
|
||||||
catch ( XMPPErrorException e ) {
|
} finally {
|
||||||
assertEquals( StanzaError.Condition.bad_request, e.getStanzaError().getCondition() );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,24 +586,21 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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;
|
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode( nodename );
|
pubSubManagerOne.createNode(nodename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node twice, using different configuration
|
// Subscribe to the node twice, using different configuration
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode( nodename );
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
|
|
||||||
subscriberNode.unsubscribe( subscriber.asEntityBareJidString() );
|
subscriberNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||||
fail( "The server should have returned an error, but did not." );
|
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')
|
// SHOULD be <unexpected-request/> (but that's not a 'MUST')
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,29 +621,26 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||||
final PubSubManager pubSubManagerThree = PubSubManager.getInstanceFor(conThree, PubSubManager.getPubSubService(conThree));
|
final PubSubManager pubSubManagerThree = PubSubManager.getInstanceFor(conThree, PubSubManager.getPubSubService(conThree));
|
||||||
pubSubManagerOne.createNode(nodename);
|
pubSubManagerOne.createNode(nodename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node, using a different user than the owner of the node.
|
// Subscribe to the node, using a different user than the owner of the node.
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode( nodename );
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
|
|
||||||
final Node unprivilegedNode = pubSubManagerThree.getNode( nodename );
|
final Node unprivilegedNode = pubSubManagerThree.getNode(nodename);
|
||||||
try {
|
try {
|
||||||
unprivilegedNode.unsubscribe( subscriber.asEntityBareJidString() );
|
unprivilegedNode.unsubscribe(subscriber.asEntityBareJidString());
|
||||||
fail( "The server should have returned a <forbidden/> error, but did not." );
|
fail("The server should have returned a <forbidden/> error, but did not.");
|
||||||
|
} catch (XMPPErrorException e) {
|
||||||
|
assertEquals(StanzaError.Condition.forbidden, e.getStanzaError().getCondition());
|
||||||
}
|
}
|
||||||
catch ( XMPPErrorException e ) {
|
} finally {
|
||||||
assertEquals( StanzaError.Condition.forbidden, e.getStanzaError().getCondition() );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,23 +660,20 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@SmackIntegrationTest
|
||||||
public void unsubscribeNodeDoesNotExistTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException
|
public void unsubscribeNodeDoesNotExistTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
{
|
|
||||||
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||||
try {
|
try {
|
||||||
// Smack righteously doesn't facilitate unsubscribing from a non-existing node. Manually crafting stanza:
|
// Smack righteously doesn't facilitate unsubscribing from a non-existing node. Manually crafting stanza:
|
||||||
final UnsubscribeExtension ext = new UnsubscribeExtension( conOne.getUser().asEntityBareJid().asEntityBareJidString(), "I-dont-exist", null );
|
final UnsubscribeExtension ext = new UnsubscribeExtension(conOne.getUser().asEntityBareJid().asEntityBareJidString(), "I-dont-exist", null);
|
||||||
final PubSub unsubscribe = PubSub.createPubsubPacket( pubSubManagerOne.getServiceJid(), IQ.Type.set, ext );
|
final PubSub unsubscribe = PubSub.createPubsubPacket(pubSubManagerOne.getServiceJid(), IQ.Type.set, ext);
|
||||||
try {
|
try {
|
||||||
pubSubManagerOne.sendPubsubPacket(unsubscribe);
|
pubSubManagerOne.sendPubsubPacket(unsubscribe);
|
||||||
fail( "The server should have returned a <item-not-found/> error, but did not." );
|
fail("The server should have returned a <item-not-found/> error, but did not.");
|
||||||
|
} catch (XMPPErrorException e) {
|
||||||
|
assertEquals(StanzaError.Condition.item_not_found, e.getStanzaError().getCondition());
|
||||||
}
|
}
|
||||||
catch ( XMPPErrorException e ) {
|
} finally {
|
||||||
assertEquals( StanzaError.Condition.item_not_found, e.getStanzaError().getCondition() );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -735,38 +697,35 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
* @throws TestNotPossibleException if the server does not support the functionality required for this test.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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.
|
// Depending on multi-subscribe is a fail-safe way to be sure that subscription IDs will exist.
|
||||||
if ( !pubSubManagerOne.getSupportedFeatures().containsFeature( PubSubFeature.multi_subscribe ) ) {
|
if (!pubSubManagerOne.getSupportedFeatures().containsFeature(PubSubFeature.multi_subscribe)) {
|
||||||
throw new TestNotPossibleException( "Feature 'multi-subscribe' not supported on the server." );
|
throw new TestNotPossibleException("Feature 'multi-subscribe' not supported on the server.");
|
||||||
}
|
}
|
||||||
|
|
||||||
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
final String nodename = "sinttest-unsubscribe-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode( nodename );
|
pubSubManagerOne.createNode(nodename);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Subscribe to the node twice, using different configuration
|
// Subscribe to the node twice, using different configuration
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formA = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formA.setDigestFrequency( 1 );
|
formA.setDigestFrequency(1);
|
||||||
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions( subscriber.toString() ).getFillableForm();
|
final FillableSubscribeForm formB = subscriberNode.getSubscriptionOptions(subscriber.toString()).getFillableForm();
|
||||||
formB.setDigestFrequency( 2 );
|
formB.setDigestFrequency(2);
|
||||||
|
|
||||||
subscriberNode.subscribe( subscriber, formA );
|
subscriberNode.subscribe(subscriber, formA);
|
||||||
subscriberNode.subscribe( subscriber, formB );
|
subscriberNode.subscribe(subscriber, formB);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
subscriberNode.unsubscribe( subscriber.asEntityBareJidString(), "this-is-not-an-existing-subscription-id" );
|
subscriberNode.unsubscribe(subscriber.asEntityBareJidString(), "this-is-not-an-existing-subscription-id");
|
||||||
fail( "The server should have returned a <not-acceptable/> error, but did not." );
|
fail("The server should have returned a <not-acceptable/> error, but did not.");
|
||||||
|
} catch (XMPPErrorException e) {
|
||||||
|
assertEquals(StanzaError.Condition.not_acceptable, e.getStanzaError().getCondition());
|
||||||
}
|
}
|
||||||
catch ( XMPPErrorException e ) {
|
} finally {
|
||||||
assertEquals( StanzaError.Condition.not_acceptable, e.getStanzaError().getCondition() );
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -787,18 +746,16 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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;
|
final String nodename = "sinttest-get-empty-subscriptions-test-nodename-" + testRunId;
|
||||||
pubSubManagerOne.createNode(nodename);
|
pubSubManagerOne.createNode(nodename);
|
||||||
try {
|
try {
|
||||||
// Assert that subscriptions for a non-subscriber is reported as an empty list.
|
// Assert that subscriptions for a non-subscriber is reported as an empty list.
|
||||||
final List<Subscription> subscriptions = pubSubManagerTwo.getNode( nodename ).getSubscriptions();
|
final List<Subscription> subscriptions = pubSubManagerTwo.getNode(nodename).getSubscriptions();
|
||||||
assertNotNull( subscriptions );
|
assertNotNull(subscriptions);
|
||||||
assertTrue( subscriptions.isEmpty() );
|
assertTrue(subscriptions.isEmpty());
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -813,29 +770,25 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws PubSubException if the involved node is not a pubsub node.
|
* @throws PubSubException if the involved node is not a pubsub node.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 nodename = "sinttest-receive-published-item-nodename-" + testRunId;
|
||||||
final String needle = "test content " + Math.random();
|
final String needle = "test content " + Math.random();
|
||||||
LeafNode publisherNode = pubSubManagerOne.createNode(nodename);
|
LeafNode publisherNode = pubSubManagerOne.createNode(nodename);
|
||||||
try {
|
try {
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe( subscriber );
|
subscriberNode.subscribe(subscriber);
|
||||||
|
|
||||||
final CompletableFuture<Stanza> result = new CompletableFuture<>();
|
final CompletableFuture<Stanza> result = new CompletableFuture<>();
|
||||||
conTwo.addAsyncStanzaListener( result::complete, stanza -> stanza.toXML().toString().contains( needle ) );
|
conTwo.addAsyncStanzaListener(result::complete, stanza -> stanza.toXML().toString().contains(needle));
|
||||||
|
|
||||||
publisherNode.publish( new PayloadItem<>( GeoLocation.builder().setDescription( needle ).build() ) );
|
publisherNode.publish(new PayloadItem<>(GeoLocation.builder().setDescription(needle).build()));
|
||||||
|
|
||||||
assertNotNull( result.get( conOne.getReplyTimeout(), TimeUnit.MILLISECONDS ) );
|
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);
|
throw new AssertionError("The published item was not received by the subscriber.", e);
|
||||||
}
|
} finally {
|
||||||
finally {
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
pubSubManagerOne.deleteNode( nodename );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -861,8 +814,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
try {
|
try {
|
||||||
LeafNode leafNode = (LeafNode) node;
|
LeafNode leafNode = (LeafNode) node;
|
||||||
leafNode.publish();
|
leafNode.publish();
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode(nodename);
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -916,8 +868,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
});
|
});
|
||||||
assertEquals(StanzaError.Type.MODIFY, e.getStanzaError().getType());
|
assertEquals(StanzaError.Type.MODIFY, e.getStanzaError().getType());
|
||||||
assertNotNull(e.getStanzaError().getExtension("item-forbidden", "http://jabber.org/protocol/pubsub#errors"));
|
assertNotNull(e.getStanzaError().getExtension("item-forbidden", "http://jabber.org/protocol/pubsub#errors"));
|
||||||
}
|
} finally {
|
||||||
finally {
|
|
||||||
pubSubManagerOne.deleteNode(nodename);
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -943,12 +894,12 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
public void deleteNonExistentNodeTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
public void deleteNonExistentNodeTest() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
|
||||||
final String nodename = "sinttest-delete-node-that-does-not-exist-" + testRunId;
|
final String nodename = "sinttest-delete-node-that-does-not-exist-" + testRunId;
|
||||||
// Delete an non existent node
|
// Delete an non existent node
|
||||||
assertFalse( pubSubManagerOne.deleteNode(nodename), "The server should have returned a <item-not-found/> error, but did not." );
|
assertFalse(pubSubManagerOne.deleteNode(nodename), "The server should have returned a <item-not-found/> error, but did not.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert that the server send a notification to subscribers when deleting a
|
* Assert that the server send a notification to subscribers when deleting a
|
||||||
* node that exist
|
* node that exist.
|
||||||
*
|
*
|
||||||
* <p>
|
* <p>
|
||||||
* From XEP-0060 § 8.4.1:
|
* From XEP-0060 § 8.4.1:
|
||||||
|
@ -957,14 +908,11 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* deletion request, consisting of a <delete/> element whose 'node'
|
* deletion request, consisting of a <delete/> element whose 'node'
|
||||||
* attribute specifies the NodeID of the node to be deleted </blockquote>
|
* attribute specifies the NodeID of the node to be deleted </blockquote>
|
||||||
*
|
*
|
||||||
* @throws NoResponseException if there was no response from
|
* @throws NoResponseException if there was no response from the remote entity.
|
||||||
* the remote entity.
|
* @throws NotConnectedException if the XMPP connection is not connected.
|
||||||
* @throws NotConnectedException if the XMPP connection is not
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
* connected.
|
* @throws PubSubException.NotAPubSubNodeException if the node cannot be accessed.
|
||||||
* @throws InterruptedException if the calling thread was
|
* @throws ExecutionException if the execution was aborted by an exception
|
||||||
* interrupted.
|
|
||||||
* @throws PubSubException.NotAPubSubNodeException if the node cannot be
|
|
||||||
* accessed.
|
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@SmackIntegrationTest
|
||||||
public void deleteNodeAndNotifySubscribersTest() throws NoResponseException, ExecutionException,
|
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 nodename = "sinttest-delete-node-that-exist-" + testRunId;
|
||||||
final String needle = "<event xmlns='http://jabber.org/protocol/pubsub#event'>";
|
final String needle = "<event xmlns='http://jabber.org/protocol/pubsub#event'>";
|
||||||
try {
|
try {
|
||||||
LeafNode node = pubSubManagerOne.createNode(nodename);
|
@SuppressWarnings("unused") LeafNode node = pubSubManagerOne.createNode(nodename);
|
||||||
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
final Node subscriberNode = pubSubManagerTwo.getNode(nodename);
|
||||||
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
final EntityBareJid subscriber = conTwo.getUser().asEntityBareJid();
|
||||||
subscriberNode.subscribe(subscriber);
|
subscriberNode.subscribe(subscriber);
|
||||||
|
@ -1005,8 +953,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
* @throws InterruptedException if the calling thread was interrupted.
|
* @throws InterruptedException if the calling thread was interrupted.
|
||||||
*/
|
*/
|
||||||
@SmackIntegrationTest
|
@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 nodename = "sinttest-publish-item-nodename-" + testRunId;
|
||||||
final String itemId = "reused-id-for-testrun-" + testRunId;
|
final String itemId = "reused-id-for-testrun-" + testRunId;
|
||||||
final String needleA = "test content A" + Math.random();
|
final String needleA = "test content A" + Math.random();
|
||||||
|
@ -1018,8 +965,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
config.setMaxItems(2);
|
config.setMaxItems(2);
|
||||||
|
|
||||||
LeafNode node = (LeafNode) pubSubManagerOne.createNode(nodename, config);
|
LeafNode node = (LeafNode) pubSubManagerOne.createNode(nodename, config);
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
// Publish a new item.
|
// Publish a new item.
|
||||||
node.publish(new PayloadItem<>(itemId, GeoLocation.builder().setDescription(needleA).build()));
|
node.publish(new PayloadItem<>(itemId, GeoLocation.builder().setDescription(needleA).build()));
|
||||||
node.publish(new PayloadItem<>(itemId, GeoLocation.builder().setDescription(needleB).build()));
|
node.publish(new PayloadItem<>(itemId, GeoLocation.builder().setDescription(needleB).build()));
|
||||||
|
@ -1031,9 +977,7 @@ public class PubSubIntegrationTest extends AbstractSmackIntegrationTest {
|
||||||
assertEquals(itemId, item.getId());
|
assertEquals(itemId, item.getId());
|
||||||
assertFalse(item.toXML().toString().contains(needleA));
|
assertFalse(item.toXML().toString().contains(needleA));
|
||||||
assertTrue(item.toXML().toString().contains(needleB));
|
assertTrue(item.toXML().toString().contains(needleB));
|
||||||
}
|
} finally {
|
||||||
finally
|
|
||||||
{
|
|
||||||
pubSubManagerOne.deleteNode(nodename);
|
pubSubManagerOne.deleteNode(nodename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue