Skip to content

Commit

Permalink
Bug 36028102 - Build: AsyncNamedMapExecutorTests.shouldUseExecutor
Browse files Browse the repository at this point in the history
(merge ce/main -> ce/23.09 104743)

[git-p4: depot-paths = "//dev/coherence-ce/release/coherence-ce-v23.09/": change = 104747]
  • Loading branch information
thegridman committed Nov 20, 2023
1 parent fa728bf commit ce34921
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package cache;

import com.oracle.bedrock.testsupport.deferred.Eventually;
import com.tangosol.net.AsyncNamedCache;
import com.tangosol.net.AsyncNamedMap;
import com.tangosol.net.Coherence;
Expand All @@ -15,6 +16,7 @@
import org.junit.BeforeClass;
import org.junit.Test;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -42,7 +44,7 @@ public static void setup() throws Exception
}

@Test
public void shouldUseExecutor()
public void shouldUseExecutor() throws Exception
{
NamedCache<String, String> cache = s_session.getCache("dist-test");
Executor real = Executors.newSingleThreadExecutor();
Expand All @@ -54,11 +56,12 @@ public void shouldUseExecutor()
real.execute(runnable);
return null;
})
.when(executor).execute(any(Runnable.class));
.when(executor).execute(any(Runnable.class));

AsyncNamedCache<String, String> async = cache.async(AsyncNamedMap.Complete.using(executor));
async.put("key-1", "value-1");
assertThat(cache.get("key-1"), is("value-1"));
AsyncNamedCache<String, String> async = cache.async(AsyncNamedMap.Complete.using(executor));
CompletableFuture<Void> future = async.put("key-1", "value-1");
future.get(1, TimeUnit.MINUTES);
Eventually.assertDeferred(() -> cache.get("key-1"), is("value-1"));

verify(executor, atLeastOnce()).execute(any(Runnable.class));
}
Expand Down

0 comments on commit ce34921

Please sign in to comment.