make java sample code independent of Scala (#25800)
* need this for gathering and compiling java sources (in IDE), https://github.com/patriknw/akka-compile-ide-java
This commit is contained in:
parent
e7347ffee4
commit
d71ba251ed
2 changed files with 24 additions and 8 deletions
|
|
@ -11,17 +11,33 @@ import akka.cluster.ClusterEvent;
|
|||
import akka.cluster.typed.*;
|
||||
//#cluster-imports
|
||||
import akka.actor.testkit.typed.javadsl.TestProbe;
|
||||
import docs.akka.cluster.typed.BasicClusterManualSpec;
|
||||
import com.typesafe.config.Config;
|
||||
import com.typesafe.config.ConfigFactory;
|
||||
|
||||
// FIXME these tests are awaiting typed Java testkit to be able to await cluster forming like in BasicClusterExampleSpec
|
||||
public class BasicClusterExampleTest { // extends JUnitSuite {
|
||||
|
||||
private Config clusterConfig = ConfigFactory.parseString(
|
||||
"akka { \n" +
|
||||
" actor.provider = cluster \n" +
|
||||
" remote { \n" +
|
||||
" netty.tcp { \n" +
|
||||
" hostname = \"127.0.0.1\" \n" +
|
||||
" port = 2551 \n" +
|
||||
" } \n" +
|
||||
" } \n" +
|
||||
"} \n");
|
||||
|
||||
private Config noPort = ConfigFactory.parseString(
|
||||
" akka.remote.netty.tcp.port = 0 \n" +
|
||||
" akka.remote.artery.canonical.port = 0 \n");
|
||||
|
||||
// @Test
|
||||
public void clusterApiExample() {
|
||||
ActorSystem<Object> system = ActorSystem.create(Behaviors.empty(), "ClusterSystem",
|
||||
BasicClusterManualSpec.noPort().withFallback(BasicClusterManualSpec.clusterConfig()));
|
||||
noPort.withFallback(clusterConfig));
|
||||
ActorSystem<Object> system2 = ActorSystem.create(Behaviors.empty(), "ClusterSystem",
|
||||
BasicClusterManualSpec.noPort().withFallback(BasicClusterManualSpec.clusterConfig()));
|
||||
noPort.withFallback(clusterConfig));
|
||||
|
||||
try {
|
||||
//#cluster-create
|
||||
|
|
@ -52,9 +68,9 @@ public class BasicClusterExampleTest { // extends JUnitSuite {
|
|||
// @Test
|
||||
public void clusterLeave() throws Exception {
|
||||
ActorSystem<Object> system = ActorSystem.create(Behaviors.empty(), "ClusterSystem",
|
||||
BasicClusterManualSpec.noPort().withFallback(BasicClusterManualSpec.clusterConfig()));
|
||||
noPort.withFallback(clusterConfig));
|
||||
ActorSystem<Object> system2 = ActorSystem.create(Behaviors.empty(), "ClusterSystem",
|
||||
BasicClusterManualSpec.noPort().withFallback(BasicClusterManualSpec.clusterConfig()));
|
||||
noPort.withFallback(clusterConfig));
|
||||
|
||||
try {
|
||||
Cluster cluster = Cluster.get(system);
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@
|
|||
* Copyright (C) 2016-2018 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package jdocs
|
||||
package jdocs;
|
||||
|
||||
import org.scalatest.junit.JUnitSuite
|
||||
import org.scalatest.junit.JUnitSuite;
|
||||
|
||||
/**
|
||||
* Base class for all runnable example tests written in Java
|
||||
*/
|
||||
abstract class AbstractJavaTest extends JUnitSuite {
|
||||
public abstract class AbstractJavaTest extends JUnitSuite {
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue