Skip to content

Commit

Permalink
Simplified serialization test a bit.
Browse files Browse the repository at this point in the history
Signed-off-by: Juergen Fickel <juergen.fickel@bosch.io>
  • Loading branch information
Juergen Fickel committed Jan 19, 2022
1 parent ee9eca4 commit 7620c8c
Showing 1 changed file with 9 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,41 +12,33 @@
*/
package org.eclipse.ditto.connectivity.service.messaging;

import static org.assertj.core.api.Assertions.assertThat;

import org.eclipse.ditto.internal.utils.akka.ActorSystemResource;
import org.junit.ClassRule;
import org.junit.Test;

import com.typesafe.config.ConfigFactory;

import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.testkit.javadsl.TestKit;

/**
* Unit test for {@link ClientActorRefs}.
*/
public final class ClientActorRefsTest {

@ClassRule
public static ActorSystemResource actorSystemResource =
public static final ActorSystemResource ACTOR_SYSTEM_RESOURCE =
ActorSystemResource.newInstance(ConfigFactory.load("client-actor-refs-test"));

@Test
public void serializationWorks() {
final ActorSystem actorSystem = actorSystemResource.getActorSystem();
final ActorRef ref1 = actorSystemResource.newTestProbe().ref();
final ActorRef ref2 = actorSystemResource.newTestProbe().ref();
final var underTest = ClientActorRefs.empty();
underTest.add(ref1);
underTest.add(ref2);
final var messageReceiver = new TestKit(actorSystem);
final var messageSender = new TestKit(actorSystem);
underTest.add(ACTOR_SYSTEM_RESOURCE.newTestProbe().ref());
underTest.add(ACTOR_SYSTEM_RESOURCE.newTestProbe().ref());
final var messageReceiver = ACTOR_SYSTEM_RESOURCE.newTestKit();
final var messageSender = ACTOR_SYSTEM_RESOURCE.newTestKit();
final var messageReceiverRef = messageReceiver.getRef();

messageReceiverRef.tell(underTest, messageSender.getRef());

final var receivedClientActorRefs = messageReceiver.expectMsgClass(underTest.getClass());

assertThat(receivedClientActorRefs).isEqualTo(underTest);
messageReceiver.expectMsg(underTest);
}

}

0 comments on commit 7620c8c

Please sign in to comment.