This is an automated email from the ASF dual-hosted git repository.

fmariani pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/main by this push:
     new 45f925c069dc [camel-mina] Automate MinaProducerShutdownManualIT
45f925c069dc is described below

commit 45f925c069dcf71b2f08489336e920b53038be75
Author: JinyuChen97 <[email protected]>
AuthorDate: Fri Mar 13 10:22:17 2026 +0000

    [camel-mina] Automate MinaProducerShutdownManualIT
    
    https://issues.apache.org/jira/browse/CAMEL-22519
---
 components/camel-mina/pom.xml                      | 33 --------
 .../mina/MinaProducerShutdownManualIT.java         | 97 ----------------------
 .../component/mina/MinaProducerShutdownTest.java   | 65 +++++++++++++++
 3 files changed, 65 insertions(+), 130 deletions(-)

diff --git a/components/camel-mina/pom.xml b/components/camel-mina/pom.xml
index e3787390f6e4..8ed6910cc93c 100644
--- a/components/camel-mina/pom.xml
+++ b/components/camel-mina/pom.xml
@@ -77,37 +77,4 @@
         </dependency>
     </dependencies>
 
-    <profiles>
-        <profile>
-            <id>full</id>
-            <activation>
-                <property>
-                    <name>!quickly</name>
-                </property>
-            </activation>
-            <build>
-                <plugins>
-                    <plugin>
-                        <artifactId>maven-surefire-plugin</artifactId>
-                        <configuration>
-                            <excludes>
-                                <!-- This test just show the shutdown error -->
-                                
<exclude>**/MinaProducerShutdownTest.*</exclude>
-                            </excludes>
-                        </configuration>
-                    </plugin>
-
-                    <plugin>
-                        <!-- allows the special unittest to be ran via 'mvn 
compile exec:java' -->
-                        <groupId>org.codehaus.mojo</groupId>
-                        <artifactId>exec-maven-plugin</artifactId>
-                        <configuration>
-                            
<mainClass>org.apache.camel.component.mina.MinaProducerShutdownManualIT</mainClass>
-                            
<includePluginDependencies>false</includePluginDependencies>
-                        </configuration>
-                    </plugin>
-                </plugins>
-            </build>
-        </profile>
-    </profiles>
 </project>
diff --git 
a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownManualIT.java
 
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownManualIT.java
deleted file mode 100644
index edbc61d59db8..000000000000
--- 
a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownManualIT.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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.component.mina;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.Endpoint;
-import org.apache.camel.Exchange;
-import org.apache.camel.Producer;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.impl.DefaultCamelContext;
-import org.apache.camel.util.StopWatch;
-import org.junit.jupiter.api.Disabled;
-import org.junit.jupiter.api.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Unit testing for using a MinaProducer that it can shutdown properly 
(CAMEL-395)
- * <p>
- * Run this test from maven: mvn exec:java and see the output if there is a 
error.
- */
-@Disabled
-public class MinaProducerShutdownManualIT {
-
-    private static final Logger LOG = 
LoggerFactory.getLogger(MinaProducerShutdownManualIT.class);
-    private static final String URI = 
"mina:tcp://localhost:6321?textline=true&sync=false";
-    private StopWatch stopWatch;
-    private CamelContext context;
-
-    public static void main(String[] args) throws Exception {
-        MinaProducerShutdownManualIT me = new MinaProducerShutdownManualIT();
-        me.testProducer();
-    }
-
-    @Test
-    public void testProducer() throws Exception {
-        // use shutdown hook to verify that we have stopped within 5 seconds
-        Thread hook = new AssertShutdownHook();
-        Runtime.getRuntime().addShutdownHook(hook);
-
-        stopWatch = new StopWatch();
-
-        context = new DefaultCamelContext();
-        context.addRoutes(createRouteBuilder());
-        context.start();
-
-        sendMessage();
-
-        context.stop();
-    }
-
-    private class AssertShutdownHook extends Thread {
-
-        @Override
-        public void run() {
-            long diff = stopWatch.taken();
-            if (diff > 5000) {
-                LOG.error("ERROR: MinaProducer should be able to shutdown 
within 5000 millis: time={}", diff);
-            }
-        }
-    }
-
-    private void sendMessage() throws Exception {
-        Endpoint endpoint = context.getEndpoint(URI);
-        Producer producer = endpoint.createProducer();
-
-        Exchange exchange = endpoint.createExchange();
-        exchange.getIn().setBody("Hello World");
-
-        producer.start();
-        producer.process(exchange);
-        producer.stop();
-    }
-
-    private RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-
-            public void configure() {
-                from(URI).to("mock:result");
-            }
-        };
-    }
-}
diff --git 
a/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java
 
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java
new file mode 100644
index 000000000000..b4e49ddeee1a
--- /dev/null
+++ 
b/components/camel-mina/src/test/java/org/apache/camel/component/mina/MinaProducerShutdownTest.java
@@ -0,0 +1,65 @@
+/*
+ * 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.component.mina;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Producer;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.util.StopWatch;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+/**
+ * Unit testing for using a MinaProducer that it can shutdown properly 
(CAMEL-395)
+ */
+public class MinaProducerShutdownTest extends BaseMinaTest {
+
+    @Test
+    public void testProducer() throws Exception {
+        Endpoint endpoint = context.getEndpoint(getUri());
+        Producer producer = endpoint.createProducer();
+
+        Exchange exchange = endpoint.createExchange();
+        exchange.getIn().setBody("Hello World");
+
+        StopWatch stopWatch = new StopWatch();
+        producer.start();
+        producer.process(exchange);
+        producer.stop();
+
+        context.stop();
+        long diff = stopWatch.taken();
+
+        assertTrue(diff < 5000, "MinaProducer should be able to shutdown 
within 5000 millis: time=" + diff);
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+
+            public void configure() {
+                from(getUri()).to("mock:result");
+            }
+        };
+    }
+
+    private String getUri() {
+        return "mina:tcp://localhost:" + getPort() + 
"?textline=true&sync=false";
+    }
+}

Reply via email to