<commit_before>package org.elasticsoftware.elasticactors.test;

import org.apache.log4j.BasicConfigurator;
import org.elasticsoftware.elasticactors.ActorRef;
import org.elasticsoftware.elasticactors.ActorSystem;
import org.elasticsoftware.elasticactors.base.actors.ActorDelegate;
import org.elasticsoftware.elasticactors.base.actors.ReplyActor;
import org.testng.annotations.Test;

import java.util.concurrent.CountDownLatch;

import static java.lang.String.format;

/**
 * @author <NAME>
 */
public class GreetingTest {
    @Test
    public void testGreeting() throws Exception {
        BasicConfigurator.configure();
        TestActorSystem testActorSystem = new TestActorSystem();
        testActorSystem.initialize();

        ActorSystem actorSystem = testActorSystem.getActorSystem();
        ActorRef greeter = actorSystem.actorOf("greeter",GreetingActor.class);

        //ScheduledMessageRef messageRef = actorSystem.getScheduler().scheduleOnce(null,new Greeting("Delayed Message"),greeter,2, TimeUnit.SECONDS);

        final CountDownLatch countDownLatch = new CountDownLatch(2);

        ActorRef replyActor = actorSystem.tempActorOf(ReplyActor.class,new ActorDelegate(false) {
            @Override
            public void onReceive(ActorRef sender, Object message) throws Exception {
                if(message instanceof ScheduledGreeting) {
                    System.out.println("Got Scheduled Greeting");
                } else if(message instanceof Greeting) {
                    System.out.println(format("Got Greeting from %s",((Greeting)message).getWho()));
                }
                countDownLatch.countDown();
            }
        });

        greeter.tell(new Greeting("<NAME>"),replyActor);

        countDownLatch.await();

        testActorSystem.destroy();
    }
}<commit_msg>made test more resilient to failures (don't wait forever on the CountDownLatch)<commit_after>package org.elasticsoftware.elasticactors.test;

import org.apache.log4j.BasicConfigurator;
import org.elasticsoftware.elasticactors.ActorRef;
import org.elasticsoftware.elasticactors.ActorSystem;
import org.elasticsoftware.elasticactors.base.actors.ActorDelegate;
import org.elasticsoftware.elasticactors.base.actors.ReplyActor;
import org.testng.annotations.Test;

import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;

import static java.lang.String.format;
import static org.testng.Assert.assertTrue;

/**
 * @author <NAME>
 */
public class GreetingTest {
    @Test
    public void testGreeting() throws Exception {
        BasicConfigurator.configure();
        TestActorSystem testActorSystem = new TestActorSystem();
        testActorSystem.initialize();

        ActorSystem actorSystem = testActorSystem.getActorSystem();
        ActorRef greeter = actorSystem.actorOf("greeter",GreetingActor.class);

        //ScheduledMessageRef messageRef = actorSystem.getScheduler().scheduleOnce(null,new Greeting("Delayed Message"),greeter,2, TimeUnit.SECONDS);

        final CountDownLatch countDownLatch = new CountDownLatch(2);

        ActorRef replyActor = actorSystem.tempActorOf(ReplyActor.class,new ActorDelegate(false) {
            @Override
            public void onReceive(ActorRef sender, Object message) throws Exception {
                if(message instanceof ScheduledGreeting) {
                    System.out.println("Got Scheduled Greeting");
                } else if(message instanceof Greeting) {
                    System.out.println(format("Got Greeting from %s",((Greeting)message).getWho()));
                }
                countDownLatch.countDown();
            }
        });

        greeter.tell(new Greeting("<NAME>"),replyActor);

        assertTrue(countDownLatch.await(5, TimeUnit.SECONDS));

        testActorSystem.destroy();
    }
}
{'fraction_non_alphanumeric': 0.09892416688533194, 'fraction_numerical': 0.0018367882445552348, 'mean_word_length': 3.406936416184971, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '4266690', 'n_tokens_mistral': 1071, 'n_tokens_neox': 1003, 'n_words': 187}