You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2024/01/04 07:30:24 UTC

(camel) branch main updated: CAMEL-20113: camel/tests consolidating (#12643)

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

orpiske 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 89c0f22f57b CAMEL-20113: camel/tests consolidating (#12643)
89c0f22f57b is described below

commit 89c0f22f57b7ae45f8786f9d4d819b2ed01df387
Author: Ivan Kulaga <ku...@gmail.com>
AuthorDate: Thu Jan 4 13:30:19 2024 +0600

    CAMEL-20113: camel/tests consolidating (#12643)
    
    org.apache.camel.itest.proxy
    -EchoProduceTest - all that there is in the test is checked in other tests, so this test is deleted;
    org.apache.camel.itest.test
    -SpringDebugBeforeTest - is duplicated by org.apache.camel.test.patterns.DebugSpringTest so this test is deleted;
    org.apache.camel.itest.tx
    -Jms2RequiresNewTest - is duplicated by org.apache.camel.component.jms.tx.QueueToQueueTransactionTest so this test is deleted;
---
 .../java/org/apache/camel/itest/proxy/Echo.java    |  23 ----
 .../org/apache/camel/itest/proxy/EchoClient.java   |  33 ------
 .../apache/camel/itest/proxy/EchoProduceTest.java  |  47 --------
 .../camel/itest/test/SpringDebugBeforeTest.java    |  72 ------------
 .../apache/camel/itest/tx/Jms2RequiresNewTest.java | 121 ---------------------
 .../camel/itest/test/SpringDebugBeforeTest.xml     |  34 ------
 .../camel/itest/tx/Jms2RequiresNewTest-context.xml |  63 -----------
 7 files changed, 393 deletions(-)

diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/Echo.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/Echo.java
deleted file mode 100644
index 86ded76fa94..00000000000
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/Echo.java
+++ /dev/null
@@ -1,23 +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.itest.proxy;
-
-public interface Echo {
-
-    String hello(String name);
-
-}
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/EchoClient.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/EchoClient.java
deleted file mode 100644
index d7f7988e66f..00000000000
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/EchoClient.java
+++ /dev/null
@@ -1,33 +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.itest.proxy;
-
-import jakarta.annotation.Resource;
-
-import org.springframework.stereotype.Component;
-
-@Component("client")
-public class EchoClient {
-
-    @Resource(name = "myEcho")
-    private Echo echo;
-
-    public String hello(String name) {
-        return echo.hello(name);
-    }
-
-}
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/EchoProduceTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/EchoProduceTest.java
deleted file mode 100644
index 63cdcf7f182..00000000000
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/proxy/EchoProduceTest.java
+++ /dev/null
@@ -1,47 +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.itest.proxy;
-
-import org.apache.camel.Produce;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.test.junit5.CamelTestSupport;
-import org.junit.jupiter.api.Test;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-
-public class EchoProduceTest extends CamelTestSupport {
-
-    @Produce("direct:start")
-    private Echo echo;
-
-    @Test
-    void testEchoProduce() {
-        String reply = echo.hello("Camel");
-        assertEquals("Hello Camel", reply);
-    }
-
-    @Override
-    protected RouteBuilder createRouteBuilder() {
-        return new RouteBuilder() {
-            @Override
-            public void configure() {
-                from("direct:start")
-                        .transform().simple("Hello ${body}");
-            }
-        };
-    }
-}
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/test/SpringDebugBeforeTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/test/SpringDebugBeforeTest.java
deleted file mode 100644
index 7cc7d81fb6f..00000000000
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/test/SpringDebugBeforeTest.java
+++ /dev/null
@@ -1,72 +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.itest.test;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.camel.Exchange;
-import org.apache.camel.Processor;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.model.ProcessorDefinition;
-import org.apache.camel.test.spring.junit5.CamelSpringTestSupport;
-import org.junit.jupiter.api.Test;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
-
-public class SpringDebugBeforeTest extends CamelSpringTestSupport {
-
-    private final List<String> before = new ArrayList<>();
-
-    @Override
-    public boolean isUseDebugger() {
-        // must enable debugger
-        return true;
-    }
-
-    @Override
-    protected AbstractApplicationContext createApplicationContext() {
-        return new ClassPathXmlApplicationContext("org/apache/camel/itest/test/SpringDebugBeforeTest.xml");
-    }
-
-    @Override
-    protected void debugBefore(
-            Exchange exchange, Processor processor, ProcessorDefinition<?> definition, String id, String label) {
-        before.add(id);
-    }
-
-    @Test
-    void testDebugBefore() throws Exception {
-        getMockEndpoint("mock:SpringDebugBeforeTestResult").expectedMessageCount(1);
-
-        template.sendBody("direct:SpringDebugBeforeTestStart", "Hello World");
-
-        MockEndpoint.assertIsSatisfied(context);
-
-        assertEquals(2, before.size());
-
-        // The ID is not truly deterministic and may be appended a number. To avoid issues with the
-        // IDs receiving a different number other than 1 (as is the case when running multiple tests)
-        // checks only for the preceding ID string for each of the declared routes.
-        assertTrue(before.get(0).startsWith("log"));
-        assertTrue(before.get(1).startsWith("to"));
-
-    }
-}
diff --git a/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/Jms2RequiresNewTest.java b/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/Jms2RequiresNewTest.java
deleted file mode 100644
index 5b5d2cc5acd..00000000000
--- a/tests/camel-itest/src/test/java/org/apache/camel/itest/tx/Jms2RequiresNewTest.java
+++ /dev/null
@@ -1,121 +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.itest.tx;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.EndpointInject;
-import org.apache.camel.ExchangePattern;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.itest.ITestSupport;
-import org.apache.camel.itest.utils.extensions.JmsServiceExtension;
-import org.apache.camel.test.spring.junit5.CamelSpringTest;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.RegisterExtension;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.annotation.DirtiesContext;
-import org.springframework.test.context.ContextConfiguration;
-
-/**
- * Unit test will look for the spring .xml file with the same class name but postfixed with -config.xml as filename.
- * <p/>
- */
-@CamelSpringTest
-@ContextConfiguration
-@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
-public class Jms2RequiresNewTest {
-
-    @RegisterExtension
-    public static JmsServiceExtension jmsServiceExtension = JmsServiceExtension.createExtension();
-
-    private static final int PORT3 = ITestSupport.getPort3();
-
-    @Autowired
-    private CamelContext camelContext;
-
-    @EndpointInject("mock:result1")
-    private MockEndpoint result1;
-
-    @EndpointInject("mock:result2")
-    private MockEndpoint result2;
-
-    @EndpointInject("mock:dlq")
-    private MockEndpoint dlq;
-
-    @EndpointInject("direct:start")
-    private ProducerTemplate start;
-
-    @BeforeEach
-    public void setUpRoute() throws Exception {
-        camelContext.addRoutes(new RouteBuilder() {
-            @Override
-            public void configure() {
-                onException(Exception.class)
-                        .markRollbackOnly();
-
-                from("direct:start").transacted("PROPAGATION_REQUIRES_NEW").to("activemq:queue:start");
-                from("activemq:queue:result1").transacted("PROPAGATION_REQUIRES_NEW").to("mock:result1");
-                from("activemq:queue:result2").transacted("PROPAGATION_REQUIRES_NEW").to("mock:result2");
-                from("activemq:queue:DLQ").transacted("PROPAGATION_REQUIRES_NEW").to("mock:dlq");
-
-                from("activemq:queue:start")
-                        .transacted("PROPAGATION_REQUIRES_NEW")
-                        .setExchangePattern(ExchangePattern.InOnly)
-                        .to("activemq:queue:result1")
-                        .to("direct:route2")
-                        .choice()
-                        .when(body().contains("Neverland"))
-                        .throwException(new RuntimeException("Expected!"));
-
-                from("direct:route2")
-                        .transacted("PROPAGATION_REQUIRES_NEW")
-                        .setExchangePattern(ExchangePattern.InOnly)
-                        .to("activemq:queue:result2");
-
-            }
-        });
-    }
-
-    @Test
-    void testSendThrowingException() throws Exception {
-        result1.expectedMessageCount(0);
-        result2.expectedMessageCount(1);
-        dlq.expectedMessageCount(1);
-
-        start.sendBody("Single ticket to Neverland please!");
-
-        result2.assertIsSatisfied();
-        dlq.assertIsSatisfied();
-        result1.assertIsSatisfied();
-    }
-
-    @Test
-    void testSend() throws Exception {
-        result1.expectedMessageCount(1);
-        result2.expectedMessageCount(1);
-        dlq.expectedMessageCount(0);
-
-        start.sendBody("Piotr Klimczak");
-
-        result1.assertIsSatisfied();
-        result2.assertIsSatisfied();
-        dlq.assertIsSatisfied();
-    }
-
-}
diff --git a/tests/camel-itest/src/test/resources/org/apache/camel/itest/test/SpringDebugBeforeTest.xml b/tests/camel-itest/src/test/resources/org/apache/camel/itest/test/SpringDebugBeforeTest.xml
deleted file mode 100644
index a02e9b0c9c7..00000000000
--- a/tests/camel-itest/src/test/resources/org/apache/camel/itest/test/SpringDebugBeforeTest.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    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.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">
-
-    <camelContext xmlns="http://camel.apache.org/schema/spring">
-        <route>
-            <from uri="direct:SpringDebugBeforeTestStart"/>
-            <log message="Got ${body}"/>
-            <to uri="mock:SpringDebugBeforeTestResult"/>
-        </route>
-    </camelContext>
-
-</beans>
diff --git a/tests/camel-itest/src/test/resources/org/apache/camel/itest/tx/Jms2RequiresNewTest-context.xml b/tests/camel-itest/src/test/resources/org/apache/camel/itest/tx/Jms2RequiresNewTest-context.xml
deleted file mode 100644
index aa867edf60b..00000000000
--- a/tests/camel-itest/src/test/resources/org/apache/camel/itest/tx/Jms2RequiresNewTest-context.xml
+++ /dev/null
@@ -1,63 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    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.
-
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xsi:schemaLocation="
-       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
-       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
-       http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
-
-    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
-
-    <!-- use required TX -->
-    <bean id="PROPAGATION_REQUIRES_NEW" class="org.apache.camel.spring.spi.SpringTransactionPolicy">
-        <property name="transactionManager" ref="jtaTransactionManager"/>
-        <property name="propagationBehaviorName" value="PROPAGATION_REQUIRES_NEW"/>
-    </bean>
-
-    <!-- Setup Narayana transaction manager and user transaction -->
-    <bean id="narayanaTransactionManager" class="com.arjuna.ats.jta.TransactionManager" factory-method="transactionManager" />
-    <bean id="narayanaUserTransaction" class="com.arjuna.ats.jta.UserTransaction" factory-method="userTransaction" />
-
-    <!-- this is the Spring JtaTransactionManager which under the hood uses Narayana -->
-    <bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager">
-        <property name="transactionManager" ref="narayanaTransactionManager"/>
-        <property name="userTransaction" ref="narayanaUserTransaction"/>
-    </bean>
-
-    <!-- Is the ConnectionFactory to connect to the JMS broker -->
-    <!-- notice how we must use the XA connection factory -->
-    <bean id="jmsXaConnectionFactory" class="org.apache.activemq.artemis.jms.client.ActiveMQXAConnectionFactory">
-        <property name="brokerURL" value="vm://itest-jms"/>
-    </bean>
-
-    <!-- define the activemq Camel component so we can integrate with the AMQ broker below -->
-    <bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
-        <property name="connectionFactory" ref="jmsXaConnectionFactory"/>
-        <!-- must indicate that we use transacted acknowledge mode -->
-        <property name="transacted" value="true"/>
-        <!-- refer to the transaction manager -->
-        <property name="transactionManager" ref="jtaTransactionManager"/>
-    </bean>
-
-    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-    </camelContext>
-
-</beans>