davsclaus commented on code in PR #21219: URL: https://github.com/apache/camel/pull/21219#discussion_r2765894599
########## core/camel-core/src/test/java/org/apache/camel/processor/DefaultConsumerBridgeErrorHandlerContinuedTest.java: ########## @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.processor; + +import java.util.Map; + +import org.apache.camel.Component; +import org.apache.camel.Consumer; +import org.apache.camel.ContextTestSupport; +import org.apache.camel.Endpoint; +import org.apache.camel.Exchange; +import org.apache.camel.Processor; +import org.apache.camel.Producer; +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.support.DefaultComponent; +import org.apache.camel.support.ScheduledPollConsumer; +import org.apache.camel.support.ScheduledPollEndpoint; +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +/** + * Tests that bridgeErrorHandler with continued(true) properly executes the onException route and allows processing to + * continue. + * <p> + * This is a regression test for CAMEL-22907. + */ +public class DefaultConsumerBridgeErrorHandlerContinuedTest extends ContextTestSupport { + + @Test + public void testDefaultConsumerBridgeErrorHandlerContinued() throws Exception { + // The onException route should execute with continued(true) + getMockEndpoint("mock:onException").expectedMinimumMessageCount(1); + getMockEndpoint("mock:subroute").expectedMinimumMessageCount(1); + + // With continued(true), processing should continue after error handling + // However, since the consumer throws before creating a valid exchange, + // mock:result won't receive messages + getMockEndpoint("mock:result").expectedMessageCount(0); + + assertMockEndpointsSatisfied(); + + // Verify the exception is present in the onException route + Exception cause = getMockEndpoint("mock:onException").getReceivedExchanges().get(0) + .getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class); + assertNotNull(cause); + assertEquals("Simulated", cause.getMessage()); + } + + @Override + protected RouteBuilder createRouteBuilder() { + return new RouteBuilder() { + @Override + public void configure() { + // register our custom component + getContext().addComponent("my", new MyComponent()); + + // configure on exception with continued(true) + // The onException route should execute and processing should continue + onException(Exception.class).continued(true) Review Comment: can you copy this test and make it handled(false) instead of continued(true) so we have this use-case tested also -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
