2012-01-19 14:38:44 +00:00
|
|
|
/**
|
|
|
|
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
|
|
|
|
*/
|
2011-05-23 11:37:56 -04:00
|
|
|
|
2012-01-19 14:38:44 +00:00
|
|
|
package akka.camel;
|
2011-05-23 11:37:56 -04:00
|
|
|
|
2012-01-19 14:38:44 +00:00
|
|
|
import akka.actor.ActorRef;
|
|
|
|
|
import akka.actor.ActorSystem;
|
|
|
|
|
import akka.actor.Props;
|
2012-06-29 13:33:20 +02:00
|
|
|
import scala.concurrent.util.FiniteDuration;
|
2011-05-23 11:37:56 -04:00
|
|
|
import org.junit.AfterClass;
|
|
|
|
|
import org.junit.Test;
|
|
|
|
|
|
2012-01-19 14:38:44 +00:00
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
import static org.junit.Assert.assertEquals;
|
2011-05-23 11:37:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author Martin Krasser
|
|
|
|
|
*/
|
|
|
|
|
public class ConsumerJavaTestBase {
|
|
|
|
|
|
2012-01-19 14:38:44 +00:00
|
|
|
static ActorSystem system = ActorSystem.create("test");
|
|
|
|
|
static Camel camel = (Camel) CamelExtension.get(system);
|
|
|
|
|
|
2011-05-23 11:37:56 -04:00
|
|
|
|
|
|
|
|
@AfterClass
|
|
|
|
|
public static void tearDownAfterClass() {
|
2012-01-19 14:38:44 +00:00
|
|
|
system.shutdown();
|
2011-05-23 11:37:56 -04:00
|
|
|
}
|
|
|
|
|
|
2012-01-19 14:38:44 +00:00
|
|
|
@Test
|
2011-05-23 11:37:56 -04:00
|
|
|
public void shouldHandleExceptionThrownByActorAndGenerateCustomResponse() {
|
2012-01-19 14:38:44 +00:00
|
|
|
ActorRef ref = system.actorOf(new Props().withCreator(SampleErrorHandlingConsumer.class));
|
|
|
|
|
camel.awaitActivation(ref, new FiniteDuration(1, TimeUnit.SECONDS));
|
|
|
|
|
|
|
|
|
|
String result = camel.template().requestBody("direct:error-handler-test-java", "hello", String.class);
|
2011-05-23 11:37:56 -04:00
|
|
|
assertEquals("error: hello", result);
|
|
|
|
|
}
|
|
|
|
|
}
|