// putAll doesn't work in older versions (so we use new client) - that is a different issue completely
@Test(dataProvider = "collectionsAndVersion")
   public void testIteration(CollectionOp op, ProtocolVersion version) throws IOException {
      Map<String, String> dataIn = new HashMap<>();
      dataIn.put("aKey", "aValue");
      dataIn.put("bKey", "bValue");
      RemoteCache<Object, Object> cacheToUse;
      RemoteCacheManager temporaryManager;
      if (version != ProtocolVersion.DEFAULT_PROTOCOL_VERSION) {
         String servers = HotRodClientTestingUtil.getServersString(hotrodServers);
         org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder =
               new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
         // Set the version on the manager to connect with
         clientBuilder.version(version);
         clientBuilder.addServers(servers);
         temporaryManager = new RemoteCacheManager(clientBuilder.build());
         cacheToUse = temporaryManager.getCache();
      } else {
         temporaryManager = null;
         cacheToUse = remoteCache;
      }
      try {
         // putAll doesn't work in older versions (so we use new client) - that is a different issue completely
         remoteCache.putAll(dataIn);
         CloseableIteratorCollection<?> collection = op.function.apply(cacheToUse);
         // If we don't support it we should get an exception
         if (version.compareTo(op.minimumVersionForIteration()) < 0) {
            Exceptions.expectException(UnsupportedOperationException.class, () -> {
               try (CloseableIterator<?> iter = collection.iterator()) {
               }
            });
         } else {
            try (CloseableIterator<?> iter = collection.iterator()) {
               assertTrue(iter.hasNext());
               assertNotNull(iter.next());
               assertTrue(iter.hasNext());
            }
         }
      } finally {
         if (temporaryManager != null) {
            temporaryManager.close();
         }
      }
   }
}
try {
// putAll doesn't work in older versions (so we use new client) - that is a different issue completely
remoteCache.putAll(dataIn);
CloseableIteratorCollection<?> collection = op.function.apply(cacheToUse);
// Set the version on the manager to connect with
clientBuilder.version(version);
clientBuilder.addServers(servers);
temporaryManager = new RemoteCacheManager(clientBuilder.build());
cacheToUse = temporaryManager.getCache();
} else {
temporaryManager = null;
cacheToUse = remoteCache;
}
try {
// putAll doesn't work in older versions (so we use new client) - that is a different issue completely
remoteCache.putAll(dataIn);
CloseableIteratorCollection<?> collection = op.function.apply(cacheToUse);
// If we don't support it we should get an exception
if (version.compareTo(op.minimumVersionForIteration()) < 0) {
Exceptions.expectException(UnsupportedOperationException.class, () -> {
try (CloseableIterator<?> iter = collection.iterator()) {
}
});
} else {
try (CloseableIterator<?> iter = collection.iterator()) {
public void testIteration(CollectionOp op, ProtocolVersion version) throws IOException {
Map<String, String> dataIn = new HashMap<>();
dataIn.put("aKey", "aValue");
dataIn.put("bKey", "bValue");
RemoteCache<Object, Object> cacheToUse;
RemoteCacheManager temporaryManager;
if (version != ProtocolVersion.DEFAULT_PROTOCOL_VERSION) {
String servers = HotRodClientTestingUtil.getServersString(hotrodServers);
org.infinispan.client.hotrod.configuration.ConfigurationBuilder clientBuilder =
new org.infinispan.client.hotrod.configuration.ConfigurationBuilder();
// Set the version on the manager to connect with
clientBuilder.version(version);
clientBuilder.addServers(servers);
temporaryManager = new RemoteCacheManager(clientBuilder.build());
cacheToUse = temporaryManager.getCache();
} else {
temporaryManager = null;
cacheToUse = remoteCache;
}
try {
// putAll doesn't work in older versions (so we use new client) - that is a different issue completely
remoteCache.putAll(dataIn);
CloseableIteratorCollection<?> collection = op.function.apply(cacheToUse);
// If we don't support it we should get an exception
if (version.compareTo(op.minimumVersionForIteration()) < 0) {
Exceptions.expectException(UnsupportedOperationException.class, () -> {
try (CloseableIterator<?> iter = collection.iterator()) {
}
});
} else {
try (CloseableIterator<?> iter = collection.iterator()) {
assertTrue(iter.hasNext());
assertNotNull(iter.next());
assertTrue(iter.hasNext());
}
}
} finally {
if (temporaryManager != null) {
temporaryManager.close();
}
}