pekko/akka-docs/src/test/java/jdocs/persistence/testkit/PersistenceInitTest.java

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

49 lines
1.6 KiB
Java
Raw Normal View History

2020-03-30 16:24:38 +02:00
/*
2022-02-04 12:36:44 +01:00
* Copyright (C) 2020-2022 Lightbend Inc. <https://www.lightbend.com>
2020-03-30 16:24:38 +02:00
*/
package jdocs.persistence.testkit;
import org.apache.pekko.actor.testkit.typed.javadsl.TestKitJunitResource;
2020-03-30 16:24:38 +02:00
import com.typesafe.config.ConfigFactory;
import jdocs.AbstractJavaTest;
import org.junit.ClassRule;
import org.junit.Test;
import java.util.UUID;
2020-03-30 16:56:22 +02:00
// #imports
import org.apache.pekko.persistence.testkit.javadsl.PersistenceInit;
import org.apache.pekko.Done;
2020-03-30 16:24:38 +02:00
import java.time.Duration;
import java.util.concurrent.CompletionStage;
import java.util.concurrent.TimeUnit;
2020-03-30 16:56:22 +02:00
// #imports
2020-03-30 16:24:38 +02:00
public class PersistenceInitTest extends AbstractJavaTest {
@ClassRule
public static final TestKitJunitResource testKit =
2020-03-30 16:56:22 +02:00
new TestKitJunitResource(
ConfigFactory.parseString(
"akka.persistence.journal.plugin = \"akka.persistence.journal.inmem\" \n"
+ "akka.persistence.journal.inmem.test-serialization = on \n"
+ "akka.persistence.snapshot-store.plugin = \"akka.persistence.snapshot-store.local\" \n"
+ "akka.persistence.snapshot-store.local.dir = \"target/snapshot-"
+ UUID.randomUUID().toString()
+ "\" \n")
.withFallback(ConfigFactory.defaultApplication()));
2020-03-30 16:24:38 +02:00
@Test
public void testInit() throws Exception {
2020-03-30 16:56:22 +02:00
// #init
2020-03-30 16:24:38 +02:00
Duration timeout = Duration.ofSeconds(5);
2020-03-30 16:56:22 +02:00
CompletionStage<Done> done =
PersistenceInit.initializeDefaultPlugins(testKit.system(), timeout);
2020-03-30 16:24:38 +02:00
done.toCompletableFuture().get(timeout.getSeconds(), TimeUnit.SECONDS);
2020-03-30 16:56:22 +02:00
// #init
2020-03-30 16:24:38 +02:00
}
}