remove all but one occurrence of single-arg tell()
This commit is contained in:
parent
2502919c6e
commit
ce49ffe3c6
71 changed files with 550 additions and 538 deletions
|
|
@ -21,39 +21,42 @@ import akka.actor.Props;
|
|||
import akka.testkit.AkkaSpec;
|
||||
import akka.testkit.JavaTestKit;
|
||||
|
||||
|
||||
/**
|
||||
* @author Martin Krasser
|
||||
*/
|
||||
public class ConsumerJavaTestBase {
|
||||
|
||||
static ActorSystem system = ActorSystem.create("test", AkkaSpec.testConf());
|
||||
static ActorSystem system = ActorSystem.create("test", AkkaSpec.testConf());
|
||||
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() {
|
||||
system.shutdown();
|
||||
}
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() {
|
||||
system.shutdown();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shouldHandleExceptionThrownByActorAndGenerateCustomResponse() throws Exception {
|
||||
new JavaTestKit(system) {{
|
||||
String result = new EventFilter<String>(Exception.class) {
|
||||
protected String run() {
|
||||
FiniteDuration 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);
|
||||
}};
|
||||
}
|
||||
@Test
|
||||
public void shouldHandleExceptionThrownByActorAndGenerateCustomResponse()
|
||||
throws Exception {
|
||||
new JavaTestKit(system) {
|
||||
{
|
||||
String result = new EventFilter<String>(Exception.class) {
|
||||
protected String run() {
|
||||
FiniteDuration timeout = Duration.create(1, TimeUnit.SECONDS);
|
||||
Camel camel = CamelExtension.get(system);
|
||||
ExecutionContext executionContext = system.dispatcher();
|
||||
try {
|
||||
@SuppressWarnings("unused")
|
||||
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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue