From abd25ff526cc2ec7fad7c7cb0fa0fdc5a08dbc79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tibor=20Zim=C3=A1nyi?= Date: Tue, 30 Jul 2024 09:15:31 +0200 Subject: [PATCH] Align with updated infinispan version. --- .../infinispan/provider/InfinispanContext.java | 3 ++- .../infinispan/provider/InfinispanPingService.java | 3 ++- .../provider/InfinispanPingServiceTest.java | 11 +++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanContext.java b/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanContext.java index ac22b751d3..10aa482121 100644 --- a/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanContext.java +++ b/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanContext.java @@ -35,6 +35,7 @@ import org.infinispan.client.hotrod.configuration.SaslQop; import org.infinispan.client.hotrod.exceptions.HotRodClientException; import org.infinispan.client.hotrod.impl.RemoteCacheImpl; +import org.infinispan.client.hotrod.impl.operations.PingResponse; import org.infinispan.client.hotrod.marshall.ProtoStreamMarshaller; import org.infinispan.commons.CacheConfigurationException; import org.infinispan.protostream.BaseMarshaller; @@ -390,7 +391,7 @@ public boolean isAlive() { RemoteCacheImpl remoteCache = (RemoteCacheImpl) this.cacheManager.getCache(); try { - boolean isStarted = remoteCache.ping().isSuccess(); + boolean isStarted = ((PingResponse) remoteCache.ping().toCompletableFuture().get()).isSuccess(); if (logger.isDebugEnabled()) { logger.debug("Infinispan server is not started"); } diff --git a/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingService.java b/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingService.java index 1212d4005b..922d8bb9cc 100644 --- a/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingService.java +++ b/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/main/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingService.java @@ -21,6 +21,7 @@ import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.impl.RemoteCacheImpl; +import org.infinispan.client.hotrod.impl.operations.PingResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,7 +45,7 @@ public InfinispanPingService(RemoteCacheImpl remoteCache) { this.executor.submit(() -> { while (!stop) { try { - this.alive = remoteCache.ping().isSuccess(); + this.alive = ((PingResponse) remoteCache.ping().toCompletableFuture().get()).isSuccess(); } catch (Exception e) { if (logger.isDebugEnabled()) { logger.error("Infinispan server is not started"); diff --git a/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/test/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingServiceTest.java b/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/test/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingServiceTest.java index bef11de095..d1d9d5c258 100644 --- a/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/test/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingServiceTest.java +++ b/uberfire-extensions/uberfire-metadata/uberfire-metadata-backends/uberfire-metadata-backend-infinispan/src/test/java/org/uberfire/ext/metadata/backend/infinispan/provider/InfinispanPingServiceTest.java @@ -17,6 +17,7 @@ package org.uberfire.ext.metadata.backend.infinispan.provider; import org.infinispan.client.hotrod.impl.RemoteCacheImpl; +import org.infinispan.client.hotrod.impl.operations.PingResponse; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -24,6 +25,8 @@ import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; +import java.util.concurrent.ExecutionException; + import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; @@ -37,12 +40,12 @@ public class InfinispanPingServiceTest { private RemoteCacheImpl remoteCache; @Before - public void setUp() { - when(remoteCache.ping().isSuccess()).thenReturn(true); + public void setUp() throws ExecutionException, InterruptedException { + when(((PingResponse) remoteCache.ping().toCompletableFuture().get()).isSuccess()).thenReturn(true); } @Test - public void testPingSuccess() { + public void testPingSuccess() throws ExecutionException, InterruptedException { { InfinispanPingService service = spy(new InfinispanPingService(remoteCache)); assertTrue(service.ping()); @@ -50,7 +53,7 @@ public void testPingSuccess() { } { - when(remoteCache.ping().isSuccess()).thenReturn(false); + when(((PingResponse) remoteCache.ping().toCompletableFuture().get()).isSuccess()).thenReturn(false); InfinispanPingService service = spy(new InfinispanPingService(remoteCache)); assertFalse(service.ping()); service.stop();