Skip to content

Commit

Permalink
Align with updated infinispan version. (#1419)
Browse files Browse the repository at this point in the history
  • Loading branch information
baldimir committed Sep 6, 2024
1 parent 10478b5 commit 1b75101
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
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;
import org.mockito.Answers;
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;
Expand All @@ -37,20 +40,20 @@ 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());
service.stop();
}

{
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();
Expand Down

0 comments on commit 1b75101

Please sign in to comment.