commit 56c4005f48d953617bf4e54b7ea105010aa3bbde
parent a41fe95866584d55c70313c75d29b1dcdedfff6c
Author: Daniel Gultsch <daniel@gultsch.de>
Date: Mon, 6 Jun 2016 14:19:59 +0200
manually iterating over disco items ignoring faulty items
Diffstat:
1 file changed, 24 insertions(+), 1 deletion(-)
diff --git a/src/main/java/eu/siacs/compliance/tests/AbstractServiceTest.java b/src/main/java/eu/siacs/compliance/tests/AbstractServiceTest.java
@@ -5,9 +5,9 @@ import eu.siacs.compliance.Result;
import rocks.xmpp.core.session.XmppClient;
import rocks.xmpp.extensions.disco.ServiceDiscoveryManager;
import rocks.xmpp.extensions.disco.model.items.Item;
+import rocks.xmpp.extensions.disco.model.items.ItemNode;
import rocks.xmpp.util.concurrent.AsyncResult;
-import java.util.List;
import java.util.concurrent.TimeUnit;
public abstract class AbstractServiceTest extends AbstractTest {
@@ -19,12 +19,35 @@ public abstract class AbstractServiceTest extends AbstractTest {
@Override
public Result run() {
ServiceDiscoveryManager manager = client.getManager(ServiceDiscoveryManager.class);
+
+ //manually iterating over items. ignoring the faulty ones
+ AsyncResult<ItemNode> items = manager.discoverItems(client.getDomain());
+ try {
+ for(Item item : items.getResult(10,TimeUnit.SECONDS).getItems()) {
+ try {
+ for(String feature : manager.discoverInformation(item.getJid()).getResult(10, TimeUnit.SECONDS).getFeatures()) {
+ if (getNamespace().equals(feature)) {
+ return Result.PASSED;
+ }
+ }
+ } catch (Exception e) {
+ //ignored
+ }
+ }
+ } catch (Exception e) {
+ return Result.FAILED;
+ }
+ return Result.FAILED;
+
+ //this is how it should be. but it throws an exeception if one of the items fails
+ /*
AsyncResult<List<Item>> result = manager.discoverServices(getNamespace());
try {
return result.getResult(10, TimeUnit.SECONDS).size() >= 1 ? Result.PASSED : Result.FAILED;
} catch (Exception e) {
return Result.FAILED;
}
+ */
}
public abstract String getNamespace();