Merge with master

This commit is contained in:
Viktor Klang 2012-08-14 16:29:38 +02:00
commit 4a15892b84
13 changed files with 159 additions and 269 deletions

View file

@ -7,14 +7,15 @@ package akka.camel;
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.testkit.JavaTestKit;
import scala.concurrent.Await;
import scala.concurrent.ExecutionContext;
import scala.concurrent.util.Duration;
import org.junit.AfterClass;
import org.junit.Test;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import akka.testkit.AkkaSpec;
import akka.testkit.JavaTestKit.EventFilter;
import static org.junit.Assert.assertEquals;
@ -24,9 +25,7 @@ import static org.junit.Assert.assertEquals;
*/
public class ConsumerJavaTestBase {
static ActorSystem system = ActorSystem.create("test");
static Camel camel = CamelExtension.get(system);
static ActorSystem system = ActorSystem.create("test", AkkaSpec.testConf());
@AfterClass
public static void tearDownAfterClass() {
@ -35,13 +34,24 @@ public class ConsumerJavaTestBase {
@Test
public void shouldHandleExceptionThrownByActorAndGenerateCustomResponse() throws Exception {
Duration timeout = Duration.create(1, TimeUnit.SECONDS);
ExecutionContext executionContext = system.dispatcher();
ActorRef ref = Await.result(
camel.activationFutureFor(system.actorOf(new Props(SampleErrorHandlingConsumer.class)), timeout, executionContext),
timeout);
String result = camel.template().requestBody("direct:error-handler-test-java", "hello", String.class);
assertEquals("error: hello", result);
new JavaTestKit(system) {{
String result = new EventFilter<String>(Exception.class) {
protected String run() {
Duration timeout = Duration.create(1, TimeUnit.SECONDS);
Camel camel = CamelExtension.get(system);
ExecutionContext executionContext = system.dispatcher();
try {
ActorRef ref = Await.result(
camel.activationFutureFor(system.actorOf(new Props(SampleErrorHandlingConsumer.class)), timeout, executionContext),
timeout);
return camel.template().requestBody("direct:error-handler-test-java", "hello", String.class);
}
catch (Exception e) {
return e.getMessage();
}
}
}.occurrences(1).exec();
assertEquals("error: hello", result);
}};
}
}