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 22868ffa Add camel-asn1 integration test (#405)
22868ffa is described below
commit 22868ffafd4efb55825a80d5c7e5b27d82d88f31
Author: François de Parscau <[email protected]>
AuthorDate: Thu Jul 4 17:57:42 2024 +0200
Add camel-asn1 integration test (#405)
---
tests/features/camel-asn1/pom.xml | 33 ++++++++++++
.../karaf/camel/test/CamelAsn1RouteSupplier.java | 49 +++++++++++++++++
.../apache/karaf/camel/itest/CamelAsn1ITest.java | 60 +++++++++++++++++++++
.../src/test/resources/asn1_data/SMS_SINGLE.tt | Bin 0 -> 229 bytes
tests/features/pom.xml | 1 +
5 files changed, 143 insertions(+)
diff --git a/tests/features/camel-asn1/pom.xml
b/tests/features/camel-asn1/pom.xml
new file mode 100644
index 00000000..f6624295
--- /dev/null
+++ b/tests/features/camel-asn1/pom.xml
@@ -0,0 +1,33 @@
+<?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-asn1-test</artifactId>
+ <name>Apache Camel :: Karaf :: Tests :: Features :: ASN1</name>
+
+</project>
\ No newline at end of file
diff --git
a/tests/features/camel-asn1/src/main/java/org/apache/karaf/camel/test/CamelAsn1RouteSupplier.java
b/tests/features/camel-asn1/src/main/java/org/apache/karaf/camel/test/CamelAsn1RouteSupplier.java
new file mode 100644
index 00000000..c005276a
--- /dev/null
+++
b/tests/features/camel-asn1/src/main/java/org/apache/karaf/camel/test/CamelAsn1RouteSupplier.java
@@ -0,0 +1,49 @@
+/*
+ * 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 java.util.function.Function;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.RouteDefinition;
+import org.apache.camel.model.dataformat.ASN1DataFormat;
+import
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteSupplier;
+import org.apache.karaf.camel.itests.CamelRouteSupplier;
+import org.osgi.service.component.annotations.Component;
+
+
+@Component(
+ name = "karaf-camel-asn1-test",
+ immediate = true,
+ service = CamelRouteSupplier.class
+)
+public class CamelAsn1RouteSupplier extends
AbstractCamelSingleFeatureResultMockBasedRouteSupplier {
+
+ @Override
+ protected Function<RouteBuilder, RouteDefinition> consumerRoute() {
+ final ASN1DataFormat asn1 = new ASN1DataFormat();
+ return builder ->
+
builder.fromF("file:%s/test-classes/asn1_data?fileName=SMS_SINGLE.tt&noop=true",
+ System.getProperty("project.target"))
+ .unmarshal(asn1).marshal(asn1);
+ }
+
+ @Override
+ protected boolean producerEnabled() {
+ return false;
+ }
+}
+
diff --git
a/tests/features/camel-asn1/src/test/java/org/apache/karaf/camel/itest/CamelAsn1ITest.java
b/tests/features/camel-asn1/src/test/java/org/apache/karaf/camel/itest/CamelAsn1ITest.java
new file mode 100644
index 00000000..b3741981
--- /dev/null
+++
b/tests/features/camel-asn1/src/test/java/org/apache/karaf/camel/itest/CamelAsn1ITest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Predicate;
+import org.apache.camel.component.mock.MockEndpoint;
+import
org.apache.karaf.camel.itests.AbstractCamelSingleFeatureResultMockBasedRouteITest;
+import org.apache.karaf.camel.itests.CamelKarafTestHint;
+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;
+
+@CamelKarafTestHint
+@RunWith(PaxExam.class)
+@ExamReactorStrategy(PerClass.class)
+public class CamelAsn1ITest extends
AbstractCamelSingleFeatureResultMockBasedRouteITest {
+
+ @Override
+ public void configureMock(MockEndpoint mock) {
+ try {
+ final byte[] content = Files.readAllBytes(
+
Path.of("%s/test-classes/asn1_data/SMS_SINGLE.tt".formatted(System.getProperty("project.target"))));
+ mock.expectedMessageCount(1);
+ mock.expectedMessagesMatches(new Predicate() {
+ @Override
+ public boolean matches(Exchange exchange) {
+ byte[] body = exchange.getIn().getBody(byte[].class);
+ return Arrays.equals(content, body);
+ }
+ });
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+
+ @Test
+ public void testResultMock() throws Exception {
+ assertMockEndpointsSatisfied();
+ }
+
+}
\ No newline at end of file
diff --git
a/tests/features/camel-asn1/src/test/resources/asn1_data/SMS_SINGLE.tt
b/tests/features/camel-asn1/src/test/resources/asn1_data/SMS_SINGLE.tt
new file mode 100644
index 00000000..672f98ce
Binary files /dev/null and
b/tests/features/camel-asn1/src/test/resources/asn1_data/SMS_SINGLE.tt differ
diff --git a/tests/features/pom.xml b/tests/features/pom.xml
index f667154f..6090f1f5 100644
--- a/tests/features/pom.xml
+++ b/tests/features/pom.xml
@@ -40,6 +40,7 @@
<module>camel-activemq</module>
<module>camel-amqp</module>
<module>camel-arangodb</module>
+ <module>camel-asn1</module>
<module>camel-aws2-iam</module>
<module>camel-aws2-s3</module>
<module>camel-aws2-ses</module>