Java Code Examples for org.jivesoftware.smack.SmackConfiguration#setDefaultReplyTimeout()
The following examples show how to use
org.jivesoftware.smack.SmackConfiguration#setDefaultReplyTimeout() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigureFormTest.java From Smack with Apache License 2.0 | 6 votes |
@Test public void getConfigFormWithTimeout() throws XMPPException, InterruptedException, SmackException, IOException { ThreadedDummyConnection con = ThreadedDummyConnection.newInstance(); PubSubManager mgr = new PubSubManager(con, PubSubManagerTest.DUMMY_PUBSUB_SERVICE); DiscoverInfoBuilder info = DiscoverInfo.builder("disco-result") .ofType(IQ.Type.result) .from(PubSubManagerTest.DUMMY_PUBSUB_SERVICE); Identity ident = new Identity("pubsub", null, "leaf"); info.addIdentity(ident); DiscoverInfo discoverInfo = info.build(); con.addIQReply(discoverInfo); Node node = mgr.getNode("princely_musings"); SmackConfiguration.setDefaultReplyTimeout(100); con.setTimeout(); assertThrows(SmackException.class, () -> { node.getNodeConfiguration(); }); }
Example 2
Source File: SmackIntegrationTestFramework.java From Smack with Apache License 2.0 | 4 votes |
public synchronized TestRunResult run() throws KeyManagementException, NoSuchAlgorithmException, SmackException, IOException, XMPPException, InterruptedException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { // The DNS resolver is not really a per sinttest run setting. It is not even a per connection setting. Instead // it is a global setting, but we treat it like a per sinttest run setting. switch (config.dnsResolver) { case minidns: MiniDnsResolver.setup(); break; case javax: JavaxResolver.setup(); break; case dnsjava: DNSJavaResolver.setup(); break; } testRunResult = new TestRunResult(); // Create a connection manager *after* we created the testRunId (in testRunResult). this.connectionManager = new XmppConnectionManager(this); LOGGER.info("SmackIntegrationTestFramework [" + testRunResult.testRunId + ']' + ": Starting\nSmack version: " + SmackConfiguration.getVersion()); if (config.debugger != Configuration.Debugger.none) { // JUL Debugger will not print any information until configured to print log messages of // level FINE // TODO configure JUL for log? SmackConfiguration.addDisabledSmackClass("org.jivesoftware.smack.debugger.JulDebugger"); SmackConfiguration.DEBUG = true; } if (config.replyTimeout > 0) { SmackConfiguration.setDefaultReplyTimeout(config.replyTimeout); } if (config.securityMode != SecurityMode.required && config.accountRegistration == AccountRegistration.inBandRegistration) { AccountManager.sensitiveOperationOverInsecureConnectionDefault(true); } // TODO print effective configuration String[] testPackages; if (config.testPackages == null || config.testPackages.isEmpty()) { testPackages = new String[] { "org.jivesoftware.smackx", "org.jivesoftware.smack" }; } else { testPackages = config.testPackages.toArray(new String[config.testPackages.size()]); } Reflections reflections = new Reflections(testPackages, new SubTypesScanner(), new TypeAnnotationsScanner(), new MethodAnnotationsScanner(), new MethodParameterScanner()); Set<Class<? extends AbstractSmackIntegrationTest>> inttestClasses = reflections.getSubTypesOf(AbstractSmackIntegrationTest.class); Set<Class<? extends AbstractSmackLowLevelIntegrationTest>> lowLevelInttestClasses = reflections.getSubTypesOf(AbstractSmackLowLevelIntegrationTest.class); Set<Class<? extends AbstractSmackIntTest>> classes = new HashSet<>(inttestClasses.size() + lowLevelInttestClasses.size()); classes.addAll(inttestClasses); classes.addAll(lowLevelInttestClasses); { // Remove all abstract classes. // TODO: This may be a good candidate for Java stream filtering once Smack is Android API 24 or higher. Iterator<Class<? extends AbstractSmackIntTest>> it = classes.iterator(); while (it.hasNext()) { Class<? extends AbstractSmackIntTest> clazz = it.next(); if (Modifier.isAbstract(clazz.getModifiers())) { it.remove(); } } } if (classes.isEmpty()) { throw new IllegalStateException("No test classes found"); } LOGGER.info("SmackIntegrationTestFramework [" + testRunResult.testRunId + "]: Finished scanning for tests, preparing environment"); environment = prepareEnvironment(); try { runTests(classes); } catch (Throwable t) { // Log the thrown Throwable to prevent it being shadowed in case the finally block below also throws. LOGGER.log(Level.SEVERE, "Unexpected abort because runTests() threw throwable", t); throw t; } finally { // Ensure that the accounts are deleted and disconnected before we continue connectionManager.disconnectAndCleanup(); } return testRunResult; }