@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();
         }
      }
   }
@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();
        
         clientBuilder.version(version);
         clientBuilder.addServers(servers);
         temporaryManager = new RemoteCacheManager(clientBuilder.build());
         cacheToUse = temporaryManager.getCache();
      } else {
         temporaryManager = null;
         cacheToUse = remoteCache;
      }
      try {
        
         remoteCache.putAll(dataIn);
         CloseableIteratorCollection<?> collection = op.function.apply(cacheToUse);
        
         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();
         }
      }
   }
@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(); clientbuilder.version(version); clientbuilder.addservers(servers); temporarymanager = new remotecachemanager(clientbuilder.build()); cachetouse = temporarymanager.getcache(); } else { temporarymanager = null; cachetouse = remotecache; } try { remotecache.putall(datain); closeableiteratorcollection<?> collection = op.function.apply(cachetouse); 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(); } } }