title: How to test an untyped actor deployment from a typed context using akka BehaviorTestKit?
body: <p>I'm working on typed akka application and for some reason, I need to use untyped actors from typed context.</p>
  
  <p>I wrote a simple test to try BehaviorTestKit and typed akka testkit. For typed actors it works but for an actor with untyped child I get <strong>"only adapted untyped ActorContext permissible</strong>" error.</p>
  
  <p>Here is the parent actor:</p>
  
  <pre><code>public class AppGuardianTest extends AbstractBehavior&lt;String&gt; {
      private ActorContext context;
  
      public AppGuardianTest(ActorContext context) {
          this.context = context;
  
          ActorRef child = Adapter.actorOf(context, SomeUntypedActor.props(), "child");     
      }
      @Override
      public Receive&lt;String&gt; createReceive() {
          return receiveBuilder()
                  .onMessage(String.class, m -&gt; Behaviors.same())
                  .onSignal(PostStop.class, signal -&gt; postStop()).build();
      }
      private Behavior&lt;String&gt; postStop() {
          context.getLog().info("Application stopped");
          return this;
      }
      public static Behavior behavior() {
          return Behaviors.setup(AppGuardianTest::new);
      }
  }
  </code></pre>
  
  <p>The child actor</p>
  
  <pre><code>public class SomeUntypedActor extends AbstractActor {
      public static Props props() {
          return Props.create(SomeUntypedActor.class);
      }
  
      @Override
      public Receive createReceive() {
          return receiveBuilder().matchAny(m -&gt; {
              System.out.println(m);
          }).build();
      }
  }
  </code></pre>
  
  <p>and the test</p>
  
  <pre><code>import akka.actor.testkit.typed.scaladsl.{BehaviorTestKit, ScalaTestWithActorTestKit}
  import some.test.AppGuardianTest
  import org.scalatest.WordSpecLike
  class AppGuardianSpec extends ScalaTestWithActorTestKit with WordSpecLike {
  
    "appGuardian" should {
      "deploy child" in {
        val testKit = BehaviorTestKit(AppGuardianTest.behavior())
        val child = testKit.childInbox[String]("child")
      }
    }
  }
  </code></pre>
  
  <p>Exception:</p>
  
  <pre><code>only adapted untyped ActorContext permissible (Inbox(Actor[akka.actor.typed.inbox://anonymous/testkit#1338528633]) of class akka.actor.testkit.typed.internal.EffectfulActorContext)
  java.lang.UnsupportedOperationException: only adapted untyped ActorContext permissible (Inbox(Actor[akka.actor.typed.inbox://anonymous/testkit#1338528633]) of class akka.actor.testkit.typed.internal.EffectfulActorContext)
      at akka.actor.typed.internal.adapter.ActorContextAdapter$.toUntypedImp(ActorContextAdapter.scala:110)
      at akka.actor.typed.internal.adapter.ActorContextAdapter$.toUntyped(ActorContextAdapter.scala:125)
      at akka.actor.typed.javadsl.Adapter$.actorOf(Adapter.scala:88)
      at akka.actor.typed.javadsl.Adapter.actorOf(Adapter.scala)
      at some.test.AppGuardianTest.&lt;init&gt;(AppGuardianTest.java:15)
      at akka.actor.typed.javadsl.Behaviors$.$anonfun$setup$1(Behaviors.scala:43)
      at akka.actor.typed.Behavior$DeferredBehavior$$anon$1.apply(Behavior.scala:239)
      at akka.actor.typed.Behavior$.start(Behavior.scala:324)
  ...
  </code></pre>