THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
- AsyncInvocation – return type from VM#invokeAsync and implements Future
- Disconnect – disconnect in all or specified VM
- Host – provides the DUnit VMs
- VM – provides invocation API for a DUnit VM
...
Code Block |
---|
package org.apache.geode.internal.cache.backup; import static org.apache.geode.test.dunit.Disconnect.disconnectAllFromDS; import static org.apache.geode.test.dunit.Disconnect.disconnectFromDS; import static org.apache.geode.test.dunit.Host.getHost; import static org.apache.geode.test.dunit.IgnoredException.addIgnoredException; import static org.apache.geode.test.dunit.Invoke.invokeInEveryVM; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.awaitility.Awaitility.await; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; import org.junit.Rule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.apache.geode.test.dunit.VM; import org.apache.geode.test.dunit.rules.CacheRule; import org.apache.geode.test.dunit.rules.DistributedRestoreSystemProperties; import org.apache.geode.test.dunit.rules.DistributedTestRule; import org.apache.geode.test.dunit.rules.SharedCountersRule; import org.apache.geode.test.dunit.rules.SharedErrorCollector; import org.apache.geode.test.junit.categories.DistributedTest; /** * Use DistributedRule to launch additional JVMs to use in the test.<br> * Use CacheRule to keep references to Cache in each JVM which will be cleaned up.<br> * Use DistributedRestoreSystemProperties to restore properties across all JVMs.<br> * Use SharedCountersRule for blackboard style counters in all JVMs.<br> * Use SharedErrorCollector to perform assertions in callbacks/listeners.<br> * Use SerializableTemporaryFolder to provide temporary directories for all JVMs.<br> * <p> * Above static imports show the most commonly used DUnit utilities, AssertJ and * Awaitility. */ @SuppressWarnings("serial") public class OpsWithChangingMembershipDistributedTest implements Serializable { private VM vm0; private VM vm1; private VM vm2; private VM vm3; @Rule public DistributedRule distributedRule = new DistributedRule(); @Rule public CacheRule cacheRule = new CacheRule(); @Rule public DistributedRestoreSystemProperties restoreSystemProperties = new DistributedRestoreSystemProperties(); @Rule public SharedErrorCollector errorCollector = new SharedErrorCollector(); @Rule public SerializableTemporaryFolder temporaryFolder = new SerializableTemporaryFolder(); @Before public void setUp() { // arrange: perform as much of your setUp as possible in @Before vm0.invoke(() -> { Cache cache = cacheRule.getOrCreateCache(); // additional setup }); } @Test public void incrementalBackupWithMissingBaselineThrows() { // act: manipulate VMs with invoke or invokeAsync // assert: don't forget to actually use assertions! } } |