/** * Get a PubSub manager for the default PubSub service of the connection. * * @param connection * @return the default PubSub manager. */ public static PubSubManager getInstance(XMPPConnection connection) { DomainBareJid pubSubService = null; if (connection.isAuthenticated()) { try { pubSubService = getPubSubService(connection); } catch (NoResponseException | XMPPErrorException | NotConnectedException e) { LOGGER.log(Level.WARNING, "Could not determine PubSub service", e); } catch (InterruptedException e) { LOGGER.log(Level.FINE, "Interrupted while trying to determine PubSub service", e); } } if (pubSubService == null) { try { // Perform an educated guess about what the PubSub service's domain bare JID may be pubSubService = JidCreate.domainBareFrom("pubsub." + connection.getXMPPServiceDomain()); } catch (XmppStringprepException e) { throw new RuntimeException(e); } } return getInstance(connection, pubSubService); }
public PubSubIntegrationTest(SmackIntegrationTestEnvironment environment) throws TestNotPossibleException, NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { super(environment); DomainBareJid pubSubService = PubSubManager.getPubSubService(conOne); if (pubSubService == null) { throw new TestNotPossibleException("No PubSub service found"); } pubSubManagerOne = PubSubManager.getInstance(conOne, pubSubService); if (!pubSubManagerOne.canCreateNodesAndPublishItems()) { throw new TestNotPossibleException("PubSub service does not allow node creation"); } }