}
}
@Test
public void loop_exceedsMax() throws Exception {
PipelineImpl pipeline = createPipeline(new LogValve(), valve, new LogValve());
// default maxLoopCount = 10
valve.setLoopBody(createPipeline(new LogValve(), new LogValve(), new LogValve()));
valve.afterPropertiesSet();
try {
pipeline.newInvocation().invoke();
fail();
} catch (TooManyLoopsException e) {
assertThat(e, exception("Too many loops: exceeds the maximum count: 10"));
}
assertLog("1-1", //
"2-1-loop-0", "2-2-loop-0", "2-3-loop-0", //
"2-1-loop-1", "2-2-loop-1", "2-3-loop-1", //
"2-1-loop-2", "2-2-loop-2", "2-3-loop-2", //
"2-1-loop-3", "2-2-loop-3", "2-3-loop-3", //
"2-1-loop-4", "2-2-loop-4", "2-3-loop-4", //
"2-1-loop-5", "2-2-loop-5", "2-3-loop-5", //
"2-1-loop-6", "2-2-loop-6", "2-3-loop-6", //
"2-1-loop-7", "2-2-loop-7", "2-3-loop-7", //
"2-1-loop-8", "2-2-loop-8", "2-3-loop-8", //
"2-1-loop-9", "2-2-loop-9", "2-3-loop-9" //
);
// set maxLoopCount = 1
valve.setLoopBody(createPipeline(new LogValve(), new LogValve(), new LogValve()));
valve.setMaxLoopCount(1);
try {
pipeline.newInvocation().invoke();
fail();
} catch (TooManyLoopsException e) {
assertThat(e, exception("Too many loops: exceeds the maximum count: 1"));
}