davsclaus commented on code in PR #26850:
URL: https://github.com/apache/camel/pull/26850#discussion_r4093212538


##########
core/camel-core/src/test/java/org/apache/camel/processor/enricher/EnricherResourceCompletionTest.java:
##########
@@ -0,0 +1,122 @@
+/*
+ * 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.enricher;
+
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.apache.camel.AggregationStrategy;
+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.DefaultEndpoint;
+import org.apache.camel.support.DefaultProducer;
+import org.apache.camel.support.SynchronizationAdapter;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+/**
+ * The on completions registered on the resource exchange (for example to 
close a response stream) run when the enrich
+ * fails, both when the resource fails and when the aggregation fails.
+ */
+public class EnricherResourceCompletionTest extends ContextTestSupport {
+
+    private final AtomicInteger completions = new AtomicInteger();
+
+    @Test
+    public void testResourceFailed() {
+        assertThrows(Exception.class, () -> 
template.requestBody("direct:resourceFails", "Hello"));
+        await().atMost(5, TimeUnit.SECONDS).untilAsserted(() -> 
assertEquals(1, completions.get()));
+    }
+
+    @Test
+    public void testAggregationFailed() {

Review Comment:
   Added in 17fe16ee7579: `testAggregationReturnsNull`. One difference from the 
suggestion: enrich does not fail when the strategy returns null. The original 
message just continues unchanged, so the test checks that the body is still 
`Hello` rather than expecting an exception. It fails without the fix and passes 
with it.
   
   On backporting: that is left to the committers, who add the `port/*` labels.
   
   _Claude Code on behalf of Claus Ibsen_



-- 
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]

Reply via email to