This is an automated email from the ASF dual-hosted git repository. nfilotto pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-karaf.git
The following commit(s) were added to refs/heads/main by this push: new 1eb2668b Ref #426: Add camel-cbor integration test (#427) 1eb2668b is described below commit 1eb2668be8cbb86e52d6c46c1131e8187f8b5a16 Author: François de Parscau <116000379+f2p...@users.noreply.github.com> AuthorDate: Sat Jul 13 10:17:06 2024 +0200 Ref #426: Add camel-cbor integration test (#427) --- tests/features/camel-cbor/pom.xml | 40 ++++++++++++++++ .../karaf/camel/test/CamelCborRouteSupplier.java | 56 ++++++++++++++++++++++ .../apache/karaf/camel/itest/CamelCborITest.java | 46 ++++++++++++++++++ tests/features/pom.xml | 1 + 4 files changed, 143 insertions(+) diff --git a/tests/features/camel-cbor/pom.xml b/tests/features/camel-cbor/pom.xml new file mode 100644 index 00000000..5fd476f6 --- /dev/null +++ b/tests/features/camel-cbor/pom.xml @@ -0,0 +1,40 @@ +<?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. + +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.apache.camel.karaf</groupId> + <artifactId>camel-karaf-features-test</artifactId> + <version>4.6.0-SNAPSHOT</version> + </parent> + + <artifactId>camel-cbor-test</artifactId> + <name>Apache Camel :: Karaf :: Tests :: Features :: CBOR</name> + + <dependencies> + <dependency> + <groupId>org.apache.camel</groupId> + <artifactId>camel-cbor</artifactId> + <version>${camel-version}</version> + </dependency> + </dependencies> +</project> \ No newline at end of file diff --git a/tests/features/camel-cbor/src/main/java/org/apache/karaf/camel/test/CamelCborRouteSupplier.java b/tests/features/camel-cbor/src/main/java/org/apache/karaf/camel/test/CamelCborRouteSupplier.java new file mode 100644 index 00000000..5dd7345c --- /dev/null +++ b/tests/features/camel-cbor/src/main/java/org/apache/karaf/camel/test/CamelCborRouteSupplier.java @@ -0,0 +1,56 @@ +/* + * 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.karaf.camel.test; + +import static org.apache.camel.builder.Builder.constant; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.camel.builder.RouteBuilder; +import org.apache.camel.component.cbor.CBORDataFormat; +import org.apache.camel.model.RouteDefinition; +import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier; +import org.osgi.service.component.annotations.Component; + +@Component( + name = "karaf-camel-cbor-test", + immediate = true, + service = CamelCborRouteSupplier.class +) +public class CamelCborRouteSupplier extends AbstractCamelSingleFeatureResultMockBasedRouteSupplier { + + @Override + protected boolean consumerEnabled() { + return false; + } + + @Override + protected void configureProducer(RouteBuilder builder, RouteDefinition producerRoute) { + CBORDataFormat format = new CBORDataFormat(); + format.useMap(); + + Map<String, Object> in = new HashMap<>(); + in.put("name", "OK"); + + producerRoute.setBody(constant(in)) + .marshal(format) + .log("marshalled ${body}") + .unmarshal(format) + .toF("mock:%s", getResultMockName()); + } +} + diff --git a/tests/features/camel-cbor/src/test/java/org/apache/karaf/camel/itest/CamelCborITest.java b/tests/features/camel-cbor/src/test/java/org/apache/karaf/camel/itest/CamelCborITest.java new file mode 100644 index 00000000..b693a0eb --- /dev/null +++ b/tests/features/camel-cbor/src/test/java/org/apache/karaf/camel/itest/CamelCborITest.java @@ -0,0 +1,46 @@ +/* + * Licensed 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.karaf.camel.itest; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.camel.component.mock.MockEndpoint; +import org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.ops4j.pax.exam.junit.PaxExam; +import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy; +import org.ops4j.pax.exam.spi.reactors.PerClass; + +@RunWith(PaxExam.class) +@ExamReactorStrategy(PerClass.class) +public class CamelCborITest extends AbstractCamelSingleFeatureResultMockBasedRouteITest { + + @Override + public void configureMock(MockEndpoint mock) { + Map<String, Object> in = new HashMap<>(); + in.put("name", "OK"); + mock.expectedMessageCount(1); + mock.message(0).body().isInstanceOf(Map.class); + mock.message(0).body().isEqualTo(in); + } + + @Test + public void testResultMock() throws Exception { + assertMockEndpointsSatisfied(); + } + + +} \ No newline at end of file diff --git a/tests/features/pom.xml b/tests/features/pom.xml index 5d2ce2b3..209a4b02 100644 --- a/tests/features/pom.xml +++ b/tests/features/pom.xml @@ -55,6 +55,7 @@ <module>camel-base64</module> <module>camel-bindy</module> <module>camel-caffeine</module> + <module>camel-cbor</module> <module>camel-core</module> <module>camel-drill</module> <module>camel-ehcache</module>