Removing awaitActivation and awaitDeactivation and just retain the future-returning methods as to promote not to block.
This commit is contained in:
parent
52e4a18ebe
commit
7ba74434de
10 changed files with 179 additions and 215 deletions
|
|
@ -7,10 +7,12 @@ package akka.camel;
|
|||
import akka.actor.ActorRef;
|
||||
import akka.actor.ActorSystem;
|
||||
import akka.actor.Props;
|
||||
import scala.concurrent.util.FiniteDuration;
|
||||
import scala.concurrent.Await;
|
||||
import scala.concurrent.util.Duration;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -22,7 +24,7 @@ import static org.junit.Assert.assertEquals;
|
|||
public class ConsumerJavaTestBase {
|
||||
|
||||
static ActorSystem system = ActorSystem.create("test");
|
||||
static Camel camel = (Camel) CamelExtension.get(system);
|
||||
static Camel camel = CamelExtension.get(system);
|
||||
|
||||
|
||||
@AfterClass
|
||||
|
|
@ -31,9 +33,11 @@ public class ConsumerJavaTestBase {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleExceptionThrownByActorAndGenerateCustomResponse() {
|
||||
ActorRef ref = system.actorOf(new Props().withCreator(SampleErrorHandlingConsumer.class));
|
||||
camel.awaitActivation(ref, new FiniteDuration(1, TimeUnit.SECONDS));
|
||||
public void shouldHandleExceptionThrownByActorAndGenerateCustomResponse() throws Exception {
|
||||
Duration timeout = Duration.create(1, TimeUnit.SECONDS);
|
||||
ActorRef ref = Await.result(
|
||||
camel.activationFutureFor(system.actorOf(new Props(SampleErrorHandlingConsumer.class)), timeout),
|
||||
timeout);
|
||||
|
||||
String result = camel.template().requestBody("direct:error-handler-test-java", "hello", String.class);
|
||||
assertEquals("error: hello", result);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue