<commit_before>package com.carmanconsulting.akka;

import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.Terminated;
import akka.actor.UntypedActor;
import org.junit.Test;

public class StoppingTest extends AkkaTestCase {
//----------------------------------------------------------------------------------------------------------------------
// Other Methods
//----------------------------------------------------------------------------------------------------------------------

    @Test
    public void testStopMethod() {
        ActorRef echo = system().actorOf(Props.create(EchoAndStop.class), "echo");
        watch(echo);
        echo.tell("Hello", testActor());
        expectMsg("Hello");
        expectMsgClass(Terminated.class);
    }

//----------------------------------------------------------------------------------------------------------------------
// Inner Classes
//----------------------------------------------------------------------------------------------------------------------

    public static class EchoAndStop extends UntypedActor {
        @Override
        public void onReceive(Object message) throws Exception {
            sender().tell(message, self());
            context().stop(self());
        }
    }

    public static class EchoAndStopAfterN extends UntypedActor {
        private int n;

        public EchoAndStopAfterN(int n) {
            this.n = n;
        }

        @Override
        public void onReceive(Object message) throws Exception {
            sender().tell(message, self());
            if (n-- == 0) {
                self().tell(PoisonPill.getInstance(), ActorRef.noSender());
            }

        }
    }
}<commit_msg>Removing unused code.<commit_after>package com.carmanconsulting.akka;

import akka.actor.ActorRef;
import akka.actor.PoisonPill;
import akka.actor.Props;
import akka.actor.Terminated;
import akka.actor.UntypedActor;
import org.junit.Test;

public class StoppingTest extends AkkaTestCase {
//----------------------------------------------------------------------------------------------------------------------
// Other Methods
//----------------------------------------------------------------------------------------------------------------------

    @Test
    public void testStopMethod() {
        ActorRef echo = system().actorOf(Props.create(EchoAndStop.class), "echo");
        watch(echo);
        echo.tell("Hello", testActor());
        expectMsg("Hello");
        expectMsgClass(Terminated.class);
    }

//----------------------------------------------------------------------------------------------------------------------
// Inner Classes
//----------------------------------------------------------------------------------------------------------------------

    public static class EchoAndStop extends UntypedActor {
        @Override
        public void onReceive(Object message) throws Exception {
            sender().tell(message, self());
            context().stop(self());
        }
    }
}
{'fraction_non_alphanumeric': 0.3913470993117011, 'fraction_numerical': 0.00032776138970829236, 'mean_word_length': 0.9805321219987021, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1563413', 'n_tokens_mistral': 648, 'n_tokens_neox': 609, 'n_words': 134}