Skip to content

Commit 9732812

Browse files
committed
COH-32632 Build: Replace the use of Bedrock's Eventually.assertThat() with Eventually.assertDeferred()
(merge main -> ce/main 118613) [git-p4: depot-paths = "//dev/coherence-ce/main/": change = 118614]
1 parent 3cfd090 commit 9732812

File tree

9 files changed

+62
-55
lines changed

9 files changed

+62
-55
lines changed

prj/examples/guides/140-client-events/src/test/java/com/oracle/coherence/guides/clientevents/ClientEventsTest.java

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77

88
package com.oracle.coherence.guides.clientevents;
@@ -28,10 +28,8 @@
2828
import org.junit.jupiter.api.BeforeAll;
2929
import org.junit.jupiter.api.Test;
3030

31-
import java.util.concurrent.atomic.AtomicBoolean;
3231
import java.util.concurrent.atomic.AtomicInteger;
3332

34-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
3533
import static org.hamcrest.CoreMatchers.is;
3634

3735
/**
@@ -97,17 +95,17 @@ public void testMapListeners() {
9795
customers.remove(1); // <5>
9896

9997
// ensure that we see all events <6>
100-
Eventually.assertThat(invoking(mapListener).getInsertCount(), is(2));
101-
Eventually.assertThat(invoking(mapListener).getUpdateCount(), is(1));
102-
Eventually.assertThat(invoking(mapListener).getRemoveCount(), is(1));
98+
Eventually.assertDeferred(mapListener::getInsertCount, is(2));
99+
Eventually.assertDeferred(mapListener::getUpdateCount, is(1));
100+
Eventually.assertDeferred(mapListener::getRemoveCount, is(1));
103101

104102
customers.removeMapListener(mapListener);
105103
// #end::testStandardMapListener[]
106104

107105
// #tag::testMultiplexingMapListener[]
108106
Logger.info("*** testMultiplexingMapListener");
109107
customers.clear();
110-
MapListener<Integer, Customer> multiplexingMapListener = new MultiplexingCustomerMapListener(); // <1>
108+
MultiplexingCustomerMapListener multiplexingMapListener = new MultiplexingCustomerMapListener(); // <1>
111109
// Multiplexing MapListener listening on all entries
112110
customers.addMapListener(multiplexingMapListener); // <2>
113111

@@ -118,7 +116,7 @@ public void testMapListeners() {
118116
customers.remove(1);
119117

120118
// ensure that we see all events <4>
121-
Eventually.assertThat(invoking((MultiplexingCustomerMapListener) multiplexingMapListener).getCount(), is(3));
119+
Eventually.assertDeferred(multiplexingMapListener::getCount, is(3));
122120

123121
customers.removeMapListener(multiplexingMapListener);
124122
// #end::testMultiplexingMapListener[]
@@ -143,8 +141,8 @@ public void testMapListeners() {
143141
customers.clear();
144142

145143
// should only be 1 insert and 1 delete as we are listening on the key // <7>
146-
Eventually.assertThat(invoking(this).getInsertCount(), is(1));
147-
Eventually.assertThat(invoking(this).getDeleteCount(), is(1));
144+
Eventually.assertDeferred(this::getInsertCount, is(1));
145+
Eventually.assertDeferred(this::getDeleteCount, is(1));
148146

149147
// #end::testSimpleMapListener[]
150148

@@ -171,10 +169,10 @@ public void testMapListeners() {
171169
customers.put(customer4.getId(), customer4);
172170

173171
// ensure that we see all events // <4>
174-
Eventually.assertThat(invoking(mapListener).getInsertCount(), is(2));
172+
Eventually.assertDeferred(mapListener::getInsertCount, is(2));
175173

176174
// ensure we only receive lite events
177-
Eventually.assertThat(invoking(mapListener).getLiteEvents(), is(2));
175+
Eventually.assertDeferred(mapListener::getLiteEvents, is(2));
178176

179177
customers.removeMapListener(mapListener, eventFilter);
180178
// #end::testListenOnQueries[]
@@ -205,8 +203,8 @@ public void testMapListeners() {
205203
customers.invoke(2, Processors.update(Customer::setCustomerType, Customer.SILVER));
206204

207205
// ensure that we see all events // <5>
208-
Eventually.assertThat(invoking(mapListener).getInsertCount(), is(1));
209-
Eventually.assertThat(invoking(mapListener).getUpdateCount(), is(2));
206+
Eventually.assertDeferred(mapListener::getInsertCount, is(1));
207+
Eventually.assertDeferred(mapListener::getUpdateCount, is(2));
210208

211209
customers.removeMapListener(mapListener, eventFilter);
212210
// #end::testEventTypes[]

prj/examples/guides/190-cache-stores/src/test/java/com/oracle/coherence/guides/cachestores/HSqlDbCacheStoreWriteBehindTest.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000-2021 Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.oracle.coherence.guides.cachestores;
88

@@ -18,7 +18,6 @@
1818
import org.junit.jupiter.api.BeforeAll;
1919
import org.junit.jupiter.api.Test;
2020

21-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
2221
import static org.hamcrest.CoreMatchers.is;
2322
import static org.junit.jupiter.api.Assertions.assertEquals;
2423

@@ -67,7 +66,7 @@ public void testHsqlDbCacheStore() throws SQLException {
6766
Base.sleep(15000L);
6867

6968
// Issuing Eventually assertThat in case of heavily loaded machine
70-
Eventually.assertThat(invoking(this).getCustomerDBCount(), is(100));
69+
Eventually.assertDeferred(this::getCustomerDBCount, is(100));
7170
// #end::wait[]
7271
}
7372
finally {

prj/examples/guides/200-federation/src/test/java/com/oracle/coherence/guides/federation/FederationExampleTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import java.util.HashMap;
3737
import java.util.Map;
3838

39-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
4039
import static org.hamcrest.CoreMatchers.is;
4140
import static org.junit.jupiter.api.Assertions.assertEquals;
4241

@@ -71,8 +70,8 @@ public static void _startup() {
7170
secondaryMember = platform.launch(CoherenceCacheServer.class, secondaryClusterOptions.asArray());
7271

7372

74-
Eventually.assertThat(invoking(primaryMember).getClusterSize(), is(1));
75-
Eventually.assertThat(invoking(secondaryMember).getClusterSize(), is(1));
73+
Eventually.assertDeferred(() -> primaryMember.getClusterSize(), is(1));
74+
Eventually.assertDeferred(() -> secondaryMember.getClusterSize(), is(1));
7675
}
7776

7877
@AfterAll

prj/examples/tutorials/200-persistence/src/test/java/com/oracle/coherence/tutorials/persistence/PersistenceExampleTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -41,7 +41,6 @@
4141
import java.util.Map;
4242
import java.util.concurrent.TimeUnit;
4343

44-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
4544
import static com.oracle.coherence.tutorials.persistence.NotificationWatcher.waitForRegistration;
4645
import static org.junit.jupiter.api.Assertions.assertEquals;
4746

@@ -125,7 +124,7 @@ public void runTest() throws Exception {
125124

126125
invokeOperationWithWait(registry, "createSnapshot", SERVICE_NAME, "snapshot1");
127126

128-
Eventually.assertThat(invoking(listener).getEventCount(), Matchers.is(2));
127+
Eventually.assertDeferred(() -> listener.getEventCount(), Matchers.is(2));
129128

130129
server.removeNotificationListener(mBean, listener);
131130
}

prj/test/distribution/osgi/src/test/java/com/tangosol/coherence/osgi/TestCacheServerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.coherence.osgi;
88

@@ -58,13 +58,13 @@ public void testCacheServer() throws BundleException, InterruptedException
5858
assertThat(container.getBundle("Coherence"), hasState(Bundle.ACTIVE));
5959
assertThat(container.getBundle("CoherenceTestCacheServer"), hasState(Bundle.ACTIVE));
6060

61-
Eventually.assertThat(invoking(hasThreadGroupSize(is(5))).matches("TestCacheServerPartitionedService"), is(true));
61+
Eventually.assertDeferred(() -> hasThreadGroupSize(is(5)).matches("TestCacheServerPartitionedService"), is(true));
6262

6363
// stop the bundle and ensure there are no threads associated
6464
// with the service remaining
6565
container.getBundle("CoherenceTestCacheServer").stop();
6666
listBundles();
6767

68-
Eventually.assertThat(invoking(hasThreadGroupSize(anyOf(nullValue(), is(0)))).matches("TestCacheServerPartitionedService"), is(true));
68+
Eventually.assertDeferred(() -> hasThreadGroupSize(anyOf(nullValue(), is(0))).matches("TestCacheServerPartitionedService"), is(true));
6969
}
7070
}

prj/test/performance/psr/src/test/java/com/tangosol/coherence/performance/AbstractPerformanceTests.java

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2020, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.coherence.performance;
88

@@ -13,6 +13,7 @@
1313
import com.oracle.bedrock.runtime.concurrent.RemoteCallable;
1414
import com.oracle.bedrock.testsupport.deferred.Eventually;
1515
import com.oracle.bedrock.util.Pair;
16+
import com.oracle.coherence.common.base.Exceptions;
1617
import com.oracle.coherence.common.base.Timeout;
1718
import com.tangosol.coherence.performance.psr.Console;
1819
import com.tangosol.coherence.performance.psr.ConsoleExtended;
@@ -40,11 +41,11 @@
4041
import java.util.Map;
4142
import java.util.concurrent.ExecutionException;
4243
import java.util.concurrent.TimeUnit;
44+
import java.util.concurrent.TimeoutException;
4345
import java.util.function.BiFunction;
4446
import java.util.function.Supplier;
4547
import java.util.stream.Collectors;
4648

47-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
4849
import static com.oracle.bedrock.deferred.DeferredHelper.within;
4950
import static org.hamcrest.CoreMatchers.is;
5051
import static org.hamcrest.CoreMatchers.notNullValue;
@@ -241,17 +242,24 @@ public void beforeParameters() throws Throwable
241242
for (CoherenceClusterMember member : members)
242243
{
243244
System.err.println("Waiting for " + member.getName() + " to be balanced");
244-
Eventually.assertThat(invoking(this).isBalanced(member, status), is(true), within(5, TimeUnit.MINUTES));
245+
Eventually.assertDeferred(() -> this.isBalanced(member, status), is(true), within(5, TimeUnit.MINUTES));
245246
}
246247
System.err.println("All storage members balanced.");
247248

248249
System.err.println("Waiting for Console to be ready...");
249-
Eventually.assertThat(invoking(f_environment).isConsoleReady(), is(true));
250+
Eventually.assertDeferred(() -> f_environment.isConsoleReady(), is(true));
250251
}
251252

252-
public boolean isBalanced(CoherenceClusterMember member, ServiceStatus status) throws Exception
253+
public boolean isBalanced(CoherenceClusterMember member, ServiceStatus status)
253254
{
254-
return member.submit(new IsBalanced(status)).get(1, TimeUnit.MINUTES);
255+
try
256+
{
257+
return member.submit(new IsBalanced(status)).get(1, TimeUnit.MINUTES);
258+
}
259+
catch (Exception e)
260+
{
261+
throw Exceptions.ensureRuntimeException(e);
262+
}
255263
}
256264

257265

prj/test/performance/psr/src/test/java/com/tangosol/coherence/performance/PsrPerformanceEnvironment.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
55
* https://oss.oracle.com/licenses/upl.
@@ -44,6 +44,7 @@
4444
import com.oracle.bedrock.runtime.remote.java.options.JavaDeployment;
4545
import com.oracle.bedrock.testsupport.deferred.Eventually;
4646
import com.oracle.bedrock.util.Capture;
47+
import com.oracle.coherence.common.base.Exceptions;
4748
import com.oracle.coherence.common.util.MemorySize;
4849
import com.tangosol.coherence.performance.psr.Console;
4950
import com.tangosol.coherence.performance.psr.ConsoleExtended;
@@ -77,9 +78,7 @@
7778
import java.util.stream.Collectors;
7879
import java.util.stream.StreamSupport;
7980

80-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
8181
import static org.hamcrest.CoreMatchers.is;
82-
import static org.junit.Assert.assertThat;
8382

8483
/**
8584
* @author jk 2015.11.26
@@ -940,8 +939,8 @@ protected CoherenceCluster startCluster(
940939

941940
for (CoherenceClusterMember member : cluster)
942941
{
943-
Eventually.assertThat(invoking(member).getClusterSize(), is(nSize));
944-
Eventually.assertThat(invoking(this).areAllAutoStartServicesRunning(member), is(true));
942+
Eventually.assertDeferred(member::getClusterSize, is(nSize));
943+
Eventually.assertDeferred(() -> this.areAllAutoStartServicesRunning(member), is(true));
945944
}
946945
}
947946
catch (Throwable t)
@@ -957,9 +956,16 @@ protected CoherenceCluster startCluster(
957956
}
958957

959958
// Must be public - used in Eventually.assertThat
960-
public boolean areAllAutoStartServicesRunning(CoherenceClusterMember member) throws Exception
959+
public boolean areAllAutoStartServicesRunning(CoherenceClusterMember member)
961960
{
962-
return member.submit(new AreAllAutoStartServicesRunning()).get(2, TimeUnit.MINUTES);
961+
try
962+
{
963+
return member.submit(new AreAllAutoStartServicesRunning()).get(2, TimeUnit.MINUTES);
964+
}
965+
catch (Exception e)
966+
{
967+
throw Exceptions.ensureRuntimeException(e);
968+
}
963969
}
964970

965971
protected void modifySchema(Platform platform, OptionsByType schema)
@@ -1119,7 +1125,7 @@ private synchronized CoherenceCluster startClients(PlatformGroup<Platform> Platf
11191125
{
11201126
for (CoherenceClusterMember runner : assembly)
11211127
{
1122-
Eventually.assertThat(invoking(runner).submit(new RunnerIsRunning()), is(true));
1128+
Eventually.assertDeferred(() -> runner.submit(new RunnerIsRunning()), is(true));
11231129
}
11241130
}
11251131

prj/test/unit/coherence-tests/src/test/java/com/tangosol/coherence/component/util/DaemonPoolComponentTest.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.coherence.component.util;
88

@@ -21,7 +21,6 @@
2121
import org.junit.Before;
2222
import org.junit.Test;
2323

24-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
2524
import static org.hamcrest.core.Is.is;
2625
import static org.junit.Assert.*;
2726

@@ -118,13 +117,13 @@ protected void testResizeWithAssociatedBacklog(final int cThreadsDelta)
118117
// wait for the work to complete and validate the order of execution
119118
for (TestRunnable task : listWork)
120119
{
121-
Eventually.assertThat(invoking(task).wasExecuted(), is(true));
120+
Eventually.assertDeferred(task::wasExecuted, is(true));
122121

123122
assertTrue(task.wasExecutedInOrder());
124123
}
125124

126-
Eventually.assertThat("Queue is stuck at " + getBacklog(),
127-
invoking(this).getBacklog(), is(0));
125+
Eventually.assertDeferred("Queue is stuck at " + getBacklog(),
126+
this::getBacklog, is(0));
128127

129128
try
130129
{

prj/test/unit/coherence-tests/src/test/java/com/tangosol/internal/util/DaemonPoolTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
2-
* Copyright (c) 2000, 2022, Oracle and/or its affiliates.
2+
* Copyright (c) 2000, 2025, Oracle and/or its affiliates.
33
*
44
* Licensed under the Universal Permissive License v 1.0 as shown at
5-
* http://oss.oracle.com/licenses/upl.
5+
* https://oss.oracle.com/licenses/upl.
66
*/
77
package com.tangosol.internal.util;
88

@@ -37,7 +37,6 @@
3737

3838
import org.mockito.stubbing.Answer;
3939

40-
import static com.oracle.bedrock.deferred.DeferredHelper.invoking;
4140
import static org.hamcrest.Matchers.is;
4241
import static org.hamcrest.Matchers.notNullValue;
4342
import static org.junit.Assert.*;
@@ -176,7 +175,7 @@ public void testGuardianRecovery()
176175
TestRunnable task = new TestRunnable(0, 4000L);
177176
pool.add(task);
178177

179-
Eventually.assertThat(invoking(task).getGuardable(), is(notNullValue()));
178+
Eventually.assertDeferred(task::getGuardable, is(notNullValue()));
180179
guardable = task.getGuardable();
181180
sleep(1000L);
182181

@@ -196,7 +195,7 @@ public void testGuardianTermination()
196195
TestRunnable task = new TestRunnable(0, 4000L);
197196
pool.add(task);
198197

199-
Eventually.assertThat(invoking(task).getGuardable(), is(notNullValue()));
198+
Eventually.assertDeferred(task::getGuardable, is(notNullValue()));
200199
guardable = task.getGuardable();
201200

202201
sleep(1000L);

0 commit comments

Comments
 (0)