gnodet-bot commented on code in PR #26709:
URL: https://github.com/apache/camel/pull/26709#discussion_r4066252125


##########
components/camel-groovy/src/test/java/org/apache/camel/language/groovy/GroovyDefaultCompilePostProcessorTest.java:
##########
@@ -0,0 +1,87 @@
+/*
+ * 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.language.groovy;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.spi.CompilePostProcessor;
+import org.apache.camel.spi.SimpleFunction;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Without any {@link CompilePostProcessor} in the registry (as in a 
camel-main, Spring Boot or Quarkus application,
+ * unlike camel-jbang) the compiler falls back to the built-in processors for 
the Camel annotations.
+ */
+public class GroovyDefaultCompilePostProcessorTest extends CamelTestSupport {
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+
+        DefaultGroovyScriptCompiler compiler = new 
DefaultGroovyScriptCompiler();
+        compiler.setCamelContext(context);
+        
compiler.setScriptPattern("file:src/test/resources/camel-groovy-default/*");
+        context.addService(compiler);
+
+        return context;
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            @Override
+            public void configure() {
+                from("direct:mask")
+                        .setBody().simple("${maskEmail(${body})}")
+                        .to("mock:result");
+
+                from("direct:order")
+                        .convertBodyTo(Order.class)
+                        .setBody().simple("${body.id}")
+                        .to("mock:result");
+            }
+        };
+    }
+
+    @Test
+    public void testBindToRegistryWithoutRegisteredPostProcessor() throws 
Exception {
+        
assertTrue(context.getRegistry().findByType(CompilePostProcessor.class).isEmpty());
+        assertInstanceOf(SimpleFunction.class, 
context.getRegistry().lookupByName("mask-email-function"));
+
+        
getMockEndpoint("mock:result").expectedBodiesReceived("j***@example.com");
+        template.sendBody("direct:mask", "[email protected]");
+        MockEndpoint.assertIsSatisfied(context);
+    }
+
+    @Test
+    public void testConverterWithoutRegisteredPostProcessor() throws Exception 
{
+        assertNotNull(context.getTypeConverterRegistry().lookup(Order.class, 
String.class));
+
+        getMockEndpoint("mock:result").expectedBodiesReceived("123");
+        template.sendBody("direct:order", " 123 ");
+        MockEndpoint.assertIsSatisfied(context);

Review Comment:
   ⚠️ **Missing test: `EventNotifier` in the default-processor path.**
   
   The test verifies `@BindToRegistry` and `@Converter` work without any 
registered `CompilePostProcessor`, but there is no equivalent test for 
`EventNotifier`. `EventNotifierCompilePostProcessor` is the third member of 
`defaultPostProcessors`, and the old behaviour (before this PR) was to skip 
post-processing entirely when no processors were registered — meaning 
`EventNotifier` support in non-CLI runtimes is completely new behaviour 
introduced by this PR, yet it goes untested here.
   
   Add a third Groovy test resource (e.g. `TestEventNotifier.groovy`) annotated 
so that it is an `EventNotifier`, and assert that after context start, 
`camelContext.getManagementStrategy().getEventNotifiers()` contains an instance 
of that class.



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